コード例 #1
0
 protected virtual void OnMoving(MovingEventArgs mea)
 {
     if (Moving != null)
     {
         Moving(this, mea);
     }
 }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: PdnBaseForm.cs プロジェクト: herbqiao/paint.net
        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;
            }
        }
コード例 #6
0
ファイル: PdnBaseForm.cs プロジェクト: herbqiao/paint.net
 protected virtual void OnMoving(MovingEventArgs mea)
 {
     if (Moving != null)
     {
         Moving(this, mea);
     }
 }
コード例 #7
0
ファイル: AppWorkspace.cs プロジェクト: herbqiao/paint.net
 private void ParentForm_Moving(object sender, MovingEventArgs e)
 {
     UpdateSnapObstacle();
 }
コード例 #8
0
 protected virtual void OnMoving(MovingEventArgs mea)
 {
     Moving?.Invoke(this, mea);
 }