示例#1
0
        //default node function implementions - override to change
        public virtual void DeleteSingleLink(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, false); // updating is off, don't force
                        }
                        else
                        {
                            myTree.DeleteNodeWithID(this.LinkID.Value, true, false, false);
                        }

                        myTree.OnItemDelete(clickedItemTag.GetFunctionValue(), this);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                }
            }
        }
示例#2
0
        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");
                }
            }
        }
示例#3
0
        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 deleteDecisionMaker(CustomContextMenuTag clickedItemTag)
        {
            CustomTreeView myTree = (CustomTreeView)this.TreeView;
            VSGController myController = (VSGController)myTree.Controller;
            List<int> ids = myController.GetChildIDs(myController.ScenarioId, "CreateEvent", "Scenario");
            List<int> dmIDs;
            bool stopDelete = false;
            foreach (int id in ids)
            {
                dmIDs = myController.GetChildIDs(id, "DecisionMaker", "Scenario");
                if (dmIDs.Contains(NodeID))
                {
                    stopDelete = true;
                }

            }

            if (stopDelete)
            {
                MessageBox.Show("Warning: Cannot delete Decision Maker because it owns units.\nPlease delete or reassign units with the Scenario Director first.");
                return;
            }
            this.DeleteComponent(clickedItemTag);
        }
示例#5
0
 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);
     }
 }
示例#6
0
        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);

        }
示例#7
0
        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");
                }
            }
        }
示例#8
0
        protected void CustomTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs args)
        {
            if (AllowUserInput)
            {
                if (args.Button == MouseButtons.Right) // right click
                {
                    this.ContextMenuStrip.Items.Clear();

                    // detect node click
                    if (args.Node != null && (args.X >= args.Node.Bounds.Left) && (args.X <= args.Node.Bounds.Right) &&
                            (args.Y >= args.Node.Bounds.Top) && (args.Y <= args.Node.Bounds.Bottom))
                    {
                        ProcessingNode cast = (ProcessingNode)args.Node;
       
                        // handle right click by populating with node functions
                        List<Function> functions = cast.Functions;

                        if (functions != null)
                        {
                            ToolStripItem newItem;

                            if (functions.Count > 0)
                            {
                                NodeFunctionListEventArgs e = new NodeFunctionListEventArgs(cast, functions);
                                OnNodeFunctionList(e);
                            }

                            foreach (Function f in functions)
                            {
                                if (f.Visible)
                                {
                                    newItem = this.ContextMenuStrip.Items.Add(f.FunctionName);
                                    if (!f.Enabled)
                                        newItem.Enabled = f.Enabled;
                                    CustomContextMenuTag customTag = new CustomContextMenuTag(cast, f.FunctionName, f.FunctionAction);
                                    customTag.Arguments = f.Arguments;
                                    newItem.Tag = customTag;
                                }
                            }
                        }
                    } // arg check
                } // right click
            } // input
        }
示例#9
0
        public virtual void copyMultipleCreateEvent(CustomContextMenuTag clickedItemTag)
        {
            CustomTreeView myTree = (CustomTreeView)this.TreeView;
            ProcessingNode myNode = (ProcessingNode)this;
            VSGController myController = (VSGController)myTree.Controller;
            int incrementedSuffix = 0;
            int counter = 0;
            int numberOfDuplicates;
            VSG.Dialogs.SingleIntegerInputDialog input = new VSG.Dialogs.SingleIntegerInputDialog("How many duplicates would you like to create?", "Amount of duplication");
            if (input.ShowDialog(out numberOfDuplicates) == DialogResult.Cancel)
            {
                return;
            }
            try
            {
                String baseName = myController.GetComponentName(myNode.NodeID);
                String insertName;
                List<String> ignoreComp = new List<string>();

                ignoreComp.Add("DecisionMaker");

                List<string> componentNames = new List<string>();
                System.Data.DataTable dt = myController.GetComponentTable();
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    componentNames.Add(dr["name"].ToString());    
                }

                myController.TurnViewUpdateOff();

                while (counter < numberOfDuplicates)
                {
                    insertName = String.Format("{0}_{1}", baseName, incrementedSuffix);
                    while (componentNames.Contains(insertName))
                    {
                        insertName = String.Format("{0}_{1}", baseName, ++incrementedSuffix);
                    }
                    myController.EventClone(myTree.GetCustomTreeRootId(this.LinkType), myNode.NodeID, insertName, "Scenario", ignoreComp, myTree.GetCustomTreeRootId(this.LinkType), "Scenario", -1, -1);
                    componentNames.Add(insertName);
                    incrementedSuffix++;
                    counter++;
                }

                myController.TurnViewUpdateOn(false, false); // don't push out events

                myTree.UpdateViewComponent(); // manaully update
            }
            catch (Exception e)
            {
                myController.TurnViewUpdateOn(false, false); // don't push out events
                myTree.UpdateViewComponent(); // manaully update
                System.Windows.Forms.MessageBox.Show(e.Message, "Duplication Error");
            }
        }
