Example #1
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");
                }
            }
        }
        // Add button
        private void AddClick(object sender, EventArgs e)
        {
            if (Enabled)
            {
                CustomAddButtonToolStripItem callingButton = (CustomAddButtonToolStripItem)sender;

                // bring up a form for input
                InputForm tempInput = new InputForm(formName, inputPrompt); // create the dialog
                int x = Cursor.Position.X;
                int y = Cursor.Position.Y;
                tempInput.Location = new Point(x, y);

                DialogResult result = tempInput.ShowDialog();

                if (result == DialogResult.OK)
                {
                    // add a root component (mission plan, organization, etc.)
                    try
                    {
                        ComponentAndLinkID clid = myController.AddComponent(this.RootID, this.RootID, type, tempInput.TopInputFieldValue, m_LinkType, tempInput.BottomInputFieldValue);
                        m_lastCreatedID = clid.ComponentID;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Unable to add item", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        this.AddClick(sender, e);
                    }
                }
                else if (result == DialogResult.Retry)
                {
                    MessageBox.Show(errorText);
                    this.AddClick(sender, e);
                }
                else
                {
                    m_lastCreatedID = -1;
                }
            }
            else
            {
                MessageBox.Show("Please select a Project first.  Go to File->Select/Create Project");
            }
        }
Example #3
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");
                }
            }
        }
Example #4
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);
        }
Example #5
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");
                }
            }
        }
Example #6
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);
            }
        }
Example #7
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);
            }
        }
Example #8
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);
        }
Example #9
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);
        }
Example #10
0
        // переход на форму ввода
        private void InputToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var inputForm = new InputForm();

            inputForm.Show();
        }