Exemplo n.º 1
0
        private void _trayIcon_MouseMove(object sender, MouseEventArgs e)
        {
            if (AppData.MainMV.TotalUnReadCount == 0)
            {
                return;
            }

            if (_iconFlashTimer == null || !_iconFlashTimer.IsEnabled)
            {
                return;
            }

            //鼠标移入托盘图标后显示弹框
            if (_trayWin == null)
            {
                _trayWin              = new TrayWindow();
                _trayWin.DataContext  = AppData.MainMV.ChatListVM;
                _trayWin.MouseEnter  += _trayWin_MouseEnter;
                _trayWin.MouseLeave  += _trayWin_MouseLeave;
                _trayWin.SizeChanged += _trayWin_SizeChanged;
                _trayWin.Closed      += delegate
                {
                    _trayWin.SizeChanged -= _trayWin_SizeChanged;
                    _trayWin              = null;
                    _trayWinTimer.Stop();
                };
            }

            if (_trayWinTimer.IsEnabled == false)
            {
                _trayWinTimer.Start();
            }

            _trayWin.Show();
        }
Exemplo n.º 2
0
        protected void IconClick(object sender, EventArgs e)
        {
            if (e is MouseEventArgs)
            {
                if ((e as MouseEventArgs).Button == MouseButtons.Right)
                {
                    return;
                }
            }

            if (this.Window == null)
            {
                this.Window = new TrayWindow();
            }

            if (this.Window.IsDisposed)
            {
                this.Window = new TrayWindow();
            }

            if (this.Window.Visible)
            {
                this.Window.Close();
            }
            else
            {
                this.Window.Show();
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes the instance.
 /// </summary>
 public static void Initialize(TrayWindow window)
 {
     if (Instance == null)
     {
         IdleIcon = new Icon(ResourceHelper.GetResourceStream(ResourceHelper.TrayIconIdle),
                             new System.Drawing.Size(new System.Drawing.Point(16, 16)));
         AlertIcon = new Icon(ResourceHelper.GetResourceStream(ResourceHelper.TrayIconAlert),
                              new System.Drawing.Size(new System.Drawing.Point(16, 16)));
         Instance = new TrayBusiness(window);
     }
     else
     {
         throw new InvalidOperationException(
                   "The instance is already loaded.");
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes the instance.
 /// </summary>
 public static void Initialize(TrayWindow window)
 {
     if (Instance == null)
     {
         IdleIcon = new Icon(ResourceHelper.GetResourceStream(ResourceHelper.TrayIconIdle),
             new System.Drawing.Size(new System.Drawing.Point(16, 16)));
         AlertIcon = new Icon(ResourceHelper.GetResourceStream(ResourceHelper.TrayIconAlert),
             new System.Drawing.Size(new System.Drawing.Point(16, 16)));
         Instance = new TrayBusiness(window);
     }
     else
     {
         throw new InvalidOperationException(
             "The instance is already loaded.");
     }
 }
Exemplo n.º 5
0
        private TrayBusiness(TrayWindow window)
        {
            _window = window;

            // Subscribe to the main window close event to show notification if needed.
            NavigationActor.Instance.MainWindowClose += OnMainWindowClosed;

            // Assign icon.
            Tray.Icon = IdleIcon;

            // Handle Tray events.
            Tray.TrayBalloonTipClicked += OnTrayNotificationClicked;
            Tray.TrayMouseDoubleClick  += OnTrayDoubleClick;

            // Run a first check.
            Task.Run(() => { Thread.Sleep(BeforeFirstCheckDelay); Check(); });

            // Initialize the check timer.
            _checkTimer          = new DispatcherTimer();
            _checkTimer.Interval = Properties.Settings.Default.TrayCheckInterval;
            _checkTimer.Tick    += OnCheckTick;
            _checkTimer.Start();
        }
Exemplo n.º 6
0
        private TrayBusiness(TrayWindow window)
        {
            _window = window;

            // Subscribe to the main window close event to show notification if needed.
            NavigationActor.Instance.MainWindowClose += OnMainWindowClosed;

            // Assign icon.
            Tray.Icon = IdleIcon;

            // Handle Tray events.
            Tray.TrayBalloonTipClicked += OnTrayNotificationClicked;
            Tray.TrayMouseDoubleClick += OnTrayDoubleClick;

            // Run a first check.
            Task.Run(() => { Thread.Sleep(BeforeFirstCheckDelay); Check(); });

            // Initialize the check timer.
            _checkTimer = new DispatcherTimer();
            _checkTimer.Interval = Properties.Settings.Default.TrayCheckInterval;
            _checkTimer.Tick += OnCheckTick;
            _checkTimer.Start();
        }