示例#10
0
        public virtual void deleteCreateEvent(CustomContextMenuTag clickedItemTag)
        {
            CustomTreeView myTree = (CustomTreeView)this.TreeView;
            ProcessingNode myNode = (ProcessingNode)this;
            VSGController myController = (VSGController)myTree.Controller;
            List<String> ignore = new List<string>();
            ignore.Add("DecisionMaker");

            myController.TurnViewUpdateOff();

            myController.DeleteComponentAndChildren(myNode.NodeID, "Scenario", ignore);
            //myNode.DeleteComponent(clickedItemTag);

            myController.TurnViewUpdateOn();
        }
示例#11
0
        public void CommonRename(InputForm tempInput, CustomContextMenuTag clickedItemTag)
        {
            CustomTreeView myTree = (CustomTreeView)this.TreeView;

            ComponentOptions compOptions = new ComponentOptions();
            compOptions.LevelDown = 0;
            IXPathNavigable component = myTree.Controller.GetComponentAndChildren(NodeID, LinkType, compOptions);

            XPathNavigator componentNav = component.CreateNavigator();
            componentNav = componentNav.SelectSingleNode(String.Format("//*[@ID='{0}']", NodeID));

            string name = componentNav.GetAttribute("Name", componentNav.NamespaceURI);
            string description = componentNav.GetAttribute("Description", componentNav.NamespaceURI);

            tempInput.TopInputFieldValue = name;
            tempInput.BottomInputFieldValue = description;

            DialogResult result = tempInput.ShowDialog(myTree);

            if (result == DialogResult.OK)
            {
                String newName = tempInput.TopInputFieldValue;
                String newDescription = tempInput.BottomInputFieldValue;

                if (!newName.Equals(name))
                {
                    try
                    {
                        //myTree.RootID
                        myTree.Controller.UpdateComponentName(myTree.GetCustomTreeRootId(LinkType), NodeID, LinkType, newName);
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Unable to update name", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                if (!newDescription.Equals(description))
                {
                    try
                    {
                        myTree.Controller.UpdateComponentDescription(NodeID, newDescription);
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Unable to update description", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }

                myTree.OnItemRename(this.NodeID, this.NodeType, newName, newDescription);
            }
        }
示例#12
0
        public virtual void RenameComponent(CustomContextMenuTag clickedItemTag)
        {
            // bring up a form for input
            InputForm tempInput = new InputForm(clickedItemTag.GetFunctionName(), clickedItemTag.GetNode().myType); // create the dialog
            tempInput.StartPosition = FormStartPosition.Manual;
            tempInput.ButtonAddText = "OK";
            int x = Cursor.Position.X;
            int y = Cursor.Position.Y;
            tempInput.Location = new Point(x, y);

            CommonRename(tempInput, clickedItemTag);
        }
示例#13
0
        public virtual void RenameComponent(CustomContextMenuTag clickedItemTag, Object[] args)
        {
            InputForm tempInput = new InputForm(clickedItemTag.GetFunctionName(), clickedItemTag.GetNode().myType);
            tempInput.StartPosition = FormStartPosition.Manual;
            tempInput.ButtonAddText = "OK";
            int x = Cursor.Position.X;
            int y = Cursor.Position.Y;
            tempInput.Location = new Point(x, y);

            if (args.Length >= 1)
            {
                tempInput.AlphaNumericTop = Boolean.Parse((String)args[0]);
            }

            if (args.Length >= 2)
            {
                tempInput.AlphaNumericBottom = Boolean.Parse((String)args[0]);
            }

            CommonRename(tempInput, clickedItemTag);
        }
示例#14
0
        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);
                }
            }
        }
