void cboEpisodeTypeFilter_SelectionChanged(object sender, SelectionChangedEventArgs e) { //return; ComboBox cbo = (ComboBox)sender; object obj = cbo.SelectedItem; if (obj == null) { return; } try { AnimeEpisodeTypeVM epType = obj as AnimeEpisodeTypeVM; AnimeSeriesVM animeSeries = (AnimeSeriesVM)this.DataContext; if (animeSeries == null) { return; } episodeType = epType.EpisodeType; RefreshEpisodes(); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
private void SetWatchedStatusOnSeries(bool watchedStatus, int maxEpisodeNumber) { try { AnimeSeriesVM animeSeries = (AnimeSeriesVM)this.DataContext; if (animeSeries == null) { return; } this.Cursor = Cursors.Wait; AnimeEpisodeTypeVM epType = cboEpisodeTypeFilter.SelectedItem as AnimeEpisodeTypeVM; JMMServerVM.Instance.clientBinaryHTTP.SetWatchedStatusOnSeries(animeSeries.AnimeSeriesID.Value, watchedStatus, maxEpisodeNumber, (int)epType.EpisodeType, JMMServerVM.Instance.CurrentUser.JMMUserID.Value); MainListHelperVM.Instance.UpdateHeirarchy(animeSeries); RefreshEpisodes(); this.Cursor = Cursors.Arrow; Window parentWindow = Window.GetWindow(this); Utils.PromptToRateSeries(animeSeries, parentWindow); } catch (Exception ex) { this.Cursor = Cursors.Arrow; Utils.ShowErrorMessage("SetWatchedStatusOnSeries: " + ex.Message); logger.ErrorException(ex.ToString(), ex); } }
public void PopulateToolbars() { try { AnimeSeriesVM animeSeries = this.DataContext as AnimeSeriesVM; if (animeSeries == null) { return; } CurrentEpisodeTypes.Clear(); foreach (AnimeEpisodeTypeVM epType in animeSeries.EpisodeTypes) { CurrentEpisodeTypes.Add(epType); } cboEpisodeTypeFilter.ItemsSource = CurrentEpisodeTypes; // look for the epiosde type of normal episodes int idx = 0; for (int i = 0; i < cboEpisodeTypeFilter.Items.Count; i++) { AnimeEpisodeTypeVM epType = cboEpisodeTypeFilter.Items[i] as AnimeEpisodeTypeVM; if (epType.EpisodeType == EpisodeType.Episode) { idx = i; break; } } if (cboEpisodeTypeFilter.Items.Count > 0) { cboEpisodeTypeFilter.SelectedIndex = idx; } RefreshEpisodes(); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
//[LogExecutionTime] public void ShowChildWrappers(MainListWrapper wrapper) { try { CurrentWrapper = wrapper; CurrentWrapperIsGroup = wrapper is GroupFilterVM; CurrentListWrapperIsGroup = wrapper is AnimeGroupVM; if (wrapper is AnimeGroupVM) { //LastAnimeGroupID = ((AnimeGroupVM)wrapper).AnimeGroupID.Value; MainListHelperVM.Instance.CurrentOpenGroupFilter = "AnimeGroupVM|" + ((AnimeGroupVM)wrapper).AnimeGroupID.Value; } if (wrapper is GroupFilterVM) { CurrentGroupFilter = (GroupFilterVM)wrapper; //LastGroupFilterID = ((GroupFilterVM)wrapper).GroupFilterID.Value; MainListHelperVM.Instance.CurrentOpenGroupFilter = "GroupFilterVM|" + ((GroupFilterVM)wrapper).GroupFilterID.Value; } if (wrapper is AnimeSeriesVM) { CurrentSeries = wrapper as AnimeSeriesVM; //LastAnimeSeriesID = ((AnimeSeriesVM)wrapper).AnimeSeriesID.Value; MainListHelperVM.Instance.CurrentOpenGroupFilter = "NoGroup"; } if (wrapper == null) { MainListHelperVM.Instance.CurrentOpenGroupFilter = "Init"; } System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { // update wrappers // check where this wrapper sits in the heirarchy and remove anything below it int pos = -1; if (wrapper != null) { for (int i = 0; i < BreadCrumbs.Count; i++) { if (wrapper is GroupFilterVM && BreadCrumbs[i] is GroupFilterVM) { GroupFilterVM wrapObj = wrapper as GroupFilterVM; GroupFilterVM bcObj = BreadCrumbs[i] as GroupFilterVM; if (wrapObj.FilterName == bcObj.FilterName) { pos = i; } } if (wrapper is AnimeGroupVM && BreadCrumbs[i] is AnimeGroupVM) { AnimeGroupVM wrapObj = wrapper as AnimeGroupVM; AnimeGroupVM bcObj = BreadCrumbs[i] as AnimeGroupVM; if (wrapObj.AnimeGroupID == bcObj.AnimeGroupID) { pos = i; } } if (wrapper is AnimeSeriesVM && BreadCrumbs[i] is AnimeSeriesVM) { AnimeSeriesVM wrapObj = wrapper as AnimeSeriesVM; AnimeSeriesVM bcObj = BreadCrumbs[i] as AnimeSeriesVM; if (wrapObj.AnimeSeriesID == bcObj.AnimeSeriesID) { pos = i; } } if (wrapper is AnimeEpisodeTypeVM && BreadCrumbs[i] is AnimeEpisodeTypeVM) { AnimeEpisodeTypeVM wrapObj = wrapper as AnimeEpisodeTypeVM; AnimeEpisodeTypeVM bcObj = BreadCrumbs[i] as AnimeEpisodeTypeVM; if (wrapObj.EpisodeTypeDescription == bcObj.EpisodeTypeDescription) { pos = i; } } if (wrapper is AnimeEpisodeVM && BreadCrumbs[i] is AnimeEpisodeVM) { AnimeEpisodeVM wrapObj = wrapper as AnimeEpisodeVM; AnimeEpisodeVM bcObj = BreadCrumbs[i] as AnimeEpisodeVM; if (wrapObj.AnimeEpisodeID == bcObj.AnimeEpisodeID) { pos = i; } } } } else { pos = 0; } if (pos >= 0) { for (int i = BreadCrumbs.Count - 1; i >= 0; i--) { if (i >= pos) { BreadCrumbs.RemoveAt(i); } } } BreadCrumbs.Add(wrapper); if (wrapper is GroupFilterVM) { if (AllGroupsDictionary.Count == 0) { RefreshGroupsSeriesData(); } // apply sorting // get default sorting from the group filter } // means we are at the top level if (wrapper == null) { CurrentWrapperList.Clear(); foreach (GroupFilterVM grpFilter in AllGroupFiltersDictionary.Values.Where(a => !a.GroupFilterParentId.HasValue).OrderBy(a => a.FilterName)) { CurrentWrapperList.Add(grpFilter); } } else { CurrentWrapperList.Clear(); foreach (MainListWrapper wp in wrapper.GetDirectChildren()) { CurrentWrapperList.Add(wp); } } SetGroupFilterSortingOnMainList(); ViewGroups.Refresh(); //new FilterMainListBox(ViewGroups, SearchTextBox, CurrentGroupFilter); }); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }