当前位置: 首页>>代码示例>>C#>>正文


C# NodeViewData.CanBeDragged方法代码示例

本文整理汇总了C#中Behaviac.Design.NodeViewData.CanBeDragged方法的典型用法代码示例。如果您正苦于以下问题:C# NodeViewData.CanBeDragged方法的具体用法?C# NodeViewData.CanBeDragged怎么用?C# NodeViewData.CanBeDragged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Behaviac.Design.NodeViewData的用法示例。


在下文中一共展示了NodeViewData.CanBeDragged方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnMouseDown

        /// <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);
        }
开发者ID:Just4F,项目名称:behaviac,代码行数:81,代码来源:BehaviorTreeView.cs

示例2: OnMouseDown

        /// <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);
        }
开发者ID:KeyleXiao,项目名称:behaviac,代码行数:66,代码来源:BehaviorTreeView.cs


注:本文中的Behaviac.Design.NodeViewData.CanBeDragged方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。