/// <summary> /// Inicializa los comandos /// </summary> private void InitCommands() { NewBookCommand = new BaseCommand("Nuevo libro", parameter => ExecuteAction(nameof(NewBookCommand), null), parameter => CanExecuteAction(nameof(NewBookCommand), null)) .AddListener(this, nameof(TreeBooksViewModel.SelectedNode)); NewLibraryCommand = new BaseCommand("Nueva biblioteca", parameter => ExecuteAction(nameof(PropertiesCommand), null), parameter => CanExecuteAction(nameof(PropertiesCommand), null)) .AddListener(this, nameof(TreeBooksViewModel.SelectedNode)); OpenBookCommand = new BaseCommand("Abrir libro", parameter => ExecuteAction(nameof(OpenBookCommand), null), parameter => CanExecuteAction(nameof(OpenBookCommand), null)) .AddListener(this, nameof(TreeBooksViewModel.SelectedNode)); CompileCommand = new BaseCommand("Compilar libro", canExecute => ExecuteAction(nameof(CompileCommand), null), parameter => CanExecuteAction(nameof(CompileCommand), null)) .AddListener(this, nameof(TreeBooksViewModel.SelectedNode)); DeleteCommand.AddListener(this, nameof(TreeBooksViewModel.SelectedNode)); }
public ExplorerProjectViewModel(Controllers.IPlugStudioController plugStudioController) { // Inicializa los datos PlugStudioController = plugStudioController; Children = new ObservableCollection <ExplorerProjectNodeViewModel>(); // Inicializa los comandos NewFolderCommand = new BaseCommand(parameter => NewFolder(), parameter => CanExecuteAction(nameof(NewFolderCommand), parameter)) .AddListener(this, nameof(SelectedNode)); NewFileCommand = new BaseCommand(parameter => NewFile(), parameter => CanExecuteAction(nameof(NewFileCommand), parameter)) .AddListener(this, nameof(SelectedNode)); CopyCommand = new BaseCommand(parameter => CopySelectedItem(), parameter => CanExecuteAction(nameof(CopyCommand), parameter)) .AddListener(this, nameof(SelectedNode)); PasteCommand = new BaseCommand(parameter => PasteItem(), parameter => CanExecuteAction(nameof(PasteCommand), parameter)) .AddListener(this, nameof(SelectedNode)); MenuCommand = new BaseCommand(parameter => ExecuteMenuOption(parameter as MenuModel), parameter => CanExecuteMenuOption(parameter as MenuModel)); DeleteCommand.AddListener(this, nameof(SelectedNode)); PropertiesCommand.AddListener(this, nameof(SelectedNode)); }
/// <summary> /// Inicializa las propiedades /// </summary> private void InitProperties() { MenuGroupViewModel menuGroup; // Inicializa los comandos OpenOpmlCommand = new BaseCommand("Abrir archivo OPML", parameter => ExecuteAction(nameof(OpenOpmlCommand), parameter)); NewFolderCommand = new BaseCommand("Nueva carpeta", parameter => ExecuteAction(nameof(NewFolderCommand), parameter), parameter => CanExecuteAction(nameof(NewFolderCommand), parameter)) .AddListener(this, nameof(TreeBlogsViewModel.SelectedNode)); NewBlogCommand = new BaseCommand("Nuevo blog", parameter => ExecuteAction(nameof(NewBlogCommand), parameter), parameter => CanExecuteAction(nameof(NewBlogCommand), parameter)) .AddListener(this, nameof(TreeBlogsViewModel.SelectedNode)); DownloadCommand = new BaseCommand("Descargar", parameter => ExecuteAction(nameof(DownloadCommand), parameter), parameter => CanExecuteAction(nameof(DownloadCommand), parameter)) .AddListener(this, nameof(TreeBlogsViewModel.SelectedNode)); SeeNewsCommand = new BaseCommand("Ver noticias", parameter => ExecuteAction(nameof(SeeNewsCommand), parameter), parameter => CanExecuteAction(nameof(SeeNewsCommand), parameter)) .AddListener(this, nameof(TreeBlogsViewModel.SelectedNode)); DeleteCommand.AddListener(this, nameof(TreeBlogsViewModel.SelectedNode)); // Añade los menús de la ventana principal menuGroup = MenuCompositionData.Menus.Add("Nuevo", MenuGroupViewModel.TargetMenuType.MainMenu, MenuGroupViewModel.TargetMainMenuItemType.FileOpenItems); menuGroup.MenuItems.Add("Archivo OPML", BlogReaderViewModel.Instance.GetIconRoute(BlogReaderViewModel.IconIndex.NewBlog), OpenOpmlCommand); menuGroup = MenuCompositionData.Menus.Add("Nuevo", MenuGroupViewModel.TargetMenuType.MainMenu, MenuGroupViewModel.TargetMainMenuItemType.FileNewItems); menuGroup.MenuItems.Add("Nueva carpeta", BlogReaderViewModel.Instance.GetIconRoute(BlogReaderViewModel.IconIndex.NewFolder), NewFolderCommand); menuGroup.MenuItems.Add("Nuevo blog", BlogReaderViewModel.Instance.GetIconRoute(BlogReaderViewModel.IconIndex.NewBlog), NewBlogCommand); // Inicializa el árbol Tree = new TreeBlogsViewModel(Folder); }