AlertsMessage.xaml.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Shapes;
  14. namespace PDF_Master.CustomControl
  15. {
  16. public enum ContentResult
  17. {
  18. Cancel,
  19. MiddleCancel,
  20. Ok
  21. }
  22. /// <summary>
  23. /// AlertsMessage.xaml 的交互逻辑
  24. /// 因为是纯UI的逻辑显示,所以没有再创建VM
  25. /// </summary>
  26. public partial class AlertsMessage : Window
  27. {
  28. public ContentResult result = ContentResult.Cancel;
  29. public bool isChecked = false;
  30. private Window ownerWindow;
  31. public AlertsMessage()
  32. {
  33. InitializeComponent();
  34. ownerWindow = App.Current.MainWindow;
  35. }
  36. public void ShowAskAgainCheck()
  37. {
  38. ChbDonotAskAgain.Visibility = Visibility.Visible;
  39. }
  40. /// <summary>
  41. /// 两个按钮弹窗
  42. /// </summary>
  43. public void HaveCheckBoxShow(string title, string content,string contentCheckBox, string cancelBtn, string okBtn)
  44. {
  45. TitleText.Text = title;
  46. ContentText.Text = content;
  47. CancelBtn.Visibility = Visibility.Collapsed;
  48. MiddleCancelBtn.Content = cancelBtn;
  49. OkBtn.Content = okBtn;
  50. ChbDonotAskAgain.Content = contentCheckBox;
  51. ChbDonotAskAgain.Visibility = Visibility.Visible;
  52. Width = 408;
  53. Grid.SetColumn(MiddleCancelBtn, 2);
  54. Grid.SetColumn(OkBtn, 1);
  55. Grid.SetColumn(ChbDonotAskAgain, 0);
  56. BtnGrid.ColumnDefinitions.Clear();
  57. var column = new ColumnDefinition();
  58. var column2 = new ColumnDefinition();
  59. var column0 = new ColumnDefinition();
  60. column.Width = new GridLength(1, GridUnitType.Star);
  61. column2.Width = new GridLength(1, GridUnitType.Star);
  62. column0.Width = new GridLength(2, GridUnitType.Star);
  63. BtnGrid.ColumnDefinitions.Add(column0);
  64. BtnGrid.ColumnDefinitions.Add(column);
  65. BtnGrid.ColumnDefinitions.Add(column2);
  66. if (ownerWindow != null)
  67. {
  68. this.Owner = ownerWindow;
  69. ShowDialog();
  70. }
  71. }
  72. /// <summary>
  73. /// 一个按钮弹窗
  74. /// </summary>
  75. public void Show(string title, string content,string okBtn)
  76. {
  77. TitleText.Text = title;
  78. ContentText.Text = content;
  79. CancelBtn.Visibility = Visibility.Collapsed;
  80. MiddleCancelBtn.Visibility = Visibility.Collapsed;
  81. OkBtn.Content = okBtn;
  82. Width = 408;
  83. Grid.SetColumn(OkBtn, 3);
  84. BtnGrid.ColumnDefinitions.Clear();
  85. var column = new ColumnDefinition();
  86. var column2 = new ColumnDefinition();
  87. var column3 = new ColumnDefinition();
  88. column.Width = new GridLength(1, GridUnitType.Star);
  89. column2.Width = new GridLength(1, GridUnitType.Star);
  90. column3.Width = new GridLength(1, GridUnitType.Star);
  91. BtnGrid.ColumnDefinitions.Add(column);
  92. BtnGrid.ColumnDefinitions.Add(column2);
  93. BtnGrid.ColumnDefinitions.Add(column3);
  94. this.Show();
  95. }
  96. /// <summary>
  97. /// 两个按钮弹窗
  98. /// </summary>
  99. public void Show(string title,string content,string cancelBtn,string okBtn)
  100. {
  101. TitleText.Text = title;
  102. ContentText.Text = content;
  103. CancelBtn.Visibility = Visibility.Collapsed;
  104. MiddleCancelBtn.Content = cancelBtn;
  105. OkBtn.Content = okBtn;
  106. Width = 408;
  107. Grid.SetColumn(MiddleCancelBtn, 1);
  108. Grid.SetColumn(OkBtn, 0);
  109. BtnGrid.ColumnDefinitions.Clear();
  110. var column = new ColumnDefinition();
  111. var column2 = new ColumnDefinition();
  112. column.Width = new GridLength(1, GridUnitType.Star);
  113. column2.Width = new GridLength(1, GridUnitType.Star);
  114. BtnGrid.ColumnDefinitions.Add(column);
  115. BtnGrid.ColumnDefinitions.Add(column2);
  116. this.Show();
  117. }
  118. /// <summary>
  119. /// 三个按钮弹窗
  120. /// </summary>
  121. public void Show(string title, string content, string cancelBtn1, string cancelBtn2, string okBtn)
  122. {
  123. TitleText.Text = title;
  124. ContentText.Text = content;
  125. CancelBtn.Visibility = Visibility.Visible;
  126. CancelBtn.Content = cancelBtn1;
  127. MiddleCancelBtn.Content = cancelBtn2;
  128. OkBtn.Content = okBtn;
  129. Grid.SetColumn(CancelBtn, 2);
  130. Grid.SetColumn(MiddleCancelBtn, 1);
  131. Grid.SetColumn(OkBtn, 0);
  132. BtnGrid.ColumnDefinitions.Clear();
  133. var column = new ColumnDefinition();
  134. var column2 = new ColumnDefinition();
  135. var column3 = new ColumnDefinition();
  136. column.Width = new GridLength(1, GridUnitType.Star);
  137. column2.Width = new GridLength(1, GridUnitType.Star);
  138. column3.Width = new GridLength(1, GridUnitType.Star);
  139. BtnGrid.ColumnDefinitions.Add(column);
  140. BtnGrid.ColumnDefinitions.Add(column2);
  141. BtnGrid.ColumnDefinitions.Add(column3);
  142. this.Show();
  143. }
  144. public void ShowDialog(string title, string content, string okBtn)
  145. {
  146. TitleText.Text = title;
  147. ContentText.Text = content;
  148. CancelBtn.Visibility = Visibility.Collapsed;
  149. MiddleCancelBtn.Visibility = Visibility.Collapsed;
  150. OkBtn.Content = okBtn;
  151. Width = 408;
  152. Grid.SetColumn(OkBtn, 3);
  153. BtnGrid.ColumnDefinitions.Clear();
  154. var column = new ColumnDefinition();
  155. var column2 = new ColumnDefinition();
  156. var column3 = new ColumnDefinition();
  157. column.Width = new GridLength(1, GridUnitType.Star);
  158. column2.Width = new GridLength(1, GridUnitType.Star);
  159. column3.Width = new GridLength(1, GridUnitType.Star);
  160. BtnGrid.ColumnDefinitions.Add(column);
  161. BtnGrid.ColumnDefinitions.Add(column2);
  162. BtnGrid.ColumnDefinitions.Add(column3);
  163. if (ownerWindow != null)
  164. {
  165. Owner = ownerWindow;
  166. WindowStartupLocation = WindowStartupLocation.CenterOwner;
  167. ShowDialog();
  168. }
  169. }
  170. public void ShowDialog(string title, string content, string cancelBtn, string okBtn)
  171. {
  172. TitleText.Text = title;
  173. ContentText.Text = content;
  174. CancelBtn.Visibility = Visibility.Collapsed;
  175. MiddleCancelBtn.Content = cancelBtn;
  176. OkBtn.Content = okBtn;
  177. Width = 408;
  178. Grid.SetColumn(MiddleCancelBtn, 1);
  179. Grid.SetColumn(OkBtn, 0);
  180. BtnGrid.ColumnDefinitions.Clear();
  181. var column = new ColumnDefinition();
  182. var column2 = new ColumnDefinition();
  183. column.Width = new GridLength(1, GridUnitType.Star);
  184. column2.Width = new GridLength(1, GridUnitType.Star);
  185. BtnGrid.ColumnDefinitions.Add(column);
  186. BtnGrid.ColumnDefinitions.Add(column2);
  187. if (ownerWindow != null)
  188. {
  189. Owner = ownerWindow;
  190. WindowStartupLocation = WindowStartupLocation.CenterOwner;
  191. ShowDialog();
  192. }
  193. }
  194. public void ShowDialog(string title, string content, string cancelBtn1, string cancelBtn2, string okBtn)
  195. {
  196. TitleText.Text = title;
  197. ContentText.Text = content;
  198. CancelBtn.Visibility = Visibility.Visible;
  199. CancelBtn.Content = cancelBtn1;
  200. MiddleCancelBtn.Content = cancelBtn2;
  201. OkBtn.Content = okBtn;
  202. Grid.SetColumn(CancelBtn, 2);
  203. Grid.SetColumn(MiddleCancelBtn, 1);
  204. Grid.SetColumn(OkBtn, 0);
  205. BtnGrid.ColumnDefinitions.Clear();
  206. var column = new ColumnDefinition();
  207. var column2 = new ColumnDefinition();
  208. var column3 = new ColumnDefinition();
  209. column.Width = new GridLength(1, GridUnitType.Star);
  210. column2.Width = new GridLength(1, GridUnitType.Star);
  211. column3.Width = new GridLength(1, GridUnitType.Star);
  212. BtnGrid.ColumnDefinitions.Add(column);
  213. BtnGrid.ColumnDefinitions.Add(column2);
  214. BtnGrid.ColumnDefinitions.Add(column3);
  215. if (ownerWindow != null)
  216. {
  217. Owner = ownerWindow;
  218. WindowStartupLocation = WindowStartupLocation.CenterOwner;
  219. ShowDialog();
  220. }
  221. }
  222. private void CancelBtn_Click(object sender, RoutedEventArgs e)
  223. {
  224. result = ContentResult.Cancel;
  225. Close();
  226. }
  227. private void MiddleCancelBtn_Click(object sender, RoutedEventArgs e)
  228. {
  229. result = ContentResult.MiddleCancel;
  230. Close();
  231. }
  232. private void OkBtn_Click(object sender, RoutedEventArgs e)
  233. {
  234. result = ContentResult.Ok;
  235. Close();
  236. }
  237. private void Border_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  238. {
  239. this.DragMove();
  240. }
  241. private void ChbDonotAskAgain_Checked(object sender, RoutedEventArgs e)
  242. {
  243. isChecked = true;
  244. }
  245. private void ChbDonotAskAgain_Unchecked(object sender, RoutedEventArgs e)
  246. {
  247. isChecked = false;
  248. }
  249. }
  250. }