2024-11-01 08:05:11 +00:00
|
|
|
|
using FujianEarthquake.Common;
|
|
|
|
|
|
using System;
|
2024-10-11 09:26:14 +00:00
|
|
|
|
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;
|
2024-11-01 08:05:11 +00:00
|
|
|
|
|
|
|
|
|
|
//串口号
|
|
|
|
|
|
for (int i = 0; i < Tools.GetSerialPort().Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShorePortName.Items.Add(Tools.GetSerialPort()[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//波特率
|
|
|
|
|
|
string[] btl = new string[] { "110", "300", "600", "1200", "2400", "4800", "9600", "14400", "19200", "38400", "56000", "57600", "115200", "128000", "256000" };
|
|
|
|
|
|
for (int i = 0; i < btl.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShoreBaudRate.Items.Add(btl[i]);
|
|
|
|
|
|
}
|
2024-10-11 09:26:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetVoltageTB_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
|
|
|
|
|
{
|
2024-10-12 09:37:29 +00:00
|
|
|
|
//e.Handled = !IsTextValidForIntegerOrDecimal(e.Text);
|
|
|
|
|
|
|
|
|
|
|
|
string input = e.Text;
|
|
|
|
|
|
if (!char.IsDigit(input[0]) && input != "." && !char.IsControl(input[0]))
|
|
|
|
|
|
{
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
|
}
|
2024-10-11 09:26:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|