Exemple #1
0
        private void HandleNodeSelection(TreeNode node)
        {
            if (tvProperties.SelectedNode != node)
            {
                tvProperties.SelectedNode = node;
            }
            LoadContextMenuForTreeNode(node);

            UserControl ctrl = null;

            pnlPropertiesContainer.Controls.Clear();
            if (node != null)
            {
                var attributes = (Dictionary <string, string>)node.Tag;

                switch (node.Name.ToLower())
                {
                case "property":
                    ctrl = new PropertyControl(this, attributes, ParentControl.ControlDetails);
                    break;

                case "type-group":
                    ctrl = new TypeGroupControl(this, attributes, ParentControl.ControlDetails);
                    break;

                case "type":
                    ctrl = new TypeControl(this, attributes, ParentControl.ControlDetails);
                    break;

                default:
                    break;
                }
                node.ContextMenuStrip = this.contextMenuNode;
            }
            if (ctrl != null)
            {
                pnlPropertiesContainer.Controls.Add(ctrl);
                InformProjectNeedsBuild();
                ctrl.BringToFront();
            }
        }
Exemple #2
0
        private void HandleNodeMenuClick(string clickedNode, string op, object tag)
        {
            if (op.Equals("add"))
            {
                UserControl ctrl = null;
                pnlPropertiesContainer.Controls.Clear();
                switch (clickedNode)
                {
                case "property":
                    ctrl = new PropertyControl(this, null, ParentControl.ControlDetails);
                    break;

                case "type-group":
                    ctrl = new TypeGroupControl(this, null, ParentControl.ControlDetails);
                    break;

                case "type":
                    ctrl = new TypeControl(this, null, ParentControl.ControlDetails, tag);
                    break;

                default:
                    break;
                }
                if (ctrl != null)
                {
                    pnlPropertiesContainer.Controls.Add(ctrl);
                    InformProjectNeedsBuild();
                    ctrl.BringToFront();
                }
            }
            else if (op.Equals("delete"))
            {
                contextMenuNode.Hide();
                string mboxCaption = "Confirm Delete";
                Dictionary <string, string> details        = (Dictionary <string, string>)tag;
                ControlManifestHelper       manifestHelper = new ControlManifestHelper();
                string mboxMessage = string.Empty;

                switch (clickedNode)
                {
                case "property":
                    if (MessageBox.Show("Are you sure you want to remove this property?", mboxCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        manifestHelper.DeleteProperty(ParentControl.ControlDetails, details["Name"]);
                    }
                    break;

                case "type-group":
                    int refCount = manifestHelper.RetrieveTypeGroupReferenceCount(ParentControl.ControlDetails, details["Name"]);
                    mboxMessage = string.Empty;
                    if (refCount > 0)
                    {
                        mboxMessage = $"There {(refCount == 1 ? "is" : "are")} {refCount} reference{(refCount == 1 ? "" : "s")} for this TypeGroup. Do you still want to remove this TypeGroup?\n" +
                                      $"Removing this TypeGroup will cause build errors. Recommendation is to select 'No' and fix the references then remove the TypeGroup.";
                    }
                    else
                    {
                        mboxMessage = "Are you sure you want to remove this type group?";
                    }

                    if (MessageBox.Show(mboxMessage, mboxCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        manifestHelper.DeleteTypeGroup(ParentControl.ControlDetails, details["Name"]);
                    }
                    break;

                case "type":
                    int typeCount = manifestHelper.RetrieveTypeInTypeGroupCount(ParentControl.ControlDetails, details["type-groups"]);
                    mboxMessage = string.Empty;
                    if (typeCount == 1)
                    {
                        mboxMessage = $"You are attempting to delete the last type in {details["type-groups"]} TypeGroup. Atleast one type is required in the TypeGroup. " +
                                      $"\nDo you still want to proceed?";
                    }
                    else
                    {
                        mboxMessage = "Are you sure you want to remove this type?";
                    }

                    if (MessageBox.Show(mboxMessage, mboxCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        manifestHelper.DeleteTypeInTypeGroup(ParentControl.ControlDetails, details["type-groups"], details["type"]);
                    }
                    break;

                default:
                    break;
                }
                RefreshControlManifestDetails();
            }
        }