protected virtual void OnMoving(MovingEventArgs mea) { if (Moving != null) { Moving(this, mea); } }
private void OurWndProc(ref Message m) { switch (m.Msg) { case 0x0216: // WM_MOVING unsafe { int * p = (int *)m.LParam; Rectangle rect = Rectangle.FromLTRB(p[0], p[1], p[2], p[3]); MovingEventArgs mea = new MovingEventArgs(rect); OnMoving(mea); p[0] = mea.Rectangle.Left; p[1] = mea.Rectangle.Top; p[2] = mea.Rectangle.Right; p[3] = mea.Rectangle.Bottom; m.Result = new IntPtr(1); } break; // WinForms doesn't handle this message correctly and wrongly returns 0 instead of 1. case 0x0011: // WM_QUERYENDSESSION CancelEventArgs e = new CancelEventArgs(); OnQueryEndSession(e); m.Result = e.Cancel ? IntPtr.Zero : new IntPtr(1); break; default: base.WndProc(ref m); break; } }
protected override void OnMoving(MovingEventArgs mea) { ISnapManagerHost snapHost = this.Owner as ISnapManagerHost; if (snapHost != null) { SnapManager sm = snapHost.SnapManager; // Make sure the window titlebar always follows a constant distance from the mouse cursor // Otherwise the window may "slip" as it snaps and unsnaps if (!this.moving) { this.movingCursorDelta = new Size( Cursor.Position.X - mea.Rectangle.X, Cursor.Position.Y - mea.Rectangle.Y); this.moving = true; } mea.Rectangle = new Rectangle( Cursor.Position.X - this.movingCursorDelta.Width, Cursor.Position.Y - this.movingCursorDelta.Height, mea.Rectangle.Width, mea.Rectangle.Height); this.snapObstacle.SetBounds(mea.Rectangle); Point pt = mea.Rectangle.Location; Point newPt = sm.AdjustObstacleDestination(this.SnapObstacle, pt); Rectangle newRect = new Rectangle(newPt, mea.Rectangle.Size); this.snapObstacle.SetBounds(newRect); mea.Rectangle = newRect; } base.OnMoving(mea); }
private void OurWndProc(ref Message m) { switch (m.Msg) { case 0x0216: // WM_MOVING unsafe { int *p = (int *)m.LParam; Rectangle rect = Rectangle.FromLTRB(p[0], p[1], p[2], p[3]); MovingEventArgs mea = new MovingEventArgs(rect); OnMoving(mea); p[0] = mea.Rectangle.Left; p[1] = mea.Rectangle.Top; p[2] = mea.Rectangle.Right; p[3] = mea.Rectangle.Bottom; m.Result = new IntPtr(1); } break; // WinForms doesn't handle this message correctly and wrongly returns 0 instead of 1. case 0x0011: // WM_QUERYENDSESSION CancelEventArgs e = new CancelEventArgs(); OnQueryEndSession(e); m.Result = e.Cancel ? IntPtr.Zero : new IntPtr(1); break; default: base.WndProc(ref m); break; } }
private void ParentForm_Moving(object sender, MovingEventArgs e) { UpdateSnapObstacle(); }
protected virtual void OnMoving(MovingEventArgs mea) { Moving?.Invoke(this, mea); }