private void m_MouseDown(object sender, MouseHookEventArgs e) { lastMouseDownHandled = false; if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { currentBorder.Background = new LinearGradientBrush( Color.FromArgb(20, 255, 0, 0), Color.FromArgb(20, 255, 0, 0), 90.0); currentBorder = new AnnoyingRectangle(); borderCollectionSource.Add(currentBorder); e.Handled = lastMouseDownHandled = true; } }
private void m_MouseMove(object sender, MouseHookEventArgs e) { var pos = new Point(e.X, e.Y); if (!_isMoving) { _holePos = pos; } var delta = new Point(pos.X - _holePos.X, pos.Y - _holePos.Y); btHoleCol1.Width = new GridLength(Math.Min(_holePos.X, pos.X)); btHoleCol11.Width = new GridLength(Math.Min(_holePos.X, pos.X)); btHoleCol2.Width = new GridLength(Math.Max(Math.Abs(delta.X), 0)); btHoleCol22.Width = new GridLength(Math.Abs(delta.X)); btHoleRow1.Height = new GridLength(Math.Min(_holePos.Y, pos.Y)); btHoleRow11.Height = new GridLength(Math.Min(_holePos.Y, pos.Y)); btHoleRow2.Height = new GridLength(Math.Max(Math.Abs(delta.Y), 0)); btHoleRow22.Height = new GridLength(Math.Abs(delta.Y)); }
private void m_MouseMove(object sender, MouseHookEventArgs e) { if (_handle == IntPtr.Zero) _handle = new WindowInteropHelper(this).Handle; IntPtr hwnd = Win32.WindowFromPoint(new Win32.POINT(e.X, e.Y)); if (_handle != hwnd) { var re = new Win32.RECT(); Win32.GetWindowRect(hwnd, out re); currentBorder.X = re.m_nLeft; currentBorder.Y = re.m_nTop; currentBorder.Width = re.Width; currentBorder.Height = re.Height; //currentBorder.SetValue(Canvas.LeftProperty, (double)re.m_nLeft); //currentBorder.SetValue(Canvas.WidthProperty, (double)re.Width); //currentBorder.SetValue(Canvas.TopProperty, (double)re.m_nTop); //currentBorder.SetValue(Canvas.HeightProperty, (double)re.Height); } }
private void m_MouseUp(object sender, MouseHookEventArgs e) { e.Handled = true; _isMoving = false; }
private void m_MouseDown(object sender, MouseHookEventArgs e) { e.Handled = true; _isMoving = true; _holePos = new Point(e.X, e.Y); }
private void m_MouseDown(object sender, MouseHookEventArgs e) { if (Keyboard.IsKeyDown(Key.LeftAlt)) return; e.Handled = true; _isMoving = true; _currentBorder = new AnnoyingRectangle(); _currentBorder.Background = new LinearGradientBrush( Color.FromArgb(80, 255, 0, 0), Color.FromArgb(80, 255, 0, 0), 90.0); _borderCollectionSource.Add(_currentBorder); e.Handled = _lastMouseDownHandled = true; Down = new Point(e.X, e.Y); }
private void m_MouseUp(object sender, MouseHookEventArgs e) { if (Keyboard.IsKeyDown(Key.LeftAlt)) return; _isMoving = false; _lastMouseDownHandled = false; _currentBorder.Background = new LinearGradientBrush( Color.FromArgb(110, 255, 0, 0), Color.FromArgb(110, 255, 0, 0), 90.0); if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { //currentBorder = new AnnoyingRectangle(); //currentBorder.Background = new LinearGradientBrush( // Color.FromArgb(80, 255, 0, 0), // Color.FromArgb(80, 255, 0, 0), // 90.0); //borderCollectionSource.Add(currentBorder); e.Handled = _lastMouseDownHandled = true; } else { DoFinish(); } }
private void m_MouseMove(object sender, MouseHookEventArgs e) { if (_isMoving) { SetBounds(Math.Min(e.X, (int)Down.X), Math.Min(e.Y, (int)Down.Y), Math.Abs(e.X - (int)Down.X), Math.Abs(e.Y - (int)Down.Y)); } }
private void m_MouseUp(object sender, MouseHookEventArgs e) { e.Handled = lastMouseDownHandled; if (!Keyboard.IsKeyDown(Key.LeftCtrl) && !Keyboard.IsKeyDown(Key.RightCtrl)) { var r = new Rect(); borderCollectionSource.ToList() .ForEach(x => r.Union(new Rect((double)x.X, (double)x.Y, (double)x.Width, (double)x.Height))); //screenshot } }
/// <summary> /// The callback for the mouse hook /// </summary> /// <param name="code"></param> /// <param name="wParam"></param> /// <param name="lParam"></param> /// <returns></returns> private int HookProc(int code, int wParam, ref Win32.MSLLHOOKSTRUCT lParam) { if (code >= 0) { MouseHookEventArgs eventArgs = null; if (MouseDown != null && (wParam == (int) Win32.MouseMessages.WM_LBUTTONDOWN || wParam == (int) Win32.MouseMessages.WM_MBUTTONDOWN || wParam == (int) Win32.MouseMessages.WM_RBUTTONDOWN)) { MouseButton eMouseButtons = GetMouseButton((Win32.MouseMessages) wParam); eventArgs = new MouseHookEventArgs(eMouseButtons, 0, lParam.pt.X, lParam.pt.Y, 0, false); //this.MouseDown.Invoke(this, new MouseEventArgs(eMouseButtons, 0, lParam.pt.X, lParam.pt.Y, 0)); MouseDown(this, eventArgs); } else if (MouseUp != null && (wParam == (int) Win32.MouseMessages.WM_LBUTTONUP || wParam == (int) Win32.MouseMessages.WM_MBUTTONUP || wParam == (int) Win32.MouseMessages.WM_RBUTTONUP)) { MouseButton eMouseButtons = GetMouseButton((Win32.MouseMessages) wParam); eventArgs = new MouseHookEventArgs(eMouseButtons, 0, lParam.pt.X, lParam.pt.Y, 0, false); //this.MouseUp.Invoke(this, new MouseEventArgs(eMouseButtons, 0, lParam.pt.X, lParam.pt.Y, 0)); MouseUp(this, eventArgs); } else if (MouseWheel != null && (wParam == (int) Win32.MouseMessages.WM_MOUSEWHEEL || wParam == (int) Win32.MouseMessages.WM_MOUSEHWHEEL)) { eventArgs = new MouseHookEventArgs(MouseButton.Middle, 0, lParam.pt.X, lParam.pt.Y, 0, false); MouseWheel.Invoke(this, eventArgs); } else if (MouseMove != null && wParam == (int) Win32.MouseMessages.WM_MOUSEMOVE) { eventArgs = new MouseHookEventArgs(null, 0, lParam.pt.X, lParam.pt.Y, 0, false); MouseMove.Invoke(this, eventArgs); } if (eventArgs != null && eventArgs.Handled) { return -1; } } return Win32.CallNextHookEx(m_hHook, code, wParam, ref lParam); }