示例#15
0
        /// <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);
            }
        }
示例#16
0
        public virtual void moveDown(CustomContextMenuTag clickedItemTag)
        {
            CustomTreeView myTree = (CustomTreeView)this.TreeView;
            //ProcessingNode nextNode = (ProcessingNode)this.NextNode;
            //ProcessingNode myNode = (ProcessingNode)this;
            myTree.MoveSelectedNodeDown();

            //String nextName = "";
            //String myName = "";
            //
            //if (nextNode == null)
            //{
            //    return;
            //}

            //int myNum = GetNumFromIDString(myNode.Name);
            //int nextNum = GetNumFromIDString(nextNode.Name);
            //((VSGController)myTree.Controller).ViewUpdateStatus = false;
            //myName = UpdateIDString(nextNum, myNode.Name);
            //nextName = UpdateIDString(myNum, nextNode.Name);

            //((VSGController)myTree.Controller).UpdateComponentName(myTree.GetCustomTreeRootId(this.LinkType), myNode.NodeID, this.LinkType, myName);
            //((VSGController)myTree.Controller).UpdateComponentName(myTree.GetCustomTreeRootId(this.LinkType), nextNode.NodeID, this.LinkType, nextName);
            //((VSGController)myTree.Controller).ViewUpdateStatus = true;

        }
示例#17
0
 public virtual void deleteEvent(CustomContextMenuTag clickedItemTag)
 {
     CustomTreeView myTree = (CustomTreeView)this.TreeView;
     ProcessingNode myNode = (ProcessingNode)this;
     myNode.DeleteComponent(clickedItemTag);
 }
示例#18
0
        public virtual void CreateComponent(CustomContextMenuTag clickedItemTag, Object[] args)
        {
            String type = clickedItemTag.GetNode().myType;

            if (args.Length == 1)
            {
                String var = args[0].ToString();
                Boolean useDesc = Boolean.Parse(var);
                this.useDescription = useDesc;
                this.CreateComponent(clickedItemTag);
                this.useDescription = true; // reset
            }
            else if (args.Length >= 2)
            {
                if (args.Length == 3)
                {
                    type = (String)args[2];
                }

                // bring up a form for input
                InputForm tempInput = new InputForm(clickedItemTag.GetFunctionName(), type); // create the dialog
                tempInput.StartPosition = FormStartPosition.Manual;
                int x = Cursor.Position.X;
                int y = Cursor.Position.Y;
                tempInput.Location = new Point(x, y);

                if (args.Length >= 1)
                {
                    tempInput.AlphaNumericTop = Boolean.Parse((String)args[0]);
                }

                if (args.Length >= 2)
                {
                    tempInput.AlphaNumericBottom = Boolean.Parse((String)args[0]);
                }

                if (!useDescription)
                {
                    tempInput.HideDescriptionField();
                }

                CommonCreate(tempInput, clickedItemTag, type);
            }
        }
示例#19
0
        public virtual void copyCreateEvent(CustomContextMenuTag clickedItemTag)
        {
            CustomTreeView myTree = (CustomTreeView)this.TreeView;
            ProcessingNode myNode = (ProcessingNode)this;
            VSGController myController = (VSGController)myTree.Controller;
            try
            {
                String name = String.Format("{0}_copy", myController.GetComponentName(myNode.NodeID));
                List<String> ignoreComp = new List<string>();
                ignoreComp.Add("DecisionMaker");

                myController.TurnViewUpdateOff();
                myController.EventClone(myTree.GetCustomTreeRootId(this.LinkType), myNode.NodeID, name, "Scenario", ignoreComp, myTree.GetCustomTreeRootId(this.LinkType), "Scenario", -1, -1);
                myController.TurnViewUpdateOn(false, false); // don't push out events

                myTree.UpdateViewComponent(); // manaully update
            }
            catch (Exception e)
            {
                myController.TurnViewUpdateOn(false, false); // don't push out events
                myTree.UpdateViewComponent(); // manaully update
                System.Windows.Forms.MessageBox.Show(e.Message, "Duplication Error");
            }
        }
