public void OnMouseDown(MouseEventArgs e)
        {
            // get the world point of the mouse hit
            Coordinates worldPoint = drawingSurface.Transform.GetWorldPoint(e.Location);

            // do a hit test
            // calculate hit tolerance in world units
            double tolerance = MapSettings.PixelHitTolerance / drawingSurface.Transform.Scale;

            // check for only selectable objects
            HitTestResult hitResult = drawingSurface.HitTest(worldPoint, tolerance, HitTestFilters.SelectableOnly);

            if (hitResult.Hit) {
                // we had a hit
                // NOTE: we could add dragging support here
                // check if the selected object has changed
                object selected = drawingSurface.SelectedObject = (ISelectable)hitResult.Target;

                // check if the selected object is IInteract
                if (selected is IMouseInteract) {
                    ((IMouseInteract)selected).OnMouseDown(new MouseEvent(worldPoint, e.Clicks, e.Button));
                }
            }
            else {
                // there was no hit
                // deselect the old object if one was selected
                drawingSurface.SelectedObject = null;

                // do a screen drag if this is a left mouse click
                if (e.Button == MouseButtons.Left) {
                    dragHelper = new DragScreenHelper(drawingSurface, worldPoint);
                }
            }
        }
示例#2
0
 public void OnMouseUp(MouseEventArgs e)
 {
     if (dragHelper != null)
     {
         // apply the final point of the move
         dragHelper.InMove(e.Location);
         // kill it
         dragHelper = null;
     }
 }
 public void OnMouseUp(MouseEventArgs e)
 {
     if (dragHelper != null)
     {
         dragHelper.InMove(e.Location);
         dragHelper = null;
     }
     else if (inZoom && e.Button == MouseButtons.Left)
     {
         SetZoom(startPoint, drawingSurface.Transform.GetWorldPoint(e.Location));
         inZoom = false;
     }
 }
        public void OnMouseDown(MouseEventArgs e)
        {
            // get the world point of the mouse hit
            Coordinates worldPoint = drawingSurface.Transform.GetWorldPoint(e.Location);

            if (e.Button != MouseButtons.Left)
                return;

            // check if the control key is down
            if ((Control.ModifierKeys & Keys.Control) != Keys.None) {
                // user wants to do a drag
                dragHelper = new DragScreenHelper(drawingSurface, worldPoint);
            }
            else {
                endPoint = startPoint = worldPoint;
                inZoom = true;
            }
        }
        public void OnMouseUp(MouseEventArgs e)
        {
            if (dragHelper != null)
            {
                // apply the final point of the move
                dragHelper.InMove(e.Location);
                // kill it
                dragHelper = null;
            }
            else if (drawingSurface.SelectedObject != null)
            {
                // get the world point of the mouse hit
                Coordinates worldPoint = drawingSurface.Transform.GetWorldPoint(e.Location);

                // check if the selected object is IInteract
                if (drawingSurface.SelectedObject is IMouseInteract)
                {
                    ((IMouseInteract)drawingSurface.SelectedObject).OnMouseUp(new MouseEvent(worldPoint, e.Clicks, e.Button));
                }
            }
        }
        public void OnMouseDown(MouseEventArgs e)
        {
            // get the world point of the mouse hit
            Coordinates worldPoint = drawingSurface.Transform.GetWorldPoint(e.Location);

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            // check if the control key is down
            if ((Control.ModifierKeys & Keys.Control) != Keys.None)
            {
                // user wants to do a drag
                dragHelper = new DragScreenHelper(drawingSurface, worldPoint);
            }
            else
            {
                endPoint = startPoint = worldPoint;
                inZoom   = true;
            }
        }
        public void OnMouseDown(MouseEventArgs e)
        {
            // get the world point of the mouse hit
            Coordinates worldPoint = drawingSurface.Transform.GetWorldPoint(e.Location);

            // do a hit test
            // calculate hit tolerance in world units
            double tolerance = MapSettings.PixelHitTolerance / drawingSurface.Transform.Scale;

            // check for only selectable objects
            HitTestResult hitResult = drawingSurface.HitTest(worldPoint, tolerance, HitTestFilters.SelectableOnly);

            if (hitResult.Hit)
            {
                // we had a hit
                // NOTE: we could add dragging support here
                // check if the selected object has changed
                object selected = drawingSurface.SelectedObject = (ISelectable)hitResult.Target;

                // check if the selected object is IInteract
                if (selected is IMouseInteract)
                {
                    ((IMouseInteract)selected).OnMouseDown(new MouseEvent(worldPoint, e.Clicks, e.Button));
                }
            }
            else
            {
                // there was no hit
                // deselect the old object if one was selected
                drawingSurface.SelectedObject = null;

                // do a screen drag if this is a left mouse click
                if (e.Button == MouseButtons.Left)
                {
                    dragHelper = new DragScreenHelper(drawingSurface, worldPoint);
                }
            }
        }
 public void OnMouseUp(MouseEventArgs e)
 {
     if (dragHelper != null) {
         dragHelper.InMove(e.Location);
         dragHelper = null;
     }
     else if (inZoom && e.Button == MouseButtons.Left) {
         SetZoom(startPoint, drawingSurface.Transform.GetWorldPoint(e.Location));
         inZoom = false;
     }
 }
 public void OnDeactivate(IDrawingSurface drawingService)
 {
     this.drawingSurface = null;
     this.dragHelper = null;
     this.inZoom = false;
 }
 public void OnDeactivate(IDrawingSurface drawingService)
 {
     this.drawingSurface = null;
     this.dragHelper     = null;
     this.inZoom         = false;
 }
 public void OnActivate(IDrawingSurface drawingService)
 {
     drawingService.GetControl().Cursor = Cursors.Arrow;
     this.drawingSurface = drawingService;
     this.dragHelper     = null;
 }
 public void OnActivate(IDrawingSurface drawingService)
 {
     drawingService.GetControl().Cursor = Cursors.Arrow;
     this.drawingSurface = drawingService;
     this.dragHelper = null;
 }
        public void OnMouseUp(MouseEventArgs e)
        {
            if (dragHelper != null) {
                // apply the final point of the move
                dragHelper.InMove(e.Location);
                // kill it
                dragHelper = null;
            }
            else if (drawingSurface.SelectedObject != null) {
                // get the world point of the mouse hit
                Coordinates worldPoint = drawingSurface.Transform.GetWorldPoint(e.Location);

                // check if the selected object is IInteract
                if (drawingSurface.SelectedObject is IMouseInteract) {
                    ((IMouseInteract)drawingSurface.SelectedObject).OnMouseUp(new MouseEvent(worldPoint, e.Clicks, e.Button));
                }
            }
        }
