/// <summary> /// Handles when a mouse button was pressed. /// </summary> protected override void OnMouseDown(MouseEventArgs e) { // the graph has not yet been dragged _startMousePosition = e.Location; _lastMousePosition = e.Location; _objectDragType = ObjectDragTypes.kNone; _dragAttachment = null; _dragTargetAttachment = null; _movedSubItem = null; _fsmDragMode = FSMDragModes.kNone; if (!_clipboardPasteMode) { _currentNode = _rootNodeView.GetInsideNode(_lastMousePosition); _dragTargetNode = null; _movedNodeGraph = null; _movedNode = null; if (_currentNode != null) { if (KeyCtrlIsDown || _currentNode.IsFSM || _currentNode.CanBeDragged() && (KeyShiftIsDown || _currentNode.Node.ParentCanAdoptChildren)) { _objectDragType = ObjectDragTypes.kNode; } } } else { if (_currentNode == null) { _currentNode = _rootNodeView.GetInsideNode(_lastMousePosition); } if (_dragTargetNode == null) { _dragTargetNode = _currentNode; } } if (e.Button == MouseButtons.Left && _currentNode != null) { Debug.Check(_nodeLayoutManager != null); NodeViewData.SubItem subItem = _currentNode.GetSubItem(_currentNode, _nodeLayoutManager.ViewToGraph(e.Location)); NodeViewData.SubItemAttachment attach = subItem as NodeViewData.SubItemAttachment; if (attach != null && attach.IsSelected) { _objectDragType = ObjectDragTypes.kAttachment; } PointF graphMousePos = _nodeLayoutManager.ViewToGraph(_lastMousePosition); NodeViewData.RangeType rangeType = _currentNode.CheckFSMArrowRange(graphMousePos, out _fsmSubItem, out _fsmItemBoundingBox); if (rangeType != NodeViewData.RangeType.kNode) { _objectDragType = ObjectDragTypes.kNone; if (Plugin.EditMode == EditModes.Design) { if (rangeType == NodeViewData.RangeType.kFSMLeftArrow) { _fsmDragMode = FSMDragModes.kLeft; } else if (rangeType == NodeViewData.RangeType.kFSMRightArrow) { _fsmDragMode = FSMDragModes.kRight; } } } } if (_currentNode == null) { _objectDragType = ObjectDragTypes.kGraph; } // focus the view if not focused if (!Focused) { // we focus twice to avoid an issue with focusing the view Parent.Focus(); //OnMouseDown will cal OnGotFocus as well //Focus(); } base.OnMouseDown(e); }
/// <summary> /// Handles when a mouse button was pressed. /// </summary> protected override void OnMouseDown(MouseEventArgs e) { // the graph has not yet been dragged _lastMousePosition = e.Location; _isGraphDragged = false; _isNodeDragged = false; _dragAttachment = null; _dragTargetAttachment = null; if (!_clipboardPasteMode) { _currentNode = _rootNode.IsInside(_lastMousePosition); _dragTargetNode = null; _movedNodeGraph = null; _movedNode = null; if (_currentNode != null) { _isNodeDragged = _currentNode.CanBeDragged() && !KeyCtrlIsDown && (KeyShiftIsDown || _currentNode.Node.ParentCanAdoptChildren); } } else { if (_currentNode == null) { _currentNode = _rootNode.IsInside(e.Location); } if (_dragTargetNode == null) { _dragTargetNode = _currentNode; } } // update the mouse cursor when dragging nodes if (IsPanMode || e.Button == MouseButtons.Middle) { _panStartMousePosition = e.Location; Cursor = (e.Button == MouseButtons.Right) ? Cursors.NoMove2D : Cursors.SizeAll; } else if (e.Button == MouseButtons.Left && _currentNode != null) { Debug.Check(_nodeLayoutManager != null); NodeViewData.SubItem subItem = _currentNode.GetSubItem(_currentNode, _nodeLayoutManager.ViewToGraph(e.Location)); NodeViewData.SubItemAttachment attach = subItem as NodeViewData.SubItemAttachment; if (attach != null && attach.IsSelected) { _isNodeDragged = false; } } // focus the view if not focused if (!Focused) { // we focus twice to avoid an issue with focusing the view Parent.Focus(); //OnMouseDown will cal OnGotFocus as well //Focus(); } base.OnMouseDown(e); }