ntminer 5 rokov pred
rodič
commit
947befa3fd

+ 4 - 1
src/AppModels/MinerStudio/Vms/GpuNameCountsViewModel.cs

@@ -7,7 +7,7 @@ using System.Windows.Input;
 
 namespace NTMiner.MinerStudio.Vms {
     public class GpuNameCountsViewModel : ViewModelBase {
-        private List<GpuNameCountViewModel> _gpuNameCounts;
+        private List<GpuNameCountViewModel> _gpuNameCounts = new List<GpuNameCountViewModel>();
         private int _pageIndex = 1;
         private int _pageSize = 100;
         private string _keyword;
@@ -97,6 +97,9 @@ namespace NTMiner.MinerStudio.Vms {
             get => _gpuNameCounts;
             set {
                 if (_gpuNameCounts != value) {
+                    if (value == null) {
+                        value = new List<GpuNameCountViewModel>();
+                    }
                     _gpuNameCounts = value;
                     OnPropertyChanged(nameof(GpuNameCounts));
                 }

+ 15 - 13
src/NTMinerWpf/Vms/PagingViewModel.cs

@@ -15,21 +15,23 @@ namespace NTMiner.Vms {
         }
 
         public void Init(int total) {
-            this.Total = total;
-            int pages = (int)Math.Ceiling((double)total / _getPageSize());
-            int count = PageNumbers.Count;
-            if (pages < count) {
-                for (int n = pages + 1; n <= count; n++) {
-                    PageNumbers.Remove(n);
+            UIThread.Execute(() => {
+                this.Total = total;
+                int pages = (int)Math.Ceiling((double)total / _getPageSize());
+                int count = PageNumbers.Count;
+                if (pages < count) {
+                    for (int n = pages + 1; n <= count; n++) {
+                        PageNumbers.Remove(n);
+                    }
                 }
-            }
-            else {
-                for (int n = count + 1; n <= pages; n++) {
-                    PageNumbers.Add(n);
+                else {
+                    for (int n = count + 1; n <= pages; n++) {
+                        PageNumbers.Add(n);
+                    }
                 }
-            }
-            OnPropertyChanged(nameof(CanPageSub));
-            OnPropertyChanged(nameof(CanPageAdd));
+                OnPropertyChanged(nameof(CanPageSub));
+                OnPropertyChanged(nameof(CanPageAdd));
+            });
         }
 
         public int Total {