Пример #1
0
        private void RefreshData(bool refreshContinueWatching, bool refreshRecentAdditions, bool refreshOtherWidgets)
        {
            System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
            {
                Window parentWindow = Window.GetWindow(this);

                IsLoadingData       = true;
                this.IsEnabled      = false;
                parentWindow.Cursor = Cursors.Wait;

                RecentAdditionsType addType = RecentAdditionsType.Episode;
                if (cboDashRecentAdditionsType.SelectedIndex == 0)
                {
                    addType = RecentAdditionsType.Episode;
                }
                if (cboDashRecentAdditionsType.SelectedIndex == 1)
                {
                    addType = RecentAdditionsType.Series;
                }

                RefreshOptions opt          = new RefreshOptions();
                opt.RefreshContinueWatching = refreshContinueWatching;
                opt.RefreshRecentAdditions  = refreshRecentAdditions;
                opt.RefreshOtherWidgets     = refreshOtherWidgets;
                opt.RecentAdditionType      = addType;
                refreshDataWorker.RunWorkerAsync(opt);
            });
        }
Пример #2
0
        void refreshDataWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                RefreshOptions opt = e.Argument as RefreshOptions;

                DashboardVM.Instance.RefreshData(opt.RefreshContinueWatching, opt.RefreshRecentAdditions,
                                                 opt.RefreshOtherWidgets, opt.RecentAdditionType);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Пример #3
0
        void btnSwitchUser_Click(object sender, RoutedEventArgs e)
        {
            // authenticate user
            if (JMMServerVM.Instance.ServerOnline)
            {
                if (JMMServerVM.Instance.AuthenticateUser())
                {
                    MainListHelperVM.Instance.ClearData();
                    MainListHelperVM.Instance.ShowChildWrappers(null);

                    RecentAdditionsType addType = RecentAdditionsType.Episode;
                    if (dash.cboDashRecentAdditionsType.SelectedIndex == 0) addType = RecentAdditionsType.Episode;
                    if (dash.cboDashRecentAdditionsType.SelectedIndex == 1) addType = RecentAdditionsType.Series;

                    RefreshOptions opt = new RefreshOptions();
                    opt.RecentAdditionType = addType;
                    opt.RefreshRecentAdditions = true;
                    opt.RefreshContinueWatching = true;
                    opt.RefreshOtherWidgets = true;
                    showDashboardWorker.RunWorkerAsync(opt);

                    tabControl1.SelectedIndex = TAB_MAIN_Dashboard;
                }
            }
        }
