示例#1
0
        private void CollectCommandItems(MergeableNodeCollection <ICommandItem> nodes)
        {
            if (nodes == null || nodes.Count == 0)
            {
                return;
            }

            // Recursively get all nodes (excluding separators).
            foreach (var node in nodes)
            {
                if (node.Content is CommandSeparator)
                {
                    // Ignore
                }
                else if (node.Content is CommandGroup)
                {
                    // Ignore
                }
                else
                {
                    Debug.Assert(!CommandItems.Contains(node.Content), "Warning: Duplicate command items in toolbar.");
                    CommandItems.Add(node.Content);
                }

                CollectCommandItems(node.Children);
            }
        }
示例#2
0
        //--------------------------------------------------------------
        /// <summary>
        /// Creates the structure of the text document's context menu.
        /// </summary>
        private void AddContextMenu()
        {
            var commandExtension = Editor.Extensions.OfType<CommandExtension>().FirstOrDefault().WarnIfMissing();
            if (commandExtension == null)
            {
                _contextMenuNodes = new MergeableNodeCollection<ICommandItem>();
            }
            else
            {
                _contextMenuNodes = new MergeableNodeCollection<ICommandItem>
                {
                    new MergeableNode<ICommandItem>(commandExtension.CommandItems["Cut"]),
                    new MergeableNode<ICommandItem>(commandExtension.CommandItems["Copy"]),
                    new MergeableNode<ICommandItem>(commandExtension.CommandItems["Paste"]),
                    new MergeableNode<ICommandItem>(commandExtension.CommandItems["Delete"]),
                    new MergeableNode<ICommandItem>(new CommandSeparator("ClipboardSeparator")),
                    new MergeableNode<ICommandItem>(commandExtension.CommandItems["SelectAll"]),
                    new MergeableNode<ICommandItem>(new CommandSeparator("SelectSeparator")),
                    CreateFormatMenu(),
                    CreateFoldingMenu(),
                    new MergeableNode<ICommandItem>(new CommandSeparator("EditSeparator")),
                    new MergeableNode<ICommandItem>(CommandItems["SyntaxHighlighting"]),
                    new MergeableNode<ICommandItem>(new CommandSeparator("ViewSeparator"))
                };
            }

            ContextMenuNodeCollections.Add(_contextMenuNodes);
        }
        /// <summary>
        /// Creates the structure of the text document's context menu.
        /// </summary>
        private void AddContextMenu()
        {
            var commandExtension = Editor.Extensions.OfType <CommandExtension>().FirstOrDefault().WarnIfMissing();

            if (commandExtension == null)
            {
                _contextMenuNodes = new MergeableNodeCollection <ICommandItem>();
            }
            else
            {
                _contextMenuNodes = new MergeableNodeCollection <ICommandItem>
                {
                    new MergeableNode <ICommandItem>(commandExtension.CommandItems["Cut"]),
                    new MergeableNode <ICommandItem>(commandExtension.CommandItems["Copy"]),
                    new MergeableNode <ICommandItem>(commandExtension.CommandItems["Paste"]),
                    new MergeableNode <ICommandItem>(commandExtension.CommandItems["Delete"]),
                    new MergeableNode <ICommandItem>(new CommandSeparator("ClipboardSeparator")),
                    new MergeableNode <ICommandItem>(commandExtension.CommandItems["SelectAll"]),
                    new MergeableNode <ICommandItem>(new CommandSeparator("SelectSeparator")),
                    CreateFormatMenu(),
                    CreateFoldingMenu(),
                    new MergeableNode <ICommandItem>(new CommandSeparator("EditSeparator")),
                    new MergeableNode <ICommandItem>(CommandItems["SyntaxHighlighting"]),
                    new MergeableNode <ICommandItem>(new CommandSeparator("ViewSeparator"))
                };
            }

            ContextMenuNodeCollections.Add(_contextMenuNodes);
        }
        private void AddMenus()
        {
            var insertBeforeOpenSeparator           = new[] { new MergePoint(MergeOperation.InsertBefore, "OpenSeparator"), MergePoint.Append };
            var insertBeforeCloseSeparator          = new[] { new MergePoint(MergeOperation.InsertBefore, "CloseSeparator"), MergePoint.Append };
            var insertBeforeSaveSeparator           = new[] { new MergePoint(MergeOperation.InsertBefore, "SaveSeparator"), MergePoint.Append };
            var insertBeforeExit                    = new[] { new MergePoint(MergeOperation.InsertBefore, "Exit"), MergePoint.Append };
            var insertBeforeRecentFileSeparator     = new[] { new MergePoint(MergeOperation.InsertBefore, "RecentFilesSeparator"), MergePoint.Append };
            var insertBeforeWindowSpecificSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "WindowSpecificSeparator"), MergePoint.Append };

            _menuNodes = new MergeableNodeCollection <ICommandItem>
            {
                // File menu
                new MergeableNode <ICommandItem>(new CommandGroup("FileGroup", "_File"), insertBeforeOpenSeparator,
                                                 new MergeableNode <ICommandItem>(CommandItems["New"], insertBeforeOpenSeparator),
                                                 new MergeableNode <ICommandItem>(CommandItems["Open"], insertBeforeOpenSeparator),
                                                 new MergeableNode <ICommandItem>(CommandItems["Reload"], insertBeforeOpenSeparator),
                                                 new MergeableNode <ICommandItem>(CommandItems["Close"], insertBeforeCloseSeparator),
                                                 new MergeableNode <ICommandItem>(CommandItems["CloseAll"], insertBeforeCloseSeparator),
                                                 new MergeableNode <ICommandItem>(CommandItems["Save"], insertBeforeSaveSeparator),
                                                 new MergeableNode <ICommandItem>(CommandItems["SaveAs"], insertBeforeSaveSeparator),
                                                 new MergeableNode <ICommandItem>(CommandItems["SaveAll"], insertBeforeSaveSeparator),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("RecentFilesSeparator"), insertBeforeExit),
                                                 new MergeableNode <ICommandItem>(CommandItems["RecentFiles"], insertBeforeRecentFileSeparator)),

                // Window menu
                new MergeableNode <ICommandItem>(new CommandGroup("WindowGroup", "_Window"),
                                                 new MergeableNode <ICommandItem>(CommandItems["NewWindow"], insertBeforeWindowSpecificSeparator),
                                                 new MergeableNode <ICommandItem>(CommandItems["CloseAllDocumentsAndWindows"], insertBeforeCloseSeparator)),
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MenuManager"/> class.
 /// </summary>
 public MenuManager()
 {
     _coerceVisibilityAction = CoerceVisibility;
     Nodes        = new MergeableNodeCollection <ICommandItem>();
     CommandItems = new List <ICommandItem>();
     Menu         = new MenuItemViewModelCollection();
 }
