protected TabViewModel(MainModel mainModel, IWindowContext parentWindowContext, string title) { MainModel = mainModel; ParentWindowContext = parentWindowContext; this.title = title; Events = new EventProvider(); }
public SearchTabViewModel(MainModel mainModel, IWindowContext parentWindowContext) : base(mainModel, parentWindowContext, "Поиск") { ImportCommand = new Command(Import); SearchCommand = new Command(Search); Initialize(); }
protected virtual bool ShowPrompt(string title, string text, IWindowContext parentWindowContext) { string yes = MainModel.Localization.CurrentLanguage.MessageBox.Yes; string no = MainModel.Localization.CurrentLanguage.MessageBox.No; return(WindowManager.ShowPrompt(title, text, yes, no, parentWindowContext)); }
private void OpenFictionDetailsRequested(object sender, OpenFictionDetailsEventArgs e) { Logger.Debug($"Opening fiction book with ID = {e.FictionBook.Id}, Libgen ID = {e.FictionBook.LibgenId}."); SearchSettings.DetailsMode openDetailsMode = MainModel.AppSettings.Search.OpenDetailsMode; if (openDetailsMode == SearchSettings.DetailsMode.NEW_TAB) { FictionDetailsTabViewModel fictionDetailsTabViewModel = new FictionDetailsTabViewModel(MainModel, CurrentWindowContext, e.FictionBook, isInModalWindow: false); fictionDetailsTabViewModel.SelectDownloadRequested += SelectDownloadRequested; fictionDetailsTabViewModel.CloseTabRequested += FictionDetailsCloseTabRequested; TabViewModels.Add(fictionDetailsTabViewModel); SelectedTabViewModel = fictionDetailsTabViewModel; } else { bool modalWindow = openDetailsMode == SearchSettings.DetailsMode.NEW_MODAL_WINDOW; FictionDetailsWindowViewModel detailsWindowViewModel = new FictionDetailsWindowViewModel(MainModel, e.FictionBook, modalWindow); detailsWindowViewModel.SelectDownloadRequested += SelectDownloadRequested; IWindowContext detailsWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.FICTION_DETAILS_WINDOW, detailsWindowViewModel, CurrentWindowContext); FictionDetailsWindowSettings detailsWindowSettings = MainModel.AppSettings.Fiction.DetailsWindow; if (modalWindow) { detailsWindowContext.ShowDialog(detailsWindowSettings.Width, detailsWindowSettings.Height); detailsWindowViewModel.SelectDownloadRequested -= SelectDownloadRequested; } else { detailsWindowViewModel.WindowClosed += FictionDetailsWindowClosed; detailsWindowContext.Show(detailsWindowSettings.Width, detailsWindowSettings.Height); } } }
public static void ShowMessage(string title, string text, string ok, IWindowContext parentWindowContext = null) { MessageBoxWindow messageBoxWindow = CreateWindow(title, text, parentWindowContext); messageBoxWindow.AddButton(ok, true, true, true); messageBoxWindow.ShowDialog(); }
private void OpenNonFictionDetailsRequested(object sender, NonFictionSearchResultsTabViewModel.OpenNonFictionDetailsEventArgs e) { Logger.Debug($"Opening non-fiction book with ID = {e.NonFictionBook.Id}, Libgen ID = {e.NonFictionBook.LibgenId}."); SearchSettings.DetailsMode openDetailsMode = mainModel.AppSettings.Search.OpenDetailsMode; if (openDetailsMode == SearchSettings.DetailsMode.NEW_TAB) { NonFictionDetailsTabViewModel nonFictionDetailsTabViewModel = new NonFictionDetailsTabViewModel(mainModel, CurrentWindowContext, e.NonFictionBook, isInModalWindow: false); nonFictionDetailsTabViewModel.CloseTabRequested += NonFictionDetailsCloseTabRequested; TabViewModels.Add(nonFictionDetailsTabViewModel); SelectedTabViewModel = nonFictionDetailsTabViewModel; } else { bool modalWindow = openDetailsMode == SearchSettings.DetailsMode.NEW_MODAL_WINDOW; NonFictionDetailsWindowViewModel detailsWindowViewModel = new NonFictionDetailsWindowViewModel(mainModel, e.NonFictionBook, modalWindow); IWindowContext detailsWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.NON_FICTION_DETAILS_WINDOW, detailsWindowViewModel, CurrentWindowContext); NonFictionDetailsWindowSettings detailsWindowSettings = mainModel.AppSettings.NonFiction.DetailsWindow; if (modalWindow) { detailsWindowContext.ShowDialog(detailsWindowSettings.Width, detailsWindowSettings.Height); } else { detailsWindowContext.Show(detailsWindowSettings.Width, detailsWindowSettings.Height); } } }
private void OpenBook(LibraryItemViewModel book) { BookViewModel bookViewModel = new BookViewModel(book.Id); IWindowContext bookWindowContext = windowManager.CreateWindow(bookViewModel); bookWindowContext.ShowDialog(); }
private void Import() { OpenFileDialogParameters selectSqlDumpFileDialogParameters = new OpenFileDialogParameters { DialogTitle = "Выбор SQL-дампа", Filter = "Все поддерживаемые файлы|*.sql;*zip;*.rar;*.gz;*.7z|SQL -дампы (*.sql)|*.sql|Архивы (*.zip, *.rar, *.gz, *.7z)|*zip;*.rar;*.gz;*.7z|Все файлы (*.*)|*.*", Multiselect = false }; OpenFileDialogResult selectSqlDumpFileDialogResult = WindowManager.ShowOpenFileDialog(selectSqlDumpFileDialogParameters); if (selectSqlDumpFileDialogResult.DialogResult) { ImportWindowViewModel importWindowViewModel = new ImportWindowViewModel(mainModel, selectSqlDumpFileDialogResult.SelectedFilePaths.First()); IWindowContext importWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.IMPORT_WINDOW, importWindowViewModel, CurrentWindowContext); importWindowContext.ShowDialog(); if (IsDefaultSearchTabVisible) { DefaultSearchTabViewModel.Refresh(setFocus: true); } else { foreach (SearchTabViewModel searchTabViewModel in TabViewModels.OfType <SearchTabViewModel>()) { searchTabViewModel.Refresh(setFocus: searchTabViewModel == SelectedTabViewModel); } } } }
public void Construct(IWindowContext context, UIManager uiManager) { Context = context; _uiManager = uiManager; OnCreate(); }
private void SettingsMenuItemClick() { SettingsWindowViewModel settingsWindowViewModel = new SettingsWindowViewModel(mainModel); IWindowContext settingsWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.SETTINGS_WINDOW, settingsWindowViewModel, CurrentWindowContext); settingsWindowContext.ShowDialog(); }
protected SearchResultsTabViewModel(MainModel mainModel, IWindowContext parentWindowContext, LibgenObjectType libgenObjectType, string searchQuery) : base(mainModel, parentWindowContext, searchQuery) { this.libgenObjectType = libgenObjectType; emptySelectedItemFields = new ObservableCollection <string>(); this.searchQuery = searchQuery; lastExecutedSearchQuery = searchQuery; UpdateBookmarkedState(); isExportPanelVisible = false; isSearchProgressPanelVisible = false; isSearchResultsGridVisible = true; isStatusBarVisible = true; ExportPanelViewModel = new ExportPanelViewModel(mainModel, libgenObjectType, parentWindowContext); ExportPanelViewModel.ClosePanel += CloseExportPanel; SearchCommand = new Command(Search); InterruptSearchCommand = new Command(InterruptSearch); ToggleBookmarkCommand = new Command(ToggleBookmark); OpenDetailsCommand = new Command(OpenDetails); OpenFileCommand = new Command(OpenFile); DownloadCommand = new Command(Download); CopyCommand = new Command(param => Copy(param as string)); ToggleExportPanelCommand = new Command(ToggleExportPanel); mainModel.Localization.LanguageChanged += LocalizationLanguageChanged; Events.RaiseEvent(ViewModelEvent.RegisteredEventId.FOCUS_SEARCH_TEXT_BOX); }
private void OpenSciMagDetailsRequested(object sender, OpenSciMagDetailsEventArgs e) { Logger.Debug($"Opening article with ID = {e.SciMagArticle.Id}, Libgen ID = {e.SciMagArticle.LibgenId}."); SearchSettings.DetailsMode openDetailsMode = MainModel.AppSettings.Search.OpenDetailsMode; if (openDetailsMode == SearchSettings.DetailsMode.NEW_TAB) { SciMagDetailsTabViewModel sciMagDetailsTabViewModel = new SciMagDetailsTabViewModel(MainModel, CurrentWindowContext, e.SciMagArticle, isInModalWindow: false); sciMagDetailsTabViewModel.SelectDownloadRequested += SelectDownloadRequested; sciMagDetailsTabViewModel.CloseTabRequested += SciMagDetailsCloseTabRequested; TabViewModels.Add(sciMagDetailsTabViewModel); SelectedTabViewModel = sciMagDetailsTabViewModel; } else { bool modalWindow = openDetailsMode == SearchSettings.DetailsMode.NEW_MODAL_WINDOW; SciMagDetailsWindowViewModel detailsWindowViewModel = new SciMagDetailsWindowViewModel(MainModel, e.SciMagArticle, modalWindow); detailsWindowViewModel.SelectDownloadRequested += SelectDownloadRequested; IWindowContext detailsWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.SCI_MAG_DETAILS_WINDOW, detailsWindowViewModel, CurrentWindowContext); SciMagDetailsWindowSettings detailsWindowSettings = MainModel.AppSettings.SciMag.DetailsWindow; if (modalWindow) { detailsWindowContext.ShowDialog(detailsWindowSettings.Width, detailsWindowSettings.Height); detailsWindowViewModel.SelectDownloadRequested -= SelectDownloadRequested; } else { detailsWindowViewModel.WindowClosed += SciMagDetailsWindowClosed; detailsWindowContext.Show(detailsWindowSettings.Width, detailsWindowSettings.Height); } } }
private WindowManager() { registeredWindowsByViewName = new Dictionary<string, WindowInfo>(); registeredWindowsByViewModel = new Dictionary<Type, WindowInfo>(); openWindows = new Dictionary<string, IWindowContext>(); lastActivatedWindowContext = null; EnumerateWindowsInAssembly(); }
private void SqlDebuggerMenuItemClick() { SqlDebuggerWindowViewModel sqlDebuggerWindowViewModel = new SqlDebuggerWindowViewModel(MainModel); IWindowContext sqlDebuggerWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.SQL_DEBUGGER_WINDOW, sqlDebuggerWindowViewModel, CurrentWindowContext); sqlDebuggerWindowContext.ShowDialog(); }
public static bool ShowPrompt(string title, string text, IWindowContext parentWindowContext = null) { MessageBoxWindow messageBoxWindow = CreateWindow(title, text, parentWindowContext); messageBoxWindow.AddButton("ДА", true, false, false); messageBoxWindow.AddButton("НЕТ", false, false, true); return(messageBoxWindow.ShowDialog() == true); }
protected void ShowErrorWindow(Exception exception, IWindowContext parentWindowContext) { Logger.Exception(exception); ErrorWindowViewModel errorWindowViewModel = new ErrorWindowViewModel(exception.ToString()); IWindowContext errorWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.ERROR_WINDOW, errorWindowViewModel, parentWindowContext); errorWindowContext.ShowDialog(); }
private void ShowMainWindow(MainModel mainModel) { MainWindowViewModel mainWindowViewModel = new MainWindowViewModel(mainModel); IWindowContext windowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.MAIN_WINDOW, mainWindowViewModel); windowContext.Closed += (sender, args) => Close(); windowContext.Show(); }
private void Closed(object sender, EventArgs e) { IWindowContext windowContext = (IWindowContext)sender; openWindows.Remove(windowContext.ViewName); windowContext.Showing -= Showing; windowContext.Closed -= Closed; }
public bool? ShowDialog(IWindowContext ownerWindowContext = null, bool showMaximized = false) { OnShowing(); if (ownerWindowContext == null) ownerWindowContext = windowManager.FindActiveWindow(); Window.Owner = ownerWindowContext.Window; return ShowDialog(showMaximized, true); }
private void ShowErrorWindow(Exception exception) { Logger.Exception(exception); ErrorWindowViewModel errorWindowViewModel = new ErrorWindowViewModel(exception?.ToString() ?? "(null)"); IWindowContext errorWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.ERROR_WINDOW, errorWindowViewModel); errorWindowContext.ShowDialog(); }
private void DatabaseMenuItemClick() { DatabaseWindowViewModel databaseWindowViewModel = new DatabaseWindowViewModel(MainModel); IWindowContext databaseWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.DATABASE_WINDOW, databaseWindowViewModel, CurrentWindowContext); databaseWindowContext.ShowDialog(); }
private WindowManager() { registeredWindowsByViewName = new Dictionary <string, WindowInfo>(); registeredWindowsByViewModel = new Dictionary <Type, WindowInfo>(); openWindows = new Dictionary <string, IWindowContext>(); lastActivatedWindowContext = null; EnumerateWindowsInAssembly(); }
public SearchTabViewModel(MainModel mainModel, IWindowContext parentWindowContext) : base(mainModel, parentWindowContext, mainModel.Localization.CurrentLanguage.SearchTab.TabTitle) { ImportCommand = new Command(Import); SearchCommand = new Command(Search); Initialize(); mainModel.Localization.LanguageChanged += LocalizationLanguageChanged; }
public void Import(ImportQueueItemViewModel importQueueItemViewModel) { string databaseDumpFilePath; if (SharedSetupContext.SelectedDownloadMode == SharedSetupContext.DownloadMode.DOWNLOAD_MANAGER) { databaseDumpFilePath = importQueueItemViewModel.Collection.DownloadFilePath; } else { OpenFileDialogResult selectDatabaseDumpFileDialogResult = ImportWindowViewModel.SelectDatabaseDumpFile(MainModel); if (!selectDatabaseDumpFileDialogResult.DialogResult) { return; } databaseDumpFilePath = selectDatabaseDumpFileDialogResult.SelectedFilePaths.First(); } importQueueItemViewModel.Status = ImportQueueItemStatus.IMPORTING; TableType expectedTableType; switch (importQueueItemViewModel.Collection.Identifier) { case SharedSetupContext.CollectionIdentifier.NON_FICTION: expectedTableType = TableType.NON_FICTION; break; case SharedSetupContext.CollectionIdentifier.FICTION: expectedTableType = TableType.FICTION; break; case SharedSetupContext.CollectionIdentifier.SCIMAG: expectedTableType = TableType.SCI_MAG; break; default: throw new Exception($"Unexpected collection identifier: {importQueueItemViewModel.Collection.Identifier}."); } ImportWindowViewModel importWindowViewModel = new ImportWindowViewModel(MainModel, databaseDumpFilePath, expectedTableType); IWindowContext importWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.IMPORT_WINDOW, importWindowViewModel, SetupWizardWindowContext); importWindowContext.ShowDialog(); switch (importWindowViewModel.Status) { case ImportWindowViewModel.ImportStatus.IMPORT_COMPLETE: importQueueItemViewModel.Status = ImportQueueItemStatus.IMPORT_SUCCESSFUL; SelectNextImportQueueItem(); break; case ImportWindowViewModel.ImportStatus.IMPORT_CANCELLED: importQueueItemViewModel.Status = ImportQueueItemStatus.IMPORT_CANCELLED; break; default: importQueueItemViewModel.Status = ImportQueueItemStatus.IMPORT_ERROR; break; } }
private void ProxyServerSettingsClick() { IWindowContext setupWizardProxySettingsWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.SETUP_WIZARD_PROXY_SETTINGS_WINDOW, setupWizardProxySettingsWindowViewModel, SetupWizardWindowContext); setupWizardProxySettingsWindowViewModel.PopulateFieldsFromAppSettings(); setupWizardProxySettingsWindowViewModel.SetFocus(); setupWizardProxySettingsWindowContext.ShowDialog(); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); LibraryViewModel libraryViewModel = new LibraryViewModel(); IWindowContext libraryWindowContext = WindowManager.Instance.CreateWindow(libraryViewModel); libraryWindowContext.Closed += (sender, args) => Shutdown(); libraryWindowContext.Show(); }
public FictionDetailsTabViewModel(MainModel mainModel, IWindowContext parentWindowContext, FictionBook book, bool isInModalWindow) : base(mainModel, parentWindowContext, book.Title) { this.book = book; IsInModalWindow = isInModalWindow; DownloadBookCommand = new Command(DownloadBook); CloseCommand = new Command(CloseTab); Initialize(); }
protected TabViewModel(MainModel mainModel, IWindowContext parentWindowContext, string title) : base(mainModel) { synchronizationContext = SynchronizationContext.Current; ParentWindowContext = parentWindowContext; this.title = title; RequestCloseCommand = new Command(RequestCloseTab); Events = new EventProvider(); }
private void DatabaseMenuItemClick() { DatabaseWindowViewModel databaseWindowViewModel = new DatabaseWindowViewModel(MainModel); IWindowContext databaseWindowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.DATABASE_WINDOW, databaseWindowViewModel, CurrentWindowContext); databaseWindowContext.ShowDialog(); RefreshSearchTabCollectionAvailabilities(); }
public SciMagDetailsTabViewModel(MainModel mainModel, IWindowContext parentWindowContext, SciMagArticle article, bool isInModalWindow) : base(mainModel, parentWindowContext, article.Title) { this.article = article; IsInModalWindow = isInModalWindow; DownloadArticleCommand = new Command(DownloadArticle); CloseCommand = new Command(CloseTab); Initialize(); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); TranslationViewModel startViewModel = new TranslationViewModel(); IWindowContext startViewModelContext = WindowManager.Instance.CreateWindow(startViewModel); startViewModelContext.Closed += (sender, args) => Shutdown(); startViewModelContext.Show(); }
public bool?ShowDialog(IWindowContext ownerWindowContext = null, bool showMaximized = false) { OnShowing(); if (ownerWindowContext == null) { ownerWindowContext = windowManager.FindActiveWindow(); } Window.Owner = ownerWindowContext.Window; return(ShowDialog(showMaximized, true)); }
private void Activated(object sender, EventArgs e) { lastActivatedWindowContext = (IWindowContext)sender; }