Пример #4
0
        private void DisplayMainTab(int tabIndex)
        {
            try
            {
                CurrentMainTabIndex = tabIndex;

                if (tabIndex == TAB_MAIN_Dashboard)
                {
                    if (dash.Visibility == System.Windows.Visibility.Visible)
                    {
                        if (DashboardVM.Instance.EpsWatchNext_Recent.Count == 0 && DashboardVM.Instance.SeriesMissingEps.Count == 0
                            && DashboardVM.Instance.MiniCalendar.Count == 0 && DashboardVM.Instance.RecommendationsWatch.Count == 0
                            && DashboardVM.Instance.RecommendationsDownload.Count == 0)
                        {
                            tabControl1.IsEnabled = false;
                            this.Cursor = Cursors.Wait;

                            RecentAdditionsType addType = RecentAdditionsType.Episode;
                            if (dash.cboDashRecentAdditionsType.SelectedIndex == 0) addType = RecentAdditionsType.Episode;
                            if (dash.cboDashRecentAdditionsType.SelectedIndex == 1) addType = RecentAdditionsType.Series;

                            RefreshOptions opt = new RefreshOptions();
                            opt.RecentAdditionType = addType;
                            opt.RefreshRecentAdditions = true;
                            opt.RefreshContinueWatching = true;
                            opt.RefreshOtherWidgets = true;
                            showDashboardWorker.RunWorkerAsync(opt);

                        }
                    }
                    else
                    {
                        if (DashboardMetroVM.Instance.ContinueWatching.Count == 0)
                            dashMetro.RefreshAllData();
                    }

                    if (JMMServerVM.Instance.AllCustomTags.Count == 0) JMMServerVM.Instance.RefreshAllCustomTags();
                }

                if (tabIndex == TAB_MAIN_Collection)
                {

                    if (MainListHelperVM.Instance.AllGroupsDictionary.Count == 0)
                    {
                        MainListHelperVM.Instance.RefreshGroupsSeriesData();
                    }

                    if (MainListHelperVM.Instance.CurrentWrapper == null && lbGroupsSeries.Items.Count == 0)
                    {
                        MainListHelperVM.Instance.SearchTextBox = txtGroupSearch;
                        MainListHelperVM.Instance.CurrentGroupFilter = MainListHelperVM.Instance.AllGroupFilter;
                        MainListHelperVM.Instance.ShowChildWrappers(MainListHelperVM.Instance.CurrentWrapper);
                        lbGroupsSeries.SelectedIndex = 0;
                    }

                    if (JMMServerVM.Instance.AllCustomTags.Count == 0) JMMServerVM.Instance.RefreshAllCustomTags();
                }

                if (tabIndex == TAB_MAIN_FileManger)
                {
                    if (unRecVids.UnrecognisedFiles.Count == 0) unRecVids.RefreshUnrecognisedFiles();
                    if (JMMServerVM.Instance.AllCustomTags.Count == 0) JMMServerVM.Instance.RefreshAllCustomTags();
                }

                if (tabIndex == TAB_MAIN_Playlists)
                {
                    if (PlaylistHelperVM.Instance.Playlists == null || PlaylistHelperVM.Instance.Playlists.Count == 0) PlaylistHelperVM.Instance.RefreshData();
                    if (lbPlaylists.Items.Count > 0 && lbPlaylists.SelectedIndex < 0)
                        lbPlaylists.SelectedIndex = 0;

                }

                if (tabIndex == TAB_MAIN_Bookmarks)
                {
                    if (MainListHelperVM.Instance.BookmarkedAnime == null || MainListHelperVM.Instance.BookmarkedAnime.Count == 0) MainListHelperVM.Instance.RefreshBookmarkedAnime();

                    if (ucBookmarks.lbBookmarks.Items.Count > 0)
                        ucBookmarks.lbBookmarks.SelectedIndex = 0;

                }

                if (tabIndex == TAB_MAIN_Search)
                {
                    if (MainListHelperVM.Instance.AllSeriesDictionary == null || MainListHelperVM.Instance.AllSeriesDictionary.Count == 0) MainListHelperVM.Instance.RefreshGroupsSeriesData();
                }

                if (tabIndex == TAB_MAIN_Server)
                {
                    if (JMMServerVM.Instance.FolderProviders.Count == 0) JMMServerVM.Instance.RefreshCloudAccounts();
                    if (JMMServerVM.Instance.ImportFolders.Count == 0) JMMServerVM.Instance.RefreshImportFolders();
                }

                if (tabIndex == TAB_MAIN_Settings)
                {
                    if (JMMServerVM.Instance.FolderProviders.Count == 0)JMMServerVM.Instance.RefreshCloudAccounts();
                    if (JMMServerVM.Instance.ImportFolders.Count == 0) JMMServerVM.Instance.RefreshImportFolders();
                    if (JMMServerVM.Instance.SelectedLanguages.Count == 0) JMMServerVM.Instance.RefreshNamingLanguages();
                    if (JMMServerVM.Instance.AllUsers.Count == 0) JMMServerVM.Instance.RefreshAllUsers();
                    if (JMMServerVM.Instance.AllTags.Count == 0) JMMServerVM.Instance.RefreshAllTags();
                    if (JMMServerVM.Instance.AllCustomTags.Count == 0) JMMServerVM.Instance.RefreshAllCustomTags();
                }

                if (tabIndex == TAB_MAIN_Pinned)
                {
                    if (JMMServerVM.Instance.AllCustomTags.Count == 0) JMMServerVM.Instance.RefreshAllCustomTags();
                }

                if (tabIndex == TAB_MAIN_Downloads)
                {
                    if (UserSettingsVM.Instance.SelectedTorrentSources.Count == 0 || UserSettingsVM.Instance.UnselectedTorrentSources.Count == 0)
                        UserSettingsVM.Instance.RefreshTorrentSources();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
                tabControl1.IsEnabled = true;
            }
        }
Пример #5
0
		private void RefreshData(bool refreshContinueWatching, bool refreshRecentAdditions, bool refreshOtherWidgets)
		{
			System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
			{
				Window parentWindow = Window.GetWindow(this);

				IsLoadingData = true;
				this.IsEnabled = false;
				parentWindow.Cursor = Cursors.Wait;

				RecentAdditionsType addType = RecentAdditionsType.Episode;
				if (cboDashRecentAdditionsType.SelectedIndex == 0) addType = RecentAdditionsType.Episode;
				if (cboDashRecentAdditionsType.SelectedIndex == 1) addType = RecentAdditionsType.Series;

				RefreshOptions opt = new RefreshOptions();
				opt.TraktScrobbles = togTraktScrobbles.IsChecked.Value;
				opt.TraktShouts = togTraktShouts.IsChecked.Value;
				opt.RefreshContinueWatching = refreshContinueWatching;
				opt.RefreshRecentAdditions = refreshRecentAdditions;
				opt.RefreshOtherWidgets = refreshOtherWidgets;
				opt.RecentAdditionType = addType;
				refreshDataWorker.RunWorkerAsync(opt);
			});
		}
        void btnSwitchUser_Click(object sender, RoutedEventArgs e)
        {
            // authenticate user
              if (JMMServerVM.Instance.ServerOnline)
              {
             if (JMMServerVM.Instance.AuthenticateUser())
             {
                MainListHelperVM.Instance.ClearData();
                MainListHelperVM.Instance.ShowChildWrappers(null);

                RecentAdditionsType addType = RecentAdditionsType.Episode;
                if (dash.cboDashRecentAdditionsType.SelectedIndex == 0) addType = RecentAdditionsType.Episode;
                if (dash.cboDashRecentAdditionsType.SelectedIndex == 1) addType = RecentAdditionsType.Series;

                RefreshOptions opt = new RefreshOptions();
                opt.RecentAdditionType = addType;
                opt.RefreshRecentAdditions = true;
                opt.RefreshContinueWatching = true;
                opt.RefreshOtherWidgets = true;

                // Check if worker is busy and cancel if needed
                if (showDashboardWorker.IsBusy)
                   showDashboardWorker.CancelAsync();

                if (!showDashboardWorker.IsBusy)
                  showDashboardWorker.RunWorkerAsync(opt);
               else
                  logger.Error("Failed to start showDashboardWorker for btnSwitchUser");

                tabControl1.SelectedIndex = TAB_MAIN_Dashboard;
             }
              }
        }