Exemplo n.º 1
0
 private void GraphCtrl_MouseMove(object sender, MouseEventArgs e)
 {
     switch (this.zoomOption)
     {
         case GraphCtrl.eZoomOption.ZoomIn:
             if (e.Button != MouseButtons.Left)
                 break;
             this.Refresh();
             Graphics graphics = this.CreateGraphics();
             Point point1 = new Point();
             Point point2 = new Point();
             point1.X = this.mousePos.X < e.X ? this.mousePos.X : e.X;
             point2.X = this.mousePos.X >= e.X ? this.mousePos.X : e.X;
             point1.Y = this.mousePos.Y < e.Y ? this.mousePos.Y : e.Y;
             point2.Y = this.mousePos.Y >= e.Y ? this.mousePos.Y : e.Y;
             Rectangle rect1 = new Rectangle(point1.X, point1.Y, point2.X - point1.X, point2.Y - point1.Y);
             Rectangle rect2 = new Rectangle(point1.X, point1.Y, point2.X - point1.X + 1, point2.Y - point1.Y + 1);
             graphics.SetClip(rect2);
             graphics.DrawRectangle(new Pen(Color.Gray)
             {
                 DashStyle = DashStyle.Dot
             }, rect1);
             break;
         case GraphCtrl.eZoomOption.Hand:
             if (e.Button != MouseButtons.Left)
                 break;
             GraphCtrl.GraphFrame graphFrame = new GraphCtrl.GraphFrame();
             this.workingArea = this.GraphWindow;
             graphFrame.Left = this.frameZoom.Left - this.frameZoom.Width * (e.X - this.mousePos.X) / this.workingArea.Width;
             graphFrame.Right = this.frameZoom.Right - this.frameZoom.Width * (e.X - this.mousePos.X) / this.workingArea.Width;
             graphFrame.Top = this.frameZoom.Top - this.frameZoom.Height * (this.mousePos.Y - e.Y) / this.workingArea.Height;
             graphFrame.Bottom = this.frameZoom.Bottom - this.frameZoom.Height * (this.mousePos.Y - e.Y) / this.workingArea.Height;
             if (graphFrame.Left < this.frameFull.Left)
             {
                 graphFrame.Left = this.frameFull.Left;
                 graphFrame.Right = this.frameFull.Left + this.frameZoom.Width;
             }
             if (graphFrame.Right > this.frameFull.Right)
             {
                 graphFrame.Right = this.frameFull.Right;
                 graphFrame.Left = this.frameFull.Right - this.frameZoom.Width;
             }
             if (graphFrame.Top > this.frameFull.Top)
             {
                 graphFrame.Top = this.frameFull.Top;
                 graphFrame.Bottom = this.frameFull.Top - this.frameZoom.Height;
             }
             if (graphFrame.Bottom < this.frameFull.Bottom)
             {
                 graphFrame.Bottom = this.frameFull.Bottom;
                 graphFrame.Top = this.frameFull.Bottom + this.frameZoom.Height;
             }
             this.FrameZoom = graphFrame;
             this.updateData = true;
             break;
     }
 }
Exemplo n.º 2
0
 private void GraphCtrl_MouseUp(object sender, MouseEventArgs e)
 {
     switch (this.zoomOption)
     {
         case GraphCtrl.eZoomOption.ZoomIn:
             if (e.Button != MouseButtons.Left)
                 break;
             int num1 = this.mousePos.X < e.X ? this.mousePos.X : e.X;
             int num2 = this.mousePos.X >= e.X ? this.mousePos.X : e.X;
             int num3 = this.mousePos.Y < e.Y ? this.mousePos.Y : e.Y;
             int num4 = this.mousePos.Y >= e.Y ? this.mousePos.Y : e.Y;
             if (num1 == num2 || num3 == num4)
             {
                 this.FrameZoom *= 0.5f;
             }
             else
             {
                 GraphCtrl.GraphFrame graphFrame1 = new GraphCtrl.GraphFrame();
                 GraphCtrl.GraphFrame graphFrame2 = new GraphCtrl.GraphFrame();
                 this.workingArea = this.GraphWindow;
                 GraphCtrl.GraphFrame frameZoom = this.FrameZoom;
                 graphFrame2.Left = frameZoom.Left + frameZoom.Width * (num1 - this.workingArea.Left) / this.workingArea.Width;
                 graphFrame2.Right = frameZoom.Right - frameZoom.Width * (this.workingArea.Right - num2) / this.workingArea.Width;
                 graphFrame2.Top = frameZoom.Top - frameZoom.Height * (num3 - this.workingArea.Top) / this.workingArea.Height;
                 graphFrame2.Bottom = frameZoom.Bottom + frameZoom.Height * (this.workingArea.Bottom - num4) / this.workingArea.Height;
                 this.FrameZoom = graphFrame2;
             }
             this.updateData = true;
             break;
     }
 }
Exemplo n.º 3
0
 private void GraphCtrl_MouseDown(object sender, MouseEventArgs e)
 {
     switch (this.zoomOption)
     {
         case GraphCtrl.eZoomOption.ZoomIn:
             if (e.Button != MouseButtons.Left)
                 break;
             this.mousePos = e.Location;
             break;
         case GraphCtrl.eZoomOption.ZoomOut:
             if (e.Button != MouseButtons.Left)
                 break;
             this.FrameZoom = this.FrameZoom * 1.5f;
             this.updateData = true;
             break;
         case GraphCtrl.eZoomOption.Hand:
             if (e.Button != MouseButtons.Left)
                 break;
             this.mousePos = e.Location;
             this.frameZoom = this.FrameZoom;
             break;
     }
 }