Example #1
0
        void btnTraktCommLinks_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // get all playlists
                commTraktMenu.Items.Clear();

                MenuItem itemSeriesAdmin =
                    new MenuItem {
                    Header = Commons.Properties.Resources.CommunityLinks_ShowAdmin
                };
                itemSeriesAdmin.Click += commTraktMenuItem_Click;
                var cmd = new CommTvDBTraktMenuCommand(CommTvDBTraktItemType.ShowCommAdmin, -1);
                itemSeriesAdmin.CommandParameter = cmd;
                commTraktMenu.Items.Add(itemSeriesAdmin);

                if (AniDB_AnimeCrossRefs.TraktCrossRefExists)
                {
                    MenuItem itemSeriesLinks = new MenuItem();
                    itemSeriesLinks.Header = Commons.Properties.Resources.CommunityLins_UseMyLinks;
                    itemSeriesLinks.Click += 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);
            }
        }
Example #2
0
        void commTraktMenuItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!(e.Source is MenuItem item) || !(sender is MenuItem itemSender))
                {
                    return;
                }
                if (!item.Header.ToString().Equals(itemSender.Header.ToString()))
                {
                    return;
                }

                if (item.CommandParameter != null)
                {
                    CommTvDBTraktMenuCommand cmd = item.CommandParameter as CommTvDBTraktMenuCommand;
                    Debug.Write("Comm TvDB Menu: " + cmd + Environment.NewLine);

                    if (!(DataContext is VM_AniDB_Anime anime))
                    {
                        return;
                    }


                    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(Commons.Properties.Resources.CommunityLinks_NoLinks, Commons.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
                            return;
                        }

                        string res = VM_ShokoServer.Instance.ShokoServices.UseMyTraktLinksWebCache(anime.AnimeID);
                        Cursor = Cursors.Arrow;
                        MessageBox.Show(res, Commons.Properties.Resources.Result, MessageBoxButton.OK, MessageBoxImage.Information);
                    }

                    Cursor = Cursors.Arrow;

                    RefreshAdminData();
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }