Esempio n. 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);
        }
Esempio n. 2
0
        protected override void OnStateChanged(EventArgs e)
        {
            if (this.WindowState == System.Windows.WindowState.Minimized && App.Settings.Current.Windows.MinimizeToSysTray)
            {
                if (_notifyIcon == null)
                {
                    _notifyIcon = new NotifyIcon(this, App.ApplicationIcon);
                    _notifyIcon.DoubleClicked += (sender, args) =>
                        {
                            this.BeginInvoke(() =>
                                {
                                    this.Show();
                                    this.WindowState = _oldWindowState;
                                    this.Activate();
                                });
                        };
                }
                this.Hide();
                _notifyIcon.Show();
            }

            base.OnStateChanged(e);
        }