示例#6
0
        private static void RemoveEmptyGroups(MergeableNodeCollection <ICommandItem> nodes)
        {
            if (nodes == null || nodes.Count == 0)
            {
                return;
            }

            foreach (var node in nodes.ToArray())
            {
                // Recursively remove empty groups in children.
                RemoveEmptyGroups(node.Children);

                if (node.Content is CommandGroup)
                {
                    // Count all children, except separators.
                    int numberOfItems = node.Children?.Count(n => !(n.Content is CommandSeparator)) ?? 0;
                    if (numberOfItems == 0)
                    {
                        // node is a group node and contains no children or only separators.
                        // --> Remove this node.
                        nodes.Remove(node);
                    }
                }
            }
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolBarManager"/> class.
 /// </summary>
 public ToolBarManager()
 {
     _coerceVisibilityAction = CoerceVisibility;
     Nodes        = new MergeableNodeCollection <ICommandItem>();
     CommandItems = new List <ICommandItem>();
     ToolBars     = new ToolBarViewModelCollection();
 }
示例#8
0
 //--------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="MenuManager"/> class.
 /// </summary>
 public MenuManager()
 {
     _coerceVisibilityAction = CoerceVisibility;
     Nodes = new MergeableNodeCollection<ICommandItem>();
     CommandItems = new List<ICommandItem>();
     Menu = new MenuItemViewModelCollection();
 }
示例#9
0
        private void AddOptionsNodes()
        {
            _optionsNodes = new MergeableNodeCollection <OptionsPageViewModel>
            {
                new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Group0"),
                                                         new MergeableNode <OptionsPageViewModel>(new TestOptionsPageViewModel("Options 0")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup0")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup1")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup2")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup3")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup4"))),
                new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Group1"),
                                                         new MergeableNode <OptionsPageViewModel>(new TestOptionsPageViewModel("Options 1")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup0")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup1")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup2")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup3")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup4"))),
                new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Group2"),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup0")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup1")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup2")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup3")),
                                                         new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup4")),
                                                         new MergeableNode <OptionsPageViewModel>(new TestOptionsPageViewModel("Options 2"))),
            };

            var optionsService = Editor.Services.GetInstance <IOptionsService>().WarnIfMissing();

            optionsService?.OptionsNodeCollections.Add(_optionsNodes);
        }
示例#10
0
 //--------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolBarManager"/> class.
 /// </summary>
 public ToolBarManager()
 {
     _coerceVisibilityAction = CoerceVisibility;
     Nodes = new MergeableNodeCollection<ICommandItem>();
     CommandItems = new List<ICommandItem>();
     ToolBars = new ToolBarViewModelCollection();
 }
示例#11
0
        private void RemoveOptions()
        {
            if (_optionsNodes == null)
                return;

            var optionsService = Editor.Services.GetInstance<IOptionsService>().WarnIfMissing();
            optionsService?.OptionsNodeCollections.Remove(_optionsNodes);
            _optionsNodes = null;
        }
