public void ReportProgress(List <VM_AnimeSeries_User> series) { if (series == null || series.Count <= 0) { txtSeriesSearch.Text = string.Intern("Loading..."); txtSeriesSearch.IsEnabled = false; txtSeriesSearch.IsReadOnly = true; txtSeriesSearch.Focusable = false; lbSeries.IsEnabled = false; AllSeries.Clear(); } else { AllSeries.Clear(); series.ForEach(a => AllSeries.Add(a)); if (AllSeries.Count >= 1) { lbSeries.SelectedIndex = 0; } txtSeriesSearch.IsReadOnly = false; txtSeriesSearch.Focusable = true; txtSeriesSearch.Text = string.Empty; txtSeriesSearch.IsEnabled = true; lbSeries.IsEnabled = true; } }
public async void SearchAnime(object argument) { try { runningTask?.Cancel(); } catch {} CancellationTokenSource tokenSource = new CancellationTokenSource(); runningTask = tokenSource; //use listbox with dummy instead VM_AnimeSeries_User dummy = new VM_AnimeSeries_User(); dummy.SeriesNameOverride = "Loading..."; AllSeries.Add(dummy); btnAddSeries.IsEnabled = false; cboEpisodes.IsEnabled = false; cboMultiType.IsEnabled = false; txtSeriesSearch.IsEnabled = false; lbSeries.IsEnabled = false; List <VM_AnimeSeries_User> series = null; try { series = await Task.Run(() => SearchAnime(tokenSource, argument)); } catch (TaskCanceledException) { // ignored } bool cancelled = runningTask.IsCancellationRequested; runningTask = null; if (cancelled) { return; } // update if (series != null) { AllSeries.Clear(); series.ForEach(a => AllSeries.Add(a)); if (AllSeries.Count >= 1) { lbSeries.SelectedIndex = 0; } } txtSeriesSearch.IsEnabled = true; btnAddSeries.IsEnabled = true; cboEpisodes.IsEnabled = true; cboMultiType.IsEnabled = true; lbSeries.IsEnabled = true; }
public void RefreshGroupsSeriesData() { //LoadTestData(); //return; try { // set this to null so that it will be refreshed the next time it is needed AllAnimeDetailedDictionary = null; List <JMMServerBinary.Contract_AnimeGroup> grpsRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroups(JMMServerVM.Instance.CurrentUser.JMMUserID.Value); List <JMMServerBinary.Contract_AnimeSeries> seriesRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllSeries(JMMServerVM.Instance.CurrentUser.JMMUserID.Value); if (grpsRaw.Count == 0 || seriesRaw.Count == 0) { return; } System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate() { AllGroups.Clear(); AllSeries.Clear(); AllGroupsDictionary.Clear(); AllSeriesDictionary.Clear(); AllAnimeDictionary.Clear(); // must series before groups the binding is based on the groups, and will refresh when that is changed foreach (JMMServerBinary.Contract_AnimeSeries ser in seriesRaw) { AnimeSeriesVM serNew = new AnimeSeriesVM(ser); AllSeries.Add(serNew); AllSeriesDictionary[serNew.AnimeSeriesID.Value] = serNew; } ViewSeriesSearch.Refresh(); foreach (JMMServerBinary.Contract_AnimeGroup grp in grpsRaw) { AnimeGroupVM grpNew = new AnimeGroupVM(grp); AllGroups.Add(grpNew); AllGroupsDictionary[grpNew.AnimeGroupID.Value] = grpNew; } }); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void InitGroupsSeriesData() { //LoadTestData(); //return; try { // set this to null so that it will be refreshed the next time it is needed AllAnimeDetailedDictionary = null; List <JMMServerBinary.Contract_AnimeGroup> grpsRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroups(JMMServerVM.Instance.CurrentUser.JMMUserID.Value); List <JMMServerBinary.Contract_AnimeSeries> seriesRaw = JMMServerVM.Instance.clientBinaryHTTP.GetAllSeries(JMMServerVM.Instance.CurrentUser.JMMUserID.Value); if (grpsRaw.Count == 0 || seriesRaw.Count == 0) { return; } AllGroups.Clear(); AllSeries.Clear(); AllGroupsDictionary.Clear(); AllSeriesDictionary.Clear(); AllAnimeDictionary.Clear(); // must series before groups the binding is based on the groups, and will refresh when that is changed foreach (JMMServerBinary.Contract_AnimeSeries ser in seriesRaw) { AnimeSeriesVM serNew = new AnimeSeriesVM(ser); AllSeries.Add(serNew); AllSeriesDictionary[serNew.AnimeSeriesID.Value] = serNew; } foreach (JMMServerBinary.Contract_AnimeGroup grp in grpsRaw) { AnimeGroupVM grpNew = new AnimeGroupVM(grp); AllGroups.Add(grpNew); AllGroupsDictionary[grpNew.AnimeGroupID.Value] = grpNew; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void RefreshSeries() { try { MainListHelperVM.Instance.AllAnimeDetailedDictionary = null; AllSeries.Clear(); if (!JMMServerVM.Instance.ServerOnline) { return; } foreach (JMMServerBinary.Contract_AnimeSeries ser in JMMServerVM.Instance.clientBinaryHTTP.GetAllSeries(JMMServerVM.Instance.CurrentUser.JMMUserID.Value)) { AllSeries.Add(new AnimeSeriesVM(ser)); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
public void RefreshSeries() { try { VM_MainListHelper.Instance.AllAnimeDetailedDictionary = null; AllSeries.Clear(); if (!VM_ShokoServer.Instance.ServerOnline) { return; } foreach (VM_AnimeSeries_User ser in VM_ShokoServer.Instance.ShokoServices.GetAllSeries(VM_ShokoServer.Instance.CurrentUser.JMMUserID).Cast <VM_AnimeSeries_User>()) { AllSeries.Add(ser); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }