Esempio n. 1
0
        private void CommandBinding_DeleteMALLink(object sender, ExecutedRoutedEventArgs e)
        {
            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                AniDB_AnimeVM anime = this.DataContext as AniDB_AnimeVM;
                if (anime == null)
                {
                    return;
                }

                if (obj.GetType() == typeof(CrossRef_AniDB_MALVM))
                {
                    this.Cursor = Cursors.Wait;
                    CrossRef_AniDB_MALVM malLink = obj as CrossRef_AniDB_MALVM;

                    // prompt to select details
                    Window wdw = Window.GetWindow(this);

                    string           msg    = string.Format("Are you sure you want to delete this link?");
                    MessageBoxResult result = MessageBox.Show(msg, "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                    if (result == MessageBoxResult.Yes)
                    {
                        this.Cursor = Cursors.Wait;

                        string res = JMMServerVM.Instance.clientBinaryHTTP.RemoveLinkAniDBMAL(anime.AnimeID, malLink.StartEpisodeType, malLink.StartEpisodeNumber);
                        if (res.Length > 0)
                        {
                            MessageBox.Show(res, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        }
                        else
                        {
                            // update info
                            RefreshData();
                        }

                        this.Cursor = Cursors.Arrow;
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }
Esempio n. 2
0
        private void CommandBinding_EditMALLink(object sender, ExecutedRoutedEventArgs e)
        {
            object obj = e.Parameter;

            if (obj == null)
            {
                return;
            }

            try
            {
                AniDB_AnimeVM anime = this.DataContext as AniDB_AnimeVM;
                if (anime == null)
                {
                    return;
                }

                if (obj.GetType() == typeof(CrossRef_AniDB_MALVM))
                {
                    this.Cursor = Cursors.Wait;
                    CrossRef_AniDB_MALVM malLink = obj as CrossRef_AniDB_MALVM;

                    // prompt to select details
                    Window wdw = Window.GetWindow(this);

                    SelectMALStartForm frm = new SelectMALStartForm();
                    frm.Owner = wdw;
                    frm.Init(malLink.AnimeID, anime.FormattedTitle, malLink.MALTitle, malLink.MALID, malLink.StartEpisodeType, malLink.StartEpisodeNumber);
                    bool?result = frm.ShowDialog();
                    if (result.Value)
                    {
                        // update info
                        RefreshData();
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }