星火微课系统客户端
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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