Esempio n. 1
0
        void btnPlaylistAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                List<JMMServerBinary.Contract_Playlist> rawPlaylists = JMMServerVM.Instance.clientBinaryHTTP.GetAllPlaylists();
                PlaylistMenuCommand cmd = null;

                // get all playlists
                playlistMenu.Items.Clear();

                MenuItem itemSeries = new MenuItem();
                itemSeries.Header = "Add Series";
                itemSeries.Click += new RoutedEventHandler(playlistMenuItem_Click);
                playlistMenu.Items.Add(itemSeries);

                Separator sep = new Separator();

                MenuItem itemSeriesNew = new MenuItem();
                itemSeriesNew.Header = "New Playlist";
                itemSeriesNew.Click += new RoutedEventHandler(playlistMenuItem_Click);
                cmd = new PlaylistMenuCommand(PlaylistItemType.Series, -1); // new playlist
                itemSeriesNew.CommandParameter = cmd;
                itemSeries.Items.Add(itemSeriesNew);
                itemSeries.Items.Add(sep);

                foreach (JMMServerBinary.Contract_Playlist contract in rawPlaylists)
                {
                    MenuItem itemSeriesPL = new MenuItem();
                    itemSeriesPL.Header = contract.PlaylistName;
                    itemSeriesPL.Click += new RoutedEventHandler(playlistMenuItem_Click);
                    cmd = new PlaylistMenuCommand(PlaylistItemType.Series, contract.PlaylistID.Value);
                    itemSeriesPL.CommandParameter = cmd;
                    itemSeries.Items.Add(itemSeriesPL);
                }

                MenuItem itemAllEpisodes = new MenuItem();
                itemAllEpisodes.Header = "Add All Episodes";
                playlistMenu.Items.Add(itemAllEpisodes);

                Separator sep2 = new Separator();

                MenuItem itemAllEpisodesNew = new MenuItem();
                itemAllEpisodesNew.Header = "New Playlist";
                itemAllEpisodesNew.Click += new RoutedEventHandler(playlistMenuItem_Click);
                cmd = new PlaylistMenuCommand(PlaylistItemType.AllEpisodes, -1); // new playlist
                itemAllEpisodesNew.CommandParameter = cmd;
                itemAllEpisodes.Items.Add(itemAllEpisodesNew);
                itemAllEpisodes.Items.Add(sep2);

                foreach (JMMServerBinary.Contract_Playlist contract in rawPlaylists)
                {
                    MenuItem itemSeriesPL = new MenuItem();
                    itemSeriesPL.Header = contract.PlaylistName;
                    itemSeriesPL.Click += new RoutedEventHandler(playlistMenuItem_Click);
                    cmd = new PlaylistMenuCommand(PlaylistItemType.AllEpisodes, contract.PlaylistID.Value);
                    itemSeriesPL.CommandParameter = cmd;
                    itemAllEpisodes.Items.Add(itemSeriesPL);
                }

                MenuItem itemUnwatchedEpisodes = new MenuItem();
                itemUnwatchedEpisodes.Header = "Add Unwatched Episodes";
                playlistMenu.Items.Add(itemUnwatchedEpisodes);

                Separator sep3 = new Separator();

                MenuItem itemUnwatchedEpisodesNew = new MenuItem();
                itemUnwatchedEpisodesNew.Header = "New Playlist";
                itemUnwatchedEpisodesNew.Click += new RoutedEventHandler(playlistMenuItem_Click);
                cmd = new PlaylistMenuCommand(PlaylistItemType.UnwatchedEpisodes, -1); // new playlist
                itemUnwatchedEpisodesNew.CommandParameter = cmd;
                itemUnwatchedEpisodes.Items.Add(itemUnwatchedEpisodesNew);
                itemUnwatchedEpisodes.Items.Add(sep3);

                foreach (JMMServerBinary.Contract_Playlist contract in rawPlaylists)
                {
                    MenuItem itemSeriesPL = new MenuItem();
                    itemSeriesPL.Header = contract.PlaylistName;
                    itemSeriesPL.Click += new RoutedEventHandler(playlistMenuItem_Click);
                    cmd = new PlaylistMenuCommand(PlaylistItemType.UnwatchedEpisodes, contract.PlaylistID.Value);
                    itemSeriesPL.CommandParameter = cmd;
                    itemUnwatchedEpisodes.Items.Add(itemSeriesPL);
                }

                playlistMenu.PlacementTarget = this;
                playlistMenu.IsOpen = true;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
        void btnPlaylistAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // get all playlists
                List<JMMServerBinary.Contract_Playlist> rawPlaylists = JMMServerVM.Instance.clientBinaryHTTP.GetAllPlaylists();
                PlaylistMenuCommand cmd = null;

                playlistMenu.Items.Clear();

                Separator sep = new Separator();

                MenuItem itemNew = new MenuItem();
                itemNew.Header = Properties.Resources.EpisodeDetail_NewPlaylist;
                itemNew.Click += new RoutedEventHandler(playlistMenuItem_Click);
                cmd = new PlaylistMenuCommand(PlaylistItemType.SingleEpisode, -1); // new playlist
                itemNew.CommandParameter = cmd;
                playlistMenu.Items.Add(itemNew);
                playlistMenu.Items.Add(sep);

                foreach (JMMServerBinary.Contract_Playlist contract in rawPlaylists)
                {
                    MenuItem itemSeriesPL = new MenuItem();
                    itemSeriesPL.Header = contract.PlaylistName;
                    itemSeriesPL.Click += new RoutedEventHandler(playlistMenuItem_Click);
                    cmd = new PlaylistMenuCommand(PlaylistItemType.SingleEpisode, contract.PlaylistID.Value);
                    itemSeriesPL.CommandParameter = cmd;
                    playlistMenu.Items.Add(itemSeriesPL);
                }

                playlistMenu.PlacementTarget = this;
                playlistMenu.IsOpen = true;
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }