alielie
2026-06-04 771a0e7b6b1276087515bbe94de28358cb92963b
Plugin.TestResult/InfoTable.xaml.cs
@@ -1,4 +1,5 @@
using Plugin.TestResult_WPF.Constant;
using HMI.Util;
using Plugin.TestResult_WPF.Constant;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
@@ -66,7 +67,6 @@
            set
            {
                RaiseAndSetIfchanged(ref _okCount, value);
                RefreshCount();
            }
        }
@@ -78,7 +78,6 @@
            set
            {
                RaiseAndSetIfchanged(ref _ngCount, value);
                RefreshCount();
            }
        }
@@ -115,7 +114,16 @@
            set
            {
                RaiseAndSetIfchanged(ref _consumeTime, value);
                RaisePropertyChanged("consumeTimeStr");
            }
        }
        private double? _leftTime;
        public double? leftTime
        {
            get => _leftTime;
            set
            {
                RaiseAndSetIfchanged(ref _leftTime, value);
            }
        }
@@ -123,9 +131,45 @@
        {
            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";
                var str1 = ConvertDurtion(consumeTime);
                if (leftTime != null)
                {
                    str1 += $"/{ConvertDurtion(leftTime.Value)}";
                }
                return str1;
            }
        }
        private string ConvertDurtion(double seconds)
        {
            if (seconds <= 0)
            {
                return "0s";
            }
            if (seconds <= 60)
            {
                return $"{seconds.ToString("f2")}s";
            }
            else if (seconds <= 3600)
            {
                var min = Math.Floor(seconds / 60);
                seconds = seconds % 60;
                if (seconds > 0)
                {
                    return $"{min}m{seconds.ToString("f2")}s";
                }
                return $"{min}m";
            }
            else
            {
                var hour = Math.Floor(seconds / 3600);
                var min = Math.Floor((seconds % 3600) / 60);
                seconds = seconds % 60;
                if (seconds > 0)
                {
                    return $"{hour}h{min}m{seconds.ToString("f2")}s";
                }
                return $"{hour}h{min}m";
            }
        }
@@ -137,13 +181,21 @@
            set => RaiseAndSetIfchanged(ref _endTimeStr, value);
        }
        private void RefreshCount()
        public void UpdateNumber(int ok, int ng)
        {
            this.allCount = this.okCount + this.ngCount;
            this._okCount = ok;
            this._ngCount = ng;
            this._allCount = this._okCount + this._ngCount;
            RaisePropertyChanged("countStr");
        }
        public void UpdateConsumeTime(double consumeTime, double? leftTime)
        {
            this.consumeTime = consumeTime;
            this.leftTime = leftTime;
            RaisePropertyChanged("consumeTimeStr");
        }
        public InfoTable()
        {
            this.DataContext = this;