private void TransitionList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (this.photoListBox.SelectedItem != null && this.photoListBox.SelectedItem is ComposePhotoViewModel) { // 更新设计器以显示选定特效所需的额外的控件. // UI是一个内容绑定到视图模型的TransitionDesigner属性的ContentControl. ComposePhotoViewModel photo = (ComposePhotoViewModel)this.photoListBox.SelectedItem; photo.TransitionDesigner = TransitionFactory.CreateTransitionDesigner(this.transitionList.SelectedItem.ToString()); } }
private void EditPhotoButton_Click(object sender, System.EventArgs e) { if (this.photoListBox.SelectedItem != null && this.photoListBox.SelectedItem is ComposePhotoViewModel) { this.photoListBox.IsEnabled = false; // 备份视图模型, 因此我们可以撤销更新操作. this._viewModelBackup = ((ComposePhotoViewModel)this.photoListBox.SelectedItem).CopyTo(); this.ShowEditPanelStoryboard.Begin(); } }
private void RemovePhotoButton_Click(object sender, System.EventArgs e) { // 移除选定项目, 关闭对应流. if (this.photoListBox.SelectedItem != null && this.photoListBox.SelectedItem is ComposePhotoViewModel) { ComposePhotoViewModel photo = (ComposePhotoViewModel)this.photoListBox.SelectedItem; photo.MediaStream.Close(); this._photoDataSource.Remove(photo); photo.RemoveModel(); } }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { // 准备数据源. this._photoDataSource = new ObservableCollection <ComposePhotoViewModel>(); this.nameTextBox.Text = App.CurrentStoryName; foreach (Photo photo in App.MediaCollection) { _photoDataSource.Add(ComposePhotoViewModel.CreateFromModel(photo)); } this.photoListBox.ItemsSource = this._photoDataSource; base.OnNavigatedTo(e); }