MessageDialog.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace OpenSEMI.ClientBase
  7. {
  8. public class MessageDialog : DialogViewModel<DialogButton>
  9. {
  10. private string m_text;
  11. public string Text
  12. {
  13. get { return m_text; }
  14. set { m_text = value; NotifyOfPropertyChange("Text"); }
  15. }
  16. public DialogButton DialogButton
  17. {
  18. set
  19. {
  20. this.m_buttons.Clear();
  21. foreach (int v in Enum.GetValues(typeof(DialogButton)))
  22. {
  23. DialogButton m_btn = (DialogButton)v;
  24. if (value.HasFlag(m_btn))
  25. {
  26. ButtonControl bc = new ButtonControl();
  27. bc.Name = m_btn.ToString();
  28. if (m_btn == DialogButton.OK || m_btn == DialogButton.Yes)
  29. bc.IsDefault = true;
  30. else
  31. bc.IsDefault = false;
  32. if (m_btn == DialogButton.Cancel || m_btn == DialogButton.No)
  33. bc.IsCancel = true;
  34. else
  35. bc.IsCancel = false;
  36. m_buttons.Add(bc);
  37. }
  38. }
  39. }
  40. }
  41. private List<ButtonControl> m_buttons = new List<ButtonControl>();
  42. public List<ButtonControl> Buttons
  43. {
  44. get { return m_buttons; }
  45. }
  46. private DialogType m_DialogType = DialogType.INFO;
  47. public DialogType DialogType
  48. {
  49. get { return m_DialogType; }
  50. set { m_DialogType = value; NotifyOfPropertyChange("DialogType"); }
  51. }
  52. }
  53. public class ButtonControl
  54. {
  55. public string Name { get; set; }
  56. public bool IsDefault { get; set; }
  57. public bool IsCancel { get; set; }
  58. }
  59. }