示例#20
0
        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");
                }
            }
        }
示例#21
0
        public virtual void CreateComponent(CustomContextMenuTag clickedItemTag)
        {
            // bring up a form for input
            String type = clickedItemTag.GetNode().myType;
            InputForm tempInput = new InputForm(clickedItemTag.GetFunctionName(), type); // create the dialog
            tempInput.StartPosition = FormStartPosition.Manual;
            int x = Cursor.Position.X;
            int y = Cursor.Position.Y;
            tempInput.Location = new Point(x, y);

            if (!useDescription)
            {
                tempInput.HideDescriptionField();
            }

            CommonCreate(tempInput, clickedItemTag, type);
        }
示例#22
0
        // key, mouse events
        protected void CustomTreeView_KeyDown(object sender, KeyEventArgs e)
        {
            if (AllowUserInput)
            {
                if (e.KeyCode == Keys.Delete) // delete pressed
                {
                    myController.UnregisterForUpdate(this);
                    myController.TurnViewUpdateOff();
                    List<ProcessingNode> forDelete = CloneSelectedNodes();
                    foreach (ProcessingNode delNode in forDelete)
                    {
                        List<Function> functions = delNode.Functions;

                        bool found = false;
                        foreach (Function f in functions)
                        {
                            switch (f.FunctionAction)
                            {
                                case ConfigFileConstants.DeleteLink:
                                    found = true;
                                    delNode.DeleteLink(new CustomContextMenuTag(delNode, f.FunctionName, f.FunctionAction));
                                    break;
                                case ConfigFileConstants.DeleteComponent:
                                    found = true;
                                    delNode.DeleteComponent(new CustomContextMenuTag(delNode, f.FunctionName, f.FunctionAction));
                                    break;
                            }
                        }

                        if (!found)
                        {
                            foreach (Function f in functions)
                            {
                                // try reflection delete
                                if (f.FunctionAction.Contains("Delete"))
                                {
                                    BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
                                    MethodInfo[] methods = delNode.GetType().GetMethods(flags);

                                    foreach (MethodInfo aMethod in methods)
                                    {
                                        if (aMethod.Name == f.FunctionAction)
                                        {
                                            try
                                            {
                                                CustomContextMenuTag customTag = new CustomContextMenuTag(delNode, f.FunctionName, f.FunctionAction);
                                            
                                                Object returnObject = aMethod.Invoke(delNode, new object[] { customTag  });

                                                break;
                                            }
                                            catch (TargetParameterCountException tpce)
                                            {
                                                MessageBox.Show("Could not match specified arguments to function " + f.FunctionAction, tpce.Message);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    myController.RegisterForUpdate(this);
                    myController.TurnViewUpdateOn();
                }
                else if (e.KeyCode == Keys.Up && e.Shift)
                {
                    MoveSelectedNodeUp();
                }
                else if (e.KeyCode == Keys.Down && e.Shift)
                {
                    MoveSelectedNodeDown();
                }
                else if (e.KeyCode == Keys.Up) // select previous node
                {
                    if (selectedNodes.Count == 1)
                    {
                        ProcessingNode currentSelect = selectedNodes[0];

                        ProcessingNode previous = (ProcessingNode)currentSelect.PrevVisibleNode;

                        if (previous != null)
                        {
                            UnpaintSelectedNodes();
                            selectedNodes.Clear();
                            selectedNodes.Add(previous);
                            PaintSelectedNodes();
                            OnAfterSelect(new TreeViewEventArgs(previous));
                        }
                    }
                }
                else if (e.KeyCode == Keys.Down) // select next node
                {
                    if (selectedNodes.Count == 1)
                    {
                        ProcessingNode currentSelect = selectedNodes[0];

                        ProcessingNode next = (ProcessingNode)currentSelect.NextVisibleNode;

                        if (next != null)
                        {
                            UnpaintSelectedNodes();
                            selectedNodes.Clear();
                            selectedNodes.Add(next);
                            PaintSelectedNodes();
                            OnAfterSelect(new TreeViewEventArgs(next));
                        }
                    }
                }
            }
        }