• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Design.NodeViewData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



NodeViewData类属于Behaviac.Design命名空间,在下文中一共展示了NodeViewData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateNodeViewData

        public override NodeViewData CreateNodeViewData(NodeViewData parent, BehaviorNode rootBehavior)
        {
            NodeViewData nvd = base.CreateNodeViewData(parent, rootBehavior);
            nvd.ChangeShape(NodeShape.Ellipse);

            return nvd;
        }
开发者ID:Just4F,项目名称:behaviac,代码行数:7,代码来源:DecoratorWeight.cs


示例2: CreateNodeViewData

        public override NodeViewData CreateNodeViewData(NodeViewData parent, BehaviorNode rootBehavior)
        {
            NodeViewData nvd = base.CreateNodeViewData(parent, rootBehavior);
            nvd.ChangeShape(this.IsEndState ? NodeShape.RoundedRectangle : NodeShape.Rectangle);

            return nvd;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:7,代码来源:StateBase.cs


示例3: CreateNodeViewData

        public override NodeViewData CreateNodeViewData(NodeViewData parent, Behaviac.Design.Nodes.BehaviorNode rootBehavior)
        {
            NodeViewData nvd = base.CreateNodeViewData(parent, rootBehavior);
            nvd.ChangeShape(NodeShape.Rectangle);

            return nvd;
        }
开发者ID:nusus,项目名称:behaviac,代码行数:7,代码来源:Noop.cs


示例4: CreateNodeViewData

        public override NodeViewData CreateNodeViewData(NodeViewData parent, Behaviac.Design.Nodes.BehaviorNode rootBehavior)
        {
            NodeViewDataStyled nvd = new NodeViewDataStyled(parent, rootBehavior, this, null, __defaultBackgroundBrush, _label, _description);

            nvd.ChangeShape(NodeShape.Rectangle);

            return nvd;
        }
开发者ID:675492062,项目名称:behaviac,代码行数:8,代码来源:Nop.cs


示例5: NodeLayoutManager

 /// <summary>
 /// Creates a new NodeLayoutManager.
 /// </summary>
 /// <param name="edgePen">The pen which is used to draw the edges connecting the nodes.</param>
 /// <param name="edgePenSubReferenced">The pen which is used to draw the edges connecting sub-referenced nodes.</param>
 /// <param name="skipLabels">Defines if labels are drawn or not.</param>
 /// <param name="rootNode">The root of the nodes shown in the view.</param>
 internal NodeLayoutManager(NodeViewData rootNode, Pen edgePen, Pen edgePenHighlight, Pen edgePenUpdate, Pen edgePenSubReferenced, bool skipLabels)
 {
     _rootNodeLayout = rootNode;
     _edgePen = edgePen;
     _edgePenHighLight = edgePenHighlight;
     _edgePenUpdate = edgePenUpdate;
     _edgePenReadOnly = edgePenSubReferenced;
     _skipLabels = skipLabels;
 }
开发者ID:KeyleXiao,项目名称:behaviac,代码行数:16,代码来源:NodeLayoutManager.cs


示例6: Draw

            public override void Draw(Graphics graphics, NodeViewData nvd, RectangleF boundingBox) {
                Attach evnt = (Attach)_attachment;

                //// use a different brush depending on if the event is reacted to or blocked.
                //_labelBrush= evnt.BlockEvent ? Brushes.Orange : Brushes.White;
                _labelBrush = Brushes.White;

                base.Draw(graphics, nvd, boundingBox);
            }
开发者ID:675492062,项目名称:behaviac,代码行数:9,代码来源:NodeViewData.SubItemEvent.cs


示例7: NodeViewDataStyled

 public NodeViewDataStyled(NodeViewData parent, BehaviorNode rootBehavior, Node node, Pen borderPen, Brush backgroundBrush, Brush draggedBackgroundBrush, string label, string description, int minWidth = 120, int minHeight = 35) :
     base(parent, rootBehavior, node,
          NodeShape.RoundedRectangle,
          new Style(backgroundBrush, null, Brushes.White),
          new Style(null, DefaultCurrentBorderPen, null),
          new Style(null, __defaultSelectedBorderPen, null),
          new Style(draggedBackgroundBrush, null, null),
          new Style(null, __highlightedBorderPen, null),
          new Style(null, __updatedBorderPen, null),
          new Style(null, __prefabBorderPen, null),
          label, __defaultLabelFont, __profileLabelFont, __profileLabelBoldFont, minWidth, minHeight, description) {
 }
开发者ID:675492062,项目名称:behaviac,代码行数:12,代码来源:NodeViewDataStyled.cs


示例8: BehaviorTreeView_DragDrop

        /// <summary>
        /// Handles when dropping a tree node on the view.
        /// </summary>
        private void BehaviorTreeView_DragDrop(object sender, DragEventArgs e) {
            // make sure the view is focused
            Focus();

            // drag the property or method into the node
            string dragItem = (string)e.Data.GetData(DataFormats.Text);

            if (!string.IsNullOrEmpty(dragItem) && _dragTargetNode != null && _dragTargetNode.Node != null) {
                if (_dragTargetNode.Node.SetDefaultPropertyByDragAndDrop(dragItem)) {
                    if (ClickNode != null) {
                        ClickNode(_dragTargetNode);
                    }

                    UndoManager.Save(this.RootNode);

                    LayoutChanged();
                }

                return;
            }

            // get source node
            TreeNode sourceNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");

            if (sourceNode == null) {
                return;
            }

            NodeTag sourceNodeTag = (NodeTag)sourceNode.Tag;

            // keep the current node position
            //KeepNodePosition(_dragTargetNode);

            bool bDragBTOverNode = !((Node)this.RootNode).IsFSM && sourceNodeTag.Type == NodeTagType.Behavior && _dragTargetNode is Behaviac.Design.NodeViewData;

            // check if we are dropping an attach
            // or if we are dropping a bt to a node and the indicator is not left/right/up/bottom/center
            if (_dragAttachMode == NodeAttachMode.Attachment ||
                (bDragBTOverNode && (_dragAttachMode == NodeAttachMode.None || _dragAttachMode == NodeAttachMode.Attachment))) {
                Attachments.Attachment attach = null;

                // when we attach a behaviour we must create a special referenced behaviour node
                if (bDragBTOverNode) {
                    //drag an event(a bt) to a node
                    if (!File.Exists(sourceNodeTag.Filename))
                    {
                        MainWindow.Instance.SaveBehavior(sourceNodeTag.Defaults as Nodes.BehaviorNode, false);
                    }

                    if (File.Exists(sourceNodeTag.Filename)) {
                        // get the behavior we want to reference
                        BehaviorNode behavior = _behaviorTreeList.LoadBehavior(sourceNodeTag.Filename);
                        Behavior rootB = _rootNodeView.RootBehavior as Behavior;
                        Behavior b = behavior as Behavior;

                        if (!b.CanBeAttached || !IsCompatibleAgentType(rootB, b))
                            return;

                        attach = Behaviac.Design.Attachments.Attachment.Create(typeof(Behaviac.Design.Attachments.Event), _dragTargetNode.Node);
                        Behaviac.Design.Attachments.Event evt = (Behaviac.Design.Attachments.Event)attach;
                        evt.ReferencedBehavior = behavior;
                    }

                } else if (_dragTargetNode != null) {
                    Debug.Check(_dragAttachMode == NodeAttachMode.Attachment);

                    // add the attach to the target node
                    attach = Behaviac.Design.Attachments.Attachment.Create(sourceNodeTag.NodeType, _dragTargetNode.Node);
                }

                if (_dragTargetNode != null && attach != null && _dragTargetNode.Node.AcceptsAttachment(attach))
                {
                    attach.OnPropertyValueChanged(false);

                    attach.ResetId();
                    _dragTargetNode.Node.AddAttachment(attach);

                    NodeViewData.SubItemAttachment sub = attach.CreateSubItem();
                    _dragTargetNode.AddSubItem(sub);

                    SelectedNode = _dragTargetNode;
                    SelectedNode.SelectedSubItem = sub;

                    // call the ClickEvent event handler
                    if (ClickEvent != null) {
                        ClickEvent(SelectedNode);
                    }

                    UndoManager.Save(this.RootNode);

                    LayoutChanged();
                }
            }

            //else if (_dragAttachMode != NodeAttachMode.None)
            else {
                // attach a new node to the target node
//.........这里部分代码省略.........
开发者ID:Just4F,项目名称:behaviac,代码行数:101,代码来源:BehaviorTreeView.cs


示例9: CenterNode

        /// <summary>
        /// Centres the given node in the view.
        /// </summary>
        /// <param name="node">The node which will be centred.</param>
        internal void CenterNode(NodeViewData node) {
            _maintainNodePosition = node;

            // we use the existing maintain position stuff for that
            RectangleF bbox = node.IsFSM ? node.GetTotalBoundingBox() : node.BoundingBox;

            float width = bbox.Width <= 0.0f ? node.MinWidth : bbox.Width;
            float height = bbox.Height <= 0.0f ? node.MinHeight : bbox.Height;

            // Scale the whole graph to the suitable size in the view.
            float viewWidth = ClientSize.Width - 30;
            float viewHeight = ClientSize.Height - 30;
            bool isWidthScale = false;

            if (viewWidth > 0 && viewHeight > 0) {
                SizeF totalSize = node.GetTotalSize(_nodeLayoutManager.Padding.Width, int.MaxValue);
                float scale = 1.0f;

                if (totalSize.Width / totalSize.Height < viewWidth / viewHeight) {
                    scale = viewHeight / totalSize.Height;
                    isWidthScale = false;
                }

                else {
                    scale = viewWidth / totalSize.Width;
                    isWidthScale = true;
                }

                const float MinScale = 0.1f;
                const float MaxScale = 2.0f;

                if (scale < MinScale) {
                    _nodeLayoutManager.Scale = MinScale;
                }

                else if (scale > MaxScale) {
                    _nodeLayoutManager.Scale = MaxScale;
                }

                else {
                    _nodeLayoutManager.Scale = scale;
                }
            }

            if (node.IsFSM)
            {
                if (isWidthScale)
                    _graphOrigin = new PointF(0.0f, ClientSize.Height * 0.5f - height * 0.5f * _nodeLayoutManager.Scale);
                else
                    _graphOrigin = new PointF(ClientSize.Width * 0.5f - width * 0.5f * _nodeLayoutManager.Scale, 0.0f);
            }
            else
            {
                _graphOrigin = new PointF(20.0f, ClientSize.Height * 0.5f - height * 0.5f);
            }

            Invalidate();
        }
开发者ID:Just4F,项目名称:behaviac,代码行数:62,代码来源:BehaviorTreeView.cs


示例10: BehaviorTreeView_DragOver

        /// <summary>
        /// Handles when a tree node is dragged on the view.
        /// </summary>
        private void BehaviorTreeView_DragOver(object sender, DragEventArgs e) {
            // get the node we are dragging over
            Point pt = PointToClient(new Point(e.X, e.Y));
            NodeViewData nodeFound = _rootNodeView.GetInsideNode(new PointF(pt.X, pt.Y));

            // update last know mouse position
            _lastMousePosition = new PointF(pt.X, pt.Y);

            // update the current node
            if (nodeFound != _currentNode) {
                _currentNode = nodeFound;
                Invalidate();
            }

            // when we are moving on a node we must keep drawing as the ttach ode might change but not the node
            else if (nodeFound != null) {
                Invalidate();
            }

            // store the target node
            _dragTargetNode = _currentNode;

            // deny drop by default
            e.Effect = DragDropEffects.None;

            // process dragging the property and method string value from the Meta Browser
            string dragItem = (string)e.Data.GetData(DataFormats.Text);

            if (!string.IsNullOrEmpty(dragItem) &&
                _dragTargetNode != null && _dragTargetNode.Node != null &&
                _dragTargetNode.Node.AcceptDefaultPropertyByDragAndDrop()) {
                e.Effect = DragDropEffects.Move;

                _dragAttachMode = NodeAttachMode.None;

                return;
            }

            // make sure the correct drag attach mode is set
            if (_dragTargetNode != null) {
                if (_dragNodeDefaults is Nodes.Node && _dragAttachMode == NodeAttachMode.Attachment) {
                    _dragAttachMode = NodeAttachMode.None;

                } else if (_dragNodeDefaults is Attachments.Attachment && _dragAttachMode != NodeAttachMode.Attachment) {
                    _dragAttachMode = NodeAttachMode.Attachment;
                }
            }

            // check if we are trying to drop a node on another one
            if (_dragTargetNode != null && (e.KeyState & 1/*left mouse button*/) > 0) {
                if (_dragNodeDefaults != null &&
                    (_dragNodeDefaults is Nodes.Node && (_dragAttachMode != NodeAttachMode.None || !(_dragNodeDefaults is Nodes.BehaviorNode) || !(_dragTargetNode.Node is Nodes.BehaviorNode)) ||
                     _dragNodeDefaults is Attachments.Attachment && _dragTargetNode.Node.AcceptsAttachment(_dragNodeDefaults))) {
                    e.Effect = DragDropEffects.Move;
                }
            }

            // If this is an empty node, no effect for it.
            if (_dragTargetNode == null || _dragTargetNode.Node == null || _dragNodeDefaults == null ||
                _dragAttachMode == NodeAttachMode.None && !_dragTargetNode.Node.AcceptsAttachment(_dragNodeDefaults))
            {
                e.Effect = DragDropEffects.None;
            }

            if (_rootNodeView.IsFSM || _rootNodeView.Children.Count == 0) { // fsm or empty behavior
                if (_dragNodeDefaults != null) {
                    if (_dragNodeDefaults is Node) {
                        Node dragNode = _dragNodeDefaults as Node;

                        if (dragNode.IsFSM || dragNode is Behavior) {
                            if (_dragTargetNode == null) {
                                e.Effect = DragDropEffects.Move;
                            }
                            //else if (_dragNodeDefaults is Nodes.BehaviorNode) {
                            //    e.Effect = DragDropEffects.None;
                            //}
                        }

                    } else if (_dragNodeDefaults is Attachments.Attachment) {
                        Attachments.Attachment dragAttachment = _dragNodeDefaults as Attachments.Attachment;

                        if (dragAttachment.IsFSM) {
                            if (_dragTargetNode != null && !(_dragTargetNode.Node is Nodes.BehaviorNode) &&
                                _dragTargetNode.Node.AcceptsAttachment(dragAttachment)) {
                                e.Effect = DragDropEffects.Move;
                            }

                            else {
                                e.Effect = DragDropEffects.None;
                            }
                        }
                    }
                }
            }
        }
开发者ID:Just4F,项目名称:behaviac,代码行数:98,代码来源:BehaviorTreeView.cs


示例11: Draw

            public override void Draw(Graphics graphics, NodeViewData nvd, RectangleF boundingBox) {
                // render background
                DrawBackground(graphics, nvd, this.BackgroundBrush);

                // render the label
                PointF center = new PointF(boundingBox.Left + boundingBox.Width * 0.5f, boundingBox.Top + boundingBox.Height * 0.5f);

                SizeF labelSize = MeasureDisplayStringWidth(graphics, this.DisplayLabel, _labelFont);

                // draw text
                switch (_alignment) {
                    case (Alignment.Left):
                        graphics.DrawString(this.DisplayLabel, _labelFont, _labelBrush, boundingBox.Left + 6.0f, center.Y - labelSize.Height * 0.5f);
                        break;

                    case (Alignment.Center):
                        graphics.DrawString(this.DisplayLabel, _labelFont, _labelBrush, center.X - labelSize.Width * 0.5f, center.Y - labelSize.Height * 0.5f);
                        break;

                    case (Alignment.Right):
                        graphics.DrawString(this.DisplayLabel, _labelFont, _labelBrush, boundingBox.Right - labelSize.Width - 6.0f, center.Y - labelSize.Height * 0.5f);
                        break;
                }
            }
开发者ID:675492062,项目名称:behaviac,代码行数:24,代码来源:NodeViewData.SubItemText.cs


示例12: MoveSubItem

        private bool MoveSubItem(NodeViewData sourceNvd, NodeViewData targetNvd, NodeViewData.SubItemAttachment sourceAttachment, NodeViewData.SubItemAttachment targetAttachment, bool insertPreviously, bool isCopied) {
            if (sourceNvd != null && targetNvd != null && sourceAttachment != null &&
                sourceNvd.SetSubItem(targetNvd, sourceAttachment, targetAttachment, insertPreviously, isCopied)) {
                // set the prefab dirty for the node
                if (!string.IsNullOrEmpty(sourceNvd.Node.PrefabName)) {
                    sourceNvd.Node.HasOwnPrefabData = true;
                }

                if (!string.IsNullOrEmpty(targetNvd.Node.PrefabName)) {
                    targetNvd.Node.HasOwnPrefabData = true;
                }

                SelectedNode = targetNvd;

                // call the ClickEvent event handler
                if (ClickEvent != null) {
                    ClickEvent(SelectedNode);
                }

                UndoManager.Save(this.RootNode);

                LayoutChanged();

                return true;
            }

            return false;
        }
开发者ID:Just4F,项目名称:behaviac,代码行数:28,代码来源:BehaviorTreeView.cs


示例13: control_ClickEvent

        private void control_ClickEvent(NodeViewData node)
        {
            if (node == null)
                return;

            // if there is no subitem selected, use the properties of the node
            if (node.SelectedSubItem == null || node.SelectedSubItem.SelectableObject == null)
            {
                PropertiesDock.InspectObject(node.RootBehavior, node.Node);
            }
            // publish the properties of the subitem's selection object
            else
            {
                PropertiesDock.InspectObject(node.RootBehavior, node.SelectedSubItem.SelectableObject);
            }
        }
开发者ID:KeyleXiao,项目名称:behaviac,代码行数:16,代码来源:MainWindow.cs


示例14: OnPaint

        /// <summary>
        /// Handles the drawing and updating of the graph.
        /// </summary>
        protected override void OnPaint(PaintEventArgs e) {
            base.OnPaint(e);

            // calculate the mouse position in the graph
            PointF graphMousePos = _nodeLayoutManager.ViewToGraph(_lastMousePosition);

            // when the layout was changed it needs to be recalculated
            bool layoutChanged = _nodeLayoutManager.LayoutChanged;

            if (layoutChanged) {
                _nodeLayoutManager.UpdateLayout(e.Graphics, _forceChangeLayout);
                _forceChangeLayout = false;
            }

            // center the root behaviour if requested
            if (_pendingCenterBehavior) {
                _pendingCenterBehavior = false;
                CenterNode(_rootNodeView);
            }

            // select the pending node
            if (_selectedNodePending != null) {
                if (_selectedNodePendingParent != null) {
                    if (_selectedNodePendingParent.CanBeExpanded() && !_selectedNodePendingParent.IsExpanded) {
                        _selectedNodePendingParent.IsExpanded = true;
                        LayoutChanged();
                    }

                    SelectedNode = _selectedNodePendingParent.GetChild(_selectedNodePending);

                } else {
                    SelectedNode = RootNodeView.FindNodeViewData(_selectedNodePending);
                }

                if (SelectedNode != null) {
                    if (SelectedNode.CanBeExpanded() && !SelectedNode.IsExpanded) {
                        SelectedNode.IsExpanded = true;
                        LayoutChanged();
                    }

                    SelectedNode.SelectedSubItem = SelectedNode.GetSubItem(_selectedAttachmentPending);
                    ShowNode(SelectedNode);
                }

                _selectedNodePending = null;
                _selectedNodePendingParent = null;
                _selectedAttachmentPending = null;

                if (ClickEvent != null) {
                    ClickEvent(SelectedNode);
                }
            }

            // check if we must keep the original position of the mouse
            if (_maintainMousePosition) {
                _maintainMousePosition = false;

                // move the graph so that _graphOrigin is at the same position in the view as it was before
                float mouseX = (graphMousePos.X - _graphOrigin.X) * _nodeLayoutManager.Scale + _nodeLayoutManager.Offset.X;
                float mouseY = (graphMousePos.Y - _graphOrigin.Y) * _nodeLayoutManager.Scale + _nodeLayoutManager.Offset.Y;

                _nodeLayoutManager.Offset = new PointF(mouseX, mouseY);
            }

            // check if we must keep the original position of _maintainNodePosition
            else if (_maintainNodePosition != null) {
                // move the graph so that _graphOrigin is at the same position in the view as it was before
                RectangleF bbox = _maintainNodePosition.IsFSM ? _maintainNodePosition.GetTotalBoundingBox() : _maintainNodePosition.BoundingBox;
                PointF viewpos = new PointF(bbox.X * _nodeLayoutManager.Scale, bbox.Y * _nodeLayoutManager.Scale);

                _nodeLayoutManager.Offset = new PointF(_graphOrigin.X - viewpos.X, _graphOrigin.Y - viewpos.Y);
            }

            // reset the node whose position we want to keep
            _maintainNodePosition = null;

            // draw the graph to the view
            _nodeLayoutManager.DrawGraph(e.Graphics, graphMousePos, _currentNode, SelectedNode, _highlightedNodeIds, _updatedNodeIds, _highlightedTransitionIds, _highlightBreakPoint, _profileInfos);

            // check if we are currently dragging a node and we must draw additional data
            if (_dragTargetNode != null && _dragAttachment == null && (KeyCtrlIsDown && _movedNode != null || _dragTargetNode.Node != _movedNode)) {
                if (_dragAttachMode == NodeAttachMode.Attachment) {
                    // we could draw some stuff for attachements here
                } else {
                    // draw the arrows for the attach modes

                    // get the bounding box of the node
                    RectangleF bbox = _dragTargetNode.BoundingBox;

                    // get the bounding box of the connector
                    _dragTargetConnector = null;

                    // the depth of the area for the mouse
                    const float offset = 12.0f;

                    // the distance of the arrow from the border and its height
                    const float innerOffset = 2.0f;
//.........这里部分代码省略.........
开发者ID:Just4F,项目名称:behaviac,代码行数:101,代码来源:BehaviorTreeView.cs


示例15: OnKeyUp

        /// <summary>
        /// Handles when a key is released.
        /// </summary>
        protected override void OnKeyUp(KeyEventArgs e) {
            switch (e.KeyCode) {
                case (Keys.Enter):
                    if (SelectedNode != null) {
                        if (KeyCtrlIsDown) {
                            SelectedNode.ExpandAll(!SelectedNode.IsExpanded);
                        }

                        else {
                            SelectedNode.IsExpanded = !SelectedNode.IsExpanded;
                        }

                        LayoutChanged();

                        e.Handled = true;
                    }

                    break;

                    // store when the shift key is released
                case (Keys.ShiftKey):

                    // update the drawn graph for dragging and duplicating
                    if (_movedNodeGraph != null) {
                        _movedNodeGraph.RenderDepth = 0;
                        Invalidate();
                    }

                    break;

                    // paste from clipboard
                case (Keys.V):
                    PasteSelectedNode();

                    _clipboardPasteMode = false;

                    // reset all the drag data
                    _copiedNode = null;
                    _movedNode = null;
                    _dragTargetNode = null;
                    _dragNodeDefaults = null;
                    _movedNodeGraph = null;

                    // redraw the graph
                    Invalidate();
                    break;

                case (Keys.Left):
                case (Keys.Right):
                case (Keys.Up):
                case (Keys.Down):
                    if (e.Control)
                    {
                        break;
                    }

                    if (SelectedNode == null) {
                        SelectedNode = this.RootNodeView;

                        if (ClickNode != null) {
                            ClickNode(SelectedNode);
                        }

                        LayoutChanged();
                        break;
                    }

                    switch (e.KeyCode) {
                        case (Keys.Left):
                            if (SelectedNode != null && SelectedNode.Parent != null) {
                                SelectedNode = SelectedNode.Parent;

                                if (ClickNode != null) {
                                    ClickNode(SelectedNode);
                                }

                                LayoutChanged();
                            }

                            break;

                        case (Keys.Right):
                            if (SelectedNode != null && SelectedNode.Children.Count > 0) {
                                SelectedNode = SelectedNode.Children[0] as NodeViewData;

                                if (ClickNode != null) {
                                    ClickNode(SelectedNode);
                                }

                                LayoutChanged();
                            }

                            break;

                        case (Keys.Up):
                            if (SelectedNode != null) {
                                if (!KeyShiftIsDown || !SwitchSelection()) {
//.........这里部分代码省略.........
开发者ID:Just4F,项目名称:behaviac,代码行数:101,代码来源:BehaviorTreeView.cs


示例16: KeepNodePosition

 private void KeepNodePosition(NodeViewData nvd) {
     // keep the position of the current node
     if (nvd != null && !nvd.IsFSM)
     {
         _maintainNodePosition = nvd;
         _graphOrigin = _maintainNodePosition.DisplayBoundingBox.Location;
     }
 }
开发者ID:Just4F,项目名称:behaviac,代码行数:8,代码来源:BehaviorTreeView.cs


示例17: 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


示例18: OnMouseUp

        /// <summary>
        /// Handles when a mouse button is let go of.
        /// </summary>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            _movedSubItem = null;

            // check if we were dragging a transition for the FSM.
            if (e.Button == MouseButtons.Left && _currentNode != null && ((_objectDragType == ObjectDragTypes.kNode) && _currentNode.IsFSM || _fsmSubItem != null && _fsmDragMode != FSMDragModes.kNone)) {
                if (Plugin.EditMode == EditModes.Design && _startMousePosition != e.Location) {
                    // drag and move the fsm node
                    if ((_objectDragType == ObjectDragTypes.kNode) && _currentNode.IsFSM) {
                        UndoManager.Save(this.RootNode);

                        LayoutChanged();
                    }

                    // drag and connector the target node
                    else {
                        NodeViewData targetNvd = _rootNodeView.GetInsideNode(e.Location);

                        if (targetNvd != null && targetNvd.IsFSM && (targetNvd.Parent != null) && _fsmSubItem is NodeViewData.SubItemAttachment) {
                            NodeViewData.SubItemAttachment subItemAttachment = _fsmSubItem as NodeViewData.SubItemAttachment;

                            if (subItemAttachment.Attachment != null && subItemAttachment.Attachment.TargetFSMNodeId != targetNvd.Node.Id) {
                                subItemAttachment.Attachment.TargetFSMNodeId = targetNvd.Node.Id;

                                UndoManager.Save(this.RootNode);

                                LayoutChanged();
                            }
                        }
                    }
                }
            }

            // check if we were dragging an existing sub item.
            else if (e.Button == MouseButtons.Left && _currentNode != null && _dragTargetNode != null && _dragAttachment != null) {
                NodeViewData.SubItem targetSubItem = _dragTargetNode.GetSubItem(_dragTargetNode, _nodeLayoutManager.ViewToGraph(e.Location));

                if (KeyCtrlIsDown || targetSubItem != _dragAttachment) {
                    NodeViewData.SubItemAttachment targetAttachment = targetSubItem as NodeViewData.SubItemAttachment;

                    if ((_currentNode != _dragTargetNode || targetAttachment != null) &&
                        this.MoveSubItem(_currentNode, _dragTargetNode, _dragAttachment, targetAttachment, _dragAttachMode == NodeAttachMode.Top, KeyCtrlIsDown)) {
                        _currentNode.ClickEvent(_currentNode, _nodeLayoutManager.ViewToGraph(e.Location));

                        LayoutChanged();
                    }
                }

                _dragAttachment = null;
                _dragTargetAttachment = null;
                _dragAttachMode = NodeAttachMode.None;
            }

            // check if we were dragging or copying an existing node.
            else if (e.Button == MouseButtons.Left && (_movedNode != null || _copiedNode != null || _clipboardPasteMode)) {
                // if we have a valid target node continue
                if (_dragTargetNode != null) {
                    Node sourceNode = null;

                    if (_copiedNode != null) {
                        bool cloneBranch = !(_copiedNode is ReferencedBehavior);
                        sourceNode = (KeyShiftIsDown && cloneBranch) ? (Nodes.Node)_copiedNode.CloneBranch() : (Nodes.Node)_copiedNode.Clone();

                    } else if (_clipboardPasteMode) {
                        bool cloneBranch = !(_clipboardNode is ReferencedBehavior);
                        sourceNode = (/*KeyShiftIsDown && */cloneBranch) ? (Nodes.Node)_clipboardNode.CloneBranch() : (Nodes.Node)_clipboardNode.Clone();

                    } else if (_movedNode != null) {
                        sourceNode = _movedNode;
                    }

                    Debug.Check(sourceNode != null);
                    Node sourceParent = (Node)sourceNode.Parent;
                    BehaviorNode sourceBehavior = sourceNode.Behavior;

                    if (_dragTargetNode.Node == sourceNode) {
                        _dragAttachMode = NodeAttachMode.None;
                    }

                    if (_dragAttachMode == NodeAttachMode.Top ||
                        _dragAttachMode == NodeAttachMode.Bottom ||
                        _dragAttachMode == NodeAttachMode.Left ||
                        _dragAttachMode == NodeAttachMode.Right ||
                        _dragAttachMode == NodeAttachMode.Center) {
                        // set the prefab dirty for its previous parent
                        if (sourceParent != null && !string.IsNullOrEmpty(sourceParent.PrefabName)) {
                            sourceParent.HasOwnPrefabData = true;
                        }

                        if (KeyShiftIsDown) {
                            if (sourceParent != null) {
                                sourceParent.RemoveChild(sourceNode.ParentConnector, sourceNode);
                            }

                        } else {
                            sourceNode.ExtractNode();
                        }
//.........这里部分代码省略.........
开发者ID:Just4F,项目名称:behaviac,代码行数:101,代码来源:BehaviorTreeView.cs


示例19: ShowNode

        /// <summary>
        /// Shows the given node in the view.
        /// </summary>
        /// <param name="node">The node which will be centred.</param>
        internal void ShowNode(NodeViewData node) {
            // Expand all of its parents.
            bool layoutChanged = false;
            NodeViewData parent = node.Parent;

            while (parent != null) {
                if (!parent.IsExpanded) {
                    parent.IsExpanded = true;
                    layoutChanged = true;
                }

                parent = parent.Parent;
            }

            if (layoutChanged) {
                LayoutChanged();
            }

            // we use the existing maintain position stuff for that
            RectangleF bbox = node.BoundingBox;

            // If the node was not yet shown there is no bounding box,
            // so we simply use the min width and height for that.
            float width = bbox.Width <= 0.0f ? node.MinWidth : bbox.Width;
            float height = bbox.Height <= 0.0f ? node.MinHeight : bbox.Height;

            RectangleF displayBox = node.DisplayBoundingBox;

            // If this display bounding box is in the view, the node need not be moved.
            if (displayBox.X >= 0 && displayBox.X <= ClientSize.Width - width &&
                displayBox.Y >= 0 && displayBox.Y <= ClientSize.Height - height) {
                return;
            }

            _maintainNodePosition = node;

            _graphOrigin = new PointF(ClientSize.Width * 0.5f - width * 0.5f, ClientSize.Height * 0.5f - height * 0.5f);

            Invalidate();
        }
开发者ID:Just4F,项目名称:behaviac,代码行数:44,代码来源:BehaviorTreeView.cs


示例20: CollapseFailedBrach

        private void CollapseFailedBrach(NodeViewData nv) {
        

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Design.PropertyDef类代码示例发布时间:2022-05-24
下一篇:
C# Design.MethodDef类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap