Exemple #1
0
        void btnLoadFiles_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!VM_ShokoServer.Instance.ServerOnline)
                {
                    return;
                }

                ViewFiles.Refresh();

                Cursor = Cursors.Wait;
                EnableDisableControls(false);
                List <VM_VideoLocal> rawVids = new List <VM_VideoLocal>();

                if (LoadTypeIsRandom)
                {
                    rawVids = VM_ShokoServer.Instance.ShokoServices.RandomFileRenamePreview(udRandomFiles.Value.Value, VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList <VM_VideoLocal>();

                    /*List<int> testIDs = new List<int>();
                     *
                     *                  testIDs.Add(6041); // Gekijouban Bleach: Fade to Black Kimi no Na o Yobu
                     *                  testIDs.Add(6784); // Fate/Stay Night: Unlimited Blade Works
                     *                  testIDs.Add(5975); // Toaru Majutsu no Index
                     *                  testIDs.Add(7599); // Toaru Majutsu no Index II
                     *                  testIDs.Add(8694); // Gekijouban Toaru Majutsu no Index (movie)
                     *                  testIDs.Add(6071); // Quiz Magic Academy: The Original Animation
                     *                  testIDs.Add(4145); // Amaenaide yo!! Katsu!!
                     *                  testIDs.Add(2369); // Bleach
                     *                  testIDs.Add(69); // One Piece
                     *                  foreach (int animeID in testIDs)
                     *                  {
                     *                          List<JMMServerBinary.Contract_VideoLocal> raws = VM_ShokoServer.Instance.clientBinaryHTTP.GetVideoLocalsForAnime(animeID,
                     *                                  VM_ShokoServer.Instance.CurrentUser.JMMUserID.Value);
                     *
                     *                          rawVids.AddRange(raws);
                     *                  }*/
                }

                if (LoadTypeIsAll)
                {
                    rawVids = VM_ShokoServer.Instance.ShokoServices.RandomFileRenamePreview(int.MaxValue, VM_ShokoServer.Instance.CurrentUser.JMMUserID).CastList <VM_VideoLocal>();
                }


                if (LoadTypeIsSeries)
                {
                    Window wdw = Window.GetWindow(this);
                    SelectGroupSeriesForm frm = new SelectGroupSeriesForm();
                    frm.Owner = wdw;
                    frm.Init();

                    bool?result = frm.ShowDialog();
                    if (result.HasValue && result.Value == true)
                    {
                        if (frm.SelectedObject.GetType() == typeof(VM_AnimeGroup_User))
                        {
                            VM_AnimeGroup_User grp = frm.SelectedObject as VM_AnimeGroup_User;
                            foreach (VM_AnimeSeries_User ser in grp.AllAnimeSeries)
                            {
                                rawVids.AddRange(VM_ShokoServer.Instance.ShokoServices.GetVideoLocalsForAnime(ser.AniDB_ID,
                                                                                                              VM_ShokoServer.Instance.CurrentUser.JMMUserID).Cast <VM_VideoLocal>());
                            }
                        }
                        if (frm.SelectedObject.GetType() == typeof(VM_AnimeSeries_User))
                        {
                            VM_AnimeSeries_User ser = frm.SelectedObject as VM_AnimeSeries_User;
                            rawVids.AddRange(VM_ShokoServer.Instance.ShokoServices.GetVideoLocalsForAnime(ser.AniDB_ID,
                                                                                                          VM_ShokoServer.Instance.CurrentUser.JMMUserID).Cast <VM_VideoLocal>());
                        }
                    }
                }

                foreach (VM_VideoLocal vid in rawVids)
                {
                    VM_VideoLocal_Renamed ren = new VM_VideoLocal_Renamed();
                    ren.VideoLocalID = vid.VideoLocalID;
                    ren.VideoLocal   = vid;
                    ren.Success      = false;
                    FileResults.Add(ren);
                }

                FileCount = FileResults.Count;

                Cursor = Cursors.Arrow;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                Cursor = Cursors.Arrow;
                EnableDisableControls(true);
            }
        }
        void btnLoadFiles_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!VM_ShokoServer.Instance.ServerOnline)
                {
                    return;
                }

                ViewFiles.Refresh();

                Cursor = Cursors.Wait;
                EnableDisableControls(false);
                List <VM_VideoLocal> rawVids = new List <VM_VideoLocal>();

                if (LoadTypeIsRandom)
                {
                    rawVids = VM_ShokoServer.Instance.ShokoServices
                              .RandomFileRenamePreview(udRandomFiles.Value.Value,
                                                       VM_ShokoServer.Instance.CurrentUser.JMMUserID)
                              .CastList <VM_VideoLocal>();
                }
                else if (LoadTypeIsAll)
                {
                    rawVids = VM_ShokoServer.Instance.ShokoServices
                              .RandomFileRenamePreview(int.MaxValue, VM_ShokoServer.Instance.CurrentUser.JMMUserID)
                              .CastList <VM_VideoLocal>();
                }
                else if (LoadTypeIsSeries)
                {
                    Window wdw = Window.GetWindow(this);
                    SelectGroupSeriesForm frm = new SelectGroupSeriesForm();
                    frm.Owner = wdw;
                    frm.Init();

                    bool?result = frm.ShowDialog();
                    if (result.HasValue && result.Value == true)
                    {
                        if (frm.SelectedObject.GetType() == typeof(VM_AnimeGroup_User))
                        {
                            VM_AnimeGroup_User grp = frm.SelectedObject as VM_AnimeGroup_User;
                            foreach (VM_AnimeSeries_User ser in grp.AllAnimeSeries)
                            {
                                rawVids.AddRange(VM_ShokoServer.Instance.ShokoServices
                                                 .GetVideoLocalsForAnime(ser.AniDB_ID, VM_ShokoServer.Instance.CurrentUser.JMMUserID)
                                                 .Cast <VM_VideoLocal>());
                            }
                        }
                        if (frm.SelectedObject.GetType() == typeof(VM_AnimeSeries_User))
                        {
                            VM_AnimeSeries_User ser = frm.SelectedObject as VM_AnimeSeries_User;
                            rawVids.AddRange(VM_ShokoServer.Instance.ShokoServices
                                             .GetVideoLocalsForAnime(ser.AniDB_ID, VM_ShokoServer.Instance.CurrentUser.JMMUserID)
                                             .Cast <VM_VideoLocal>());
                        }
                    }
                }
                else if (LoadTypeIsLast)
                {
                    int number = udRandomFiles.Value.Value;
                    rawVids = VM_ShokoServer.Instance.ShokoServices
                              .SearchForFiles((int)FileSearchCriteria.LastOneHundred, number.ToString(),
                                              VM_ShokoServer.Instance.CurrentUser.JMMUserID)
                              .OrderByDescending(a => a.DateTimeCreated)
                              .CastList <VM_VideoLocal>();
                }

                foreach (VM_VideoLocal vid in rawVids)
                {
                    VM_VideoLocal_Renamed ren = new VM_VideoLocal_Renamed();
                    ren.VideoLocalID = vid.VideoLocalID;
                    ren.VideoLocal   = vid;
                    ren.Success      = false;
                    FileResults.Add(ren);
                }

                FileCount = FileResults.Count;

                Cursor = Cursors.Arrow;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                Cursor = Cursors.Arrow;
                EnableDisableControls(true);
            }
        }