here I'm talking about Double Agent (a windows7/8 version of MS Agent, the same as office 2007 I suppose).
I'm sorry I'm talking about a full product but i'm really being mad to catch an event( the bundled sample does not help for this)...
In the sample i have a similar handle:
public MsaWithDa()
{
InitializeComponent();
mDaControl = new DoubleAgent.Control.Control ();
mDaControl.Show += new DoubleAgent.Control.ShowEventHandler (mDaControl_Show);
}
and this:
private void mDaControl_Show(string CharacterID, DoubleAgent.Control.VisibilityCauseType Cause)
{
SetDaControlButtons();
}
Now I need to handle a different event (when the user select a command from the menu of the Agent).. and I have this
private void mainAgent_Command(object sender, AgentObjects.IAgentCtlCommand e)
{
mDaControlChar.Play("Wave");
mDaControlChar.Speak("Hello!");
}
It's based on the user manual of the product:
Double Agent sends this event when your application is input-active and the user chooses a command from the character's pop-up menu, or by spoken input.
public event CtlCommandEventHandler CtlCommand
I added this to the main form:
mDaControl.Command += new DoubleAgent.Control.Command(mDaControl_Command);
but something is missing and I have to pass the two values to be able to test.
Sorry, I understand this is a stupid question and sure super-basic but this is the first time I need to use Event Handlers in c#
Hope someone should help, thanks a lot
EDIT: Based on this article: Understanding events and event handlers in C#
I now coded this:
public delegate void MyEventHandler(object sender, AgentObjects.IAgentCtlCommand e);
public event MyEventHandler AgentObjects;
and this:
private void InitializeAgent()
{
mDaControl.Command += new MyEventHandler(HandleSomethingHappened);
}
private void HandleSomethingHappened(object sender, AgentObjects.IAgentCtlCommand e)
{
mDaControlChar.Play("Wave");
mDaControlChar.Speak("Hello!");
}
BUT i have an error here:
new MyEventHandler(HandleSomethingHappened)
Error 1 Cannot implicitly convert type 'XCopyPro.Main.MyEventHandler' to 'DoubleAgent.Control.CommandEventHandler' C:\Users\Shawn\Documents\Visual Studio 2013\Projects\XCopyPro\XCopyPro\FormMain.cs 159 37 XCopyPro