ConfirmationPopup.xaml.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using PixiEditor.Helpers;
  2. using System.Windows;
  3. namespace PixiEditor.Views
  4. {
  5. /// <summary>
  6. /// Interaction logic for ConfirmationPopup.xaml
  7. /// </summary>
  8. public partial class ConfirmationPopup : Window
  9. {
  10. // Using a DependencyProperty as the backing store for SaveChanges. This enables animation, styling, binding, etc...
  11. public static readonly DependencyProperty SaveChangesProperty =
  12. DependencyProperty.Register("SaveChanges", typeof(bool), typeof(ConfirmationPopup),
  13. new PropertyMetadata(true));
  14. // Using a DependencyProperty as the backing store for Body. This enables animation, styling, binding, etc...
  15. public static readonly DependencyProperty BodyProperty =
  16. DependencyProperty.Register("Body", typeof(string), typeof(ConfirmationPopup), new PropertyMetadata(""));
  17. public ConfirmationPopup()
  18. {
  19. InitializeComponent();
  20. CancelCommand = new RelayCommand(Cancel);
  21. SetResultAndCloseCommand = new RelayCommand(SetResultAndClose);
  22. DataContext = this;
  23. }
  24. public RelayCommand CancelCommand { get; set; }
  25. public RelayCommand SetResultAndCloseCommand { get; set; }
  26. public bool Result
  27. {
  28. get => (bool)GetValue(SaveChangesProperty);
  29. set => SetValue(SaveChangesProperty, value);
  30. }
  31. public string Body
  32. {
  33. get => (string)GetValue(BodyProperty);
  34. set => SetValue(BodyProperty, value);
  35. }
  36. private void SetResultAndClose(object property)
  37. {
  38. bool result = (bool)property;
  39. Result = result;
  40. DialogResult = true;
  41. Close();
  42. }
  43. private void Cancel(object property)
  44. {
  45. DialogResult = false;
  46. Close();
  47. }
  48. }
  49. }