示例#12
0
        private void AddToolBars()
        {
            _toolBarNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("StandardGroup", "Standard"),
                                                 new MergeableNode <ICommandItem>(CommandItems["Theme"])),
            };

            Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        }
        private void AddToolBars()
        {
            _toolBarNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("ViewGroup"),
                                                 new MergeableNode <ICommandItem>(CommandItems["Properties"])),
            };

            Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        }
示例#14
0
        private void AddMenus()
        {
            _menuNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("ViewGroup", "_View"),
                                                 new MergeableNode <ICommandItem>(CommandItems["ColorPicker"], new MergePoint(MergeOperation.InsertBefore, "WindowSeparator"), new MergePoint(MergeOperation.Append)))
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
        private void AddMenus()
        {
            _menuNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("ToolsGroup", "_Tools"),
                                                 new MergeableNode <ICommandItem>(CommandItems["QuickLaunch"], new MergePoint(MergeOperation.InsertBefore, "ToolsSeparator"), MergePoint.Append)),
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#16
0
        //--------------------------------------------------------------
        private void AddOptions()
        {
            _optionsNodes = new MergeableNodeCollection<OptionsPageViewModel>
            {
                new MergeableNode<OptionsPageViewModel> { Content = new TextEditorOptionsPageViewModel(this) }
            };

            var optionsService = Editor.Services.GetInstance<IOptionsService>().WarnIfMissing();
            optionsService?.OptionsNodeCollections.Add(_optionsNodes);
        }
示例#17
0
        private void AddToolBars()
        {
            _toolBarNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("Game"),
                                                 new MergeableNode <ICommandItem>(CommandItems["ShowView3D"])),
            };

            Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        }
示例#18
0
        /// <summary>
        /// Creates the menu structure of this extension.
        /// </summary>
        private void AddMenus()
        {
            // Add the "About..." menu item to the "Help" menu.
            _menuNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("HelpGroup", "_Help"),
                                                 new MergeableNode <ICommandItem>(CommandItems["ShowAboutDialog"])),
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#19
0
        private void AddMenus()
        {
            // Add the "Options..." menu item to the "Tools" menu.
            _menuNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("ToolsGroup", "_Tools"),
                                                 new MergeableNode <ICommandItem>(CommandItems["ShowOptions"], new MergePoint(MergeOperation.InsertBefore, "OptionsSeparator"), MergePoint.Append))
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#20
0
        private void AddMenus()
        {
            var insertBeforeWindowSeparator = new MergePoint(MergeOperation.InsertBefore, "WindowSeparator");

            _menuNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("ViewGroup", "_View"),
                                                 new MergeableNode <ICommandItem>(CommandItems["Output"], insertBeforeWindowSeparator, MergePoint.Append))
            };
            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#21
0
        private void AddOptions()
        {
            _optionsNodes = new MergeableNodeCollection <OptionsPageViewModel>
            {
                new MergeableNode <OptionsPageViewModel>(new OptionsGroupViewModel("General"), new MergePoint(MergeOperation.Prepend),
                                                         new MergeableNode <OptionsPageViewModel>(new ShortcutsOptionsPageViewModel(Editor))),
            };

            var optionsService = Editor.Services.GetInstance <IOptionsService>().WarnIfMissing();

            optionsService?.OptionsNodeCollections.Add(_optionsNodes);
        }
示例#22
0
        private void AddToolBars()
        {
            _toolBarNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("BuildGroup", "Build"),
                                                 new MergeableNode <ICommandItem>(CommandItems["Build"]),
                                                 new MergeableNode <ICommandItem>(CommandItems["Assembler"]),
                                                 new MergeableNode <ICommandItem>(CommandItems["Analyze"])),
            };

            Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        }
示例#23
0
        private void RemoveOptions()
        {
            if (_optionsNodes == null)
            {
                return;
            }

            var optionsService = Editor.Services.GetInstance <IOptionsService>().WarnIfMissing();

            optionsService?.OptionsNodeCollections.Remove(_optionsNodes);
            _optionsNodes = null;
        }
示例#24
0
        private void AddMenus()
        {
            var mergeBeforePrintSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "PrintSeparator"), MergePoint.Append };

            _menuNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("FileGroup", "_File"),
                                                 new MergeableNode <ICommandItem>(CommandItems["PrintPreview"], mergeBeforePrintSeparator),
                                                 new MergeableNode <ICommandItem>(CommandItems["Print"], mergeBeforePrintSeparator))
            };
            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#25
0
        private void AddToolBars()
        {
            var mergeBeforePrintSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "PrintSeparator"), MergePoint.Append };

            _toolBarNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("StandardGroup", "Standard"),
                                                 new MergeableNode <ICommandItem>(CommandItems["PrintPreview"], mergeBeforePrintSeparator),
                                                 new MergeableNode <ICommandItem>(CommandItems["Print"], mergeBeforePrintSeparator))
            };
            Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        }
