20240815_FJEQ_upperpc_seabed/FujianEarthquake_seabed_UI/备份/ProSettingView.xaml.cs

70 lines
2.1 KiB
C#
Raw Normal View History

using FujianEarthquake.ViewModels;
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.UserControls
{
/// <summary>
/// ProSettingView.xaml 的交互逻辑
/// </summary>
public partial class ProSettingView : UserControl
{
public ProSettingView()
{
InitializeComponent();
this.DataContext = MainViewModel.shoreBaseStationStatusDataViewModel;
}
private void ProVoltageTB_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
foreach (char c in e.Text)
{
// 判断是否为中文字符
if (Char.IsControl(c) || Char.IsWhiteSpace(c))
{
// 允许输入控制字符和空白字符
continue;
}
else if (c >= 0x4e00 && c <= 0x9fff)
{
// 中文字符范围参考Unicode编码
e.Handled = true; // 标记事件已处理,不再传播
return;
}
}
}
private void ProCurrentTB_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
foreach (char c in e.Text)
{
// 判断是否为中文字符
if (Char.IsControl(c) || Char.IsWhiteSpace(c))
{
// 允许输入控制字符和空白字符
continue;
}
else if (c >= 0x4e00 && c <= 0x9fff)
{
// 中文字符范围参考Unicode编码
e.Handled = true; // 标记事件已处理,不再传播
return;
}
}
}
}
}