示例#1
0
 protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
 {
     myLastPoint  = null;
     this.Capture = false;
     myDragPoint  = null;
     base.OnMouseUp(e);
 }
示例#2
0
 protected override void OnMouseLeave(EventArgs e)
 {
     if (myLastPoint != null)
     {
         using (ReversibleDrawer drawer = this.CreateReversibleDrawer())
         {
             drawer.DrawLine(0, myLastPoint.Y, this.ClientSize.Width, myLastPoint.Y);
             drawer.DrawLine(myLastPoint.X, 0, myLastPoint.X, this.ClientSize.Height);
             myLastPoint = null;
         }
     }
     base.OnMouseLeave(e);
 }
示例#3
0
        protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            myLastPoint = null;

            if (this.BehaviorStyle == XPictureBoxBehaviorStyle.DragScroll)
            {
                if (this.ImageBounds.Contains(e.X - this.AutoScrollPosition.X, e.Y - this.AutoScrollPosition.Y))
                {
                    myDragPoint   = new myPointClass();
                    myDragPoint.X = e.X;
                    myDragPoint.Y = e.Y;
                }
            }
            else if (this.BehaviorStyle == XPictureBoxBehaviorStyle.DragSelect)
            {
                if (e.Button == System.Windows.Forms.MouseButtons.Left)
                {
                    MouseCapturer cap = new MouseCapturer(this);
                    cap.ReversibleShape = ReversibleShapeStyle.Rectangle;
                    this.Cursor         = Cursors.Cross;
                    this.Capture        = true;
                    this.Refresh();
                    if (cap.CaptureMouseMove())
                    {
                        mySelectionBounds = GetBounds(cap.StartPosition, cap.EndPosition);
                        mySelectionBounds.Offset(-this.AutoScrollPosition.X, -this.AutoScrollPosition.Y);
                        Point p = this.ImageBounds.Location;
                        mySelectionBounds.Offset(-p.X, -p.Y);
                        myLastPoint = null;
                        this.Refresh();
                    }
                    this.Cursor  = Cursors.Default;
                    this.Capture = false;
                }
            }
            base.OnMouseDown(e);
        }
 public MainWindow()
 {
     DataContext = new myPointClass(100, 200);
     InitializeComponent();
 }
示例#5
0
 protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
 {
     if (this.BehaviorStyle == XPictureBoxBehaviorStyle.DragScroll)
     {
         if (myDragPoint != null)
         {
             System.Drawing.Point p = new System.Drawing.Point(
                 0 - this.AutoScrollPosition.X,
                 0 - this.AutoScrollPosition.Y);
             p.Offset(-e.X + myDragPoint.X, -e.Y + myDragPoint.Y);
             myDragPoint.X           = e.X;
             myDragPoint.Y           = e.Y;
             this.AutoScrollPosition = p;
         }
         else
         {
             if (myImage != null)
             {
                 int x = e.X - this.AutoScrollPosition.X;
                 int y = e.Y - this.AutoScrollPosition.Y;
                 if (myImage.Size.Width > this.ClientSize.Width || myImage.Size.Height > this.ClientSize.Height)
                 {
                     if (this.ImageBounds.Contains(x, y))
                     {
                         this.Cursor = System.Windows.Forms.Cursors.SizeAll;
                     }
                     else
                     {
                         this.Cursor = System.Windows.Forms.Cursors.Default;
                     }
                 }
                 else
                 {
                     this.Cursor = System.Windows.Forms.Cursors.Default;
                 }
             }
         }
     }
     else if (this.BehaviorStyle == XPictureBoxBehaviorStyle.DragSelect)
     {
         using (ReversibleDrawer drawer = this.CreateReversibleDrawer())
         {
             if (myLastPoint != null)
             {
                 drawer.DrawLine(0, myLastPoint.Y, this.ClientSize.Width, myLastPoint.Y);
                 drawer.DrawLine(myLastPoint.X, 0, myLastPoint.X, this.ClientSize.Height);
             }
             else
             {
                 myLastPoint = new myPointClass();
             }
             if (this.ImageBounds.Contains(e.X, e.Y))
             {
                 myLastPoint.X = e.X;
                 myLastPoint.Y = e.Y;
                 drawer.DrawLine(0, myLastPoint.Y, this.ClientSize.Width, myLastPoint.Y);
                 drawer.DrawLine(myLastPoint.X, 0, myLastPoint.X, this.ClientSize.Height);
             }
             else
             {
                 myLastPoint = null;
             }
         }
     }
     base.OnMouseMove(e);
 }