示例#14
0
        public void OnMouseDown(MouseEventArgs e)
        {
            // get the world point of the mouse hit
            Coordinates worldPoint = drawingSurface.Transform.GetWorldPoint(e.Location);

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            // check if the control key is down
            if ((Control.ModifierKeys & Keys.Control) != Keys.None)
            {
                // user wants to do a drag
                dragHelper = new DragScreenHelper(drawingSurface, worldPoint);
            }
            else if ((Control.ModifierKeys & Keys.Shift) != Keys.None)
            {
                // do a hit test to get a snap point
                // calculate hit tolerance in world units
                double tolerance = MapSettings.PixelHitTolerance / drawingSurface.Transform.Scale;

                // check for only selectable objects
                HitTestResult hitResult = drawingSurface.HitTest(worldPoint, tolerance, HitTestFilters.HasSnap);

                if (hitResult.Hit)
                {
                    // we have a snap point
                    if (inRuler)
                    {
                        endPoint = hitResult.SnapPoint;
                    }
                    else
                    {
                        endPoint = startPoint = hitResult.SnapPoint;
                    }
                }
                else
                {
                    // no snap point
                    if (inRuler)
                    {
                        endPoint = worldPoint;
                    }
                    else
                    {
                        endPoint = startPoint = worldPoint;
                    }
                }
                inRuler = true;
            }
            else
            {
                if (inRuler)
                {
                    endPoint = worldPoint;
                }
                else
                {
                    endPoint = startPoint = worldPoint;
                }
                inRuler = true;
            }
        }
示例#15
0
 public void OnActivate(IDrawingSurface drawingService)
 {
     this.drawingSurface = drawingService;
     this.dragHelper     = null;
     this.inRuler        = false;
 }