Exemplo n.º 1
0
        public PlaylistVM(JMMServerBinary.Contract_Playlist contract)
        {
            PlaylistObjects = new ObservableCollection <PlaylistItemVM>();

            Populate(contract);
            //PopulatePlaylistObjects();
        }
Exemplo n.º 2
0
        public void Populate(JMMServerBinary.Contract_Playlist contract)
        {
            this.PlaylistID       = contract.PlaylistID;
            this.PlaylistName     = contract.PlaylistName;
            this.PlaylistItems    = contract.PlaylistItems;
            this.DefaultPlayOrder = contract.DefaultPlayOrder;
            this.PlayWatched      = contract.PlayWatched;
            this.PlayUnwatched    = contract.PlayUnwatched;

            this.PlayWatchedBool   = PlayWatched == 1;
            this.PlayUnwatchedBool = PlayUnwatched == 1;
        }
Exemplo n.º 3
0
        public static PlaylistVM CreatePlaylist(Window owner)
        {
            try
            {
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(AppSettings.Culture);

                DialogText dlg = new DialogText();
                dlg.Init(Properties.Resources.Playlist_Name + " ", "");
                dlg.Owner = owner;
                bool?res = dlg.ShowDialog();
                if (res.HasValue && res.Value)
                {
                    if (string.IsNullOrEmpty(dlg.EnteredText))
                    {
                        Utils.ShowErrorMessage(Properties.Resources.Playlist_NameBlank);
                        return(null);
                    }

                    JMMServerBinary.Contract_Playlist pl = new JMMServerBinary.Contract_Playlist();
                    pl.DefaultPlayOrder = (int)PlaylistPlayOrder.Sequential;
                    pl.PlaylistItems    = "";
                    pl.PlaylistName     = dlg.EnteredText;
                    pl.PlayUnwatched    = 1;
                    pl.PlayWatched      = 0;
                    JMMServerBinary.Contract_Playlist_SaveResponse resp = JMMServerVM.Instance.clientBinaryHTTP.SavePlaylist(pl);

                    if (!string.IsNullOrEmpty(resp.ErrorMessage))
                    {
                        Utils.ShowErrorMessage(resp.ErrorMessage);
                        return(null);
                    }

                    // refresh data
                    PlaylistHelperVM.Instance.RefreshData();

                    PlaylistVM plRet = new PlaylistVM(resp.Playlist);
                    return(plRet);
                }

                return(null);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
                return(null);
            }
        }
Exemplo n.º 4
0
        public static PlaylistVM CreatePlaylist(Window owner)
        {
            try
            {
                DialogText dlg = new DialogText();
                dlg.Init("Enter playlist name: ", "");
                dlg.Owner = owner;
                bool?res = dlg.ShowDialog();
                if (res.HasValue && res.Value)
                {
                    if (string.IsNullOrEmpty(dlg.EnteredText))
                    {
                        Utils.ShowErrorMessage("Please enter a playlist name");
                        return(null);
                    }

                    JMMServerBinary.Contract_Playlist pl = new JMMServerBinary.Contract_Playlist();
                    pl.DefaultPlayOrder = (int)PlaylistPlayOrder.Sequential;
                    pl.PlaylistItems    = "";
                    pl.PlaylistName     = dlg.EnteredText;
                    pl.PlayUnwatched    = 1;
                    pl.PlayWatched      = 0;
                    JMMServerBinary.Contract_Playlist_SaveResponse resp = JMMServerVM.Instance.clientBinaryHTTP.SavePlaylist(pl);

                    if (!string.IsNullOrEmpty(resp.ErrorMessage))
                    {
                        Utils.ShowErrorMessage(resp.ErrorMessage);
                        return(null);
                    }

                    // refresh data
                    PlaylistHelperVM.Instance.RefreshData();

                    PlaylistVM plRet = new PlaylistVM(resp.Playlist);
                    return(plRet);
                }

                return(null);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
                return(null);
            }
        }
Exemplo n.º 5
0
        public void Save()
        {
            JMMServerBinary.Contract_Playlist pl = new JMMServerBinary.Contract_Playlist();
            pl.PlaylistID       = this.PlaylistID;
            pl.DefaultPlayOrder = this.DefaultPlayOrder;
            pl.PlaylistItems    = this.PlaylistItems;
            pl.PlaylistName     = this.PlaylistName;
            pl.PlayUnwatched    = this.PlayUnwatched;
            pl.PlayWatched      = this.PlayWatched;
            JMMServerBinary.Contract_Playlist_SaveResponse resp = JMMServerVM.Instance.clientBinaryHTTP.SavePlaylist(pl);

            if (!string.IsNullOrEmpty(resp.ErrorMessage))
            {
                Utils.ShowErrorMessage(resp.ErrorMessage);
                return;
            }

            this.PlayWatchedBool   = PlayWatched == 1;
            this.PlayUnwatchedBool = PlayUnwatched == 1;
        }
