public SysTray(Window Window, Icon Icon, System.Windows.Controls.ContextMenu Menu) { _window = Window; _contextMenu = Menu; _leftClick = SysTrayActions.ShowWindow; _rightClick = SysTrayActions.OpenContextMenu; _doubleClick = SysTrayActions.ShowWindow; _startup = SysTrayActions.ShowWindow; _notify = new NotifyIcon(); _notify.Icon = Icon; _notify.Visible = true; _notify.MouseClick += new MouseEventHandler(_notify_MouseClick); _notify.DoubleClick += new EventHandler(_notify_DoubleClick); TakeAction(SysTraySource.Startup, _startup); }
private void TakeAction(SysTraySource Source, SysTrayActions Action) { switch (Action) { case SysTrayActions.HideWindow: HideWindow(); break; case SysTrayActions.OpenContextMenu: _contextMenu.IsOpen = true; break; case SysTrayActions.ShowWindow: ShowWindow(); break; case SysTrayActions.CustomAction: OnCustomAction(Source); break; } }