Beispiel #1
0
        private void DrawZoomWindow(MouseEventArgs args)
        {
            mouseUpPoint.X = args.X;
            mouseUpPoint.Y = args.Y;

            if (this.NeedToEraseRubber)
            {
                DrawXORFrame();
            }

            if (ClientRectangle.Contains(PointToClient(Control.MousePosition)))
            {
                rubberRect = GViewer.RectFromPoints(PointToScreen(mouseDownPoint), PointToScreen(mouseUpPoint));
                DrawXORFrame();
            }
        }
Beispiel #2
0
        protected override void OnMouseUp(MouseEventArgs args)
        {
            base.OnMouseUp(args);
            MsaglMouseEventArgs iArgs = CreateMouseEventArgs(args);

            gViewer.RaiseMouseUpEvent(iArgs);
            if (NeedToEraseRubber)
            {
                DrawXorFrame();
            }

            if (!iArgs.Handled)
            {
                if (gViewer.OriginalGraph != null && MouseDraggingMode == DraggingMode.WindowZoom)
                {
                    var    p = mouseDownPoint;
                    double f = Math.Max(Math.Abs(p.X - args.X), Math.Abs(p.Y - args.Y)) / GViewer.Dpi;
                    if (f > gViewer.ZoomWindowThreshold && zoomWindow)
                    {
                        mouseUpPoint = new Point(args.X, args.Y);
                        if (ClientRectangle.Contains(mouseUpPoint))
                        {
                            var r = GViewer.RectFromPoints(mouseDownPoint, mouseUpPoint);
                            r.Intersect(gViewer.DestRect);
                            if (GViewer.ModifierKeyWasPressed() == false)
                            {
                                mouseDownPoint.X = r.Left;
                                mouseDownPoint.Y = r.Top;
                                mouseUpPoint.X   = r.Right;
                                mouseUpPoint.Y   = r.Bottom;
                                P2     p1 = gViewer.ScreenToSource(mouseDownPoint);
                                P2     p2 = gViewer.ScreenToSource(mouseUpPoint);
                                double sc = Math.Min((double)ClientRectangle.Width / r.Width,
                                                     ClientRectangle.Height / (double)r.Height);
                                P2 center = 0.5f * (p1 + p2);
                                gViewer.SetTransformOnScaleAndCenter(sc, center);
                                Invalidate();
                            }
                        }
                    }
                }
            }
            zoomWindow = false;
        }