68 lines
1.8 KiB
C#
68 lines
1.8 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
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;
|
|||
|
|
|
|||
|
|
namespace FujianEarthquake.Views
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// SystemControlView.xaml 的交互逻辑
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class SystemControlView : UserControl
|
|||
|
|
{
|
|||
|
|
public SystemControlView()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
|
|||
|
|
this.DataContext = MainWindow.mainViewModel;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SetVoltageTB_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
|||
|
|
{
|
|||
|
|
e.Handled = !IsTextValidForIntegerOrDecimal(e.Text);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SetCurrentTB_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
|||
|
|
{
|
|||
|
|
e.Handled = !IsTextValidForIntegerOrDecimal(e.Text);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ProVoltageTB_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
|||
|
|
{
|
|||
|
|
e.Handled = !IsTextValidForIntegerOrDecimal(e.Text);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ProCurrentTB_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
|||
|
|
{
|
|||
|
|
e.Handled = !IsTextValidForIntegerOrDecimal(e.Text);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private bool IsTextValidForIntegerOrDecimal(string text)
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(text))
|
|||
|
|
return false;
|
|||
|
|
|
|||
|
|
foreach (char c in text)
|
|||
|
|
{
|
|||
|
|
if (char.IsControl(c) || c == '.')
|
|||
|
|
continue;
|
|||
|
|
|
|||
|
|
if (!char.IsDigit(c))
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|