示例#26
0
        private void AddMenus()
        {
            _menuNodes = new MergeableNodeCollection <ICommandItem>
            {
                // File menu
                new MergeableNode <ICommandItem>(new CommandGroup("FileGroup", "_File"),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("OpenSeparator")),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("CloseSeparator")),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("SaveSeparator")),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("PrintSeparator")),
                                                 new MergeableNode <ICommandItem>(CommandItems["Exit"])),

                // Edit menu
                new MergeableNode <ICommandItem>(new CommandGroup("EditGroup", "_Edit"),
                                                 new MergeableNode <ICommandItem>(CommandItems["Undo"]),
                                                 new MergeableNode <ICommandItem>(CommandItems["Redo"]),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("UndoSeparator")),
                                                 new MergeableNode <ICommandItem>(CommandItems["Cut"]),
                                                 new MergeableNode <ICommandItem>(CommandItems["Copy"]),
                                                 new MergeableNode <ICommandItem>(CommandItems["Paste"]),
                                                 new MergeableNode <ICommandItem>(CommandItems["Delete"]),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("ClipboardSeparator")),
                                                 new MergeableNode <ICommandItem>(CommandItems["SelectAll"]),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("SelectSeparator")),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("SearchSeparator"))),

                // View menu
                new MergeableNode <ICommandItem>(new CommandGroup("ViewGroup", "_View"),
                                                 new MergeableNode <ICommandItem>(_toolBarsCommandItem),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("GuiSeparator")),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("WindowSeparator")),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("DocumentSeparator"))),

                // Tools menu
                new MergeableNode <ICommandItem>(new CommandGroup("ToolsGroup", "_Tools"),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("ToolsSeparator")),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("OptionsSeparator"))),

                // Window menu
                new MergeableNode <ICommandItem>(new CommandGroup("WindowGroup", "_Window"),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("WindowSpecificSeparator")),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("CloseSeparator")),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("DockSeparator")),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("WindowManagementSeparator")),
                                                 new MergeableNode <ICommandItem>(new CommandSeparator("WindowListSeparator"))),

                // Help menu
                new MergeableNode <ICommandItem>(new CommandGroup("HelpGroup", "_Help")),
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#27
0
        private static void CreateToolBarItems(MergeableNodeCollection <ICommandItem> nodes, ToolBarItemViewModelCollection toolBarItems)
        {
            foreach (var node in nodes)
            {
                if (node?.Content == null)
                {
                    continue;
                }

                var toolBarItem = node.Content.CreateToolBarItem();
                toolBarItems.Add(toolBarItem);
            }
        }
示例#28
0
        public void MergeShouldThrowWhenContentIsNull()
        {
            var nodeCollection = new MergeableNodeCollection <NamedObject>();

            nodeCollection.AddRange(new[]
            {
                new MergeableNode <NamedObject>(),
            });

            MergeAlgorithm <NamedObject> mergeAlgorithm = new MergeAlgorithm <NamedObject>();

            Assert.Throws <NotSupportedException>(() => mergeAlgorithm.Merge(_emptyNodeCollection, nodeCollection));
        }
示例#29
0
        private void AddOptions()
        {
            _optionsNodes = new MergeableNodeCollection <OptionsPageViewModel>
            {
                new MergeableNode <OptionsPageViewModel> {
                    Content = new ThemeOptionsPageViewModel(this)
                }
            };

            var optionsService = Editor.Services.GetInstance <IOptionsService>().WarnIfMissing();

            optionsService?.OptionsNodeCollections.Add(_optionsNodes);
        }
示例#30
0
        private void AddToolBars()
        {
            _toolBarNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("FindGroup", "Find"),
                                                 new MergeableNode <ICommandItem>(CommandItems["QuickFind"]),
                                                 new MergeableNode <ICommandItem>(CommandItems["FindNext"])),
                new MergeableNode <ICommandItem>(new CommandGroup("ViewGroup"),
                                                 new MergeableNode <ICommandItem>(CommandItems["FindAndReplace"])),
            };

            Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        }
示例#31
0
        protected override void OnShutdown()
        {
            Editor.Services.GetInstance <IAboutService>()?.ExtensionDescriptions.Remove(_extensionDescription);

            Editor.Services.GetInstance <IOptionsService>()?.OptionsNodeCollections.Remove(_optionsNodes);
            _optionsNodes = null;

            Editor.ToolBarNodeCollections.Remove(_toolBarNodes);
            _toolBarNodes = null;

            CommandItems.Clear();

            EditorHelper.UnregisterResources(_resourceDictionary);
        }
