UserOutCodeRegion.xaml.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 == 0)
  40. {
  41. text_Code1.Focus();
  42. }
  43. else if (text_Code1.Text.Length > 1)
  44. {
  45. text_Code1.Text = text_Code1.Text.Substring(0, 1);
  46. text_Code1.Focus();
  47. }
  48. }
  49. private void text_Code2_TextChanged(object sender, TextChangedEventArgs e)
  50. {
  51. if (text_Code2.Text.Length >= 1)
  52. {
  53. text_Code3.Focus();
  54. }
  55. else if (text_Code2.Text.Length == 0)
  56. {
  57. text_Code1.Focus();
  58. }
  59. else if (text_Code2.Text.Length > 1)
  60. {
  61. text_Code2.Text = text_Code2.Text.Substring(0, 1);
  62. text_Code2.Focus();
  63. }
  64. }
  65. private void text_Code3_TextChanged(object sender, TextChangedEventArgs e)
  66. {
  67. if (text_Code3.Text.Length >= 1)
  68. {
  69. text_Code4.Focus();
  70. }
  71. else if (text_Code3.Text.Length == 0)
  72. {
  73. text_Code2.Focus();
  74. }
  75. else if (text_Code3.Text.Length > 1)
  76. {
  77. text_Code3.Text = text_Code3.Text.Substring(0, 1);
  78. text_Code3.Focus();
  79. }
  80. }
  81. private void text_Code4_TextChanged(object sender, TextChangedEventArgs e)
  82. {
  83. if (this.text_Code4.Text.Length >= 1)
  84. {
  85. this.text_Code5.Focus();
  86. }
  87. else if (text_Code4.Text.Length == 0)
  88. {
  89. text_Code3.Focus();
  90. }
  91. else if (text_Code4.Text.Length > 1)
  92. {
  93. text_Code4.Text = text_Code4.Text.Substring(0, 1);
  94. text_Code4.Focus();
  95. }
  96. }
  97. private void text_Code5_TextChanged(object sender, TextChangedEventArgs e)
  98. {
  99. if (this.text_Code5.Text.Length == 1)
  100. {
  101. this.text_Code6.Focus();
  102. }
  103. else if (text_Code5.Text.Length == 0)
  104. {
  105. text_Code4.Focus();
  106. }
  107. else if (text_Code5.Text.Length > 1)
  108. {
  109. text_Code5.Text = text_Code5.Text.Substring(0, 1);
  110. text_Code5.Focus();
  111. }
  112. }
  113. private void text_Code6_TextChanged(object sender, TextChangedEventArgs e)
  114. {
  115. if (this.text_Code6.Text.Length == 1)
  116. {
  117. text_Code6.Focus();
  118. }
  119. else if (text_Code6.Text.Length == 0)
  120. {
  121. text_Code5.Focus();
  122. }
  123. else if (text_Code6.Text.Length > 1)
  124. {
  125. text_Code6.Text = text_Code6.Text.Substring(0, 1);
  126. text_Code6.Focus();
  127. }
  128. }
  129. }
  130. }