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(Shoko.Commons.Properties.Resources.EpisodeDetail_PlaylistMenu + cmd.ToString() + Environment.NewLine); VM_AnimeEpisode_User ep = DataContext as VM_AnimeEpisode_User; if (ep == null) { return; } // get the playlist VM_Playlist pl = null; if (cmd.PlaylistID < 0) { pl = VM_PlaylistHelper.CreatePlaylist(Window.GetWindow(this)); if (pl == null) { return; } } else { pl = (VM_Playlist)VM_ShokoServer.Instance.ShokoServices.GetPlaylist(cmd.PlaylistID); if (pl == null) { MessageBox.Show(Shoko.Commons.Properties.Resources.EpisodeDetail_PlaylistMissing, Shoko.Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error); return; } } Cursor = Cursors.Wait; pl.AddEpisode(ep.AnimeEpisodeID); pl.Save(); VM_PlaylistHelper.Instance.RefreshData(); Cursor = Cursors.Arrow; } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
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); } }