using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; 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 Aitex.Core.UI.MVVM; using Aitex.Triton160.UI.ViewModel; namespace Aitex.Jet.UI.Views { /// /// DiagnoseView.xaml 的交互逻辑 /// public partial class DiagnoseView : UserControl { public DiagnoseView() { InitializeComponent(); this.DataContext = new DiagnoseViewModel(); this.IsVisibleChanged += LeakCheckView_IsVisibleChanged; } private void LeakCheckView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { (this.DataContext as TimerViewModelBase).EnableTimer(this.IsVisible); if (this.IsVisible) (this.DataContext as DiagnoseViewModel).UpdateLeakCheckResult(); } private void OnPreviewTextInput(object sender, TextCompositionEventArgs e) { e.Handled = !IsTextAllowed(e.Text); } private static bool IsTextAllowed(string text) { Regex regex = new Regex("[^0-9.]+"); //regex that matches disallowed text return !regex.IsMatch(text); } } }