示例#1
0
 private void NotifyIcon_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         if (NotifyWin == null)
         {
             NotifyWin       = new ChildWondows.NotifyWindow(this);
             NotifyWin.Owner = this;
         }
         System.Drawing.Point pt = System.Windows.Forms.Control.MousePosition;//WPF方法
         NotifyWin.Show();
         float dpi = GetDpi();
         NotifyWin.Left = pt.X / dpi;
         NotifyWin.Top  = pt.Y / dpi - NotifyWin.ActualHeight;
         NotifyWin.Activate();
     }
     //else if (e.Button == System.Windows.Forms.MouseButtons.Left)
     //{
     //    if (Visibility == Visibility.Hidden)
     //    {
     //        Show();
     //    }
     //    else if (Visibility == Visibility.Visible)
     //    {
     //        WindowState = WindowState.Normal;
     //    }
     //}
 }
示例#2
0
 private void InitNotyfy()
 {
     NotifyWin                    = new ChildWondows.NotifyWindow(this);
     NotifyWin.Owner              = this;
     notifyIcon                   = new System.Windows.Forms.NotifyIcon();
     notifyIcon.Text              = Title;                 //最小化到托盘时,鼠标点击时显示的文本
     notifyIcon.Icon              = FromImageSource(Icon); //程序图标
     notifyIcon.Visible           = true;
     notifyIcon.MouseDoubleClick += NotifyIcon_MouseDoubleClick;
     //notifyIcon.MouseDown += NotifyIcon_MouseDown;
     notifyIcon.MouseClick += NotifyIcon_MouseDown;
     BalloonTips("Just Listen");
 }