示例#32
0
        //private void AddToolBars()
        //{
        //    _toolBarNodes = new MergeableNodeCollection<ICommandItem>
        //    {
        //        new MergeableNode<ICommandItem>(new CommandGroup("LayoutGroup", "Layout"),
        //            new MergeableNode<ICommandItem>(CommandItems["WindowLayout"])),
        //    };

        //    Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        //}


        //private void RemoveToolBars()
        //{
        //    Editor.ToolBarNodeCollections.Remove(_toolBarNodes);
        //    _toolBarNodes = null;
        //}


        private void AddDockContextMenu()
        {
            _contextMenuNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(CommandItems["Close"]),
                new MergeableNode <ICommandItem>(new CommandSeparator("FileSeparator")),
                new MergeableNode <ICommandItem>(CommandItems["AutoHide"]),
                new MergeableNode <ICommandItem>(CommandItems["Dock"]),
                new MergeableNode <ICommandItem>(CommandItems["Float"]),
                new MergeableNode <ICommandItem>(new CommandSeparator("DockSeparator")),
            };

            Editor.DockContextMenuNodeCollections.Add(_contextMenuNodes);
        }
示例#33
0
        private static void MergeNodes(MergeableNodeCollection <ICommandItem> nodes, params IEnumerable <MergeableNodeCollection <ICommandItem> >[] nodeCollections)
        {
            var mergeAlgorithm = new MergeAlgorithm <ICommandItem> {
                CloneNodesOnMerge = true
            };

            foreach (var nodeCollection in nodeCollections)
            {
                foreach (var additionalNodes in nodeCollection)
                {
                    mergeAlgorithm.Merge(nodes, additionalNodes);
                }
            }
        }
示例#34
0
        protected override void OnShutdown()
        {
            Editor.Services.GetInstance<IAboutService>()?.ExtensionDescriptions.Remove(_extensionDescription);

            Editor.Services.GetInstance<IOptionsService>()?.OptionsNodeCollections.Remove(_optionsNodes);
            _optionsNodes = null;

            Editor.ToolBarNodeCollections.Remove(_toolBarNodes);
            _toolBarNodes = null;

            CommandItems.Clear();

            EditorHelper.UnregisterResources(_resourceDictionary);
        }
示例#35
0
        private void AddMenus()
        {
            var insertBeforeToolsGroup = new[] { new MergePoint(MergeOperation.InsertBefore, "ToolsGroup"), MergePoint.Append };

            _menuNodes = new MergeableNodeCollection <ICommandItem>
            {
                new MergeableNode <ICommandItem>(new CommandGroup("BuildGroup", "_Build"), insertBeforeToolsGroup,
                                                 new MergeableNode <ICommandItem>(CommandItems["Build"]),
                                                 new MergeableNode <ICommandItem>(CommandItems["Assembler"]),
                                                 new MergeableNode <ICommandItem>(CommandItems["Analyze"])),
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#36
0
        public void Traversal()
        {
            var nodeCollection = new MergeableNodeCollection <NamedObject>();

            nodeCollection.AddRange(new[]
            {
                new MergeableNode <NamedObject>(new NamedObject("File")),
                new MergeableNode <NamedObject>(new NamedObject("Edit"),
                                                new MergeableNode <NamedObject>(new NamedObject("Undo")),
                                                new MergeableNode <NamedObject>(new NamedObject("Redo"))),
                new MergeableNode <NamedObject>(new NamedObject("Tools")),
                new MergeableNode <NamedObject>(new NamedObject("Help")),
            });

            // GetRoot()
            Assert.AreSame(nodeCollection[1], nodeCollection[1].Children[1].GetRoot());

            // GetAncestors()
            var ancestors = nodeCollection[1].Children[1].GetAncestors().ToList();

            Assert.AreEqual(1, ancestors.Count);
            Assert.AreSame(nodeCollection[1], ancestors[0]);

            // GetDescendants()
            var descendants = nodeCollection[1].GetDescendants().ToList();

            Assert.AreEqual(2, descendants.Count);
            Assert.AreSame(nodeCollection[1].Children[0], descendants[0]);
            Assert.AreSame(nodeCollection[1].Children[1], descendants[1]);

            descendants = nodeCollection[1].GetDescendants(false).ToList();
            Assert.AreEqual(2, descendants.Count);
            Assert.AreSame(nodeCollection[1].Children[0], descendants[0]);
            Assert.AreSame(nodeCollection[1].Children[1], descendants[1]);

            // GetSubtree()
            var subtree = nodeCollection[1].GetSubtree().ToList();

            Assert.AreEqual(3, subtree.Count);
            Assert.AreSame(nodeCollection[1], subtree[0]);
            Assert.AreSame(nodeCollection[1].Children[0], subtree[1]);
            Assert.AreSame(nodeCollection[1].Children[1], subtree[2]);

            subtree = nodeCollection[1].GetSubtree(false).ToList();
            Assert.AreEqual(3, subtree.Count);
            Assert.AreSame(nodeCollection[1], subtree[0]);
            Assert.AreSame(nodeCollection[1].Children[0], subtree[1]);
            Assert.AreSame(nodeCollection[1].Children[1], subtree[2]);
        }
示例#37
0
        //--------------------------------------------------------------
        private void AddContextMenu()
        {
            var saveMergePoints = new[] { new MergePoint(MergeOperation.InsertBefore, "Close"), MergePoint.Append };
            var insertBeforeFileSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "FileSeparator"), MergePoint.Append };
            _contextMenuNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(CommandItems["Save"], saveMergePoints),
                new MergeableNode<ICommandItem>(CommandItems["SaveAs"], saveMergePoints),
                new MergeableNode<ICommandItem>(CommandItems["Close"], new MergePoint(MergeOperation.Replace, "Close"), MergePoint.Append),
                new MergeableNode<ICommandItem>(CommandItems["CloseAllButThis"], insertBeforeFileSeparator),
                new MergeableNode<ICommandItem>(CommandItems["CloseAll"], insertBeforeFileSeparator),
                new MergeableNode<ICommandItem>(new CommandSeparator("CloseSeparator"), insertBeforeFileSeparator),
                new MergeableNode<ICommandItem>(CommandItems["CopyFullPath"], insertBeforeFileSeparator),
                new MergeableNode<ICommandItem>(CommandItems["OpenContainingFolder"], insertBeforeFileSeparator),
                new MergeableNode<ICommandItem>(new CommandSeparator("UriSeparator"), insertBeforeFileSeparator),
            };

            DockContextMenuNodeCollections.Add(_contextMenuNodes);
        }