Exemplo n.º 6
0
        void playlistMenuItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                MenuItem item       = e.Source as MenuItem;
                MenuItem itemSender = sender as MenuItem;

                if (item == null || itemSender == null)
                {
                    return;
                }
                if (!item.Header.ToString().Equals(itemSender.Header.ToString()))
                {
                    return;
                }

                if (item != null && item.CommandParameter != null)
                {
                    PlaylistMenuCommand cmd = item.CommandParameter as PlaylistMenuCommand;
                    Debug.Write(Properties.Resources.EpisodeDetail_PlaylistMenu + cmd.ToString() + Environment.NewLine);

                    AnimeEpisodeVM ep = this.DataContext as AnimeEpisodeVM;
                    if (ep == null)
                    {
                        return;
                    }

                    // get the playlist
                    PlaylistVM pl = null;
                    if (cmd.PlaylistID < 0)
                    {
                        pl = PlaylistHelperVM.CreatePlaylist(Window.GetWindow(this));
                        if (pl == null)
                        {
                            return;
                        }
                    }
                    else
                    {
                        JMMServerBinary.Contract_Playlist plContract = JMMServerVM.Instance.clientBinaryHTTP.GetPlaylist(cmd.PlaylistID);
                        if (plContract == null)
                        {
                            MessageBox.Show(Properties.Resources.EpisodeDetail_PlaylistMissing, Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }
                        pl = new PlaylistVM(plContract);
                    }

                    this.Cursor = Cursors.Wait;

                    pl.AddEpisode(ep.AnimeEpisodeID);
                    pl.Save();

                    PlaylistHelperVM.Instance.RefreshData();

                    this.Cursor = Cursors.Arrow;
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Exemplo n.º 7
0
        public static PlaylistVM CreatePlaylist(Window owner)
        {
            try
            {
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(AppSettings.Culture);

                DialogText dlg = new DialogText();
                dlg.Init(Properties.Resources.Playlist_Name + " ", "");
                dlg.Owner = owner;
                bool? res = dlg.ShowDialog();
                if (res.HasValue && res.Value)
                {
                    if (string.IsNullOrEmpty(dlg.EnteredText))
                    {
                        Utils.ShowErrorMessage(Properties.Resources.Playlist_NameBlank);
                        return null;
                    }

                    JMMServerBinary.Contract_Playlist pl = new JMMServerBinary.Contract_Playlist();
                    pl.DefaultPlayOrder = (int)PlaylistPlayOrder.Sequential;
                    pl.PlaylistItems = "";
                    pl.PlaylistName = dlg.EnteredText;
                    pl.PlayUnwatched = 1;
                    pl.PlayWatched = 0;
                    JMMServerBinary.Contract_Playlist_SaveResponse resp = JMMServerVM.Instance.clientBinaryHTTP.SavePlaylist(pl);

                    if (!string.IsNullOrEmpty(resp.ErrorMessage))
                    {
                        Utils.ShowErrorMessage(resp.ErrorMessage);
                        return null;
                    }

                    // refresh data
                    PlaylistHelperVM.Instance.RefreshData();

                    PlaylistVM plRet = new PlaylistVM(resp.Playlist);
                    return plRet;
                }

                return null;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
                return null;
            }
        }
Exemplo n.º 8
0
        public void Save()
        {
            JMMServerBinary.Contract_Playlist pl = new JMMServerBinary.Contract_Playlist();
            pl.PlaylistID = this.PlaylistID;
            pl.DefaultPlayOrder = this.DefaultPlayOrder;
            pl.PlaylistItems = this.PlaylistItems;
            pl.PlaylistName = this.PlaylistName;
            pl.PlayUnwatched = this.PlayUnwatched;
            pl.PlayWatched = this.PlayWatched;
            JMMServerBinary.Contract_Playlist_SaveResponse resp = JMMServerVM.Instance.clientBinaryHTTP.SavePlaylist(pl);

            if (!string.IsNullOrEmpty(resp.ErrorMessage))
            {
                Utils.ShowErrorMessage(resp.ErrorMessage);
                return;
            }

            this.PlayWatchedBool = PlayWatched == 1;
            this.PlayUnwatchedBool = PlayUnwatched == 1;
        }
Exemplo n.º 9
0
		public static PlaylistVM CreatePlaylist(Window owner)
		{
			try
			{
				DialogText dlg = new DialogText();
				dlg.Init("Enter playlist name: ", "");
				dlg.Owner = owner;
				bool? res = dlg.ShowDialog();
				if (res.HasValue && res.Value)
				{
					if (string.IsNullOrEmpty(dlg.EnteredText))
					{
						Utils.ShowErrorMessage("Please enter a playlist name");
						return null;
					}

					JMMServerBinary.Contract_Playlist pl = new JMMServerBinary.Contract_Playlist();
					pl.DefaultPlayOrder = (int)PlaylistPlayOrder.Sequential;
					pl.PlaylistItems = "";
					pl.PlaylistName = dlg.EnteredText;
					pl.PlayUnwatched = 1;
					pl.PlayWatched = 0;
					JMMServerBinary.Contract_Playlist_SaveResponse resp = JMMServerVM.Instance.clientBinaryHTTP.SavePlaylist(pl);

					if (!string.IsNullOrEmpty(resp.ErrorMessage))
					{
						Utils.ShowErrorMessage(resp.ErrorMessage);
						return null;
					}

					// refresh data
					PlaylistHelperVM.Instance.RefreshData();

					PlaylistVM plRet = new PlaylistVM(resp.Playlist);
					return plRet;
				}

				return null;
			}
			catch (Exception ex)
			{
				Utils.ShowErrorMessage(ex);
				return null;
			}
		}