private async void EditCover_OnClick(object sender, RoutedEventArgs e) { var frameworkElement = sender as FrameworkElement; if (frameworkElement == null) return; var vm = frameworkElement.DataContext as VideoInfoViewModel; if (vm == null) return; var dlg = new CoverEditorWindow(); var cover = await vm.TryGetCoverAsync(); if (cover != null) { dlg.ViewModel.ModifyMode(cover); dlg.UpdateRadioButtonCheckedStatus(); } else { dlg.ViewModel.CreateMode(); } if (dlg.ShowDialog() == true) { await dlg.ViewModel.CommitAsync(); vm.BeginUpdateCover(); } }
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; } }
private async void EditCoverButton_OnClick(object sender, RoutedEventArgs e) { var dlg = new CoverEditorWindow(); if (this.ViewModel.Cover != null) { if (this.ViewModel.Cover.Action == ObjectChangedAction.Create) { dlg.ViewModel.CreateMode(); } else { dlg.ViewModel.ModifyMode(this.ViewModel.Cover.Source); } dlg.ViewModel.DoubanId = this.ViewModel.Cover.DoubanId; dlg.ViewModel.CoverSourceType = this.ViewModel.Cover.CoverSourceType; dlg.ViewModel.Uri = this.ViewModel.Cover.Uri; dlg.ViewModel.BinaryData = this.ViewModel.Cover.BinaryData; dlg.ViewModel.SaveToObject(dlg.ViewModel.Source); } else { if (this.ViewModel.Action == ObjectChangedAction.Create /* create a video */ || this.ViewModel.Source.CoverId == null /* video has not cover */) { dlg.ViewModel.CreateMode(); } else { var cover = await JryVideoCore.Current.CurrentDataCenter.CoverManager.FindAsync(this.ViewModel.Source.CoverId); if (cover == null) // database error ? { dlg.ViewModel.CreateMode(); } else { dlg.ViewModel.ModifyMode(cover); } } } dlg.UpdateRadioButtonCheckedStatus(); if (dlg.ShowDialog() == true) { this.ViewModel.Cover = dlg.ViewModel; } }
private async void EditCover_OnClick(object sender, RoutedEventArgs e) { var vm = this.ViewModel.InfoView; var dlg = new CoverEditorWindow(); var cover = await vm.TryGetCoverAsync(); if (cover != null) { dlg.ViewModel.ModifyMode(cover); dlg.UpdateRadioButtonCheckedStatus(); } else { dlg.ViewModel.CreateMode(); } if (dlg.ShowDialog() == true) { await dlg.ViewModel.CommitAsync(); vm.BeginUpdateCover(); } }