private void GenerateContextMenu() { ContextMenuRoot.RemoveAllChildren(); if (Hierarchical == null || Hierarchical == _allhierarchical || Hierarchical == _searchHierarchical) { return; } ContextMenuRoot.AddChild(new MenuViewModel("Add cards", new RelayCommand(CardInputCommandExecute), 1)); ContextMenuRoot.AddChild(new MenuViewModel("Remove cards", new RelayCommand(CardInputCommandExecute), -1)); ContextMenuRoot.AddChild(MenuViewModel.Separator()); ContextMenuRoot.AddChild(new MenuViewModel("Add cards (Graphic)", new RelayCommand(CollectionInputGraphicCommandExecute))); ContextMenuRoot.AddChild(MenuViewModel.Separator()); if (Hierarchical.Selected is not HierarchicalResultNodeViewModel nodeViewModel) { MenuViewModel copyMenu = new MenuViewModel("Copy to .."); ContextMenuRoot.AddChild(copyMenu); ContextMenuRoot.AddChild(new MenuViewModel("Remove from collection", new RelayCommand(RemoveCommandExecute))); MenuViewModel moveMenu = new MenuViewModel("Move to .."); List <ICardCollection> cardCollections = new List <ICardCollection>(_magicDatabase.GetAllCollections()); if (cardCollections.Count > 1) { ContextMenuRoot.AddChild(moveMenu); } foreach (ICardCollection collection in cardCollections) { string name = collection.Name; copyMenu.AddChild(new MenuViewModel(name, new RelayCommand(CopyCommandExecute), collection)); if (Hierarchical.Name != name) { moveMenu.AddChild(new MenuViewModel(name, new RelayCommand(MoveCommandExecute), collection)); } } }
private void CreateMenu() { //File MenuViewModel fileMenu = new MenuViewModel("_File"); fileMenu.AddChild(new MenuViewModel("Update _Editions Database...", new RelayCommand(UpdateDatabaseCommandExecute))); fileMenu.AddChild(new MenuViewModel("Update _Rules Database..", new RelayCommand(UpdateRulesDatabaseCommandExecute))); fileMenu.AddChild(new MenuViewModel("Update _Images Database..", new RelayCommand(UpdateImageDatabaseCommandExecute))); //Not Allowed in release version, the update is done by copy of referential #if DEBUG fileMenu.AddChild(new MenuViewModel("Update _Preconstructed Decks Database..", new RelayCommand(UpdatePreconstructedDeckCommandExecute))); #endif fileMenu.AddChild(MenuViewModel.Separator()); //Price MenuViewModel priceMenu = new MenuViewModel("Update _Prices Database"); foreach (PriceSource pricesource in (PriceSource[])Enum.GetValues(typeof(PriceSource))) { priceMenu.AddChild(new MenuViewModel(pricesource.ToString("g"), new RelayCommand(UpdatePriceDatabaseCommandExecute), pricesource)); } fileMenu.AddChild(priceMenu); fileMenu.AddChild(MenuViewModel.Separator()); fileMenu.AddChild(new MenuViewModel("Search...", new RelayCommand(SearchCommandExecute))); fileMenu.AddChild(MenuViewModel.Separator()); fileMenu.AddChild(new MenuViewModel("_Exit", new RelayCommand(CloseCommandExecute))); MenuRoot.AddChild(fileMenu); //Collection _collectionViewModel = new MenuViewModel("_Collection"); GenerateCollectionMenu(); MenuRoot.AddChild(_collectionViewModel); //Database Management MenuViewModel dbManagementMenu = new MenuViewModel("_Database Management"); dbManagementMenu.AddChild(new MenuViewModel("_Audit", new RelayCommand(AuditCommandExecute))); dbManagementMenu.AddChild(MenuViewModel.Separator()); MenuViewModel updateTableMenu = new MenuViewModel("_Update table"); dbManagementMenu.AddChild(updateTableMenu); MenuRoot.AddChild(dbManagementMenu); //Database Management/Update table updateTableMenu.AddChild(new MenuViewModel("_Block", new RelayCommand(BlockModificationCommandExecute))); updateTableMenu.AddChild(new MenuViewModel("_Edition", new RelayCommand(EditionModificationCommandExecute))); updateTableMenu.AddChild(new MenuViewModel("_Language", new RelayCommand(LanguageModificationCommandExecute))); updateTableMenu.AddChild(new MenuViewModel("_Translate", new RelayCommand(TranslateModificationCommandExecute))); //Tools MenuViewModel toolsMenu = new MenuViewModel("_Tools"); toolsMenu.AddChild(new MenuViewModel("_Options", new RelayCommand(OptionCommandExecute))); toolsMenu.AddChild(MenuViewModel.Separator()); toolsMenu.AddChild(new MenuViewModel("_Check for new version", new RelayCommand(CheckNewVersionCommandExecute))); if (_magicDatabase.PictureDatabaseMigration.CouldMigrate) { toolsMenu.AddChild(MenuViewModel.Separator()); toolsMenu.AddChild(new MenuViewModel("_Migrate pictures database images", new RelayCommand(MigrationPictureDatabaseCommandExecute))); } MenuRoot.AddChild(toolsMenu); //? MenuViewModel aboutMenu = new MenuViewModel("?"); aboutMenu.AddChild(new MenuViewModel("_Version", new RelayCommand(VersionCommandExecute))); MenuRoot.AddChild(aboutMenu); GenerateContextMenu(); }