UserOutCodeRegion.xaml.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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.Navigation;
  14. using System.Windows.Shapes;
  15. using Prism.Ioc;
  16. using Prism.Regions;
  17. namespace PDF_Office.Views.Dialog.ServiceDialog
  18. {
  19. /// <summary>
  20. /// CodeRegion.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class UserOutCodeRegion : UserControl
  23. {
  24. public UserOutCodeRegion()
  25. {
  26. InitializeComponent();
  27. Loaded += Focus_Loaded;
  28. }
  29. private void Focus_Loaded(object sender, RoutedEventArgs e)
  30. {
  31. text_Code1.Focus();
  32. }
  33. private void Code_TextChanged(object sender, TextChangedEventArgs e)
  34. {
  35. Grid_UserCodemsgVis.Visibility = Visibility.Collapsed;
  36. if (text_Code1.Text.Length == 1)
  37. {
  38. text_Code2.Focus();
  39. }
  40. else if (text_Code1.Text.Length > 1)
  41. {
  42. string str = text_Code1.Text;
  43. text_Code1.Text = str.Substring(0, 1);
  44. str = str.Remove(0, 1);
  45. if (str.Length > 0)
  46. {
  47. text_Code2.Text = str;
  48. }
  49. }
  50. }
  51. private void text_Code2_TextChanged(object sender, TextChangedEventArgs e)
  52. {
  53. Grid_UserCodemsgVis.Visibility = Visibility.Collapsed;
  54. if (text_Code2.Text.Length == 1)
  55. {
  56. text_Code3.Focus();
  57. }
  58. else if (text_Code2.Text.Length > 1)
  59. {
  60. string str = text_Code2.Text;
  61. text_Code2.Text = str.Substring(0, 1);
  62. str = str.Remove(0, 1);
  63. if (str.Length > 0)
  64. {
  65. text_Code3.Text = str;
  66. }
  67. }
  68. }
  69. private void text_Code3_TextChanged(object sender, TextChangedEventArgs e)
  70. {
  71. Grid_UserCodemsgVis.Visibility = Visibility.Collapsed;
  72. if (text_Code3.Text.Length == 1)
  73. {
  74. text_Code4.Focus();
  75. }
  76. else if (text_Code3.Text.Length > 1)
  77. {
  78. string str = text_Code3.Text;
  79. text_Code3.Text = str.Substring(0, 1);
  80. str = str.Remove(0, 1);
  81. if (str.Length > 0)
  82. {
  83. text_Code4.Text = str;
  84. }
  85. }
  86. }
  87. private void text_Code4_TextChanged(object sender, TextChangedEventArgs e)
  88. {
  89. Grid_UserCodemsgVis.Visibility = Visibility.Collapsed;
  90. if (this.text_Code4.Text.Length == 1)
  91. {
  92. this.text_Code5.Focus();
  93. }
  94. else if (text_Code4.Text.Length > 1)
  95. {
  96. string str = text_Code4.Text;
  97. text_Code4.Text = str.Substring(0, 1);
  98. str = str.Remove(0, 1);
  99. if (str.Length > 0)
  100. {
  101. text_Code5.Text = str;
  102. }
  103. }
  104. }
  105. private void text_Code5_TextChanged(object sender, TextChangedEventArgs e)
  106. {
  107. Grid_UserCodemsgVis.Visibility = Visibility.Collapsed;
  108. if (this.text_Code5.Text.Length == 1)
  109. {
  110. this.text_Code6.Focus();
  111. }
  112. else if (text_Code5.Text.Length > 1)
  113. {
  114. string str = text_Code5.Text;
  115. text_Code5.Text = str.Substring(0, 1);
  116. str = str.Remove(0, 1);
  117. if (str.Length > 0)
  118. {
  119. text_Code6.Text = str;
  120. }
  121. }
  122. }
  123. private void text_Code6_TextChanged(object sender, TextChangedEventArgs e)
  124. {
  125. Grid_UserCodemsgVis.Visibility = Visibility.Collapsed;
  126. if (this.text_Code6.Text.Length == 1)
  127. {
  128. text_Code6.Focus();
  129. }
  130. else if (text_Code6.Text.Length > 1)
  131. {
  132. string str = text_Code6.Text;
  133. text_Code6.Focus();
  134. text_Code6.Text = str.Substring(0, 1);
  135. }
  136. }
  137. private void text_Code1_KeyUp(object sender, KeyEventArgs e)
  138. {
  139. if (e.Key == Key.Back)
  140. {
  141. text_Code1.Text = "";
  142. text_Code1.Focus();
  143. }
  144. }
  145. private void text_Code2_KeyUp(object sender, KeyEventArgs e)
  146. {
  147. if (e.Key == Key.Back)
  148. {
  149. text_Code2.Text = "";
  150. text_Code1.Focus();
  151. }
  152. }
  153. private void text_Code3_KeyUp(object sender, KeyEventArgs e)
  154. {
  155. if (e.Key == Key.Back)
  156. {
  157. text_Code3.Text = "";
  158. text_Code2.Focus();
  159. }
  160. }
  161. private void text_Code4_KeyUp(object sender, KeyEventArgs e)
  162. {
  163. if (e.Key == Key.Back)
  164. {
  165. text_Code4.Text = "";
  166. text_Code3.Focus();
  167. }
  168. }
  169. private void text_Code5_KeyUp(object sender, KeyEventArgs e)
  170. {
  171. if (e.Key == Key.Back)
  172. {
  173. text_Code5.Text = "";
  174. text_Code4.Focus();
  175. }
  176. }
  177. private void text_Code6_KeyUp(object sender, KeyEventArgs e)
  178. {
  179. if (e.Key == Key.Back)
  180. {
  181. text_Code6.Text = "";
  182. text_Code5.Focus();
  183. }
  184. }
  185. }
  186. }