private async void EditCoverButton_OnClick(object sender, RoutedEventArgs e)
        {
            CoverEditorWindow dlg;

            if (this.ViewModel.Cover != null)
            {
                dlg = new CoverEditorWindow(this.ViewModel.Cover);
            }
            else
            {
                dlg = new CoverEditorWindow(await CoverEditorViewModel.FromAsync(this.ViewModel.GetManagers().CoverManager, this.ViewModel.GetCommitObject()));
            }

            if (dlg.ViewModel.DoubanId.IsNullOrWhiteSpace() && !this.ViewModel.DoubanId.IsNullOrWhiteSpace())
            {
                dlg.ViewModel.DoubanId = this.ViewModel.DoubanId;
            }

            if (dlg.ViewModel.ImdbId.IsNullOrWhiteSpace())
            {
                if (!this.ViewModel.Parent.Source.ImdbId.IsNullOrWhiteSpace())
                {
                    dlg.ViewModel.ImdbId = this.ViewModel.Parent.Source.ImdbId;
                }
                else if (!this.ViewModel.ImdbId.IsNullOrWhiteSpace())
                {
                    dlg.ViewModel.ImdbId = this.ViewModel.ImdbId;
                }
            }

            if (dlg.ShowDialog() == true)
            {
                this.ViewModel.Cover = dlg.ViewModel;
            }
        }
Example #2
0
        public async Task OpenCoverEditorWindows(Window parent)
        {
            if (this.SeriesView.TestVersionObsolete(parent))
            {
                return;
            }

            var viewModel = await CoverEditorViewModel.FromAsync(this.GetManagers().CoverManager, this.Source);

            viewModel.DoubanId = this.Source.DoubanId ?? string.Empty;
            viewModel.ImdbId   = this.SeriesView.Source.ImdbId ?? this.Source.ImdbId ?? string.Empty;
            var dlg = new CoverEditorWindow(viewModel);

            if (dlg.ViewModel.DoubanId.IsNullOrWhiteSpace() && !this.Source.DoubanId.IsNullOrWhiteSpace())
            {
                dlg.ViewModel.DoubanId = this.Source.DoubanId;
            }

            if (dlg.ViewModel.ImdbId.IsNullOrWhiteSpace())
            {
                if (!this.SeriesView.Source.ImdbId.IsNullOrWhiteSpace())
                {
                    dlg.ViewModel.ImdbId = this.SeriesView.Source.ImdbId;
                }
                else if (!this.Source.ImdbId.IsNullOrWhiteSpace())
                {
                    dlg.ViewModel.ImdbId = this.Source.ImdbId;
                }
            }

            if (dlg.ShowDialog() == true)
            {
                await dlg.ViewModel.CommitAsync();

                this.CoverViewModel.RefreshProperties();
            }
        }
 public CoverEditorWindow(CoverEditorViewModel viewModel)
 {
     this.InitializeComponent();
     this.DataContext = this.ViewModel = viewModel;
 }
 public CoverEditorWindow()
 {
     this.InitializeComponent();
     this.DataContext = this.ViewModel = new CoverEditorViewModel();
 }