private static void CollectionNavigator_BeforeDelete(object sender, CancelDataEventArgs<object> e) { if (MessageBox.Show("Delete picture?", "Delete picture", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { e.Cancel = true; } }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { if (CurrentPosition == null) { return; } var handler = BeforeDelete; if (handler == null) { return; } var collection = ItemsSource; int index = CurrentPosition.Value - 1; object item = collection[index]; CancelDataEventArgs <object> eventArgs = new CancelDataEventArgs <object>(item); handler(this, eventArgs); if (eventArgs.Cancel) { return; } collection.RemoveAt(index); ItemsSourceChanged(); }
private static void CollectionNavigator_BeforeDelete(object sender, CancelDataEventArgs <object> e) { if (MessageBox.Show("Delete picture?", "Delete picture", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { e.Cancel = true; } }
private void OnEntryCommand_Executing(object sender, CancelDataEventArgs e) { var handler = CommandExecuting; if (handler != null) { var entry = (CommandEntry)sender; var cancelArgs = new CommandExecutingEventArgs(entry.Name, e.Value); handler.Invoke(this, cancelArgs); e.Cancel = cancelArgs.Cancel; } }
private void AttachedPicture_DescriptionChanging(object sender, CancelDataEventArgs <string> e) { if (!string.IsNullOrEmpty(e.Data)) { foreach (IAttachedPicture picture1 in base.Items) { if (((picture1 != sender) && !string.IsNullOrEmpty(picture1.Description)) && (string.Compare(picture1.Description, e.Data, false) == 0)) { return; } } } }
private void CollectionNavigator_BeforeAdd(object sender, CancelDataEventArgs<object> e) { if (_openFileDialog.ShowDialog() != true) { e.Cancel = true; return; } Picture picture = new Picture(_openFileDialog.FileName); if (picture.ImageSource != null) e.Data = picture; else e.Cancel = true; }
private void AttachedPicture_PictureTypeChanging(object sender, CancelDataEventArgs <PictureType> e) { foreach (IAttachedPicture picture1 in base.Items) { if ((((PictureType)e.Data) == PictureType.OtherFileIcon) && (picture1.PictureType == PictureType.OtherFileIcon)) { return; } if ((((PictureType)e.Data) == PictureType.FileIcon32x32Png) && (picture1.PictureType == PictureType.FileIcon32x32Png)) { return; } } }
private void CollectionNavigator_BeforeAdd(object sender, CancelDataEventArgs <object> e) { if (_openFileDialog.ShowDialog() != true) { e.Cancel = true; return; } Picture picture = new Picture(_openFileDialog.FileName); if (picture.ImageSource != null) { e.Data = picture; } else { e.Cancel = true; } }
private void AttachedPicture_PictureTypeChanging(object sender, CancelDataEventArgs <PictureType> e) { foreach (IAttachedPicture attachedPicture in Items) { if (e.Data == PictureType.OtherFileIcon && attachedPicture.PictureType == PictureType.OtherFileIcon) { // TODO: Make this a warning //e.Cancel = true; //e.CancelReason = "There may only be one picture of this picture type in the tag"; return; } if (e.Data == PictureType.FileIcon32x32Png && attachedPicture.PictureType == PictureType.FileIcon32x32Png) { // TODO: Make this a warning //e.Cancel = true; //e.CancelReason = "There may only be one picture of this picture type in the tag"; return; } } }
private void AddButton_Click(object sender, RoutedEventArgs e) { var handler = BeforeAdd; if (handler == null) { return; } var collection = ItemsSource; CancelDataEventArgs <object> eventArgs = new CancelDataEventArgs <object>(null); handler(this, eventArgs); if (eventArgs.Cancel || eventArgs.Data == null) { return; } collection.Add(eventArgs.Data); ItemsSourceChanged(); CurrentPosition = collection.Count; }
private void AttachedPicture_DescriptionChanging(object sender, CancelDataEventArgs <string> e) { if (string.IsNullOrEmpty(e.Data)) { return; } foreach (IAttachedPicture attachedPicture in Items) { if (attachedPicture != sender) { if (string.IsNullOrEmpty(attachedPicture.Description) == false) { if (string.Compare(attachedPicture.Description, e.Data, false) == 0) { // TODO: Make this a warning //e.Cancel = true; //e.CancelReason = "A picture with this description already exists in the tag"; return; } } } } }
private void OnCommandExecuting(object sender, CancelDataEventArgs e) { Executing?.Invoke(this, e); }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { if (CurrentPosition == null) return; var handler = BeforeDelete; if (handler == null) return; var collection = ItemsSource; int index = CurrentPosition.Value - 1; object item = collection[index]; CancelDataEventArgs<object> eventArgs = new CancelDataEventArgs<object>(item); handler(this, eventArgs); if (eventArgs.Cancel) return; collection.RemoveAt(index); ItemsSourceChanged(); }
private void AddButton_Click(object sender, RoutedEventArgs e) { var handler = BeforeAdd; if (handler == null) return; var collection = ItemsSource; CancelDataEventArgs<object> eventArgs = new CancelDataEventArgs<object>(null); handler(this, eventArgs); if (eventArgs.Cancel || eventArgs.Data == null) return; collection.Add(eventArgs.Data); ItemsSourceChanged(); CurrentPosition = collection.Count; }