示例#38
0
        private void CollectCommandItems(MergeableNodeCollection<ICommandItem> nodes)
        {
            if (nodes == null || nodes.Count == 0)
                return;

            // Recursively get all nodes (excluding separators).
            foreach (var node in nodes)
            {
                if (node.Content is CommandSeparator)
                {
                    // Ignore
                }
                else if (node.Content is CommandGroup)
                {
                    // Ignore
                }
                else
                {
                    Debug.Assert(!CommandItems.Contains(node.Content), "Warning: Duplicate command items in menu.");
                    CommandItems.Add(node.Content);
                }

                CollectCommandItems(node.Children);
            }
        }
示例#39
0
        private static void RemoveEmptyGroups(MergeableNodeCollection<ICommandItem> nodes)
        {
            if (nodes == null || nodes.Count == 0)
                return;

            foreach (var node in nodes.ToArray())
            {
                // Recursively remove empty groups in children.
                RemoveEmptyGroups(node.Children);

                if (node.Content is CommandGroup)
                {
                    // Count all children, except separators.
                    int numberOfItems = node.Children?.Count(n => !(n.Content is CommandSeparator)) ?? 0;
                    if (numberOfItems == 0)
                    {
                        // node is a group node and contains no children or only separators.
                        // --> Remove this node.
                        nodes.Remove(node);
                    }
                }
            }
        }
示例#40
0
 private static void MergeNodes(MergeableNodeCollection<ICommandItem> nodes, params IEnumerable<MergeableNodeCollection<ICommandItem>>[] nodeCollections)
 {
     var mergeAlgorithm = new MergeAlgorithm<ICommandItem> { CloneNodesOnMerge = true };
     foreach (var nodeCollection in nodeCollections)
         foreach (var additionalNodes in nodeCollection)
             mergeAlgorithm.Merge(nodes, additionalNodes);
 }
示例#41
0
        private void AddMenus()
        {
            var insertAfterPaste = new[] { new MergePoint(MergeOperation.InsertAfter, "Paste"), MergePoint.Append };
            var insertBeforeSearchSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "SearchSeparator"), MergePoint.Append };
            var insertBeforeDocumentSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "DocumentSeparator"), MergePoint.Append };

            _menuNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(new CommandGroup("EditGroup", "_Edit"),
                    new MergeableNode<ICommandItem>(CommandItems["PasteMultiple"], insertAfterPaste),
                    new MergeableNode<ICommandItem>(CommandItems["GoToLine"], insertBeforeSearchSeparator),
                    CreateFormatMenu(),
                    CreateFoldingMenu()),
                new MergeableNode<ICommandItem>(new CommandGroup("ViewGroup", "_View"),
                    new MergeableNode<ICommandItem>(CommandItems["SyntaxHighlighting"], insertBeforeDocumentSeparator)),
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#42
0
        private void AddToolBars()
        {
            var insertBeforeFileSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "FileSeparator"), MergePoint.Append };

            _toolBarNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(new CommandGroup("StandardGroup", "Standard"),
                    new MergeableNode<ICommandItem>(CommandItems["New"], insertBeforeFileSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["Open"], insertBeforeFileSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["Save"], insertBeforeFileSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["SaveAll"], insertBeforeFileSeparator)),
            };

            Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        }
示例#43
0
        private void AddToolBars()
        {
            _toolBarNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(new CommandGroup("Game"),
                    new MergeableNode<ICommandItem>(CommandItems["ShowView3D"])),
            };

            Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        }
