void btnTraktCommLinks_Click(object sender, RoutedEventArgs e) { try { CommTvDBTraktMenuCommand cmd = null; // get all playlists commTraktMenu.Items.Clear(); MenuItem itemSeriesAdmin = new MenuItem(); itemSeriesAdmin.Header = "Show Community Admin"; itemSeriesAdmin.Click += new RoutedEventHandler(commTraktMenuItem_Click); cmd = new CommTvDBTraktMenuCommand(CommTvDBTraktItemType.ShowCommAdmin, -1); // new playlist itemSeriesAdmin.CommandParameter = cmd; commTraktMenu.Items.Add(itemSeriesAdmin); if (AniDB_AnimeCrossRefs.TraktCrossRefExists) { MenuItem itemSeriesLinks = new MenuItem(); itemSeriesLinks.Header = "Use My Links"; itemSeriesLinks.Click += new RoutedEventHandler(commTraktMenuItem_Click); cmd = new CommTvDBTraktMenuCommand(CommTvDBTraktItemType.UseMyLinks, -1); // new playlist itemSeriesLinks.CommandParameter = cmd; commTraktMenu.Items.Add(itemSeriesLinks); } commTraktMenu.PlacementTarget = this; commTraktMenu.IsOpen = true; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
void btnTvDBCommLinks_Click(object sender, RoutedEventArgs e) { try { CommTvDBTraktMenuCommand cmd = null; // get all playlists commTvDBMenu.Items.Clear(); MenuItem itemSeriesAdmin = new MenuItem(); itemSeriesAdmin.Header = Properties.Resources.CommunityLinks_ShowAdmin; itemSeriesAdmin.Click += new RoutedEventHandler(commTvDBMenuItem_Click); cmd = new CommTvDBTraktMenuCommand(CommTvDBTraktItemType.ShowCommAdmin, -1); // new playlist itemSeriesAdmin.CommandParameter = cmd; commTvDBMenu.Items.Add(itemSeriesAdmin); if (AniDB_AnimeCrossRefs.TvDBCrossRefExists) { MenuItem itemSeriesLinks = new MenuItem(); itemSeriesLinks.Header = Properties.Resources.CommunityLins_UseMyLinks; itemSeriesLinks.Click += new RoutedEventHandler(commTvDBMenuItem_Click); cmd = new CommTvDBTraktMenuCommand(CommTvDBTraktItemType.UseMyLinks, -1); // new playlist itemSeriesLinks.CommandParameter = cmd; commTvDBMenu.Items.Add(itemSeriesLinks); } commTvDBMenu.PlacementTarget = this; commTvDBMenu.IsOpen = true; } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }
void commTraktMenuItem_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) { CommTvDBTraktMenuCommand cmd = item.CommandParameter as CommTvDBTraktMenuCommand; Debug.Write("Comm TvDB Menu: " + cmd.ToString() + Environment.NewLine); AniDB_AnimeVM anime = this.DataContext as AniDB_AnimeVM; if (anime == null) { return; } this.Cursor = Cursors.Wait; if (cmd.MenuType == CommTvDBTraktItemType.ShowCommAdmin) { MainWindow mainwdw = (MainWindow)Window.GetWindow(this); if (mainwdw == null) { return; } mainwdw.ShowWebCacheAdmin(anime); } if (cmd.MenuType == CommTvDBTraktItemType.UseMyLinks) { if (!AniDB_AnimeCrossRefs.TraktCrossRefExists) { MessageBox.Show("You don't have any links", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } string res = JMMServerVM.Instance.clientBinaryHTTP.UseMyTraktLinksWebCache(anime.AnimeID); this.Cursor = Cursors.Arrow; MessageBox.Show(res, "Result", MessageBoxButton.OK, MessageBoxImage.Information); } this.Cursor = Cursors.Arrow; RefreshAdminData(); } } catch (Exception ex) { Utils.ShowErrorMessage(ex); } }