Why the EventArgs are blocked in CommandAdapter ?

Topics: CAB & Smart Client Software Factory
Oct 28, 2005 at 5:10 AM
originally posted by: jwang49

In EventCommandAdapter :
public void InvokerEventHandler(object sender, EventArgs e)
{
FireCommand()
}

In CommandAdapter :

public virtual void FireCommand()
{
if (ExecuteCommand != null)
{
ExecuteCommand(this,EventArgs.Empty)
}
}

My question is why the original sender and EventArgs are not passed into the FireCommand ?
I am more concerned about EventArgs. For example the Invoker is a TextBox, I need to get
the characters that user has typed.
Oct 28, 2005 at 5:25 AM
originally posted by: DLorenz

I'm pretty sure this doesn't matter. I don't lose any of the event arg information. If it didn't work, you wouldn't be able to use the DataEventArgs correctly, but I know for a fact that it works. Are you losing the information, or did you just look at the code and aare sking questions about it?

I think that the ExecuteCommand calls something on the incoming EventCommandAdapter, which already stores the sender and event args. Then when it goes to call into the actual method that subscribed, it uses its stored data rather than the execute command data. You'd probably have to trace through a bunch of stuff to confirm that theory, though. :)
Oct 28, 2005 at 5:51 AM
originally posted by: jwang49

I am actually loosing information. This is what I have done:

I have a Infragistics TextBoxTool, and register EventCommandAdapter for this type

commandAdapterMapService.Register(typeof(TextBoxTool), typeof(EventCommandAdapter<TextBoxTool>));

then I add invoker to the command

Command cmd = workItem.Commands"MyTextbox";
cmd.AddInvoker(textBox,"ToolKeyPress")

then I add a handler

CommandHandler("MyTextbox")
public void TextBoxHandler(object sender, EventArgs e)
{
The EventArgs gets here is an empty one
The sender gets here is a Command. Are you saying that the original EventArgs is
stored somewhere in the Adapter ? and I should use Command to find the adapter
and then retrieve the information ?
}

Thanks for the help
Oct 29, 2005 at 3:10 AM
originally posted by: DLorenz

Oh, CommandHandlers... I thought you were talking about EventPublication/EventSubscriptions...
Feb 9, 2006 at 3:54 PM
originally posted by: AndrePiwoni

Here's a good explanation why EventArgs are empty:

http://www.gotdotnet.com/codegallery/messageboard/thread.aspx?id=22f72167-af95-44ce-a6ca-f2eafbf2653c&mbid=5194517d-42c9-4cfd-b7a5-87d7cebc6c60&threadid=dfa38f94-9fc6-45de-bd40-b93b369ef1fb

In addition, CommandStrategy when it registres handler it creates Delegate of EventHandler type.