I have this code that I attach to the DoubleClick
event on the Tray Icon for my app:
ni.DoubleClick +=
delegate(object sender, EventArgs args)
{
this.MainWindow.Show();
};
But, is it possible to use this code for two events (DoubleClick
and Click
), like so:
ni.DoubleClick, ni.Click +=
delegate(object sender, EventArgs args)
{
this.MainWindow.Show();
};
Just for minimalize a code size and readability. Thanks
Put the handler in its own function:
private void ClickHandler(object sender, EventArgs args)
{
this.MainWindow.Show();
}
Then wire it up to both events:
ni.DoubleClick += ClickHandler;
ni.Click += ClickHandler;
Just create EventHandler
using lambda expression and add it to both event.
EventHandler e = (sender, args) => this.MainWindow.Show();
ni.DoubleClick += e;
ni.Click += e;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With