CodeRegion.xaml.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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 CodeRegion : UserControl
  23. {
  24. public CodeRegion()
  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_RegisterVis.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_RegisterVis.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_RegisterVis.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_RegisterVis.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_RegisterVis.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_RegisterVis.Visibility = Visibility.Collapsed;
  126. if (this.text_Code6.Text.Length == 1)
  127. {
  128. text_Code6.Focus();
  129. }
  130. else
  131. if(text_Code6.Text.Length >1)
  132. {
  133. string str = text_Code6.Text;
  134. text_Code6.Focus();
  135. text_Code6.Text = str.Substring(0, 1);
  136. }
  137. }
  138. private void text_Code1_KeyUp(object sender, KeyEventArgs e)
  139. {
  140. if (e.Key == Key.Back)
  141. {
  142. text_Code1.Text = "";
  143. text_Code1.Focus();
  144. }
  145. }
  146. private void text_Code2_KeyUp(object sender, KeyEventArgs e)
  147. {
  148. if (e.Key == Key.Back)
  149. {
  150. text_Code2.Text = "";
  151. text_Code1.Focus();
  152. }
  153. }
  154. private void text_Code3_KeyUp(object sender, KeyEventArgs e)
  155. {
  156. if (e.Key == Key.Back )
  157. {
  158. text_Code3.Text = "";
  159. text_Code2.Focus();
  160. }
  161. }
  162. private void text_Code4_KeyUp(object sender, KeyEventArgs e)
  163. {
  164. if (e.Key == Key.Back )
  165. {
  166. text_Code4.Text = "";
  167. text_Code3.Focus();
  168. }
  169. }
  170. private void text_Code5_KeyUp(object sender, KeyEventArgs e)
  171. {
  172. if (e.Key == Key.Back )
  173. {
  174. text_Code5.Text = "";
  175. text_Code4.Focus();
  176. }
  177. }
  178. private void text_Code6_KeyUp(object sender, KeyEventArgs e)
  179. {
  180. if (e.Key == Key.Back )
  181. {
  182. text_Code6.Text = "";
  183. text_Code5.Focus();
  184. }
  185. }
  186. }
  187. }