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.Triton160.UI.Views { /// /// Interaction logic for DiagnosticsView.xaml /// public partial class LeakCheckView : UserControl { public LeakCheckView() { InitializeComponent(); this.DataContext = new LeakCheckViewModel(); 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 LeakCheckViewModel).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); } } }