wenxiangchao
3 天以前 b544d5cccd76735e034c8055918a50927b437474
Plugin.TestResult/InfoTable.xaml.cs
@@ -114,7 +114,16 @@
            set
            {
                RaiseAndSetIfchanged(ref _consumeTime, value);
                RaisePropertyChanged("consumeTimeStr");
            }
        }
        private double? _leftTime;
        public double? leftTime
        {
            get => _leftTime;
            set
            {
                RaiseAndSetIfchanged(ref _leftTime, value);
            }
        }
@@ -122,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";
            }
        }
@@ -144,6 +189,13 @@
            RaisePropertyChanged("countStr");
        }
        public void UpdateConsumeTime(double consumeTime, double? leftTime)
        {
            this.consumeTime = consumeTime;
            this.leftTime = leftTime;
            RaisePropertyChanged("consumeTimeStr");
        }
        public InfoTable()
        {
            this.DataContext = this;