예제 #1
0
        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)
        {
            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();
            }
        }