void btnPlayNextEp_Click(object sender, RoutedEventArgs e)
        {
            if (UnwatchedEpisodes.Count == 0)
            {
                return;
            }

            try
            {
                AnimeEpisodeVM ep = UnwatchedEpisodes[0];
                if (ep.IsWatched == 1)
                {
                    if (UnwatchedEpisodes.Count == 1)
                    {
                        ep = UnwatchedEpisodes[1];
                    }
                    else
                    {
                        return;
                    }
                }

                if (ep.FilesForEpisode.Count == 1)
                {
                    MainWindow.videoHandler.PlayVideo(ep.FilesForEpisode[0]);
                }
                else if (ep.FilesForEpisode.Count > 1)
                {
                    if (AppSettings.AutoFileSingleEpisode)
                    {
                        VideoDetailedVM vid = MainWindow.videoHandler.GetAutoFileForEpisode(ep);
                        if (vid != null)
                        {
                            MainWindow.videoHandler.PlayVideo(vid);
                        }
                    }
                    else
                    {
                        MainWindow mainwdw = (MainWindow)Window.GetWindow(this);

                        PlayVideosForEpisodeForm frm = new PlayVideosForEpisodeForm();
                        frm.Owner = mainwdw;
                        frm.Init(ep);
                        bool?result = frm.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Пример #2
0
        private void CommandBinding_PlayEpisode(object sender, ExecutedRoutedEventArgs e)
        {
            Window parentWindow = Window.GetWindow(this);

            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                if (obj.GetType() == typeof(AnimeEpisodeVM))
                {
                    AnimeEpisodeVM ep = obj as AnimeEpisodeVM;

                    if (ep.FilesForEpisode.Count == 1)
                    {
                        MainWindow.videoHandler.PlayVideo(ep.FilesForEpisode[0]);
                    }
                    else if (ep.FilesForEpisode.Count > 1)
                    {
                        if (AppSettings.AutoFileSingleEpisode)
                        {
                            VideoDetailedVM vid = MainWindow.videoHandler.GetAutoFileForEpisode(ep);
                            if (vid != null)
                            {
                                MainWindow.videoHandler.PlayVideo(vid);
                            }
                        }
                        else
                        {
                            PlayVideosForEpisodeForm frm = new PlayVideosForEpisodeForm();
                            frm.Owner = parentWindow;
                            frm.Init(ep);
                            bool?result = frm.ShowDialog();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Пример #3
0
        private void CommandBinding_PlayEpisode(object sender, ExecutedRoutedEventArgs e)
        {
            Window parentWindow = Window.GetWindow(this);

            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                if (obj.GetType() == typeof(VM_PlaylistItem))
                {
                    VM_PlaylistItem pli = obj as VM_PlaylistItem;

                    VM_AnimeEpisode_User ep = null;

                    if (pli.ItemType == Models.Enums.PlaylistItemType.Episode)
                    {
                        ep = pli.PlaylistItem as VM_AnimeEpisode_User;
                    }
                    if (pli.ItemType == Models.Enums.PlaylistItemType.AnimeSeries)
                    {
                        VM_AnimeSeries_User ser = pli.PlaylistItem as VM_AnimeSeries_User;
                        if (ser == null)
                        {
                            return;
                        }

                        ep = (VM_AnimeEpisode_User)VM_ShokoServer.Instance.ShokoServices.GetNextUnwatchedEpisode(ser.AnimeSeriesID,
                                                                                                                 VM_ShokoServer.Instance.CurrentUser.JMMUserID);
                    }

                    if (ep == null)
                    {
                        return;
                    }
                    ep.SetTvDBInfo();
                    if (ep.FilesForEpisode.Count == 1)
                    {
                        bool force = true;
                        if (MainWindow.videoHandler.DefaultPlayer.Player.ToString() !=
                            Enum.GetName(typeof(VideoPlayer), VideoPlayer.WindowsDefault))
                        {
                            if (ep.FilesForEpisode[0].VideoLocal_ResumePosition > 0)
                            {
                                AskResumeVideo ask = new AskResumeVideo(ep.FilesForEpisode[0].VideoLocal_ResumePosition);
                                ask.Owner = Window.GetWindow(this);
                                if (ask.ShowDialog() == true)
                                {
                                    force = false;
                                }
                            }
                        }
                        MainWindow.videoHandler.PlayVideo(ep.FilesForEpisode[0], force);
                    }
                    else if (ep.FilesForEpisode.Count > 1)
                    {
                        if (AppSettings.AutoFileSingleEpisode)
                        {
                            VM_VideoDetailed vid = MainWindow.videoHandler.GetAutoFileForEpisode(ep);
                            if (vid != null)
                            {
                                bool force = true;
                                if (MainWindow.videoHandler.DefaultPlayer.Player.ToString() !=
                                    Enum.GetName(typeof(VideoPlayer), VideoPlayer.WindowsDefault))
                                {
                                    if (vid.VideoLocal_ResumePosition > 0)
                                    {
                                        AskResumeVideo ask = new AskResumeVideo(vid.VideoLocal_ResumePosition);
                                        ask.Owner = Window.GetWindow(this);
                                        if (ask.ShowDialog() == true)
                                        {
                                            force = false;
                                        }
                                    }
                                }
                                MainWindow.videoHandler.PlayVideo(vid, force);
                            }
                        }
                        else
                        {
                            PlayVideosForEpisodeForm frm = new PlayVideosForEpisodeForm();
                            frm.Owner = parentWindow;
                            frm.Init(ep);
                            frm.ShowDialog();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
        private void CommandBinding_PlayEpisode(object sender, ExecutedRoutedEventArgs e)
        {
            Window parentWindow = Window.GetWindow(this);

            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                if (obj.GetType() == typeof(VM_AnimeEpisode_User))
                {
                    VM_AnimeEpisode_User ep = obj as VM_AnimeEpisode_User;


                    if (ep.FilesForEpisode.Count == 1)
                    {
                        bool force = true;
                        if (MainWindow.videoHandler.DefaultPlayer.Player.ToString() !=
                            Enum.GetName(typeof(VideoPlayer), VideoPlayer.WindowsDefault))
                        {
                            if (ep.FilesForEpisode[0].VideoLocal_ResumePosition > 0)
                            {
                                AskResumeVideo ask = new AskResumeVideo(ep.FilesForEpisode[0].VideoLocal_ResumePosition);
                                ask.Owner = Window.GetWindow(this);
                                if (ask.ShowDialog() == true)
                                {
                                    force = false;
                                }
                            }
                        }
                        MainWindow.videoHandler.PlayVideo(ep.FilesForEpisode[0], force);
                    }
                    else if (ep.FilesForEpisode.Count > 1)
                    {
                        if (AppSettings.AutoFileSingleEpisode)
                        {
                            VM_VideoDetailed vid = MainWindow.videoHandler.GetAutoFileForEpisode(ep);
                            if (vid != null)
                            {
                                bool force = true;
                                if (MainWindow.videoHandler.DefaultPlayer.Player.ToString() !=
                                    Enum.GetName(typeof(VideoPlayer), VideoPlayer.WindowsDefault))
                                {
                                    if (vid.VideoLocal_ResumePosition > 0)
                                    {
                                        AskResumeVideo ask = new AskResumeVideo(vid.VideoLocal_ResumePosition);
                                        ask.Owner = Window.GetWindow(this);
                                        if (ask.ShowDialog() == true)
                                        {
                                            force = false;
                                        }
                                    }
                                }
                                MainWindow.videoHandler.PlayVideo(vid, force);
                            }
                        }
                        else
                        {
                            PlayVideosForEpisodeForm frm = new PlayVideosForEpisodeForm();
                            frm.Owner = parentWindow;
                            frm.Init(ep);
                            bool?result = frm.ShowDialog();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Пример #5
0
        private void CommandBinding_PlayEpisode(object sender, ExecutedRoutedEventArgs e)
        {
            Window parentWindow = Window.GetWindow(this);

            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                if (obj.GetType() == typeof(PlaylistItemVM))
                {
                    PlaylistItemVM pli = obj as PlaylistItemVM;

                    AnimeEpisodeVM ep = null;

                    if (pli.ItemType == JMMClient.PlaylistItemType.Episode)
                    {
                        ep = pli.PlaylistItem as AnimeEpisodeVM;
                    }
                    if (pli.ItemType == JMMClient.PlaylistItemType.AnimeSeries)
                    {
                        AnimeSeriesVM ser = pli.PlaylistItem as AnimeSeriesVM;
                        if (ser == null)
                        {
                            return;
                        }

                        JMMServerBinary.Contract_AnimeEpisode contract = JMMServerVM.Instance.clientBinaryHTTP.GetNextUnwatchedEpisode(ser.AnimeSeriesID.Value,
                                                                                                                                       JMMServerVM.Instance.CurrentUser.JMMUserID.Value);
                        if (contract != null)
                        {
                            ep = new AnimeEpisodeVM(contract);
                        }
                    }

                    if (ep == null)
                    {
                        return;
                    }
                    ep.SetTvDBInfo();

                    if (ep.FilesForEpisode.Count == 1)
                    {
                        MainWindow.videoHandler.PlayVideo(ep.FilesForEpisode[0]);
                    }
                    else if (ep.FilesForEpisode.Count > 1)
                    {
                        if (AppSettings.AutoFileSingleEpisode)
                        {
                            VideoDetailedVM vid = MainWindow.videoHandler.GetAutoFileForEpisode(ep);
                            if (vid != null)
                            {
                                MainWindow.videoHandler.PlayVideo(vid);
                            }
                        }
                        else
                        {
                            PlayVideosForEpisodeForm frm = new PlayVideosForEpisodeForm();
                            frm.Owner = parentWindow;
                            frm.Init(ep);
                            frm.ShowDialog();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Пример #6
0
        void lbEpisodes_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                FrameworkElement ctrl = e.OriginalSource as FrameworkElement;

                if (ctrl == null || lbEpisodes.SelectedItem == null)
                {
                    return;
                }

                // The below while loop, etc. is used to make sure that the double click event is coming from an episode detail.
                // When the ListBox is responsible for rendering the scrollbar, it turns out that the scrollbar will also raise
                // double click events. So we'll see if the EpisodeDetail is an ancestor of the original source of the event
                bool srcWasListItem = false;

                while (ctrl != null)
                {
                    if (ctrl is EpisodeDetail)
                    {
                        srcWasListItem = true;
                        break;
                    }

                    ctrl = ctrl.Parent as FrameworkElement;
                }

                if (!srcWasListItem)
                {
                    return; // The source of the event wasn't an EpisodeDetail
                }
                VM_AnimeEpisode_User ep = lbEpisodes.SelectedItem as VM_AnimeEpisode_User;

                if (ep != null)
                {
                    ep.RefreshFilesForEpisode();


                    if (ep.FilesForEpisode.Count == 1)
                    {
                        bool force = true;
                        if (MainWindow.videoHandler.DefaultPlayer.Player.ToString() !=
                            Enum.GetName(typeof(VideoPlayer), VideoPlayer.WindowsDefault))
                        {
                            if (ep.FilesForEpisode[0].VideoLocal_ResumePosition > 0)
                            {
                                AskResumeVideo ask = new AskResumeVideo(ep.FilesForEpisode[0].VideoLocal_ResumePosition);
                                ask.Owner = Window.GetWindow(this);
                                if (ask.ShowDialog() == true)
                                {
                                    force = false;
                                }
                            }
                        }
                        MainWindow.videoHandler.PlayVideo(ep.FilesForEpisode[0], force);
                    }
                    else if (ep.FilesForEpisode.Count > 1)
                    {
                        Window parentWindow = Window.GetWindow(this);

                        if (AppSettings.AutoFileSingleEpisode)
                        {
                            VM_VideoDetailed vid = MainWindow.videoHandler.GetAutoFileForEpisode(ep);
                            if (vid != null)
                            {
                                bool force = true;
                                if (MainWindow.videoHandler.DefaultPlayer.Player.ToString() !=
                                    Enum.GetName(typeof(VideoPlayer), VideoPlayer.WindowsDefault))
                                {
                                    if (vid.VideoLocal_ResumePosition > 0)
                                    {
                                        AskResumeVideo ask = new AskResumeVideo(vid.VideoLocal_ResumePosition);
                                        ask.Owner = Window.GetWindow(this);
                                        if (ask.ShowDialog() == true)
                                        {
                                            force = false;
                                        }
                                    }
                                }
                                MainWindow.videoHandler.PlayVideo(vid, force);
                            }
                        }
                        else
                        {
                            PlayVideosForEpisodeForm frm = new PlayVideosForEpisodeForm();
                            frm.Owner = parentWindow;
                            frm.Init(ep);
                            frm.ShowDialog();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex.ToString());
            }
        }
        void btnPlayNextEp_Click(object sender, RoutedEventArgs e)
        {
            if (UnwatchedEpisodes.Count == 0)
            {
                return;
            }

            try
            {
                VM_AnimeEpisode_User ep = UnwatchedEpisodes[0];

                if (ep.IsWatched == 1)
                {
                    if (UnwatchedEpisodes.Count == 1)
                    {
                        ep = UnwatchedEpisodes[1];
                    }
                    else
                    {
                        return;
                    }
                }

                if (ep.FilesForEpisode.Count == 1)
                {
                    bool force = true;
                    if (MainWindow.videoHandler.DefaultPlayer.Player.ToString() !=
                        Enum.GetName(typeof(VideoPlayer), VideoPlayer.WindowsDefault))
                    {
                        if (MainWindow.videoHandler.DefaultPlayer.Player.ToString() !=
                            Enum.GetName(typeof(VideoPlayer), VideoPlayer.WindowsDefault))
                        {
                            if (ep.FilesForEpisode[0].VideoLocal_ResumePosition > 0)
                            {
                                AskResumeVideo ask = new AskResumeVideo(ep.FilesForEpisode[0].VideoLocal_ResumePosition);
                                ask.Owner = Window.GetWindow(this);
                                if (ask.ShowDialog() == true)
                                {
                                    force = false;
                                }
                            }
                        }
                    }
                    MainWindow.videoHandler.PlayVideo(ep.FilesForEpisode[0], force);
                }
                else if (ep.FilesForEpisode.Count > 1)
                {
                    if (AppSettings.AutoFileSingleEpisode)
                    {
                        VM_VideoDetailed vid = MainWindow.videoHandler.GetAutoFileForEpisode(ep);
                        if (vid != null)
                        {
                            bool force = true;
                            if (MainWindow.videoHandler.DefaultPlayer.Player.ToString() !=
                                Enum.GetName(typeof(VideoPlayer), VideoPlayer.WindowsDefault))
                            {
                                if (vid.VideoLocal_ResumePosition > 0)
                                {
                                    AskResumeVideo ask = new AskResumeVideo(vid.VideoLocal_ResumePosition);
                                    ask.Owner = Window.GetWindow(this);
                                    if (ask.ShowDialog() == true)
                                    {
                                        force = false;
                                    }
                                }
                            }
                            MainWindow.videoHandler.PlayVideo(vid, force);
                        }
                    }
                    else
                    {
                        MainWindow mainwdw = (MainWindow)Window.GetWindow(this);

                        PlayVideosForEpisodeForm frm = new PlayVideosForEpisodeForm();
                        frm.Owner = mainwdw;
                        frm.Init(ep);
                        bool?result = frm.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }