ntminer 5 years ago
parent
commit
9412ba8d8c

+ 1 - 1
src/AppModels/MinerStudio/Vms/GpuNameCountPageViewModel.cs

@@ -13,7 +13,7 @@ namespace NTMiner.MinerStudio.Vms {
         public void Refresh() {
             RpcRoot.OfficialServer.GpuNameService.GetGpuNameCountsAsync((response, e) => {
                 if (response.IsSuccess()) {
-                    this.GpuNameCounts = response.Data.Select(a => new GpuNameCountViewModel(a)).ToList();
+                    this.GpuNameCounts = response.Data.OrderBy(a => a.GpuType.GetDescription() + a.Name).Select(a => new GpuNameCountViewModel(a)).ToList();
                 }
                 else {
                     this.GpuNameCounts = new List<GpuNameCountViewModel>();

+ 35 - 0
src/AppModels/MinerStudio/Vms/GpuNameCountViewModel.cs

@@ -1,6 +1,7 @@
 using NTMiner.Core;
 using NTMiner.Core.Gpus;
 using NTMiner.Vms;
+using System.Windows;
 
 namespace NTMiner.MinerStudio.Vms {
     public class GpuNameCountViewModel : ViewModelBase, IGpuNameCount {
@@ -32,10 +33,37 @@ namespace NTMiner.MinerStudio.Vms {
                 if (_gpuType != value) {
                     _gpuType = value;
                     OnPropertyChanged(nameof(GpuType));
+                    OnPropertyChanged(nameof(GpuTypeText));
+                    OnPropertyChanged(nameof(IsAmdVisible));
+                    OnPropertyChanged(nameof(IsNvidiaVisible));
                 }
             }
         }
 
+        public string GpuTypeText {
+            get {
+                return this.GpuType.GetDescription();
+            }
+        }
+
+        public Visibility IsAmdVisible {
+            get {
+                if (this.GpuType == GpuType.AMD) {
+                    return Visibility.Visible;
+                }
+                return Visibility.Collapsed;
+            }
+        }
+
+        public Visibility IsNvidiaVisible {
+            get {
+                if (this.GpuType == GpuType.NVIDIA) {
+                    return Visibility.Visible;
+                }
+                return Visibility.Collapsed;
+            }
+        }
+
         public string Name {
             get => _name;
             set {
@@ -52,10 +80,17 @@ namespace NTMiner.MinerStudio.Vms {
                 if (_totalMemory != value) {
                     _totalMemory = value;
                     OnPropertyChanged(nameof(TotalMemory));
+                    OnPropertyChanged(nameof(TotalMemoryGbText));
                 }
             }
         }
 
+        public string TotalMemoryGbText {
+            get {
+                return GpuName.ConvertToGb(this.TotalMemory) + " G";
+            }
+        }
+
         public bool IsValid() {
             return GpuName.IsValid(this.GpuType, this.Name, this.TotalMemory);
         }

+ 29 - 4
src/AppViews0/MinerStudio/Views/Ucs/GpuNameCountPage.xaml

@@ -12,7 +12,7 @@
     Background="White"
 	mc:Ignorable="d" 
     d:DesignHeight="700" 
-    d:DesignWidth="1200"
+    d:DesignWidth="500"
     d:DataContext="{d:DesignData Source=../Design/GpuNameCountPageViewModel.xaml}">
     <Grid Margin="0 0 0 10" Background="{StaticResource ToolbarBackground}">
 		<DataGrid 
@@ -26,11 +26,36 @@
                 <DataGridTemplateColumn Width="50" IsReadOnly="True" Header="卡型">
                     <DataGridTemplateColumn.CellTemplate>
                         <DataTemplate>
-                            <TextBox Text="{Binding GpuTypeText,Mode=OneWay}"></TextBox>
+                            <WrapPanel>
+                                <Path
+							        Width="20"
+							        Height="16"
+							        Data="{StaticResource Icon_AMD}"
+                                    Visibility="{Binding IsAmdVisible}"
+							        Fill="Red"
+							        Stretch="Fill">
+                                </Path>
+                                <Path
+							        Width="20"
+							        Height="16"
+                                    Visibility="{Binding IsNvidiaVisible}"
+							        Data="{StaticResource Icon_Nvidia}"
+							        Fill="Green"
+							        Stretch="Fill">
+                                </Path>
+                            </WrapPanel>
                         </DataTemplate>
                     </DataGridTemplateColumn.CellTemplate>
                 </DataGridTemplateColumn>
-                <DataGridTemplateColumn Width="150" IsReadOnly="True" Header="名称">
+                <DataGridTemplateColumn Width="*" IsReadOnly="True">
+                    <DataGridTemplateColumn.Header>
+                        <WrapPanel>
+                            <TextBlock>名称</TextBlock>
+                            <TextBlock Margin="8 0 0 0">共</TextBlock>
+                            <TextBlock Margin="4 0 0 0" Text="{Binding Data.GpuNameCounts.Count,Source={StaticResource proxy}}"></TextBlock>
+                            <TextBlock Margin="4 0 0 0">条</TextBlock>
+                        </WrapPanel>
+                    </DataGridTemplateColumn.Header>
                     <DataGridTemplateColumn.CellTemplate>
                         <DataTemplate>
                             <TextBox IsReadOnly="True" BorderThickness="0" Text="{Binding Name,Mode=OneTime}"></TextBox>
@@ -40,7 +65,7 @@
 				<DataGridTemplateColumn Width="100" IsReadOnly="True" Header="显存">
 					<DataGridTemplateColumn.CellTemplate>
 						<DataTemplate>
-							<TextBox Text="{Binding TotalMemoryGbText,Mode=OneWay}"></TextBox>
+                            <TextBlock Text="{Binding TotalMemoryGbText}"></TextBlock>
 						</DataTemplate>
 					</DataGridTemplateColumn.CellTemplate>
                 </DataGridTemplateColumn>

+ 2 - 2
src/AppViews0/MinerStudio/Views/Ucs/GpuNameCountPage.xaml.cs

@@ -10,13 +10,13 @@ namespace NTMiner.MinerStudio.Views.Ucs {
             ContainerWindow.ShowWindow(new ContainerWindowViewModel {
                 Title = "Gpu名称统计",
                 IconName = "Icon_Gpu",
-                Width = 300,
+                Width = 500,
                 Height = 700,
                 IsMaskTheParent = false,
                 IsChildWindow = true,
                 CloseVisible = Visibility.Visible,
                 FooterVisible = Visibility.Collapsed
-            }, ucFactory: (window) => new GpuNameCountPage());
+            }, ucFactory: (window) => new GpuNameCountPage(), fixedSize: true);
         }
 
         public GpuNameCountPageViewModel Vm { get; private set; }

+ 6 - 1
src/NTMinerDataSchemas/Core/Gpus/GpuName.cs

@@ -7,8 +7,13 @@
             return value >= 4 * NTKeyword.ULongG;
         }
 
+        public static int ConvertToGb(ulong totalMemory) {
+            int totalMemoryGb = (int)((totalMemory + NTKeyword.ULongG - 1) / NTKeyword.ULongG);
+            return totalMemoryGb;
+        }
+
         public static string Format(GpuType gpuType, string gpuName, ulong totalMemory) {
-            ulong totalMemoryGb = (totalMemory + NTKeyword.ULongG - 1) / NTKeyword.ULongG;
+            int totalMemoryGb = ConvertToGb(totalMemory);
             // 通常显卡的名称上会带显存大小,比如1060分3G版和6G版所以NVIDIA命名显卡的时候
             // 已经带上了显存信息,但不能假定带了显存信息所以这里拼接上显存信息。
             return $"{gpuType.GetName()}///{gpuName}///{totalMemoryGb.ToString()}";