private void SciMagDetailsWindowClosed(object sender, EventArgs e) { SciMagDetailsWindowViewModel sciMagDetailsWindowViewModel = sender as SciMagDetailsWindowViewModel; sciMagDetailsWindowViewModel.SelectDownloadRequested -= SelectDownloadRequested; sciMagDetailsWindowViewModel.WindowClosed -= NonFictionDetailsWindowClosed; }
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); } } }