示例#44
0
        private void AddOptionsNodes()
        {
            _optionsNodes = new MergeableNodeCollection<OptionsPageViewModel>
            {
                new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Group0"),
                    new MergeableNode<OptionsPageViewModel>(new TestOptionsPageViewModel("Options 0")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup0")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup1")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup2")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup3")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup4"))),
                new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Group1"),
                    new MergeableNode<OptionsPageViewModel>(new TestOptionsPageViewModel("Options 1")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup0")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup1")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup2")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup3")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup4"))),
                new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Group2"),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup0")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup1")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup2")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup3")),
                    new MergeableNode<OptionsPageViewModel>(new OptionsGroupViewModel("Subgroup4")),
                    new MergeableNode<OptionsPageViewModel>(new TestOptionsPageViewModel("Options 2"))),
            };

            var optionsService = Editor.Services.GetInstance<IOptionsService>().WarnIfMissing();
            optionsService?.OptionsNodeCollections.Add(_optionsNodes);
        }
示例#45
0
        private void AddMenus()
        {
            var insertBeforeCloseSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "CloseSeparator"), MergePoint.Append };
            var insertBeforeDockSeparator = new [] { new MergePoint(MergeOperation.InsertBefore, "DockSeparator"), MergePoint.Append };
            var insertBeforeWindowManagementSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "WindowManagementSeparator"), MergePoint.Append };

            _menuNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(new CommandGroup("WindowGroup", "_Window"),
                    new MergeableNode<ICommandItem>(CommandItems["Close"], insertBeforeCloseSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["AutoHide"], insertBeforeDockSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["Dock"], insertBeforeDockSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["Float"], insertBeforeDockSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["WindowLayout"], insertBeforeWindowManagementSeparator)),
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#46
0
        private void AddToolBarNodes()
        {
            _toolBarNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(new CommandGroup("TestGroup", "_Test") { AlwaysShowText = true },
                    new MergeableNode<ICommandItem>(CommandItems["TestWindow"]),
                    new MergeableNode<ICommandItem>(CommandItems["GC"]),
                    new MergeableNode<ICommandItem>(CommandItems["Throw"]),
                    new MergeableNode<ICommandItem>(CommandItems["Status1"]),
                    new MergeableNode<ICommandItem>(CommandItems["Status2"])),
            };

            Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        }
示例#47
0
 private void RemoveMenus()
 {
     Editor.MenuNodeCollections.Remove(_menuNodes);
     _menuNodes = null;
 }
示例#48
0
        private void AddMenus()
        {
            var insertBeforeWindowSeparator = new MergePoint(MergeOperation.InsertBefore, "WindowSeparator");

            _menuNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(new CommandGroup("ViewGroup", "_View"),
                    new MergeableNode<ICommandItem>(CommandItems["Output"], insertBeforeWindowSeparator, MergePoint.Append))
            };
            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#49
0
 private void AddToolBars()
 {
     var mergeBeforePrintSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "PrintSeparator"), MergePoint.Append };
     _toolBarNodes = new MergeableNodeCollection<ICommandItem>
     {
         new MergeableNode<ICommandItem>(new CommandGroup("StandardGroup", "Standard"),
             new MergeableNode<ICommandItem>(CommandItems["PrintPreview"], mergeBeforePrintSeparator),
             new MergeableNode<ICommandItem>(CommandItems["Print"], mergeBeforePrintSeparator))
     };
     Editor.ToolBarNodeCollections.Add(_toolBarNodes);
 }
示例#50
0
 private void AddMenus()
 {
     var mergeBeforePrintSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "PrintSeparator"), MergePoint.Append };
     _menuNodes = new MergeableNodeCollection<ICommandItem>
     {
         new MergeableNode<ICommandItem>(new CommandGroup("FileGroup", "_File"),
             new MergeableNode<ICommandItem>(CommandItems["PrintPreview"], mergeBeforePrintSeparator),
             new MergeableNode<ICommandItem>(CommandItems["Print"], mergeBeforePrintSeparator))
     };
     Editor.MenuNodeCollections.Add(_menuNodes);
 }
示例#51
0
 public void Constructor()
 {
     MergeableNodeCollection<NamedObject> nodeCollection = new MergeableNodeCollection<NamedObject>();
     Assert.AreEqual(0, nodeCollection.Count);
 }
示例#52
0
        private void AddToolBars()
        {
            _toolBarNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(new CommandGroup("ViewGroup"),
                    new MergeableNode<ICommandItem>(CommandItems["ColorPicker"])),
            };

            Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        }
