private void DgVideos_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                ccDetail.Content         = null;
                ccDetailMultiple.Content = null;

                AnyVideosSelected      = dgVideos.SelectedItems.Count > 0;
                OneVideoSelected       = dgVideos.SelectedItems.Count == 1;
                MultipleVideosSelected = dgVideos.SelectedItems.Count > 1;

                MultipleTypeRange  = cboMultiType.SelectedIndex == 0;
                MultipleTypeSingle = cboMultiType.SelectedIndex == 1;

                Visibility visible = Visibility.Visible;

                // if only one video selected
                if (OneVideoSelected)
                {
                    VM_VideoLocal vid = dgVideos.SelectedItem as VM_VideoLocal;
                    ccDetail.Content = vid;
                    if (vid != null && !vid.IsHashed())
                    {
                        visible = Visibility.Hidden;
                    }
                }

                // if only one video selected
                if (MultipleVideosSelected)
                {
                    MultipleVideos mv = new MultipleVideos();
                    mv.SelectedCount = dgVideos.SelectedItems.Count;
                    mv.VideoLocalIDs = new List <int>();
                    mv.VideoLocals   = new List <VM_VideoLocal>();

                    foreach (object obj in dgVideos.SelectedItems)
                    {
                        VM_VideoLocal vid = obj as VM_VideoLocal;
                        mv.VideoLocalIDs.Add(vid.VideoLocalID);
                        mv.VideoLocals.Add(vid);
                    }

                    ccDetailMultiple.Content = mv;
                    if (!mv.AllHaveHashes)
                    {
                        visible = Visibility.Hidden;
                    }
                }
                SetConfirmDetails();
                Confirm1.Visibility = Confirm2.Visibility = visible;
                if (string.IsNullOrEmpty(txtSeriesSearch.Text))
                {
                    RefreshSeries();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Ejemplo n.º 2
0
        private void CommandBinding_IgnoreFile(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                Window parentWindow = Window.GetWindow(this);

                object obj = e.Parameter;
                if (obj == null)
                {
                    return;
                }

                if (obj.GetType() == typeof(VM_VideoLocal))
                {
                    VM_VideoLocal vid = obj as VM_VideoLocal;
                    EnableDisableControls(false);

                    string result = VM_ShokoServer.Instance.ShokoServices.SetIgnoreStatusOnFile(vid.VideoLocalID, true);
                    if (result.Length > 0)
                    {
                        MessageBox.Show(result, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        RefreshUnrecognisedFiles();
                    }
                }
                if (obj.GetType() == typeof(MultipleVideos))
                {
                    MultipleVideos mv = obj as MultipleVideos;
                    foreach (int id in mv.VideoLocalIDs)
                    {
                        string result = VM_ShokoServer.Instance.ShokoServices.SetIgnoreStatusOnFile(id, true);
                        if (result.Length > 0)
                        {
                            MessageBox.Show(result, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                    }
                    RefreshUnrecognisedFiles();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }

            EnableDisableControls(true);
        }
Ejemplo n.º 3
0
        private void CommandBinding_RehashFile(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                Window parentWindow = Window.GetWindow(this);

                object obj = e.Parameter;
                if (obj == null)
                {
                    return;
                }

                if (obj.GetType() == typeof(VM_VideoLocal))
                {
                    VM_VideoLocal vid = obj as VM_VideoLocal;
                    if (vid.IsLocalFile())
                    {
                        EnableDisableControls(false);

                        VM_ShokoServer.Instance.ShokoServices.RehashFile(vid.VideoLocalID);
                    }
                }
                if (obj.GetType() == typeof(MultipleVideos))
                {
                    MultipleVideos mv = obj as MultipleVideos;
                    foreach (VM_VideoLocal v in mv.VideoLocals)
                    {
                        if (v.IsLocalFile())
                        {
                            VM_ShokoServer.Instance.ShokoServices.RehashFile(v.VideoLocalID);
                        }
                    }
                }

                MessageBox.Show(Shoko.Commons.Properties.Resources.MSG_INFO_AddedQueueCmds, Shoko.Commons.Properties.Resources.Done, MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }

            EnableDisableControls(true);
        }
Ejemplo n.º 4
0
        void lbVideos_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                ccDetail.Content         = null;
                ccDetailMultiple.Content = null;

                OneVideoSelected       = lbVideos.SelectedItems.Count == 1;
                MultipleVideosSelected = lbVideos.SelectedItems.Count > 1;

                // if only one video selected
                if (OneVideoSelected)
                {
                    VM_VideoLocal vid = lbVideos.SelectedItem as VM_VideoLocal;
                    ccDetail.Content = vid;
                }

                // if only one video selected
                if (MultipleVideosSelected)
                {
                    MultipleVideos mv = new MultipleVideos();
                    mv.SelectedCount = lbVideos.SelectedItems.Count;
                    mv.VideoLocalIDs = new List <int>();

                    foreach (object obj in lbVideos.SelectedItems)
                    {
                        VM_VideoLocal vid = obj as VM_VideoLocal;
                        mv.VideoLocalIDs.Add(vid.VideoLocalID);
                    }

                    ccDetailMultiple.Content = mv;
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Ejemplo n.º 5
0
        private void CommandBinding_DeleteFile(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                Window parentWindow = Window.GetWindow(this);

                object obj = e.Parameter;
                if (obj == null)
                {
                    return;
                }

                if (obj.GetType() == typeof(VM_VideoLocal))
                {
                    VM_VideoLocal vid = obj as VM_VideoLocal;

                    AskDeleteFile dlg = new AskDeleteFile(string.Format(Shoko.Commons.Properties.Resources.DeleteFile_Title, vid.FileName),
                                                          string.Format(Shoko.Commons.Properties.Resources.Unrecognized_ConfirmDelete, vid.FileName) + "\r\n\r\n" + Shoko.Commons.Properties.Resources.DeleteFile_Confirm,
                                                          vid.Places);
                    dlg.Owner = Window.GetWindow(this);
                    bool?res = dlg.ShowDialog();
                    if (res.HasValue && res.Value)
                    {
                        string tresult = string.Empty;
                        Cursor = Cursors.Wait;
                        foreach (CL_VideoLocal_Place lv in dlg.Selected)
                        {
                            string result =
                                VM_ShokoServer.Instance.ShokoServices.DeleteVideoLocalPlaceAndFile(
                                    lv.VideoLocal_Place_ID);
                            if (result.Length > 0)
                            {
                                tresult += result + "\r\n";
                            }
                        }
                        if (!string.IsNullOrEmpty(tresult))
                        {
                            MessageBox.Show(tresult, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK,
                                            MessageBoxImage.Error);
                        }
                        RefreshUnrecognisedFiles();
                    }
                }
                if (obj.GetType() == typeof(MultipleVideos))
                {
                    MultipleVideos mv  = obj as MultipleVideos;
                    AskDeleteFile  dlg = new AskDeleteFile(Shoko.Commons.Properties.Resources.DeleteFile_Multiple,
                                                           Shoko.Commons.Properties.Resources.Unrecognized_DeleteSelected + "\r\n\r\n" + Shoko.Commons.Properties.Resources.DeleteFile_Confirm,
                                                           mv.VideoLocals.SelectMany(a => a.Places).ToList());
                    dlg.Owner = Window.GetWindow(this);
                    bool?res = dlg.ShowDialog();
                    if (res.HasValue && res.Value)
                    {
                        string tresult = string.Empty;
                        Cursor = Cursors.Wait;
                        foreach (CL_VideoLocal_Place lv in dlg.Selected)
                        {
                            string result = VM_ShokoServer.Instance.ShokoServices.DeleteVideoLocalPlaceAndFile(lv.VideoLocal_Place_ID);
                            if (result.Length > 0)
                            {
                                tresult += result + "\r\n";
                            }
                        }
                        if (!string.IsNullOrEmpty(tresult))
                        {
                            MessageBox.Show(tresult, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        RefreshUnrecognisedFiles();
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
                RefreshUnrecognisedFiles();
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }
        }
Ejemplo n.º 6
0
        void lbVideos_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // get detailed video, episode and series info
            if (lbVideos.SelectedItems.Count == 0)
            {
                ccDetail.Content       = null;
                ccSeriesDetail.Content = null;
                OneVideoSelected       = false;
                MultipleVideosSelected = false;
                return;
            }

            if (lbVideos.SelectedItems.Count == 1)
            {
                VM_VideoLocal vid = lbVideos.SelectedItem as VM_VideoLocal;
                OneVideoSelected       = true;
                MultipleVideosSelected = false;
                displayingVidID        = vid.VideoLocalID;
                EnableDisableControls(false);

                try
                {
                    Cursor = Cursors.Wait;

                    ccDetail.Content = vid;

                    // get the episode(s)
                    VM_AnimeEpisode_User ep = (VM_AnimeEpisode_User)VM_ShokoServer.Instance.ShokoServices
                                              .GetEpisodesForFile(vid.VideoLocalID, VM_ShokoServer.Instance.CurrentUser.JMMUserID)
                                              .FirstOrDefault();

                    // whether it's null or not
                    ccSeriesDetail.Content = ep;

                    Cursor = Cursors.Arrow;
                }
                catch (Exception ex)
                {
                    Utils.ShowErrorMessage(ex);
                }
                finally
                {
                    Cursor = Cursors.Arrow;
                    EnableDisableControls(true);
                }
            }
            else
            {
                try
                {
                    Cursor = Cursors.Wait;
                    var vids = lbVideos.SelectedItems.Cast <VM_VideoLocal>().ToList();
                    OneVideoSelected       = false;
                    MultipleVideosSelected = true;
                    MultipleVideos mv = new MultipleVideos();
                    mv.SelectedCount = vids.Count;
                    mv.VideoLocalIDs = new List <int>();
                    mv.VideoLocals   = new List <VM_VideoLocal>();

                    var eps = new List <VM_AnimeEpisode_User>();

                    foreach (var vid in vids)
                    {
                        mv.VideoLocalIDs.Add(vid.VideoLocalID);
                        mv.VideoLocals.Add(vid);
                        // get the episode(s)
                        VM_AnimeEpisode_User ep = (VM_AnimeEpisode_User)VM_ShokoServer.Instance.ShokoServices
                                                  .GetEpisodesForFile(vid.VideoLocalID, VM_ShokoServer.Instance.CurrentUser.JMMUserID)
                                                  .FirstOrDefault();
                        if (ep != null)
                        {
                            eps.Add(ep);
                        }
                    }

                    ccDetailMultiple.Content = mv;
                    displayingVidID          = vids.First().VideoLocalID;

                    if (eps.GroupBy(a => a?.AnimeSeriesID ?? 0).Distinct().Count(a => a.Key != 0) == 1)
                    {
                        ccSeriesDetail.Content = eps.FirstOrDefault();
                    }
                    else
                    {
                        ccSeriesDetail.Content = null;
                    }

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