UserOutCodeRegion.xaml.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. if (text_Code1.Text.Length == 1)
  36. {
  37. text_Code2.Focus();
  38. }
  39. else if (text_Code1.Text.Length > 1)
  40. {
  41. string str = text_Code1.Text;
  42. text_Code1.Text = str.Substring(0, 1);
  43. str = str.Remove(0, 1);
  44. if (str.Length > 0)
  45. {
  46. text_Code2.Text = str;
  47. }
  48. }
  49. }
  50. private void text_Code2_TextChanged(object sender, TextChangedEventArgs e)
  51. {
  52. if (text_Code2.Text.Length == 1)
  53. {
  54. text_Code3.Focus();
  55. }
  56. else if (text_Code2.Text.Length > 1)
  57. {
  58. string str = text_Code2.Text;
  59. text_Code2.Text = str.Substring(0, 1);
  60. str = str.Remove(0, 1);
  61. if (str.Length > 0)
  62. {
  63. text_Code3.Text = str;
  64. }
  65. }
  66. }
  67. private void text_Code3_TextChanged(object sender, TextChangedEventArgs e)
  68. {
  69. if (text_Code3.Text.Length == 1)
  70. {
  71. text_Code4.Focus();
  72. }
  73. else if (text_Code3.Text.Length > 1)
  74. {
  75. string str = text_Code3.Text;
  76. text_Code3.Text = str.Substring(0, 1);
  77. str = str.Remove(0, 1);
  78. if (str.Length > 0)
  79. {
  80. text_Code4.Text = str;
  81. }
  82. }
  83. }
  84. private void text_Code4_TextChanged(object sender, TextChangedEventArgs e)
  85. {
  86. if (this.text_Code4.Text.Length == 1)
  87. {
  88. this.text_Code5.Focus();
  89. }
  90. else if (text_Code4.Text.Length > 1)
  91. {
  92. string str = text_Code4.Text;
  93. text_Code4.Text = str.Substring(0, 1);
  94. str = str.Remove(0, 1);
  95. if (str.Length > 0)
  96. {
  97. text_Code5.Text = str;
  98. }
  99. }
  100. }
  101. private void text_Code5_TextChanged(object sender, TextChangedEventArgs e)
  102. {
  103. if (this.text_Code5.Text.Length == 1)
  104. {
  105. this.text_Code6.Focus();
  106. }
  107. else if (text_Code5.Text.Length > 1)
  108. {
  109. string str = text_Code5.Text;
  110. text_Code5.Text = str.Substring(0, 1);
  111. str = str.Remove(0, 1);
  112. if (str.Length > 0)
  113. {
  114. text_Code6.Text = str;
  115. }
  116. }
  117. }
  118. private void text_Code6_TextChanged(object sender, TextChangedEventArgs e)
  119. {
  120. if (this.text_Code6.Text.Length == 1)
  121. {
  122. text_Code6.Focus();
  123. }
  124. else if (text_Code6.Text.Length > 1)
  125. {
  126. string str = text_Code6.Text;
  127. text_Code6.Focus();
  128. text_Code6.Text = str.Substring(0, 1);
  129. }
  130. }
  131. private void text_Code1_KeyUp(object sender, KeyEventArgs e)
  132. {
  133. if (e.Key == Key.Back)
  134. {
  135. text_Code1.Text = "";
  136. text_Code1.Focus();
  137. }
  138. }
  139. private void text_Code2_KeyUp(object sender, KeyEventArgs e)
  140. {
  141. if (e.Key == Key.Back)
  142. {
  143. text_Code2.Text = "";
  144. text_Code1.Focus();
  145. }
  146. }
  147. private void text_Code3_KeyUp(object sender, KeyEventArgs e)
  148. {
  149. if (e.Key == Key.Back)
  150. {
  151. text_Code3.Text = "";
  152. text_Code2.Focus();
  153. }
  154. }
  155. private void text_Code4_KeyUp(object sender, KeyEventArgs e)
  156. {
  157. if (e.Key == Key.Back)
  158. {
  159. text_Code4.Text = "";
  160. text_Code3.Focus();
  161. }
  162. }
  163. private void text_Code5_KeyUp(object sender, KeyEventArgs e)
  164. {
  165. if (e.Key == Key.Back)
  166. {
  167. text_Code5.Text = "";
  168. text_Code4.Focus();
  169. }
  170. }
  171. private void text_Code6_KeyUp(object sender, KeyEventArgs e)
  172. {
  173. if (e.Key == Key.Back)
  174. {
  175. text_Code6.Text = "";
  176. text_Code5.Focus();
  177. }
  178. }
  179. }
  180. }