alielie
2025-03-03 21e28b068c8d0763a6d4ab613388a77a0db157fb
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
using Plugin.TestResult_WPF.Constant;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Controls;
 
namespace Plugin.TestResult_WPF
{
    /// <summary>
    /// InfoTable.xaml 的交互逻辑
    /// </summary>
    public partial class InfoTable : UserControl, INotifyPropertyChanged
    {
 
        #region ...
        public event PropertyChangedEventHandler PropertyChanged;
 
        public virtual void RaisePropertyChanged(string name)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
 
        public void RaiseAndSetIfchanged<T>(ref T old, T @new, [CallerMemberName] string propertyName = null)
        {
            old = @new;
            if (propertyName != null) RaisePropertyChanged(propertyName);
        }
        #endregion
 
        private double _temperature;
        public double temperature
        {
            get => _temperature;
            set
            {
                RaiseAndSetIfchanged(ref _temperature, value);
                RaisePropertyChanged("temperatureStr");
            }
        }
 
        public string temperatureStr
        {
            get => $"{_temperature.ToString("f2")}℃";
        }
 
        private string _status;
        public string status
        {
            get => _status;
            set
            {
                RaiseAndSetIfchanged(ref _status, value);
                RaisePropertyChanged("statusStr");
            }
        }
 
        public string statusStr
        {
            get => status != null && CommonStatus.STATUS_MAP.ContainsKey(status) ? CommonStatus.STATUS_MAP[status] : "";
        }
 
        private int _okCount;
        public int okCount
        {
            get => _okCount;
            set
            {
                RaiseAndSetIfchanged(ref _okCount, value);
                RefreshCount();
            }
        }
 
        private int _ngCount;
 
        public int ngCount
        {
            get => _ngCount;
            set
            {
                RaiseAndSetIfchanged(ref _ngCount, value);
                RefreshCount();
            }
        }
 
        private int _allCount;
 
        public int allCount
        {
            get => _allCount;
            set
            {
                RaiseAndSetIfchanged(ref _allCount, value);
            }
        }
 
        public string countStr
        {
            get => $"OK:{okCount},NG:{ngCount},ALL:{allCount}";
        }
 
        private string _startTimeStr;
        public string startTimeStr
        {
            get => _startTimeStr;
            set
            {
                RaiseAndSetIfchanged(ref _startTimeStr, value);
            }
        }
 
        private double _consumeTime;
        public double consumeTime
        {
            get => _consumeTime;
            set
            {
                RaiseAndSetIfchanged(ref _consumeTime, value);
                RaisePropertyChanged("consumeTimeStr");
            }
        }
 
        public string consumeTimeStr
        {
            get
            {
                if (consumeTime < 60) return $"{consumeTime.ToString("f2")}s";
                else if (consumeTime < 3600) return $"{Math.Floor(consumeTime / 60)}m{(consumeTime % 60).ToString("f2")}s";
                return $"{Math.Floor(consumeTime / 3600)}h{Math.Floor((consumeTime % 3600) / 60)}m{(consumeTime % 60).ToString("f2")}s";
            }
        }
 
        private string _endTimeStr;
 
        public string endTimeStr
        {
            get => _endTimeStr;
            set => RaiseAndSetIfchanged(ref _endTimeStr, value);
        }
 
 
        private void RefreshCount()
        {
            this.allCount = this.okCount + this.ngCount;
            RaisePropertyChanged("countStr");
        }
 
        public InfoTable()
        {
            this.DataContext = this;
            InitializeComponent();
        }
    }
}