예제 #1
0
        /// <summary>
        /// Функция для создания контекстного меню
        /// </summary>
        /// <param name="sol"></param>
        /// <returns></returns>
        private static ContextMenu CreateContextMenu(SolutionFolder folder, ProjectExplorerControl control)
        {
            ContextMenu res = new ContextMenu();

            MenuItem itemNew = new MenuItem();

            itemNew.Header = "New";
            res.Items.Add(itemNew);

            MenuItem itemNewSolutionFolder = new MenuItem();

            itemNewSolutionFolder.Header = "New Solution Folder";
            itemNewSolutionFolder.Click += new System.Windows.RoutedEventHandler(folder.itemNewSolutionFolder_Click);
            itemNew.Items.Add(itemNewSolutionFolder);

            MenuItem itemNewProject = new MenuItem();

            itemNewProject.Header = "New Project";
            itemNewProject.Click += new System.Windows.RoutedEventHandler(folder.itemNewProject_Click);
            itemNew.Items.Add(itemNewProject);

            MenuItem itemAddExistingProject = new MenuItem();

            itemAddExistingProject.Header = "Add Existing Project";
            itemAddExistingProject.Click += new System.Windows.RoutedEventHandler(folder.itemAddExistingProject_Click);
            res.Items.Add(itemAddExistingProject);

            MenuItem itemRename = new MenuItem();

            itemRename.Header = "Rename";
            itemRename.Click += new System.Windows.RoutedEventHandler(folder.itemRename_Click);
            res.Items.Add(itemRename);

            MenuItem itemRemove = new MenuItem();

            itemRemove.Header  = "Remove";
            itemRemove.Command = control.CommandRemove;
            itemRemove.CommandBindings.Add(control.BindingRemoveCommand);
            res.Items.Add(itemRemove);

            MenuItem itemPaste = new MenuItem();

            itemPaste.Header  = "Paste";
            itemPaste.Icon    = CreateImageByPath("/HDL_Light;component/Images/Paste.png");
            itemPaste.Command = control.CommandPaste;
            itemPaste.CommandBindings.Add(control.BindingPasteCommand);
            res.Items.Add(itemPaste);

            MenuItem itemСut = new MenuItem();

            itemСut.Header  = "Cut";
            itemСut.Icon    = CreateImageByPath("/HDL_Light;component/Images/Cut.png");
            itemСut.Command = control.CommandCut;
            itemСut.CommandBindings.Add(control.BindingCutCommand);
            res.Items.Add(itemСut);

            MenuItem itemOpenFolderInExplorer = new MenuItem();

            itemOpenFolderInExplorer.Header = "Open Folder In Explorer";
            itemOpenFolderInExplorer.Click += new System.Windows.RoutedEventHandler(folder.itemOpenFolderInExplorer_Click);
            res.Items.Add(itemOpenFolderInExplorer);

            return(res);
        }
예제 #2
0
        /// <summary>
        /// Добавление папки к Xml документу
        /// </summary>
        /// <param name="_doc"></param>
        /// <param name="xml_el"></param>
        /// <param name="folder"></param>
        private static void AddSolutionFolderToXml(XmlDocument _doc, XmlElement xml_el, Solution sol, SolutionFolder folder)
        {
            XmlElement   folderNode     = _doc.CreateElement("SolutionFolder");
            XmlAttribute path_attribute = _doc.CreateAttribute("path");

            path_attribute.InnerText = FormRelativePath(sol.RootFolder.Path, folder.Path);
            folderNode.Attributes.Append(path_attribute);
            XmlAttribute expanded_attribute = _doc.CreateAttribute("expanded");

            expanded_attribute.InnerText = folder.Expanded.ToString();
            folderNode.Attributes.Append(expanded_attribute);
            foreach (SolutionFolder fold in folder.SubFolders)
            {
                AddSolutionFolderToXml(_doc, folderNode, sol, fold);
            }
            foreach (Project proj in folder.Projects)
            {
                AddProjectToXml(_doc, folderNode, sol, proj);
            }
            xml_el.AppendChild(folderNode);
        }