12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System.Text;
- 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;
- namespace vStationTool
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- private void portNum_PreviewTextInput(object sender, TextCompositionEventArgs e)
- {
- e.Handled = !char.IsDigit(e.Text, e.Text.Length - 1);
- }
- private void ipAddress_PreviewTextInput(object sender, TextCompositionEventArgs e)
- {
- e.Handled = !IsValidIpChar(e.Text);
- }
- private bool IsValidIpChar(string text)
- {
- // 检查是否是数字或.
- return char.IsDigit(text, 0) || text == ".";
- }
- }
- }
|