示例#53
0
        private void AddMenus()
        {
            var insertBeforeOpenSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "OpenSeparator"), MergePoint.Append };
            var insertBeforeCloseSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "CloseSeparator"), MergePoint.Append };
            var insertBeforeSaveSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "SaveSeparator"), MergePoint.Append };
            var insertBeforeExit = new[] { new MergePoint(MergeOperation.InsertBefore, "Exit"), MergePoint.Append };
            var insertBeforeRecentFileSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "RecentFilesSeparator"), MergePoint.Append };
            var insertBeforeWindowSpecificSeparator = new[] { new MergePoint(MergeOperation.InsertBefore, "WindowSpecificSeparator"), MergePoint.Append };

            _menuNodes = new MergeableNodeCollection<ICommandItem>
            {
                // File menu
                new MergeableNode<ICommandItem>(new CommandGroup("FileGroup", "_File"), insertBeforeOpenSeparator,
                    new MergeableNode<ICommandItem>(CommandItems["New"], insertBeforeOpenSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["Open"], insertBeforeOpenSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["Reload"], insertBeforeOpenSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["Close"], insertBeforeCloseSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["CloseAll"], insertBeforeCloseSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["Save"], insertBeforeSaveSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["SaveAs"], insertBeforeSaveSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["SaveAll"], insertBeforeSaveSeparator),
                    new MergeableNode<ICommandItem>(new CommandSeparator("RecentFilesSeparator"), insertBeforeExit),
                    new MergeableNode<ICommandItem>(CommandItems["RecentFiles"], insertBeforeRecentFileSeparator)),

                // Window menu
                new MergeableNode<ICommandItem>(new CommandGroup("WindowGroup", "_Window"),
                    new MergeableNode<ICommandItem>(CommandItems["NewWindow"], insertBeforeWindowSpecificSeparator),
                    new MergeableNode<ICommandItem>(CommandItems["CloseAllDocumentsAndWindows"], insertBeforeCloseSeparator)),
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#54
0
        private void AddMenus()
        {
            // Add the "Options..." menu item to the "Tools" menu.
            _menuNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(new CommandGroup("ToolsGroup", "_Tools"),
                    new MergeableNode<ICommandItem>(CommandItems["ShowOptions"], new MergePoint(MergeOperation.InsertBefore, "OptionsSeparator"), MergePoint.Append))
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }
示例#55
0
 private void RemoveToolBars()
 {
     Editor.MenuNodeCollections.Remove(_toolBarNodes);
     _toolBarNodes = null;
 }
示例#56
0
 private void RemoveDockContextMenu()
 {
     Editor.DockContextMenuNodeCollections.Remove(_contextMenuNodes);
     _contextMenuNodes = null;
 }
示例#57
0
        private void AddToolBars()
        {
            _toolBarNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(new CommandGroup("FindGroup", "Find"),
                    new MergeableNode<ICommandItem>(CommandItems["QuickFind"]),
                    new MergeableNode<ICommandItem>(CommandItems["FindNext"])),
                new MergeableNode<ICommandItem>(new CommandGroup("ViewGroup"),
                    new MergeableNode<ICommandItem>(CommandItems["FindAndReplace"])),
            };

            Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        }
示例#58
0
        private static void CreateMenuItems(MergeableNodeCollection<ICommandItem> nodes, MenuItemViewModelCollection menuItems)
        {
            foreach (var node in nodes)
            {
                if (node?.Content == null)
                    continue;

                var menuItem = node.Content.CreateMenuItem();
                menuItems.Add(menuItem);

                if (node.Children != null && node.Children.Count > 0)
                {
                    menuItem.Submenu = new MenuItemViewModelCollection();
                    CreateMenuItems(node.Children, menuItem.Submenu);
                }
            }
        }
示例#59
0
        //private void AddToolBars()
        //{
        //    _toolBarNodes = new MergeableNodeCollection<ICommandItem>
        //    {
        //        new MergeableNode<ICommandItem>(new CommandGroup("LayoutGroup", "Layout"),
        //            new MergeableNode<ICommandItem>(CommandItems["WindowLayout"])),
        //    };

        //    Editor.ToolBarNodeCollections.Add(_toolBarNodes);
        //}


        //private void RemoveToolBars()
        //{
        //    Editor.ToolBarNodeCollections.Remove(_toolBarNodes);
        //    _toolBarNodes = null;
        //}


        private void AddDockContextMenu()
        {
            _contextMenuNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(CommandItems["Close"]),
                new MergeableNode<ICommandItem>(new CommandSeparator("FileSeparator")),
                new MergeableNode<ICommandItem>(CommandItems["AutoHide"]),
                new MergeableNode<ICommandItem>(CommandItems["Dock"]),
                new MergeableNode<ICommandItem>(CommandItems["Float"]),
                new MergeableNode<ICommandItem>(new CommandSeparator("DockSeparator")),
            };

            Editor.DockContextMenuNodeCollections.Add(_contextMenuNodes);
        }
示例#60
0
        private void AddMenus()
        {
            _menuNodes = new MergeableNodeCollection<ICommandItem>
            {
                new MergeableNode<ICommandItem>(new CommandGroup("ViewGroup", "_View"),
                    new MergeableNode<ICommandItem>(CommandItems["ColorPicker"], new MergePoint(MergeOperation.InsertBefore, "WindowSeparator"), new MergePoint(MergeOperation.Append)))
            };

            Editor.MenuNodeCollections.Add(_menuNodes);
        }