Create custom events for the Default Console

Create custom events for the Default Console

Post by Stefan [MS » Thu, 16 Dec 2004 03:21:30


Hi Hakim,

you would need to override the default save action and add your
functionality.
The following whitepaper covers this topic:
http://www.yqcomputer.com/

Cheers,
Stefan




console ?
later
 
 
 

Create custom events for the Default Console

Post by SGFraW » Fri, 17 Dec 2004 02:23:05

Hi Stefan,

Thanks for your answer, but it was not really what I was looking for.

I finally redirect the three save action events to "home made" events in my
default console with the following code:

// Create a public event
public event InvokedActionEventHandler Saving;
public event PerformedActionEventHandler Saved;

void AuthoringReeditSaveAction1_InvokedAction(Object sender,ActionEventArgs
e) {
Saving(sender, e);}
void AuthoringReeditSaveAndExitAction1_InvokedAction(Object
sender,ActionEventArgs e) {
Saving(sender, e);}
void AuthoringSaveNewAction1_InvokedAction(Object sender,ActionEventArgs e) {
Saving(sender, e);}
void AuthoringReeditSaveAction1_PerformedAction(Object
sender,ActionEventArgs e) {
Saved(sender, e);}
void AuthoringReeditSaveAndExitAction1_PerformedAction(Object
sender,ActionEventArgs e) {
Saved(sender, e);}
void AuthoringSaveNewAction1_PerformedAction(Object sender,ActionEventArgs
e) {
Saved(sender, e);}

and register my events in InitializeComponent()

this.AuthoringReeditSaveAction1.InvokedAction += new
InvokedActionEventHandler(this.AuthoringReeditSaveAction1_InvokedAction);
this.AuthoringReeditSaveAndExitAction1.InvokedAction += new
InvokedActionEventHandler(this.AuthoringReeditSaveAndExitAction1_InvokedAction);
this.AuthoringSaveNewAction1.InvokedAction += new
InvokedActionEventHandler(this.AuthoringSaveNewAction1_InvokedAction);
this.AuthoringReeditSaveAction1.PerformedAction += new
PerformedActionEventHandler(this.AuthoringReeditSaveAction1_PerformedAction);
this.AuthoringReeditSaveAndExitAction1.PerformedAction += new
PerformedActionEventHandler(this.AuthoringReeditSaveAndExitAction1_PerformedAction);
this.AuthoringSaveNewAction1.PerformedAction += new
PerformedActionEventHandler(this.AuthoringSaveNewAction1_PerformedAction);

and now, I am able to customize my template behavior on the "saving" or
"saved" event by writing my event handler:

public void DefaultConsole1_Saved(object sender, ActionEventArgs e) {
...
}

which is also registered in InitializeComponent()

this.DefaultConsole1.Saved += new
PerformedActionEventHandler(this.DefaultConsole1_Saved);

Hope I didn't miss anything important, and that it might help somebody else.

Hakim

 
 
 

Create custom events for the Default Console

Post by SGFraW » Fri, 17 Dec 2004 02:47:12

ust a little bug in the code I have provided : we have to check first if an
event handler exists before calling it :

void AuthoringReeditSaveAction1_InvokedAction(Object sender,ActionEventArgs
e) {
if (Saving != null)
Saving(sender, e);}

Hakim

"Hakim" wrote: