예제 #1
0
        protected override void OnStateChanged(EventArgs e)
        {
            if (this.WindowState == WindowState.Minimized && App.Settings.Current.Windows.MinimizeToSysTray)
            {
                if (_notifyIcon == null)
                {
                    _notifyIcon = new NotifyIcon(this, App.ApplicationIcon);
                    _notifyIcon.DoubleClicked += (sender, args) =>
                    {
                        this.Show();
                        this.WindowState = _oldWindowState;
                        this.Activate();
                        _notifyIcon.Hide();
                    };
                    _notifyIcon.RightClicked += (sender, args) =>
                    {
                        var menu = this.FindResource("NotifyMenu") as ContextMenu;
                        if (menu != null)
                        {
                            menu.IsOpen = true;
                            System.Windows.Input.CommandManager.InvalidateRequerySuggested();
                        }
                    };
                }
                this.Hide();
                _notifyIcon.Show();
            }

            base.OnStateChanged(e);
        }
예제 #2
0
 public static void ShowNotifyIcon()
 {
     _notifyIcon = new NotifyIcon(Properties.Resources.ProgramName, Properties.Resources.UIAssistant);
     _notifyIcon.AddMenuItem(TextID.TrayIconSettings.GetLocalizedText(), (_, __) => ShowSettingsWindow());
     _notifyIcon.AddMenuItem(TextID.TrayIconExit.GetLocalizedText(), (_, __) => ExitApplication());
     _notifyIcon.Show();
 }