Exemplo n.º 1
0
 private void Cropper_MouseWheelEx(object sender, MouseEventExArgs e)
 {
     e.Handled = true;
 }
Exemplo n.º 2
0
 private void Cropper_MouseDownEx(object sender, MouseEventExArgs e)
 {
     if (e.Button == MouseButtons.Left)
       {
     start = new Point(e.X, e.Y);
     current = new Point(e.X, e.Y);
     Capturing = true;
     back.Invalidate();
       }
       else
       {
     Close();
     if (OnInputFailure != null)
     {
       OnInputFailure.Invoke();
     }
       }
       e.Handled = true;
 }
Exemplo n.º 3
0
 private void Cropper_MouseUpEx(object sender, MouseEventExArgs e)
 {
     if (e.Button == MouseButtons.Left)
       {
     UngrabAll();
     e.Handled = true;
     Close();
     if (OnSuccess != null)
     {
       OnSuccess.Invoke(CapturingRectangle);
     }
       }
 }
Exemplo n.º 4
0
 private void Cropper_MouseDoubleClickEx(object sender, MouseEventExArgs e)
 {
     e.Handled = true;
       Close();
       if (OnInputFailure != null)
       {
     OnInputFailure.Invoke();
       }
 }
Exemplo n.º 5
0
        private static IntPtr MouseHookProc(int nCode, WM wParam, IntPtr lParam)
        {
            if (nCode >= 0)
              {
            MouseLLHookStruct mouseHookStruct = (MouseLLHookStruct)
              Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct));

            MouseButtons button = MouseButtons.None;

            short mouseDelta = 0;
            int clickCount = 0;
            bool mouseDown = false;
            bool mouseUp = false;

            switch (wParam)
            {
              case WM.LBUTTONDOWN:
            mouseDown = true;
            button = MouseButtons.Left;
            clickCount = 1;
            break;
              case WM.LBUTTONUP:
            mouseUp = true;
            button = MouseButtons.Left;
            clickCount = 1;
            break;
              case WM.MBUTTONDBLCLK:
            button = MouseButtons.Left;
            clickCount = 2;
            break;
              case WM.RBUTTONDOWN:
            mouseDown = true;
            button = MouseButtons.Right;
            clickCount = 1;
            break;
              case WM.RBUTTONUP:
            mouseUp = true;
            button = MouseButtons.Right;
            clickCount = 1;
            break;
              case WM.RBUTTONDBLCLK:
            button = MouseButtons.Right;
            clickCount = 2;
            break;
              case WM.MOUSEWHEEL:
            mouseDelta = (short) ((mouseHookStruct.mouseData >> 16) & 0xffff);
            break;
            }

            MouseEventExArgs e = new MouseEventExArgs(button, clickCount,
              mouseHookStruct.pt.x, mouseHookStruct.pt.y, mouseDelta);

            if (clickCount == 2)
            {
              if (s_MouseDoubleClick != null)
              {
            s_MouseDoubleClick.Invoke(null, e);
              }

              if (s_MouseDoubleClickEx != null)
              {
            s_MouseDoubleClickEx.Invoke(null, e);
              }
            }

            if (mouseUp)
            {
              if (s_MouseUp != null)
              {
            s_MouseUp.Invoke(null, e);
              }

              if (s_MouseUpEx != null)
              {
            s_MouseUpEx.Invoke(null, e);
              }
            }

            if (mouseDown)
            {
              if (s_MouseDown != null)
              {
            s_MouseDown.Invoke(null, e);
              }

              if (s_MouseDownEx != null)
              {
            s_MouseDownEx.Invoke(null, e);
              }
            }

            if (mouseDelta != 0)
            {
              if (s_MouseWheel != null)
              {
            s_MouseWheel.Invoke(null, e);
              }

              if (s_MouseWheelEx != null)
              {
            s_MouseWheelEx.Invoke(null, e);
              }
            }

            if (m_OldX != mouseHookStruct.pt.x || m_OldY != mouseHookStruct.pt.y)
            {
              m_OldX = mouseHookStruct.pt.x;
              m_OldY = mouseHookStruct.pt.y;

              if (s_MouseMove != null)
              {
            s_MouseMove.Invoke(null, e);
              }

              if (s_MouseMoveEx != null)
              {
            s_MouseMoveEx.Invoke(null, e);
              }
            }

            if (e.Handled)
            {
              return new IntPtr(-1);
            }
              }

              return CallNextHookEx(s_MouseHookHandle, nCode, wParam, lParam);
        }
Exemplo n.º 6
0
        private void OnMouseClick(MouseEventExArgs e)
        {
            UngrabAll();
              e.Handled = true;

              if (e.Button == MouseButtons.Left)
              {
            var win = ZOrderVisibleWindows().Select<IntPtr, Pair<IntPtr, Rectangle>>(delegate(IntPtr hwnd, int idx)
            {
              Native.WINDOWINFO wi = new Native.WINDOWINFO();
              Native.GetWindowInfo(hwnd, ref wi);
              return new Pair<IntPtr, Rectangle>(hwnd, wi.rcWindow);
            }).First(x => x.Second.Contains(e.X, e.Y));

            ForceForegroundWindow(win.First);

            Size sz = new Size(Screen.AllScreens.Select(x => x.Bounds.X + x.Bounds.Width).Max(),
              Screen.AllScreens.Select(x => x.Bounds.Y + x.Bounds.Height).Max());

            int X = win.Second.X < 0 ? 0 : win.Second.X;
            int Y = win.Second.Y < 0 ? 0 : win.Second.Y;
            int width = win.Second.Right > sz.Width ? sz.Width - X : win.Second.Width;
            int height = win.Second.Bottom > sz.Height ? sz.Height - Y : win.Second.Height;
            Rectangle crop = new Rectangle(X, Y, width, height);

            Shooting(delegate { return UploadToImgur(TakeScreenshot(crop)); }, false);
              }
              else
              {
            InputFailure();
              }
        }
Exemplo n.º 7
0
 private void globalEventProvider_MouseWheelEx(object sender, MouseEventExArgs e)
 {
     e.Handled = true;
 }
Exemplo n.º 8
0
 private void globalEventProvider_MouseUpEx(object sender, MouseEventExArgs e)
 {
     OnMouseClick(e);
 }