Example #1
0
 /// <summary>
 /// Closes the context menu control shopwn earlier (if it's still visible at all).
 /// </summary>
 internal void CloseContextMenu(ICtxtMenuControl ctxtMenuCtrl)
 {
     if (ctxtForm != null && ctxtMenuCtrl == ctxtForm.CtxtMenuControl)
     {
         ctxtForm.Close();
         ctxtForm = null;
     }
 }
Example #2
0
 public override void Dispose()
 {
     if (ctxtForm != null)
     {
         ctxtForm.Dispose(); ctxtForm = null;
     }
     form.Dispose();
     if (canvas != null)
     {
         try
         {
             canvasMutex.WaitOne();
             canvas.Dispose();
             canvas = null;
         }
         finally
         {
             canvasMutex.ReleaseMutex();
         }
     }
     base.Dispose();
 }
Example #3
0
        /// <summary>
        /// Shows a context menu at the desired location, or the nearest best place.
        /// </summary>
        /// <param name="screenLoc">The desired location in screen coordinates.</param>
        /// <param name="ctxtMenuCtrl">The context menu UI to show.</param>
        internal void ShowContextMenu(Point screenLoc, ICtxtMenuControl ctxtMenuCtrl)
        {
            // If we currently have a context menu on the screen, kill it.
            if (ctxtForm != null)
            {
                ctxtForm.Close();
                ctxtForm = null;
            }
            // Create new form
            var ff = new CtxtMenuForm(ctxtMenuCtrl);
            // Calculate optimal location.
            // Horizontally: centered around pointer
            // Vertically: prefer above, with 3px in between
            Screen scr = getScreenForPoint(screenLoc);
            int    x   = screenLoc.X - ff.Width / 2;

            if (x < scr.WorkingArea.Left)
            {
                x = scr.WorkingArea.Left;
            }
            else if (x + ff.Width > scr.WorkingArea.Right)
            {
                x = scr.WorkingArea.Right - ff.Width;
            }
            int y = screenLoc.Y - ff.Height - 3;

            if (y < scr.WorkingArea.Top)
            {
                y = screenLoc.Y + 3;
            }
            ff.Location = new Point(x, y);
            // Show context menu
            ff.Show(form);
            form.Focus();
            ctxtForm = ff;
        }
Example #4
0
 /// <summary>
 /// Shows a context menu at the desired location, or the nearest best place.
 /// </summary>
 /// <param name="screenLoc">The desired location in screen coordinates.</param>
 /// <param name="ctxtMenuCtrl">The context menu UI to show.</param>
 internal void ShowContextMenu(Point screenLoc, ICtxtMenuControl ctxtMenuCtrl)
 {
     // If we currently have a context menu on the screen, kill it.
     if (ctxtForm != null)
     {
         ctxtForm.Close();
         ctxtForm = null;
     }
     // Create new form
     var ff = new CtxtMenuForm(ctxtMenuCtrl);
     // Calculate optimal location.
     // Horizontally: centered around pointer
     // Vertically: prefer above, with 3px in between
     Screen scr = getScreenForPoint(screenLoc);
     int x = screenLoc.X - ff.Width / 2;
     if (x < scr.WorkingArea.Left) x = scr.WorkingArea.Left;
     else if (x + ff.Width > scr.WorkingArea.Right) x = scr.WorkingArea.Right - ff.Width;
     int y = screenLoc.Y - ff.Height - 3;
     if (y < scr.WorkingArea.Top) y = screenLoc.Y + 3;
     ff.Location = new Point(x, y);
     // Show context menu
     ff.Show(form);
     form.Focus();
     ctxtForm = ff;
 }
Example #5
0
 /// <summary>
 /// Closes the context menu control shopwn earlier (if it's still visible at all).
 /// </summary>
 internal void CloseContextMenu(ICtxtMenuControl ctxtMenuCtrl)
 {
     if (ctxtForm != null && ctxtMenuCtrl == ctxtForm.CtxtMenuControl)
     {
         ctxtForm.Close();
         ctxtForm = null;
     }
 }
Example #6
0
 public override void Dispose()
 {
     if (ctxtForm != null) { ctxtForm.Dispose(); ctxtForm = null; }
     form.Dispose();
     if (canvas != null)
     {
         try
         {
             canvasMutex.WaitOne();
             canvas.Dispose();
             canvas = null;
         }
         finally
         {
             canvasMutex.ReleaseMutex();
         }
     }
     base.Dispose();
 }