123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using Prism.Ioc;
- using Prism.Regions;
- namespace PDF_Master.Views.Dialog.ServiceDialog
- {
- /// <summary>
- /// CodeRegion.xaml 的交互逻辑
- /// </summary>
- public partial class CodeRegion : UserControl
- {
- public CodeRegion()
- {
- InitializeComponent();
- Loaded += Focus_Loaded;
-
-
- }
- private void Focus_Loaded(object sender, RoutedEventArgs e)
- {
- text_Code1.Focus();
- }
- private void Code_TextChanged(object sender, TextChangedEventArgs e)
- {
- Grid_RegisterVis.Visibility = Visibility.Collapsed;
- text_Code1.Select(text_Code1.Text.Length, 0);
- if (text_Code1.Text.Length == 1)
- {
- text_Code2.Focus();
- }
- else if (text_Code1.Text.Length > 1)
- {
- string str = text_Code1.Text;
- text_Code1.Text = str.Substring(0, 1);
- str = str.Remove(0, 1);
- if (str.Length > 0)
- {
- text_Code2.Text = str;
- }
- }
- }
- private void text_Code2_TextChanged(object sender, TextChangedEventArgs e)
- {
- Grid_RegisterVis.Visibility = Visibility.Collapsed;
- text_Code2.Select(text_Code2.Text.Length, 0);
- if (text_Code2.Text.Length == 1)
- {
- text_Code3.Focus();
- }
- else if (text_Code2.Text.Length > 1)
- {
- string str = text_Code2.Text;
- text_Code2.Text = str.Substring(0, 1);
- str = str.Remove(0, 1);
- if (str.Length > 0)
- {
- text_Code3.Text = str;
- }
- }
- }
- private void text_Code3_TextChanged(object sender, TextChangedEventArgs e)
- {
- Grid_RegisterVis.Visibility = Visibility.Collapsed;
- text_Code3.Select(text_Code3.Text.Length, 0);
- if (text_Code3.Text.Length == 1)
- {
- text_Code4.Focus();
- }
- else if (text_Code3.Text.Length > 1)
- {
- string str = text_Code3.Text;
- text_Code3.Text = str.Substring(0, 1);
- str = str.Remove(0, 1);
- if (str.Length > 0)
- {
- text_Code4.Text = str;
- }
- }
- }
- private void text_Code4_TextChanged(object sender, TextChangedEventArgs e)
- {
- Grid_RegisterVis.Visibility = Visibility.Collapsed;
- text_Code4.Select(text_Code4.Text.Length, 0);
- if (this.text_Code4.Text.Length == 1)
- {
- this.text_Code5.Focus();
- }
- else if (text_Code4.Text.Length > 1)
- {
- string str = text_Code4.Text;
- text_Code4.Text = str.Substring(0, 1);
- str = str.Remove(0, 1);
- if (str.Length > 0)
- {
- text_Code5.Text = str;
- }
- }
- }
- private void text_Code5_TextChanged(object sender, TextChangedEventArgs e)
- {
- Grid_RegisterVis.Visibility = Visibility.Collapsed;
- text_Code5.Select(text_Code5.Text.Length, 0);
- if (this.text_Code5.Text.Length == 1)
- {
- this.text_Code6.Focus();
- }
- else if (text_Code5.Text.Length > 1)
- {
- string str = text_Code5.Text;
- text_Code5.Text = str.Substring(0, 1);
- str = str.Remove(0, 1);
- if (str.Length > 0)
- {
- text_Code6.Text = str;
- }
- }
- }
- private void text_Code6_TextChanged(object sender, TextChangedEventArgs e)
- {
- Grid_RegisterVis.Visibility = Visibility.Collapsed;
- text_Code6.Select(text_Code6.Text.Length, 0);
- if (this.text_Code6.Text.Length == 1)
- {
- text_Code6.Focus();
- }
- else if (text_Code6.Text.Length > 1)
- {
- string str = text_Code6.Text;
- text_Code6.Focus();
- text_Code6.Text = str.Substring(0, 1);
- }
- }
- private void text_Code1_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Back)
- {
- text_Code1.Text = "";
- text_Code1.Focus();
- }
- }
- private void text_Code2_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Back)
- {
- text_Code2.Text = "";
- text_Code1.Focus();
- text_Code1.Select(text_Code1.Text.Length, 0);
- }
- }
- private void text_Code3_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Back)
- {
- text_Code3.Text = "";
- text_Code2.Focus();
- text_Code2.Select(text_Code2.Text.Length, 0);
- }
- }
- private void text_Code4_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Back)
- {
- text_Code4.Text = "";
- text_Code3.Focus();
- text_Code3.Select(text_Code3.Text.Length, 0);
- }
- }
- private void text_Code5_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Back)
- {
- text_Code5.Text = "";
- text_Code4.Focus();
- text_Code4.Select(text_Code4.Text.Length, 0);
- }
- }
- private void text_Code6_KeyUp(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Back)
- {
- text_Code6.Text = "";
- text_Code5.Focus();
- text_Code5.Select(text_Code5.Text.Length, 0);
- }
- }
- private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
- {
- e.Handled = new Regex("[^0-9]+").IsMatch(e.Text);
- }
- }
- }
|