@@ -40,6 +40,8 @@ public MainWindowViewModel()
4040 _random = new Random ( ) ;
4141 }
4242
43+ #region Buttons
44+
4345 private bool CanStart => ! IsCompleted ;
4446
4547 [ RelayCommand ( CanExecute = nameof ( CanStart ) ) ]
@@ -77,6 +79,9 @@ private void Restart()
7779 Start ( ) ;
7880 }
7981
82+ #endregion
83+
84+
8085 private void UpdateProgress ( object ? sender , EventArgs e )
8186 {
8287 var received = Statistics . BytesReceived ;
@@ -95,7 +100,7 @@ private void UpdateProgress(object? sender, EventArgs e)
95100 Statistics . ProgressPercentage = ( double ) received / total * 100 ;
96101
97102 var currentSpeed = increment / _timer . Interval . TotalSeconds ;
98- Statistics . Speed = $ "{ currentSpeed / 1024 / 1024 : F1 } MB/s";
103+ Statistics . Speed = $ "{ currentSpeed / 1024 / 1024 : F2 } MB/s";
99104
100105 var remainingBytes = total - received ;
101106 Statistics . Remaining = TimeSpan . FromSeconds ( remainingBytes / currentSpeed ) ;
@@ -123,12 +128,15 @@ [ObservableProperty] [Description("下载速度")]
123128 [ ObservableProperty ] [ Description ( "剩余下载时间" ) ]
124129 private TimeSpan _remaining ;
125130
126- [ ObservableProperty ] [ Description ( "已下载大小" ) ]
131+ [ ObservableProperty ] [ Description ( "总大小" ) ] [ NotifyPropertyChangedFor ( nameof ( TotalBytesToReceiveInMB ) ) ]
127132 private long _totalBytesToReceive ;
128133
129- [ ObservableProperty ] [ Description ( "总大小" ) ]
134+ [ ObservableProperty ] [ Description ( "已下载大小" ) ] [ NotifyPropertyChangedFor ( nameof ( BytesReceivedInMB ) ) ]
130135 private long _bytesReceived ;
131136
132137 [ ObservableProperty ] [ Description ( "进度百分比" ) ]
133138 private double _progressPercentage ;
139+
140+ public double BytesReceivedInMB => ( double ) BytesReceived / 1024 / 1024 ;
141+ public double TotalBytesToReceiveInMB => ( double ) TotalBytesToReceive / 1024 / 1024 ;
134142}
0 commit comments