コード例 #1
0
ファイル: MyPictureBox.cs プロジェクト: zhuhui09/LaserGRBL
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (mStage == MouseStage.Outside)
            {
                FenceRect = GetFenceRect(MouseDownPt, new SizeF(MouseMovePt.X - MouseDownPt.X, MouseMovePt.Y - MouseDownPt.Y));
            }

            mStage = MouseStage.NoAction;
            Invalidate();
        }
コード例 #2
0
ファイル: MyPictureBox.cs プロジェクト: zhuhui09/LaserGRBL
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            mStage = GetMouseOverType(e.X, e.Y);
            if (mStage == MouseStage.Outside)
            {
                MouseDownPt = e.Location;
                MouseMovePt = e.Location;
            }
            else if (mStage == MouseStage.Fence || mStage == MouseStage.Handle)             // mouse down on rectangle or handle begine moving
            {
                MouseDownPt         = FenceRect.Location;
                MouseDownOffsetPt.X = e.X - FenceRect.X;
                MouseDownOffsetPt.Y = e.Y - FenceRect.Y;
            }
        }
コード例 #3
0
ファイル: MyPictureBox.cs プロジェクト: zhuhui09/LaserGRBL
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            MouseMovePt = e.Location;
            if (mStage != MouseStage.NoAction)
            {
                float dx, dy;

                if (mStage == MouseStage.Outside)                 // drawing rectangle
                {
                    FenceRect = GetFenceRect(MouseDownPt, new SizeF(MouseMovePt.X - MouseDownPt.X, MouseMovePt.Y - MouseDownPt.Y));
                }
                else if (mStage == MouseStage.Fence)                 // moving fence
                {
                    dx          = e.X - MouseDownPt.X;
                    dy          = e.Y - MouseDownPt.Y;
                    FenceRect.X = MouseDownPt.X + dx - MouseDownOffsetPt.X;
                    FenceRect.Y = MouseDownPt.Y + dy - MouseDownOffsetPt.Y;
                }
                else if (mStage == MouseStage.Handle)                 // moving handle
                {
                    FenceRect.Width  = Math.Abs(FenceRect.X - e.X);
                    FenceRect.Height = Math.Abs(FenceRect.Y - e.Y);
                }


                Invalidate();
            }
            else
            {
                MouseStage stage = GetMouseOverType(e.X, e.Y);
                if (stage == MouseStage.Fence)
                {
                    base.Cursor = Cursors.Hand;
                }
                else if (stage == MouseStage.Handle)
                {
                    base.Cursor = Cursors.SizeNESW;
                }
                else
                {
                    base.Cursor = Cursors.Default;
                }
            }
        }