星火微课系统客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

MessageWindow.xaml.cs 4.4KB

4 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using System.Windows;
  2. using System.Windows.Input;
  3. namespace XHWK.WKTool
  4. {
  5. /// <summary>
  6. /// 消息提示框 .show()
  7. /// </summary>
  8. public partial class MessageWindow : Window
  9. {
  10. /// <summary>
  11. /// 提示框
  12. /// </summary>
  13. /// <param name="MessageType">取消按钮 1不显示2显示</param>
  14. /// <param name="Title">标题</param>
  15. /// <param name="content">消息内容</param>
  16. public MessageWindow(int MessageType, string Title, string Content)
  17. {
  18. InitializeComponent();
  19. switch (MessageType)
  20. {
  21. case 1:
  22. borCancel.Visibility = Visibility.Hidden;
  23. break;
  24. case 2:
  25. borCancel.Visibility = Visibility.Visible;
  26. break;
  27. default:
  28. break;
  29. }
  30. lblTitle.Content = Title;
  31. if (!string.IsNullOrWhiteSpace(Content))
  32. {
  33. if (Content.Length > 143)
  34. {
  35. Content = Content.Substring(0, 140) + "...";
  36. }
  37. tbkContent.Text = Content;
  38. }
  39. else
  40. {
  41. tbkContent.Text = "错误!";
  42. }
  43. }
  44. /// <summary>
  45. /// 取消
  46. /// </summary>
  47. /// <param name="sender"></param>
  48. /// <param name="e"></param>
  49. private void BtnCancel_Click(object sender, RoutedEventArgs e)
  50. {
  51. DialogResult = false;
  52. }
  53. /// <summary>
  54. /// 确定
  55. /// </summary>
  56. /// <param name="sender"></param>
  57. /// <param name="e"></param>
  58. private void BtnOK_Click(object sender, RoutedEventArgs e)
  59. {
  60. DialogResult = true;
  61. }
  62. /// <summary>
  63. /// 消息提示框
  64. /// </summary>
  65. /// <param name="Message">消息</param>
  66. /// <returns></returns>
  67. public static MessageBoxResult Show(string Message)
  68. {
  69. string Title = "消息提示";
  70. return Show(Message, Title);
  71. }
  72. /// <summary>
  73. /// 消息提示框
  74. /// </summary>
  75. /// <param name="Message">消息</param>
  76. /// <returns></returns>
  77. public static MessageBoxResult Show(string Message, string Title)
  78. {
  79. MessageWindow message = new MessageWindow(1, Title, Message);
  80. message.ShowDialog();
  81. return MessageBoxResult.Cancel;
  82. }
  83. /// <summary>
  84. /// 消息提示框
  85. /// </summary>
  86. /// <param name="Title">标题</param>
  87. /// <param name="Message">消息</param>
  88. /// <returns></returns>
  89. public static MessageBoxResult Show(string Message, string Title, MessageBoxButton messageBox)
  90. {
  91. if (string.IsNullOrWhiteSpace(Title))
  92. {
  93. Title = "消息提示";
  94. }
  95. MessageWindow message = new MessageWindow(2, Title, Message);
  96. bool? res = message.ShowDialog();
  97. if ((bool)res)
  98. {
  99. if (messageBox == MessageBoxButton.OKCancel)
  100. {
  101. return MessageBoxResult.OK;
  102. }
  103. else
  104. {
  105. return MessageBoxResult.Yes;
  106. }
  107. }
  108. else
  109. {
  110. if (messageBox == MessageBoxButton.OKCancel)
  111. {
  112. return MessageBoxResult.Cancel;
  113. }
  114. else
  115. {
  116. return MessageBoxResult.No;
  117. }
  118. }
  119. }
  120. private static MessageBoxResult Win32ToMessageBoxResult(int value)
  121. {
  122. switch (value)
  123. {
  124. case 1:
  125. return MessageBoxResult.OK;
  126. case 2:
  127. return MessageBoxResult.Cancel;
  128. case 6:
  129. return MessageBoxResult.Yes;
  130. case 7:
  131. return MessageBoxResult.No;
  132. default:
  133. return MessageBoxResult.No;
  134. }
  135. }
  136. private void Window_MouseMove(object sender, MouseEventArgs e)
  137. {
  138. if (e.LeftButton == MouseButtonState.Pressed)
  139. {
  140. //this.DragMove();
  141. DragMove();
  142. }
  143. }
  144. }
  145. }