I'm trying to implement undo functionality with C# delegates. Basically, I've got an UndoStack that maintains a list of delegates implementing each undo operation. When the user chooses Edit:Undo, this stack pops off the first delegate and runs it. Each operation is responsible for pushing an appropriate undo delegate unto the stack. So ...
Hi,
i want to do add custom event handlers to default framework elements using DependencyProperties.
Something like the following:
<Border custom:MyProps.HandleMyEvent="someHandler">...</Border>
Here is the code behind for the control that contains the Border element:
public class MyPage : Page{
public void someHandler(object se...
Hello fellow coders,
I have created a class, that makes it easy to enter in the amount for a particular price in the same way an ATM machine allows you to enter in an amount, user does not enter the decimal.
This is a generic class called (AmountPicker), so that it can be used among many other classes. I am using it by invoking the pre...
I have a view with several embedded UITextFields, this UIView is subordinated to a UIScrollView in IB. Each text field is supposed to invoke a method called updateText defined in the viewcontroller implementation file when the user is done editing the field. For some reason, the method updateText never gets invoked. Anyone have any id...
Hi, I have a simple question about .net delegates. Say I have something like this:
public void Invoke(Action<T> action)
{
Invoke(() => action(this.Value));
}
public void Invoke(Action action)
{
m_TaskQueue.Enqueue(action);
}
The first function encloses a reference to this.Value. During runtime,...
I wrote an IEditorActionDelegate to fire from a context menu on a CompilationUnitEditor. From there I want to create a marker at the start line of the selected text. I have an ITextSelection, and an IEditorPart object. How can I get an IResource from those so that I can call resource.createMarker()?
Thanks
...
I have a C# win form where I read a file and show lines in a datagridview. Everything works fine.. and I use delegate and Invoke for displaying the lines as they are being read. It also shows a progressbar and does some other stuff like calculating line length and parse the lines to extract certain fields from each line.
Just curious, i...
I've made this to call unmanaged function from C code. pCallback is a function pointer so on the managed side is a delegate.
[DllImport("MyDLL.dll")]
public static extern Result SetCallback(
IntPtr handle,
Delegate pCallback,
CallbackType Type);
Now I am setting
public delegate void pfnCallba...
I have seen developers using the below codes quite alternatively. What is the exact difference between these, and which ones go by the standard? Are they same, as Action and Func<T> is a delegate as well:
public event Action<EmployeeEventAgs> OnLeave;
public void Leave()
{
OnLeave(new EmployeeEventAgs(this.ID));
}
VS
public deleg...
I was just browsing and came across this question:
Action vs delegate event
The answer from nobug included this code:
protected virtual void OnLeave(EmployeeEventArgs e) {
var handler = Leave;
if (handler != null)
handler(this, e);
}
Resharper also generates similar code when using the "create raising method" quick-fix.
My ...
Hey guys,
I have been looking for hours and didn't find anything so I decided to give up and ask for your precious knowledge ;)
In order to make my code cleaner, I would like to implement the delegate methods of NSXMLParser in another file ... but I couldn't find any tutorials ...
Could someone explain me briefly how to do that ?
Ch...
I am looking into someone else's code and do not have much experience with anything to do with multi-threading. I came across this line of code:
BeginInvoke((MethodInvoker)delegate() { btnCalibrate.PerformClick(); });
I was wondering why do this when just this would have worked: btnCalibrate.PerformClick();
Thanks for your answers.
...
Hi,
I have the following problem. FindRoot is actually in a third party dll and I do not have control over it. It has to be called via Begin invoke. Sometimes, the FindRoot method throws exception. This causes my whole application to crash. Now how do I prevent my application from crashing even if FindRoot throws exception.
delegate vo...
I want to check whether a simple mathematical expression would overflow (using checked and catch(OverflowException)), but without the need to use a try-catch block every time. So the expression (not the result!) should be passed to a function checkOverflow, which then acts accordingly in case of an overflow.
This is what I attempted, bu...
I’m able to assign to delegate object d a method M with less specific parameter type, but if I want to assign to d an anonymous method with same signature as method M, then I get an error. Any idea why that is?
class derivedEventArgs : EventArgs { }
delegate void newDelegate(object o, derivedEventArgs e);
static void Main...
I am consuming a web service which has a number of methods (50) which create different objects.
example:
CreateObject1(Object1 obj, int arg2)
CreateObject2(Object2 obj, int arg2)
...
CreateObjectX(ObjectX obj, int arg2)
All Objects (Object1, Object2, ObjectX...) inherit from ObjectBase.
So I am trying to do this...
delegate void DlgtC...
EDIT: this is a winform application, sorry for the inconvenience
Disclaimer: this is an assignment we got in college, and I'm stuck over this particular section of code.
I have 2 solutions in Visual Studio 2008, one for a Form and one for a DLL which the form can use for functionality. The idea is to send HTML mails from the client, an...
hi, I have some questions about using delegate patten on iPhone.
This is code using delegate patten. This code works.
SecondViewController *secondViewController = [[SecondViewController alloc] init];
secondViewController.delegate = self;
[self.navigationController pushViewController:secondViewController animated:YES];
[...
Hey guys,
I found some useful information on the web but I still can't manage to do it by myself ;)
Ok, let me put my problem in context for you :
I have a first class (myViewController) whose declaration is below :
// i just give you relevant information
RssParser *rssParser;
UIActivityIndicator *activityIndicator;
In my viewDidL...
I think I've been doing this wrong for the past year and a half of my iPhone development experience... I could use some knowledgeable clarification please!
As you may or may not know, UIView properties can be animated quite easily using the beginAnimations:forContext: method, and wrap it up with a commitAnimations call.
You can also se...