/// <summary> /// Obtiene la biblioteca seleccionada (si está seleccionado un libro, se recoge la biblioteca padre) /// </summary> private LibraryModel GetSelectedLibrarySearch() { LibraryModel library = TreeBooks.GetSelectedLibrary(); // Si está en un libro, se selecciona la biblioteca padre if (library == null) { library = TreeBooks.GetSelectedLibraryParent(); } // Devuelve la biblioteca return(library); }
/// <summary> /// Comprueba si se puede ejecutar una acción /// </summary> protected override void ExecuteAction(string action, object parameter) { switch (action) { case nameof(PropertiesCommand): if (!TreeBooks.IsSelectedBook) { OpenFormUpdateLibrary(TreeBooks.GetSelectedLibrary(), TreeBooks.GetSelectedLibraryParent()); } break; case nameof(NewBookCommand): OpenFormUpdateBook(TreeBooks.GetSelectedBook(), TreeBooks.GetSelectedLibraryParent()); break; case nameof(OpenBookCommand): OpenBook(TreeBooks.GetSelectedBook()); break; case nameof(DeleteCommand): if (TreeBooks.SelectedNode != null) { if (TreeBooks.IsSelectedLibrary) { DeleteLibrary(TreeBooks.GetSelectedLibrary()); } else if (TreeBooks.IsSelectedBook) { DeleteBook(TreeBooks.GetSelectedBook()); } } break; case nameof(CompileCommand): OpenFormCompileBook(TreeBooks.GetSelectedBook()); break; case nameof(RefreshCommand): Refresh(); break; } }