/// <summary> /// Creates a Link object and connects the tail port and head /// port of the link. /// </summary> /// <param name="cmdTarget">Parent node to add the link to</param> /// <returns>true if successful, otherwise false</returns> /// <remarks> /// If the <see cref="Syncfusion.Windows.Forms.Diagram.LinkCmd.Link"/> /// property is null when this method is called, then a new Link object /// is created by invoking the /// <see cref="Syncfusion.Windows.Forms.Diagram.LinkCmd.LinkFactory"/> /// delegate. The Link object is then added to the node passed in the /// cmdTarget parameter. Next, the tail of the link is connected to the /// <see cref="Syncfusion.Windows.Forms.Diagram.LinkCmd.SourcePort"/> /// and the head of the link is connected to the /// <see cref="Syncfusion.Windows.Forms.Diagram.LinkCmd.TargetPort"/>. /// <seealso cref="Syncfusion.Windows.Forms.Diagram.LinkCmd.LinkFactory"/> /// </remarks> public bool Do(object cmdTarget) { bool success = false; ICompositeNode parentNode = null; int childIdx; if (this.link == null) { this.link = this.linkFactory(this.points); } if (this.link != null) { parentNode = cmdTarget as ICompositeNode; if (parentNode != null) { childIdx = parentNode.AppendChild(this.link); if (this.sourcePort != null) { this.link.ConnectTail(this.sourcePort); } if (this.targetPort != null) { this.link.ConnectHead(this.targetPort); } success = true; } } return(success); }
// Start is called before the first frame update void Start() { bb = new BlackBoard(); bb.passedTime = 0.0f; bb.timer = 5.0f; bb.from = this.transform; bb.to = GameObject.FindGameObjectWithTag("Player").transform; bb.speed = 3.0f; rootNode = new SequenceNode <BlackBoard>(); rootNode.Add(NodeBuilder.WaitNode()); rootNode.Add(NodeBuilder.MoveFromTo()); }
/// <summary> /// /// </summary> /// <param name="cmdTarget"></param> /// <returns></returns> public override bool Do(object cmdTarget) { bool success = false; ICompositeNode parentNode = cmdTarget as ICompositeNode; if (parentNode != null) { foreach (INode curNode in this.Nodes) { int childIdx = parentNode.GetChildIndex(curNode); int newIdx; int childCount; if (childIdx >= 0) { parentNode.RemoveChild(childIdx); } switch (this.updType) { case ZOrderUpdate.Front: parentNode.AppendChild(curNode); break; case ZOrderUpdate.Back: parentNode.InsertChild(curNode, 0); break; case ZOrderUpdate.Forward: childCount = parentNode.ChildCount; newIdx = (childIdx < childCount) ? (childIdx + 1) : (childCount); parentNode.InsertChild(curNode, newIdx); break; case ZOrderUpdate.Backward: newIdx = (childIdx > 0) ? (childIdx - 1) : (0); parentNode.InsertChild(curNode, newIdx); break; } } } return(success); }
/// <summary> /// /// </summary> /// <param name="cmdTarget"></param> /// <returns></returns> public override bool Do(object cmdTarget) { bool success = false; ICompositeNode parentNode = null; Group curGroup; ICompositeNode curParent; int childIdx; int newIdx; INode curChild; parentNode = cmdTarget as ICompositeNode; if (parentNode != null) { IEnumerator nodeEnum = this.Nodes.GetEnumerator(); while (nodeEnum.MoveNext()) { curGroup = nodeEnum.Current as Group; if (curGroup != null) { curParent = curGroup.Parent; if (curParent != null) { childIdx = curParent.GetChildIndex(curGroup); if (childIdx >= 0) { curParent.RemoveChild(childIdx); } } for (childIdx = 0; childIdx < curGroup.ChildCount; childIdx++) { curChild = curGroup.GetChild(childIdx); newIdx = parentNode.AppendChild(curChild); } } } success = true; } return(success); }
/// <summary> /// Destroys the group created by executing the command and restores /// the nodes to their original parent. /// </summary> /// <returns>true if successful, otherwise false</returns> public override bool Undo() { bool success = false; if (this.group != null && this.groupParent != null) { NodeCollection groupMembers = new NodeCollection(); for (int childIdx = 0; childIdx < this.group.ChildCount; childIdx++) { INode curChild = this.group.GetChild(childIdx); if (curChild != null) { groupMembers.Add(curChild); } } int groupChildIdx = this.groupParent.GetChildIndex(this.group); if (groupChildIdx >= 0) { this.groupParent.RemoveChild(groupChildIdx); } this.group.RemoveAllChildren(); this.group = null; foreach (INode curChild in groupMembers) { ICompositeNode curParent = null; if (this.parentMap.Contains(curChild)) { curParent = (ICompositeNode)this.parentMap[curChild]; curParent.AppendChild(curChild); } } success = true; } return(success); }
/// <summary> /// Creates a group and populates with the list of nodes attached to /// the command. /// </summary> /// <param name="cmdTarget">Parent node that will contain the new group</param> /// <returns>true if successful, otherwise false</returns> public override bool Do(object cmdTarget) { bool success = false; ICompositeNode curParent; int childIdx; this.group = new Group(); this.parentMap.Clear(); this.groupParent = cmdTarget as ICompositeNode; if (this.groupParent != null) { foreach (INode curNode in this.Nodes) { curParent = curNode.Parent; if (curParent != null) { childIdx = curParent.GetChildIndex(curNode); if (childIdx >= 0) { this.parentMap.Add(curNode, curParent); curParent.RemoveChild(childIdx); } } childIdx = this.group.AppendChild(curNode); } childIdx = this.groupParent.AppendChild(this.group); success = true; } return(success); }
/// <summary> /// Constructs a NodePathTracker object given a view and a collection /// of nodes to track. /// </summary> /// <param name="view">View to attach to</param> /// <param name="nodes">Collection of nodes to track</param> public NodePathTracker(View view, NodeCollection nodes) : base(view) { // Load array of bounding rectangles this.trackingPath = new GraphicsPath(); this.ptUpperLeft = new Point(int.MaxValue, int.MaxValue); System.Drawing.Rectangle curBounds; foreach (INode curNode in nodes) { IGraphics graphicsObj = curNode as IGraphics; IBounds2DF nodeBounds = curNode as IBounds2DF; ITransform nodeTrans = curNode as ITransform; ICompositeNode nodeParent = curNode.Parent; // Push the parent transforms for the current node onto the stack if (nodeTrans != null) { Global.MatrixStack.Push(nodeTrans.ParentTransform); } // Get the bounds of the current node in world coordinates if (nodeBounds != null) { curBounds = this.view.ViewToDevice(this.view.WorldToView(nodeBounds.Bounds)); if (curBounds.Left < this.ptUpperLeft.X) { this.ptUpperLeft.X = curBounds.Left; } if (curBounds.Top < this.ptUpperLeft.Y) { this.ptUpperLeft.Y = curBounds.Top; } } else { curBounds = new System.Drawing.Rectangle(0, 0, 0, 0); } if (graphicsObj != null) { GraphicsPath grfxPath = graphicsObj.GraphicsPath; if (grfxPath != null) { this.trackingPath.AddPath(grfxPath, false); } } else if (nodeBounds != null) { this.trackingPath.AddRectangle(curBounds); } // Get the constraining region for the current node and add it // to the constraining region for the tracker Region curRgnConstraint = null; if (nodeParent != null) { curRgnConstraint = nodeParent.GetConstrainingRegion(curNode); if (curRgnConstraint != null) { if (this.rgnConstraint == null) { this.rgnConstraint = curRgnConstraint.Clone(); } else { this.rgnConstraint.Union(curRgnConstraint); } } } // Reset matrix stack Global.MatrixStack.Clear(); } }