Blame view

OS.Spin/OS.Spin.View/MainWindowControls/UCBottom.xaml.cs 2.59 KB
8ca6e89d   Tuo Wenbo   20211021
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  using OS.Spin.Common;
  using System;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Threading;
  
  namespace OS.Spin.View.MainWindowControls
  {
      /// <summary>
      /// UserControlTwo.xaml 的交互逻辑
      /// </summary>
      public partial class UCBottom : UserControl
      {
          public UCBottom()
          {
              InitializeComponent();
          }
          private DispatcherTimer dispatcherTimer = null;
          private void UserControl_Loaded(object sender, RoutedEventArgs e)
          {
              ShowBottmoData();
          }
          /// <summary>
          /// 显示界面最下端数据
          /// </summary>
          private void ShowBottmoData()
          {
              dispatcherTimer = new DispatcherTimer();
              dispatcherTimer.Tick += OnTimerHandler;
              dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);//100毫秒刷新一次
              dispatcherTimer.Start();
          }
  
          /// <summary>
          /// 定时刷新更新窗口底部数据
          /// </summary>
          /// <param name="sender"></param>
          /// <param name="e"></param>
          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));
              }
          }
      }
  }