using OS.Spin.Common; using System; using System.Windows; using System.Windows.Controls; using System.Windows.Threading; namespace OS.Spin.View.MainWindowControls { /// /// UserControlTwo.xaml 的交互逻辑 /// public partial class UCBottom : UserControl { public UCBottom() { InitializeComponent(); } private DispatcherTimer dispatcherTimer = null; private void UserControl_Loaded(object sender, RoutedEventArgs e) { ShowBottmoData(); } /// /// 显示界面最下端数据 /// private void ShowBottmoData() { dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += OnTimerHandler; dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);//每100毫秒刷新一次 dispatcherTimer.Start(); } /// /// 定时刷新更新窗口底部数据 /// /// /// private void OnTimerHandler(object sender, EventArgs e) { try { //当前已检 if (!string.Format("{0} 米", OS.Spin.Running.Cache.GetInstance().CMeter.ToString("N")).Equals(txtCheckedValue.Text)) txtCheckedValue.Text = string.Format("{0} 米", OS.Spin.Running.Cache.GetInstance().CMeter.ToString("N")); //当前速度 if (!txtSpeedValue.Text.Equals(string.Format("{0} 米/分钟", OS.Spin.Running.Cache.GetInstance().Speed.ToString("N")))) txtSpeedValue.Text = string.Format("{0} 米/分钟", OS.Spin.Running.Cache.GetInstance().Speed.ToString("N")); //当前时间 txtDateTimeValue.Text = DateTime.Now.ToLocalTime().ToString(); ////瑕疵数量 if (!OS.Spin.Commands.Controller.GetInstance().FlawCount.ToString().Equals(txtFlawCountValue.Text)) txtFlawCountValue.Text = string.Format("{0}", OS.Spin.Commands.Controller.GetInstance().FlawCount); //总扣分 if (!string.Format(" - {0}", OS.Spin.Commands.Controller.GetInstance().Scores).Equals(txtTotalDeductValue.Text)) txtTotalDeductValue.Text = string.Format(" - {0}", OS.Spin.Commands.Controller.GetInstance().Scores); } catch (Exception ex) { LogisTrac.WriteLog(string.Format("OnTimerHandler:{0}", ex.Message)); } } } }