CodeRegion.xaml.cs 5.5 KB

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