Exemplo n.º 1
0
        private void contextMenuStripItem_Opening(object sender, CancelEventArgs e)
        {
            if (treeView.SelectedNode == null)
            {
                e.Cancel = true;
                return;
            }

            if (treeView.SelectedNode.Tag == null)
            {
                toolStripMenuItemCommand.Visible      = false;
                toolStripMenuItemRename.Visible       = false;
                toolStripMenuItemIconSettings.Visible = false;
            }
            else
            {
                foreach (ToolStripItem menuItem in contextMenuStrip.Items)
                {
                    menuItem.Visible = true;
                }

                ItemProperty tag = (ItemProperty)treeView.SelectedNode.Tag;
                toolStripMenuItemRemoveIcon.Enabled = tag.HasIcon();
                toolStripMenuItemCommand.Visible    = !tag.IsSubMenu;

                if (tag.HasIcon())
                {
                    toolStripComboBoxIconSize.Enabled = true;
                    if (tag.HasCustomIconSize())
                    {
                        toolStripComboBoxIconSize.Text = tag.IconSize.ToString();
                    }
                    else
                    {
                        toolStripComboBoxIconSize.Text = toolStripComboBoxIconSize.Items[0].ToString();
                    }
                }
                else
                {
                    toolStripComboBoxIconSize.Enabled = false;
                    toolStripComboBoxIconSize.Text    = "";
                }
            }

            if (treeView.SelectedNode.Parent == null)
            {
                toolStripMenuItemMoveToPrevLevel.Enabled = false;
            }
            else
            {
                toolStripMenuItemMoveToPrevLevel.Enabled = treeView.SelectedNode.Parent != null;
            }


            toolStripMenuItemMoveUp.Enabled   = treeView.SelectedNode.PrevNode != null;
            toolStripMenuItemMoveDown.Enabled = treeView.SelectedNode.NextNode != null;
        }
Exemplo n.º 2
0
        void XML_GenerateContent(XmlDocument curDoc, XmlElement xmlParent, TreeNodeCollection nodes)
        {
            foreach (TreeNode curNode in nodes)
            {
                if (curNode.Tag == null)
                {
                    xmlParent.AppendChild(curDoc.CreateElement("separator"));
                }
                else
                {
                    XmlElement   curXMLNode;
                    ItemProperty tag = (ItemProperty)curNode.Tag;
                    if (tag.IsSubMenu)
                    {
                        curXMLNode = curDoc.CreateElement("submenu");
                    }
                    else
                    {
                        curXMLNode           = curDoc.CreateElement("item");
                        curXMLNode.InnerText = "" + tag.Command + "";
                        if (tag.Arguments != "")
                        {
                            curXMLNode.InnerText += "|" + tag.Arguments + "";
                        }
                    }

                    curXMLNode.SetAttribute("text", curNode.Text);

                    if (tag.HasIcon())
                    {
                        curXMLNode.SetAttribute("icon", tag.IconFile);
                        if (tag.IconIndex > 0)
                        {
                            curXMLNode.SetAttribute("index", tag.IconIndex.ToString());
                        }
                        if (tag.HasCustomIconSize())
                        {
                            curXMLNode.SetAttribute("size", tag.IconSize.ToString());
                        }
                    }

                    if (tag.IsSubMenu)
                    {
                        XML_GenerateContent(curDoc, curXMLNode, curNode.Nodes);
                    }

                    xmlParent.AppendChild(curXMLNode);
                }
            }
        }
Exemplo n.º 3
0
        private void toolStripMenuItemBrowseIcon_Click(object sender, EventArgs e)
        {
            if (treeView.SelectedNode == null)
            {
                return;
            }

            if (treeView.SelectedNode.Tag == null)
            {
                return;
            }

            ItemProperty   tag = (ItemProperty)treeView.SelectedNode.Tag;
            OpenIconDialog dlg = new OpenIconDialog();

            if (tag.HasIcon())
            {
                dlg.IconFile = tag.IconFile;
            }
            else
            {
                dlg.IconFile = tag.Command;
            }

            dlg.IconIndex = tag.IconIndex;
            if (dlg.ShowDialog(this.Handle) == DialogResult.Cancel)
            {
                return;
            }

            tag.IconFile  = dlg.IconFile;
            tag.IconIndex = dlg.IconIndex;



            //Icon selectedIcon = IconManager.GetIcon(dlg.IconFile, dlg.IconIndex, false);
            //imageList.Images.Add(selectedIcon);
            //selectedIcon.Dispose();
            treeView.SelectedNode.ImageKey         = imageList_AddIcon(tag.IconFile, tag.IconIndex);
            treeView.SelectedNode.SelectedImageKey = treeView.SelectedNode.ImageKey;

            UpdateInfoPanel();
        }