CustomDialogMessage.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. namespace GDNXFD.Alert.Config.Model
  2. {
  3. using GalaSoft.MvvmLight;
  4. using GalaSoft.MvvmLight.Command;
  5. using GDNXFD.Alert.Config.Converters;
  6. using System;
  7. using System.Windows;
  8. using System.Windows.Input;
  9. /// <summary>
  10. /// Dialog message
  11. /// </summary>
  12. public class CustomDialogMessage : ObservableObject
  13. {
  14. private Action acceptAction;
  15. private Action cancelAction;
  16. private RelayCommand acceptCommand;
  17. private RelayCommand cancelCommand;
  18. //private TravelTypeToTextConverter travelTypeToTextConverter = new TravelTypeToTextConverter();
  19. private string message;
  20. /// <summary>
  21. /// Constructor
  22. /// </summary>
  23. /// <param name="acceptAction">Action to be executed when pressing accept button</param>
  24. /// <param name="message">Dialog message</param>
  25. /// <param name="showCancel">Show or not cancel button</param>
  26. public CustomDialogMessage(Action acceptAction, string message, Visibility showCancel)
  27. {
  28. this.acceptAction = acceptAction;
  29. Message = message;
  30. ShowCancel = showCancel;
  31. this.acceptCommand = new RelayCommand(() =>
  32. {
  33. this.acceptAction();
  34. this.cancelAction();
  35. });
  36. }
  37. /// <summary>
  38. /// Confirms dialog.
  39. /// </summary>
  40. public ICommand AcceptCommand
  41. {
  42. get { return this.acceptCommand; }
  43. }
  44. /// <summary>
  45. /// Do nothing.
  46. /// </summary>
  47. public ICommand CancelCommand
  48. {
  49. get { return this.cancelCommand; }
  50. }
  51. /// <summary>
  52. /// Action to be executed when cancel command is called.
  53. /// </summary>
  54. public Action CancelAction {
  55. get { return this.cancelAction; }
  56. set
  57. {
  58. this.cancelAction = value;
  59. this.cancelCommand = new RelayCommand(this.cancelAction);
  60. }
  61. }
  62. /// <summary>
  63. /// Dialog message.
  64. /// </summary>
  65. public string Message
  66. {
  67. get
  68. {
  69. return this.message;
  70. }
  71. set
  72. {
  73. this.message = value;
  74. RaisePropertyChanged(() => Message);
  75. }
  76. }
  77. /// <summary>
  78. /// Show or not cancel button
  79. /// </summary>
  80. public Visibility ShowCancel { get; set; }
  81. }
  82. }