Beispiel #1
0
 private void ShowSearchResults(SearchTabViewModel searchTabViewModel, TabViewModel searchResultsTabViewModel)
 {
     if (searchTabViewModel != DefaultSearchTabViewModel)
     {
         searchTabViewModel.NonFictionSearchComplete -= SearchTabNonFictionSearchComplete;
         searchTabViewModel.FictionSearchComplete    -= SearchTabFictionSearchComplete;
         searchTabViewModel.SciMagSearchComplete     -= SearchTabSciMagSearchComplete;
         TabViewModels.Remove(searchTabViewModel);
     }
     TabViewModels.Add(searchResultsTabViewModel);
     SelectedTabViewModel = searchResultsTabViewModel;
     NotifyPropertyChanged(nameof(IsDefaultSearchTabVisible));
     NotifyPropertyChanged(nameof(AreTabsVisible));
     NotifyPropertyChanged(nameof(IsNewTabButtonVisible));
 }
Beispiel #2
0
        private void Initialize()
        {
            AppSettings appSettings = mainModel.AppSettings;

            AppSettings.MainWindowSettings mainWindowSettings = appSettings.MainWindow;
            WindowWidth       = mainWindowSettings.Width;
            WindowHeight      = mainWindowSettings.Height;
            WindowLeft        = mainWindowSettings.Left;
            WindowTop         = mainWindowSettings.Top;
            IsWindowMaximized = mainWindowSettings.Maximized;
            DefaultSearchTabViewModel.ImportRequested          += DefaultSearchTabViewModel_ImportRequested;
            DefaultSearchTabViewModel.NonFictionSearchComplete += SearchTabNonFictionSearchComplete;
            DefaultSearchTabViewModel.FictionSearchComplete    += SearchTabFictionSearchComplete;
            DefaultSearchTabViewModel.SciMagSearchComplete     += SearchTabSciMagSearchComplete;
            selectedTabViewModel = null;
        }
Beispiel #3
0
        private void CloseTab(TabViewModel tabViewModel)
        {
            switch (tabViewModel)
            {
            case SearchTabViewModel searchTabViewModel:
                searchTabViewModel.NonFictionSearchComplete -= SearchTabNonFictionSearchComplete;
                searchTabViewModel.FictionSearchComplete    -= SearchTabFictionSearchComplete;
                searchTabViewModel.SciMagSearchComplete     -= SearchTabSciMagSearchComplete;
                break;

            case NonFictionSearchResultsTabViewModel nonFictionSearchResultsTabViewModel:
                nonFictionSearchResultsTabViewModel.OpenNonFictionDetailsRequested -= OpenNonFictionDetailsRequested;
                break;

            case NonFictionDetailsTabViewModel nonFictionDetailsTabViewModel:
                nonFictionDetailsTabViewModel.CloseTabRequested -= NonFictionDetailsCloseTabRequested;
                break;

            case FictionDetailsTabViewModel fictionDetailsTabViewModel:
                fictionDetailsTabViewModel.CloseTabRequested -= FictionDetailsCloseTabRequested;
                break;

            case SciMagDetailsTabViewModel sciMagDetailsTabViewModel:
                sciMagDetailsTabViewModel.CloseTabRequested -= SciMagDetailsCloseTabRequested;
                break;
            }
            int removingTabIndex = TabViewModels.IndexOf(tabViewModel);

            TabViewModels.Remove(tabViewModel);
            NotifyPropertyChanged(nameof(IsDefaultSearchTabVisible));
            NotifyPropertyChanged(nameof(AreTabsVisible));
            NotifyPropertyChanged(nameof(IsNewTabButtonVisible));
            if (!TabViewModels.Any())
            {
                SelectedTabViewModel = null;
                DefaultSearchTabViewModel.Refresh(setFocus: true);
            }
            else
            {
                int newSelectedTabIndex = TabViewModels.Count > removingTabIndex ? removingTabIndex : TabViewModels.Count - 1;
                SelectedTabViewModel = TabViewModels[newSelectedTabIndex];
            }
        }