Exemplo n.º 1
0
        private bool ConfirmDeletion()
        {
            string message;
            var    notYetDeleted = AllSeries.Where(series => !series.ScheduledDeleteTime.HasValue);

            if (SelectedSeries.Any(selected => selected.ScheduledDeleteTime.HasValue))
            {
                message = SR.MessageSelectSeriesNotAlreadyScheduledForDeletion;
                Context.DesktopWindow.ShowMessageBox(message, MessageBoxActions.Ok);
                return(false);
            }

            if (notYetDeleted.All(notDeleted => SelectedSeries.Any(selected => selected.SeriesInstanceUid == notDeleted.SeriesInstanceUid)))
            {
                message = SR.MessageConfirmDeleteEntireStudy;
            }
            else
            {
                message = Context.SelectedSeries.Count == 1
                                     ? SR.MessageConfirmDeleteSeries
                                     : String.Format(SR.MessageFormatConfirmDeleteSeries, Context.SelectedSeries.Count);

                message = String.Format("{0} {1}", SR.MessagePartialStudyWarning, message);
            }

            return(DialogBoxAction.Yes == Context.DesktopWindow.ShowMessageBox(message, MessageBoxActions.YesNo));
        }
        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)
        {
            lock (runningTasks)
            {
                if (runningTasks.Count > 0)
                {
                    foreach (CancellationTokenSource runningTask in runningTasks)
                    {
                        runningTask.Cancel();
                    }
                }
            }
            CancellationTokenSource tokenSource = new CancellationTokenSource();
            var token = tokenSource.Token;

            lock (runningTasks)
            {
                runningTasks.Add(tokenSource);
            }

            Progress <List <VM_AnimeSeries_User> > progress = new Progress <List <VM_AnimeSeries_User> >(ReportProgress);

            AllSeries.Clear();
            await Task.Run(() =>
            {
                SearchAnime(token, argument, progress);
                lock (runningTasks)
                {
                    runningTasks.Remove(tokenSource);
                }
            }, token);
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        public int GetInnerHits()
        {
            if (string.IsNullOrWhiteSpace(AllSeries))
            {
                return(0);
            }

            return(AllSeries.Count(c => c == '*'));
        }
Exemplo n.º 6
0
        public void ClearData()
        {
            AllGroups.Clear();
            AllSeries.Clear();
            AllGroupsDictionary.Clear();
            AllSeriesDictionary.Clear();
            AllAnimeDictionary.Clear();

            ViewSeriesSearch.Refresh();
        }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
 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);
     }
 }
Exemplo n.º 11
0
        public int GetInnerHits(int countingShots)
        {
            if (string.IsNullOrWhiteSpace(AllSeries))
            {
                return(0);
            }

            string Result = AllSeries;

            int len = countingShots;

            if (AllSeries.Length < countingShots)
            {
                len = AllSeries.Length;
            }

            Result = AllSeries.Substring(0, len);


            return(Result.Count(c => c == '*'));
        }
Exemplo n.º 12
0
 //use cases:
 //1. load what is selected if files grid
 //2. initial fetch to fill AllSeries list
 //3. load series that was just added
 public void RefreshSeries(bool all = false)
 {
     try
     {
         VM_MainListHelper.Instance.AllAnimeDetailedDictionary = null;
         AllSeries.Clear();
         if (!VM_ShokoServer.Instance.ServerOnline)
         {
             return;
         }
         if (AnyVideosSelected)
         {
             SearchAnime(dgVideos.SelectedItems);
         }
         else if (all)
         {
             SearchAnime(null);
         }
     }
     catch (Exception ex)
     {
         Utils.ShowErrorMessage(ex);
     }
 }
Exemplo n.º 13
0
        private void LoadTestData()
        {
            System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action) delegate()
            {
                AllGroups.Clear();
                AllSeries.Clear();

                AnimeGroupVM grpNew = new AnimeGroupVM();
                grpNew.GroupName    = grpNew.SortName = "Bleach";
                AllGroups.Add(grpNew);

                grpNew           = new AnimeGroupVM();
                grpNew.GroupName = grpNew.SortName = "Naruto";
                AllGroups.Add(grpNew);

                grpNew           = new AnimeGroupVM();
                grpNew.GroupName = grpNew.SortName = "High School of the Dead";
                AllGroups.Add(grpNew);

                grpNew           = new AnimeGroupVM();
                grpNew.GroupName = grpNew.SortName = "Gundam";
                AllGroups.Add(grpNew);
            });
        }