private void RefreshData(bool refreshContinueWatching, bool refreshRecentAdditions, bool refreshOtherWidgets)
        {
            Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
            {
                Window parentWindow = Window.GetWindow(this);

                IsLoadingData       = true;
                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);
            });
        }
Ejemplo n.º 2
0
        public void RefreshRecentAdditions(RecentAdditionsType addType)
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    RecentAdditions.Clear();
                });

                if (addType == RecentAdditionsType.Episode)
                {
                    List <JMMServerBinary.Contract_AnimeEpisode> epContracts =
                        JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesRecentlyAdded(UserSettingsVM.Instance.Dash_RecentAdditions_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                    {
                        foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts)
                        {
                            AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
                            ep.RefreshAnime();

                            if (ep.AniDB_Anime == null)
                            {
                                ep.RefreshAnime(true); // this might be a new series
                            }
                            if (ep.AniDB_Anime != null)
                            {
                                ep.SetTvDBInfo();
                                RecentAdditions.Add(ep);
                            }
                        }
                        ViewRecentAdditions.Refresh();
                    });
                }
                else
                {
                    List <JMMServerBinary.Contract_AnimeSeries> serContracts =
                        JMMServerVM.Instance.clientBinaryHTTP.GetSeriesRecentlyAdded(UserSettingsVM.Instance.Dash_RecentAdditions_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                    {
                        foreach (JMMServerBinary.Contract_AnimeSeries contract in serContracts)
                        {
                            AnimeSeriesVM ser = new AnimeSeriesVM(contract);
                            RecentAdditions.Add(ser);
                        }
                        ViewRecentAdditions.Refresh();
                    });
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }
Ejemplo n.º 3
0
        public void RefreshRecentAdditions(RecentAdditionsType addType)
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate {
                    RecentAdditions.Clear();
                });

                if (addType == RecentAdditionsType.Episode)
                {
                    List <VM_AnimeEpisode_User> epContracts =
                        VM_ShokoServer.Instance.ShokoServices.GetEpisodesRecentlyAdded(VM_UserSettings.Instance.Dash_RecentAdditions_Items, VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList <VM_AnimeEpisode_User>();

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate
                    {
                        foreach (VM_AnimeEpisode_User ep in epContracts)
                        {
                            ep.RefreshAnime();

                            if (ep.AniDB_Anime == null)
                            {
                                ep.RefreshAnime(true); // this might be a new series
                            }
                            if (ep.AniDB_Anime != null)
                            {
                                ep.SetTvDBInfo();
                                RecentAdditions.Add(ep);
                            }
                        }
                        ViewRecentAdditions.Refresh();
                    });
                }
                else
                {
                    List <VM_AnimeSeries_User> serContracts =
                        VM_ShokoServer.Instance.ShokoServices.GetSeriesRecentlyAdded(VM_UserSettings.Instance.Dash_RecentAdditions_Items, VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList <VM_AnimeSeries_User>();

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate
                    {
                        foreach (VM_AnimeSeries_User ser in serContracts)
                        {
                            RecentAdditions.Add(ser);
                        }
                        ViewRecentAdditions.Refresh();
                    });
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
        void btnExpandDashRecentAdditions_Click(object sender, RoutedEventArgs e)
        {
            RecentAdditionsType addType = RecentAdditionsType.Episode;

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

            if (VM_UserSettings.Instance.DashRecentAdditionsCollapsed && VM_Dashboard.Instance.RecentAdditions.Count == 0)
            {
                VM_Dashboard.Instance.RefreshRecentAdditions(addType);
            }

            VM_UserSettings.Instance.DashRecentAdditionsExpanded = !VM_UserSettings.Instance.DashRecentAdditionsExpanded;
        }
Ejemplo n.º 5
0
        public void RefreshRecentAdditions(RecentAdditionsType addType)
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
                {
                    RecentAdditions.Clear();
                });

                if (addType == RecentAdditionsType.Episode)
                {
                    List<JMMServerBinary.Contract_AnimeEpisode> epContracts =
                        JMMServerVM.Instance.clientBinaryHTTP.GetEpisodesRecentlyAdded(UserSettingsVM.Instance.Dash_RecentAdditions_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
                    {
                        foreach (JMMServerBinary.Contract_AnimeEpisode contract in epContracts)
                        {
                            AnimeEpisodeVM ep = new AnimeEpisodeVM(contract);
                            ep.RefreshAnime();

                            if (ep.AniDB_Anime == null)
                                ep.RefreshAnime(true); // this might be a new series

                            if (ep.AniDB_Anime != null)
                            {
                                ep.SetTvDBInfo();
                                RecentAdditions.Add(ep);
                            }
                        }
                        ViewRecentAdditions.Refresh();
                    });
                }
                else
                {
                    List<JMMServerBinary.Contract_AnimeSeries> serContracts =
                        JMMServerVM.Instance.clientBinaryHTTP.GetSeriesRecentlyAdded(UserSettingsVM.Instance.Dash_RecentAdditions_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value);

                    System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
                    {
                        foreach (JMMServerBinary.Contract_AnimeSeries contract in serContracts)
                        {
                            AnimeSeriesVM ser = new AnimeSeriesVM(contract);
                            RecentAdditions.Add(ser);
                        }
                        ViewRecentAdditions.Refresh();
                    });
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }
Ejemplo n.º 6
0
        public void RefreshData(bool refreshContinueWatching, bool refreshRecentAdditions, bool refreshOtherWidgets, RecentAdditionsType addType)
        {
            try
            {
                IsLoadingData = true;

                // clear all displayed data
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
                {
                    if (refreshContinueWatching) EpsWatchNext_Recent.Clear();
                    if (refreshRecentAdditions) RecentAdditions.Clear();

                    if (refreshOtherWidgets)
                    {
                        SeriesMissingEps.Clear();
                        EpsWatchedRecently.Clear();
                        MiniCalendar.Clear();
                        RecommendationsWatch.Clear();
                        RecommendationsDownload.Clear();
                    }

                    if (refreshOtherWidgets)
                    {
                        ViewEpsWatchedRecently.Refresh();
                        ViewSeriesMissingEps.Refresh();
                        ViewMiniCalendar.Refresh();
                        ViewRecommendationsWatch.Refresh();
                        ViewRecommendationsDownload.Refresh();
                        ViewRecentAdditions.Refresh();
                    }

                    if (refreshContinueWatching) ViewEpsWatchNext_Recent.Refresh();
                    if (refreshRecentAdditions) ViewRecentAdditions.Refresh();
                });

                DateTime start = DateTime.Now;
                MainListHelperVM.Instance.RefreshGroupsSeriesData();
                TimeSpan ts = DateTime.Now - start;

                logger.Trace("Dashboard Time: RefreshGroupsSeriesData: {0}", ts.TotalMilliseconds);

                if (refreshContinueWatching && UserSettingsVM.Instance.DashWatchNextEpExpanded)
                    RefreshEpsWatchNext_Recent();

                if (refreshRecentAdditions && UserSettingsVM.Instance.DashRecentAdditionsExpanded)
                    RefreshRecentAdditions(addType);

                if (refreshOtherWidgets)
                {
                    if (UserSettingsVM.Instance.DashRecentlyWatchEpsExpanded)
                        RefreshRecentlyWatchedEps();

                    if (UserSettingsVM.Instance.DashSeriesMissingEpisodesExpanded)
                        RefreshSeriesMissingEps();

                    if (UserSettingsVM.Instance.DashMiniCalendarExpanded)
                        RefreshMiniCalendar();

                    if (UserSettingsVM.Instance.DashRecommendationsWatchExpanded)
                        RefreshRecommendationsWatch();

                    if (UserSettingsVM.Instance.DashRecommendationsDownloadExpanded)
                        RefreshRecommendationsDownload();

                }

                IsLoadingData = false;

            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }
Ejemplo n.º 7
0
        public void RefreshData(bool refreshContinueWatching, bool refreshRecentAdditions, bool refreshOtherWidgets, RecentAdditionsType addType)
        {
            try
            {
                IsLoadingData = true;

                // clear all displayed data
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
                {
                    if (refreshContinueWatching)
                    {
                        EpsWatchNext_Recent.Clear();
                    }
                    if (refreshRecentAdditions)
                    {
                        RecentAdditions.Clear();
                    }

                    if (refreshOtherWidgets)
                    {
                        SeriesMissingEps.Clear();
                        EpsWatchedRecently.Clear();
                        MiniCalendar.Clear();
                        RecommendationsWatch.Clear();
                        RecommendationsDownload.Clear();
                    }

                    if (refreshOtherWidgets)
                    {
                        ViewEpsWatchedRecently.Refresh();
                        ViewSeriesMissingEps.Refresh();
                        ViewMiniCalendar.Refresh();
                        ViewRecommendationsWatch.Refresh();
                        ViewRecommendationsDownload.Refresh();
                        ViewRecentAdditions.Refresh();
                    }

                    if (refreshContinueWatching)
                    {
                        ViewEpsWatchNext_Recent.Refresh();
                    }
                    if (refreshRecentAdditions)
                    {
                        ViewRecentAdditions.Refresh();
                    }
                });

                DateTime start = DateTime.Now;
                MainListHelperVM.Instance.RefreshGroupsSeriesData();
                TimeSpan ts = DateTime.Now - start;

                logger.Trace("Dashboard Time: RefreshGroupsSeriesData: {0}", ts.TotalMilliseconds);

                if (refreshContinueWatching && UserSettingsVM.Instance.DashWatchNextEpExpanded)
                {
                    RefreshEpsWatchNext_Recent();
                }

                if (refreshRecentAdditions && UserSettingsVM.Instance.DashRecentAdditionsExpanded)
                {
                    RefreshRecentAdditions(addType);
                }

                if (refreshOtherWidgets)
                {
                    if (UserSettingsVM.Instance.DashRecentlyWatchEpsExpanded)
                    {
                        RefreshRecentlyWatchedEps();
                    }

                    if (UserSettingsVM.Instance.DashSeriesMissingEpisodesExpanded)
                    {
                        RefreshSeriesMissingEps();
                    }

                    if (UserSettingsVM.Instance.DashMiniCalendarExpanded)
                    {
                        RefreshMiniCalendar();
                    }

                    if (UserSettingsVM.Instance.DashRecommendationsWatchExpanded)
                    {
                        RefreshRecommendationsWatch();
                    }

                    if (UserSettingsVM.Instance.DashRecommendationsDownloadExpanded)
                    {
                        RefreshRecommendationsDownload();
                    }
                }

                IsLoadingData = false;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }