//default node function implementions - override to change public virtual void DeleteLink(CustomContextMenuTag clickedItemTag) { if (this.LinkID.HasValue) { CustomTreeView myTree = (CustomTreeView)this.TreeView; if (myTree != null && this.LinkID.HasValue) { try { if (myTree.Controller.ViewUpdateStatus == false) { myTree.DeleteNodeWithID(this.LinkID.Value, false, false); // updating is off, don't force } else { myTree.DeleteNodeWithID(this.LinkID.Value, true, false); } myTree.OnItemDelete(clickedItemTag.GetFunctionValue(), this); } catch (Exception e) { MessageBox.Show(e.Message); } } } }
public virtual void createObjectInstance(CustomContextMenuTag clickedItemTag) { CustomTreeView myTree = (CustomTreeView)this.TreeView; // bring up a form for input //InputForm tempInput = new InputForm(clickedItemTag.GetFunctionName(), clickedItemTag.GetNode().NodeType); // create the dialog InputForm tempInput = new InputForm(clickedItemTag.GetFunctionName(), "CreateEvent"); // create the dialog tempInput.StartPosition = FormStartPosition.Manual; int x = Cursor.Position.X; int y = Cursor.Position.Y; tempInput.Location = new Point(x, y); DialogResult result = tempInput.ShowDialog(myTree); if (result == DialogResult.OK) { // create a resource String name = tempInput.TopInputFieldValue; if (NodeType.ToLowerInvariant() != name.ToLowerInvariant()) { try { int addID; if (NodeID >= 0) // fake nodes are -1 { addID = NodeID; } else { addID = myTree.GetCustomTreeRootId(this.LinkType); } //int added = myTree.Controller.AddComponent(myTree.GetCustomTreeRootId(this.LinkType), addID, NodeType, tempInput.TopInputFieldValue, this.LinkType, tempInput.BottomInputFieldValue); //myTree.OnItemAdd(clickedItemTag.GetFunctionValue(), added, NodeType, tempInput.TopInputFieldValue); //int ceId = myTree.Controller.CreateComponent("CreateEvent", tempInput.TopInputFieldValue, tempInput.BottomInputFieldValue); myTree.Controller.TurnViewUpdateOff(); // because add and connect will both send out component udpates and update the whole screen ComponentAndLinkID added = myTree.Controller.AddComponent(myTree.GetCustomTreeRootId(this.LinkType), myTree.GetCustomTreeRootId(this.LinkType), "CreateEvent", tempInput.TopInputFieldValue, this.LinkType, tempInput.BottomInputFieldValue); int ceLinkId = myTree.Controller.Connect(myTree.GetCustomTreeRootId(this.LinkType), added.ComponentID, clickedItemTag.GetNode().NodeID, this.LinkType); myTree.OnItemAdd(clickedItemTag.GetFunctionValue(), added.ComponentID, ceLinkId, "CreateEvent", tempInput.TopInputFieldValue, this.LinkType); myTree.Controller.TurnViewUpdateOn(false, false); // update should be locale to this tree, so myTree.UpdateViewComponent(); // update manually } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Unable to add item", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Cannot enter item with same name as parent type"); } } }
public virtual void createChild(CustomContextMenuTag clickedItemTag, String[] args) { CustomTreeView myTree = (CustomTreeView)this.TreeView; VSGController myController = (VSGController)myTree.Controller; try { int addID; if (NodeID >= 0) // fake nodes are -1 { addID = NodeID; } else { addID = myTree.GetCustomTreeRootId(this.LinkType); } ((VSGController)myTree.Controller).TurnViewUpdateOff(); ComponentAndLinkID added = myTree.Controller.AddComponent(myTree.GetCustomTreeRootId(this.LinkType), addID, args[0], args[0], this.LinkType, ""); myTree.OnItemAdd(clickedItemTag.GetFunctionValue(), added.ComponentID, added.LinkID, args[0], args[0], this.LinkType); //ProcessingNode parent = (ProcessingNode)Parent; if (NodeType == "CreateEvent") { myTree.Controller.Connect(added.ComponentID, added.ComponentID, NodeID, "EventID"); } if (NodeType == "ReiterateEvent") { List<int> ids = myController.GetChildIDs(NodeID, "CreateEvent", "EventID"); if (ids.Count > 0) { myTree.Controller.Connect(added.ComponentID, added.ComponentID, ids[0], "EventID"); } } ((VSGController)myTree.Controller).TurnViewUpdateOn(true, false); // only do component update } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Unable to add item", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public virtual void createArmament(CustomContextMenuTag clickedItemTag) { CustomTreeView myTree = (CustomTreeView)this.TreeView; try { int addID; addID = NodeID; ComponentAndLinkID added = myTree.Controller.AddComponent(myTree.GetCustomTreeRootId(this.LinkType), addID, "Armament", "Armament", this.LinkType, ""); myTree.OnItemAdd(clickedItemTag.GetFunctionValue(), added.ComponentID, added.LinkID, "Armament", "Armament", this.LinkType); } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Unable to add item", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public virtual void AddListItem(CustomContextMenuTag clickedItemTag) { // C.K. // Implementation should be the same for all functions. // It seems this call just acts as a pass through to the application side ti implement the behavior. // Other calls here have base behavior. // We need to streamline this. Lets provide a method to easily extend this class and override behavior. CustomTreeView myTree = (CustomTreeView)this.TreeView; // C.K. // We should call something else besides OnItemAdd. This can be confusing since we are not // adding anything here. Instead of piggybacking on this we could create OnCreateList... // Also, we have duplicate functionality: // XML - Argument elements under Function elements // Attribute parsing - action(arg1, agr2) // Do we really need both? Lets adopt one way and go with it. if (clickedItemTag.Arguments.Length > 0) myTree.OnItemAdd(clickedItemTag.GetFunctionValue(), NodeID, NodeID, clickedItemTag.Arguments[0], Name, LinkType); else myTree.OnItemAdd(clickedItemTag.GetFunctionValue(), NodeID, NodeID, NodeType, Name, LinkType); }
public virtual void AddClass(CustomContextMenuTag clickedItemTag) { CustomTreeView myTree = (CustomTreeView)this.TreeView; // bring up a form for input InputForm tempInput = new InputForm(clickedItemTag.GetFunctionName(), clickedItemTag.GetNode().myType); // create the dialog tempInput.StartPosition = FormStartPosition.Manual; int x = Cursor.Position.X; int y = Cursor.Position.Y; tempInput.Location = new Point(x, y); DialogResult result = tempInput.ShowDialog(myTree); if (result == DialogResult.OK) { // create a resource String name = tempInput.TopInputFieldValue; if (NodeType.ToLowerInvariant() != name.ToLowerInvariant()) { try { int addID; if (NodeID >= 0) // fake nodes are -1 { addID = NodeID; } else { addID = myTree.GetCustomTreeRootId(LinkType);// myTree.RootID; } //myTree.RootID ComponentAndLinkID added = myTree.Controller.AddComponentClass(myTree.GetCustomTreeRootId(LinkType), addID, NodeType, tempInput.TopInputFieldValue, LinkType, tempInput.BottomInputFieldValue); myTree.OnItemAdd(clickedItemTag.GetFunctionValue(), added.ComponentID, added.LinkID, NodeType, tempInput.TopInputFieldValue, LinkType); } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Unable to add item", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Cannot enter item with same name as parent type"); } } }
public virtual void CommonCreate(InputForm tempInput, CustomContextMenuTag clickedItemTag, String type) { CustomTreeView myTree = (CustomTreeView)this.TreeView; DialogResult result = tempInput.ShowDialog(myTree); if (result == DialogResult.OK) { // create a resource String name = tempInput.TopInputFieldValue; if (NodeType.ToLowerInvariant() != name.ToLowerInvariant()) { try { int addID = -1; if (NodeID >= 0) // fake nodes are -1 { addID = NodeID; } else // find the next parent with non negative ID { bool IDFound = false; object parentTest = this.Parent; while (parentTest != null) { if (parentTest is ProcessingNode && !IDFound) { ProcessingNode cast = (ProcessingNode)parentTest; if (cast.NodeID >= 0) { IDFound = true; addID = cast.NodeID; } else { parentTest = cast.Parent; // keep looking } } else { parentTest = null; } } if (!IDFound) { addID = myTree.GetCustomTreeRootId(LinkType);// myTree.RootID; // if no valid parent can be found, use the rootID of the tree } } //myTree.RootID ComponentAndLinkID added = myTree.Controller.AddComponent(myTree.GetCustomTreeRootId(LinkType), addID, type, tempInput.TopInputFieldValue, LinkType, tempInput.BottomInputFieldValue); myTree.OnItemAdd(clickedItemTag.GetFunctionValue(), added.ComponentID, added.LinkID, type, tempInput.TopInputFieldValue, LinkType); } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Unable to add item", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (myTree.Controller != null) { if (!myTree.Controller.ViewUpdateStatus) { // turn updating back on myTree.Controller.TurnViewUpdateOn(false, false); } } } } else { MessageBox.Show("Cannot enter item with same name as parent type"); } } }
public virtual void DeleteComponentAndLinkTypeChildren(CustomContextMenuTag clickedItemTag, Object[] args) { for (int i = 0, length = args.Length; i < length; i++) { try { CustomTreeView myTree = (CustomTreeView)this.TreeView; myTree.Controller.DeleteComponentAndChildren(NodeID, (String)args[i]); myTree.OnItemDelete(clickedItemTag.GetFunctionValue(), this); } catch (Exception e) { MessageBox.Show(e.Message); } } }
/// <summary> /// Delete component and all children, following tree's linktype /// </summary> /// <param name="clickedItemTag"></param> public virtual void DeleteComponentAndLinkTypeChildren(CustomContextMenuTag clickedItemTag) { try { CustomTreeView myTree = (CustomTreeView)this.TreeView; myTree.Controller.DeleteComponentAndChildren(NodeID, LinkType); myTree.OnItemDelete(clickedItemTag.GetFunctionValue(), this); } catch (Exception e) { MessageBox.Show(e.Message); } }