public GetProjectTreeChildrenPipeline Execute([NotNull] IProjectTreeItem projectTreeItem)
        {
            ProjectTreeItem = projectTreeItem;

            Children = new List <IProjectTreeItem>();

            Execute();

            return(this);
        }
Example #2
0
 protected virtual void Add(IProjectTreeItem item)
 {
     _projects.Add(item);
 }
Example #3
0
 public void CallAdd(IProjectTreeItem item)
 {
     base.Add(item);
 }
Example #4
0
        void IEditorComponent.CommandClick(string control)
        {
            DialogResult    result;
            ContentDocument page;
            int             size;
            String          filename;
            String          leaf;

            size = title.Count;
            while (size-- > 0)
            {
                if (control == QualifyID(ID__TYPE_NODE, title[size]))
                {
                    OpenItem(size);
                    break;
                }
            }
            if (size == -1)
            {
                if (control == ID_MENU_CONTEXT_NEW_NOTE)
                {
                    size     = 1;
                    filename = "New Note.txt";
                    while (title.IndexOf(filename) > -1)
                    {
                        size++;
                        filename = "New Note " + size + ".txt";
                    }
                    title.Add(filename);
                    document.Add(null);
                    pane.Add(null);
                    saved.Add("");
                    editor.GUIController.ProjectTree.StartFromNode(this, ID_NODE_ROOT);
                    leaf = QualifyID(ID__TYPE_NODE, filename);
                    IProjectTreeItem item = editor.GUIController.ProjectTree.AddTreeLeaf(this, leaf, filename, ID_ICON_LEAF, false);
                    editor.GUIController.ProjectTree.SelectNode(this, leaf);
                    if (!File.Exists(filename))
                    {
                        try
                        {
                            File.WriteAllText(filename, "");
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                else
                if (control == ID_MENU_CONTEXT_DELETE)
                {
                    filename = title[selected];
                    if (MessageBox.Show("Are you sure you want to delete \"" + filename + "\"?", "Delete Note", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        if (File.Exists(filename))
                        {
                            try
                            {
                                File.Delete(filename);
                                RemoveItem(selected);
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("An error occurred while deleting \"" + filename + "\".");
                            }
                        }
                        else
                        {
                            RemoveItem(selected);
                        }
                    }
                }
                else
                if (control == ID_MENU_CONTEXT_RENAME)
                {
                    filename = title[selected];
                    leaf     = filename;
                    do
                    {
                        result = InputBox("Rename Note", "Filename:", ref leaf);
                        if (result == DialogResult.OK)
                        {
                            size = leaf.IndexOfAny(Path.GetInvalidFileNameChars());
                            if (size > -1)
                            {
                                editor.GUIController.ShowMessage("A filename cannot contain the character \"" + leaf.Substring(size, 1) + "\".", MessageBoxIconType.Warning);
                            }
                        }
                        else
                        {
                            size = -1;
                        }
                    }while(size > -1);
                    if (result == DialogResult.OK && leaf != null)
                    {
                        if (!File.Exists(leaf))
                        {
                            try
                            {
                                if (File.Exists(filename))
                                {
                                    File.Move(filename, leaf);
                                }
                                page = document[selected];
                                if (page != null && page.Visible)
                                {
                                    page.Name = leaf;
                                }
                                title[selected] = leaf;
                                RebuildTree();
                                editor.GUIController.ProjectTree.SelectNode(this, QualifyID(ID__TYPE_NODE, leaf));
                            }
                            catch (Exception)
                            {
                                editor.GUIController.ShowMessage("An error occurred while renaming \"" + filename + "\".", MessageBoxIconType.Error);
                            }
                        }
                        else
                        {
                            editor.GUIController.ShowMessage("A file with the name \"" + leaf + "\" already exists.", MessageBoxIconType.Error);
                        }
                    }
                }
            }
        }
Example #5
0
        protected virtual void Visit([NotNull, ItemNotNull] ICollection <string> sourceFileNames, [NotNull] IProjectTreeItem projectTreeItem)
        {
            if (projectTreeItem is IProjectTreeSourceFile sourceFile)
            {
                sourceFileNames.Add(sourceFile.FileName);
            }

            foreach (var child in projectTreeItem.GetChildren())
            {
                Visit(sourceFileNames, child);
            }
        }