예제 #1
0
        private void GraphCtrl_MouseMove(object sender, MouseEventArgs e)
        {
            switch (zoomOption)
            {
                case eZoomOption.None:
                case eZoomOption.ZoomOut:
                case eZoomOption.AutoScale:
                    break;

                case eZoomOption.ZoomIn:
                {
                    if (e.Button != MouseButtons.Left)
                    {
                        break;
                    }
                    Refresh();
                    Graphics graphics = base.CreateGraphics();
                    Point point = new Point();
                    Point point2 = new Point();
                    point.X = (mousePos.X < e.X) ? mousePos.X : e.X;
                    point2.X = (mousePos.X >= e.X) ? mousePos.X : e.X;
                    point.Y = (mousePos.Y < e.Y) ? mousePos.Y : e.Y;
                    point2.Y = (mousePos.Y >= e.Y) ? mousePos.Y : e.Y;
                    Rectangle rect = new Rectangle(point.X, point.Y, point2.X - point.X, point2.Y - point.Y);
                    Rectangle rectangle2 = new Rectangle(point.X, point.Y, (point2.X - point.X) + 1, (point2.Y - point.Y) + 1);
                    graphics.SetClip(rectangle2);
                    Pen pen = new Pen(Color.Gray);
                    pen.DashStyle = DashStyle.Dot;
                    graphics.DrawRectangle(pen, rect);
                    return;
                }
                case eZoomOption.Hand:
                    if (e.Button == MouseButtons.Left)
                    {
                        GraphFrame frame = new GraphFrame();
                        workingArea = GraphWindow;
                        frame.Left = frameZoom.Left - ((frameZoom.Width * (e.X - mousePos.X)) / workingArea.Width);
                        frame.Right = frameZoom.Right - ((frameZoom.Width * (e.X - mousePos.X)) / workingArea.Width);
                        frame.Top = frameZoom.Top - ((frameZoom.Height * (mousePos.Y - e.Y)) / workingArea.Height);
                        frame.Bottom = frameZoom.Bottom - ((frameZoom.Height * (mousePos.Y - e.Y)) / workingArea.Height);
                        if (frame.Left < frameFull.Left)
                        {
                            frame.Left = frameFull.Left;
                            frame.Right = frameFull.Left + frameZoom.Width;
                        }
                        if (frame.Right > frameFull.Right)
                        {
                            frame.Right = frameFull.Right;
                            frame.Left = frameFull.Right - frameZoom.Width;
                        }
                        if (frame.Top > frameFull.Top)
                        {
                            frame.Top = frameFull.Top;
                            frame.Bottom = frameFull.Top - frameZoom.Height;
                        }
                        if (frame.Bottom < frameFull.Bottom)
                        {
                            frame.Bottom = frameFull.Bottom;
                            frame.Top = frameFull.Bottom + frameZoom.Height;
                        }
                        FrameZoom = frame;
                        updateData = true;
                    }
                    break;

                default:
                    return;
            }
        }
예제 #2
0
        private void GraphCtrl_MouseUp(object sender, MouseEventArgs e)
        {
            switch (zoomOption)
            {
                case eZoomOption.None:
                case eZoomOption.ZoomOut:
                case eZoomOption.AutoScale:
                case eZoomOption.Hand:
                case eZoomOption.FullScale:
                    return;

                case eZoomOption.ZoomIn:
                {
                    if (e.Button != MouseButtons.Left)
                    {
                        return;
                    }
                    int num = (mousePos.X < e.X) ? mousePos.X : e.X;
                    int num2 = (mousePos.X >= e.X) ? mousePos.X : e.X;
                    int num3 = (mousePos.Y < e.Y) ? mousePos.Y : e.Y;
                    int num4 = (mousePos.Y >= e.Y) ? mousePos.Y : e.Y;
                    if ((num != num2) && (num3 != num4))
                    {
                        GraphFrame frameZoom = new GraphFrame();
                        GraphFrame frame2 = new GraphFrame();
                        workingArea = GraphWindow;
                        frameZoom = FrameZoom;
                        frame2.Left = frameZoom.Left + ((frameZoom.Width * (num - workingArea.Left)) / workingArea.Width);
                        frame2.Right = frameZoom.Right - ((frameZoom.Width * (workingArea.Right - num2)) / workingArea.Width);
                        frame2.Top = frameZoom.Top - ((frameZoom.Height * (num3 - workingArea.Top)) / workingArea.Height);
                        frame2.Bottom = frameZoom.Bottom + ((frameZoom.Height * (workingArea.Bottom - num4)) / workingArea.Height);
                        FrameZoom = frame2;
                        break;
                    }
                    FrameZoom = (GraphFrame) (FrameZoom * 0.5f);
                    break;
                }
                default:
                    return;
            }
            updateData = true;
        }
예제 #3
0
        private void GraphCtrl_MouseDown(object sender, MouseEventArgs e)
        {
            switch (zoomOption)
            {
                case eZoomOption.None:
                case eZoomOption.AutoScale:
                case eZoomOption.FullScale:
                    break;

                case eZoomOption.ZoomIn:
                    if (e.Button != MouseButtons.Left)
                    {
                        break;
                    }
                    mousePos = e.Location;
                    return;

                case eZoomOption.ZoomOut:
                {
                    if (e.Button != MouseButtons.Left)
                    {
                        break;
                    }
                    GraphFrame frame = (GraphFrame) (FrameZoom * 1.5f);
                    FrameZoom = frame;
                    updateData = true;
                    return;
                }
                case eZoomOption.Hand:
                    if (e.Button == MouseButtons.Left)
                    {
                        mousePos = e.Location;
                        frameZoom = FrameZoom;
                    }
                    break;

                default:
                    return;
            }
        }