ntminer 6 years ago
parent
commit
dae24b6e76

+ 0 - 7
src/AppModels/AppContext.partials.CoinKernelViewModels.cs

@@ -46,7 +46,6 @@ namespace NTMiner {
                     action: (message) => {
                         CoinKernelViewModel entity = _dicById[message.Source.GetId()];
                         var supportedGpu = entity.SupportedGpu;
-                        int sortNumber = entity.SortNumber;
                         Guid dualCoinGroupId = entity.DualCoinGroupId;
                         entity.Update(message.Source);
                         if (supportedGpu != entity.SupportedGpu) {
@@ -61,12 +60,6 @@ namespace NTMiner {
                             var kernelVm = entity.Kernel;
                             kernelVm.OnPropertyChanged(nameof(kernelVm.CoinKernels));
                         }
-                        if (sortNumber != entity.SortNumber) {
-                            CoinViewModel coinVm;
-                            if (AppContext.Instance.CoinVms.TryGetCoinVm(entity.CoinId, out coinVm)) {
-                                coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels));
-                            }
-                        }
                     });
                 On<CoinKernelRemovedEvent>("移除了币种内核后刷新VM内存", LogEnum.DevConsole,
                     action: (message) => {

+ 4 - 1
src/AppModels/Vms/CoinKernelSelectViewModel.cs

@@ -62,7 +62,10 @@ namespace NTMiner.Vms {
 
         public List<CoinKernelViewModel> QueryResults {
             get {
-                IQueryable<CoinKernelViewModel> query = Coin.CoinKernels.Where(a => a.Kernel != null && a.IsSupported).OrderBy(a => a.SortNumber).AsQueryable();
+                IQueryable<CoinKernelViewModel> query = Coin.CoinKernels
+                    .Where(a => a.Kernel != null && a.IsSupported)
+                    .OrderBy(a => a.Kernel.Code)
+                    .ThenByDescending(a => a.Kernel.Version).AsQueryable();
                 if (!Design.IsDevMode) {
                     query = query.Where(a => a.Kernel.PublishState == PublishStatus.Published);
                 }

+ 0 - 44
src/AppModels/Vms/CoinKernelViewModel.cs

@@ -10,7 +10,6 @@ namespace NTMiner.Vms {
         private Guid _id;
         private Guid _coinId;
         private Guid _kernelId;
-        private int _sortNumber;
         private Guid _dualCoinGroupId;
         private bool _isSupportPool1;
         private string _args;
@@ -35,8 +34,6 @@ namespace NTMiner.Vms {
 
         public ICommand Remove { get; private set; }
         public ICommand Edit { get; private set; }
-        public ICommand SortUp { get; private set; }
-        public ICommand SortDown { get; private set; }
         public ICommand Save { get; private set; }
 
         public ICommand AddEnvironmentVariable { get; private set; }
@@ -59,7 +56,6 @@ namespace NTMiner.Vms {
         public CoinKernelViewModel(ICoinKernel data) : this(data.GetId()) {
             _coinId = data.CoinId;
             _kernelId = data.KernelId;
-            _sortNumber = data.SortNumber;
             _dualCoinGroupId = data.DualCoinGroupId;
             _args = data.Args;
             _dualFullArgs = data.DualFullArgs;
@@ -147,36 +143,6 @@ namespace NTMiner.Vms {
                     Kernel.OnPropertyChanged(nameof(Kernel.SupportedCoins));
                 }, icon: IconConst.IconConfirm);
             });
-            this.SortUp = new DelegateCommand(() => {
-                CoinKernelViewModel upOne = AppContext.Instance.CoinKernelVms.AllCoinKernels.OrderByDescending(a => a.SortNumber).FirstOrDefault(a => a.CoinId == this.CoinId && a.SortNumber < this.SortNumber);
-                if (upOne != null) {
-                    int sortNumber = upOne.SortNumber;
-                    upOne.SortNumber = this.SortNumber;
-                    VirtualRoot.Execute(new UpdateCoinKernelCommand(upOne));
-                    this.SortNumber = sortNumber;
-                    VirtualRoot.Execute(new UpdateCoinKernelCommand(this));
-                    if (AppContext.Instance.CoinVms.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm)) {
-                        coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels));
-                    }
-                    this.Kernel.OnPropertyChanged(nameof(this.Kernel.CoinKernels));
-                    AppContext.Instance.CoinVms.OnPropertyChanged(nameof(AppContext.CoinViewModels.MainCoins));
-                }
-            });
-            this.SortDown = new DelegateCommand(() => {
-                CoinKernelViewModel nextOne = AppContext.Instance.CoinKernelVms.AllCoinKernels.OrderBy(a => a.SortNumber).FirstOrDefault(a => a.CoinId == this.CoinId && a.SortNumber > this.SortNumber);
-                if (nextOne != null) {
-                    int sortNumber = nextOne.SortNumber;
-                    nextOne.SortNumber = this.SortNumber;
-                    VirtualRoot.Execute(new UpdateCoinKernelCommand(nextOne));
-                    this.SortNumber = sortNumber;
-                    VirtualRoot.Execute(new UpdateCoinKernelCommand(this));
-                    if (AppContext.Instance.CoinVms.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm)) {
-                        coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels));
-                    }
-                    this.Kernel.OnPropertyChanged(nameof(this.Kernel.CoinKernels));
-                    AppContext.Instance.CoinVms.OnPropertyChanged(nameof(AppContext.CoinViewModels.MainCoins));
-                }
-            });
         }
 
         public Guid Id {
@@ -245,16 +211,6 @@ namespace NTMiner.Vms {
             }
         }
 
-        public int SortNumber {
-            get => _sortNumber;
-            set {
-                if (_sortNumber != value) {
-                    _sortNumber = value;
-                    OnPropertyChanged(nameof(SortNumber));
-                }
-            }
-        }
-
         public Guid DualCoinGroupId {
             get => _dualCoinGroupId;
             set {

+ 4 - 1
src/AppModels/Vms/CoinViewModel.cs

@@ -612,7 +612,10 @@ namespace NTMiner.Vms {
 
         public List<CoinKernelViewModel> CoinKernels {
             get {
-                return AppContext.Instance.CoinKernelVms.AllCoinKernels.Where(a => a.CoinId == this.Id && a.Kernel.PublishState == PublishStatus.Published).OrderBy(a => a.SortNumber).ToList();
+                return AppContext.Instance.CoinKernelVms.AllCoinKernels
+                    .Where(a => a.CoinId == this.Id && a.Kernel != null && a.Kernel.PublishState == PublishStatus.Published)
+                    .OrderBy(a => a.Kernel.Code)
+                    .ThenByDescending(a => a.Kernel.Version).ToList();
             }
         }
 

+ 3 - 7
src/AppModels/Vms/KernelViewModel.cs

@@ -205,15 +205,11 @@ namespace NTMiner.Vms {
             }
         }
 
-        public List<KernelViewModel> OtherVersionKernelVms {
-            get {
-                return AppContext.Instance.KernelVms.AllKernels.Where(a => a.Code == this.Code && a.Id != this.Id).OrderBy(a => a.Code + a.Version).ToList();
-            }
-        }
-
         public List<CoinKernelViewModel> CoinKernels {
             get {
-                return AppContext.Instance.CoinKernelVms.AllCoinKernels.Where(a => a.KernelId == this.Id).OrderBy(a => a.SortNumber).ToList();
+                return AppContext.Instance.CoinKernelVms.AllCoinKernels
+                    .Where(a => a.KernelId == this.Id)
+                    .OrderBy(a => a.CoinCode).ToList();
             }
         }
 

+ 2 - 1
src/AppViews0/Ucs/CoinKernelSelect.xaml

@@ -30,7 +30,7 @@
 					Data="{StaticResource Icon_Serach}"></Path>
 				<TextBlock Padding="2 6">搜索</TextBlock>
 				<controls:KbTextBox 
-					x:Name="TbKeyword" Width="154" Height="24"
+					x:Name="TbKeyword" Width="144" Height="24"
 					Text="{Binding Keyword, UpdateSourceTrigger=PropertyChanged}" 
 					VerticalContentAlignment="Center"
 					Hint="请输入想搜索的内核"
@@ -53,6 +53,7 @@
 						Fill="{StaticResource IconFillColor}"
 						Stretch="Fill" />
 				</controls:KbButton>
+                <TextBlock Margin="4 0 0 0" Foreground="Red" VerticalAlignment="Center">按字母表排序</TextBlock>
 			</WrapPanel>
 		</Border>
 		<controls:KbButton 

+ 0 - 96
src/AppViews0/Ucs/CoinPage.xaml

@@ -100,34 +100,6 @@
 												Stretch="Fill" />
 										</WrapPanel>
 									</controls:KbButton>
-									<controls:KbButton 
-										Margin="2 0"
-										Command="{Binding SortDown}" ToolTip="下移" 
-										Background="Transparent" BorderThickness="0"
-										CornerRadius="2">
-										<WrapPanel>
-											<Path
-												Width="8"
-												Height="18"
-												Data="{StaticResource Icon_SortDown}"
-												Fill="{StaticResource IconFillColor}"
-												Stretch="Fill" />
-										</WrapPanel>
-									</controls:KbButton>
-									<controls:KbButton 
-										Margin="2 0"
-										Command="{Binding SortUp}" ToolTip="上移" 
-										Background="Transparent" BorderThickness="0"
-										CornerRadius="2">
-										<WrapPanel>
-											<Path
-												Width="8"
-												Height="18"
-												Data="{StaticResource Icon_SortUp}"
-												Fill="{StaticResource IconFillColor}"
-												Stretch="Fill" />
-										</WrapPanel>
-									</controls:KbButton>
 								</StackPanel>
 							</DataTemplate>
 						</DataGridTemplateColumn.CellTemplate>
@@ -647,34 +619,6 @@
 														Stretch="Fill" />
 												</WrapPanel>
 											</controls:KbButton>
-											<controls:KbButton 
-												Margin="2 0"
-												Command="{Binding SortDown}" ToolTip="下移" 
-												Background="Transparent" BorderThickness="0"
-												CornerRadius="2">
-												<WrapPanel>
-													<Path
-														Width="8"
-														Height="18"
-														Data="{StaticResource Icon_SortDown}"
-														Fill="{StaticResource IconFillColor}"
-														Stretch="Fill" />
-												</WrapPanel>
-											</controls:KbButton>
-											<controls:KbButton 
-												Margin="2 0"
-												Command="{Binding SortUp}" ToolTip="上移" 
-												Background="Transparent" BorderThickness="0"
-												CornerRadius="2">
-												<WrapPanel>
-													<Path
-														Width="8"
-														Height="18"
-														Data="{StaticResource Icon_SortUp}"
-														Fill="{StaticResource IconFillColor}"
-														Stretch="Fill" />
-												</WrapPanel>
-											</controls:KbButton>
 										</StackPanel>
 									</DataTemplate>
 								</DataGridTemplateColumn.CellTemplate>
@@ -749,18 +693,6 @@
 									</DataTemplate>
 								</DataGridTemplateColumn.CellTemplate>
 							</DataGridTemplateColumn>
-							<DataGridTemplateColumn 
-								Visibility="{x:Static app:AppStatic.IsDebugModeVisible}"
-								IsReadOnly="True">
-								<DataGridTemplateColumn.Header>
-									<TextBlock Text="排序"></TextBlock>
-								</DataGridTemplateColumn.Header>
-								<DataGridTemplateColumn.CellTemplate>
-									<DataTemplate>
-										<TextBlock Text="{Binding SortNumber}"></TextBlock>
-									</DataTemplate>
-								</DataGridTemplateColumn.CellTemplate>
-							</DataGridTemplateColumn>
 							<DataGridTemplateColumn Width="*" IsReadOnly="True">
 								<DataGridTemplateColumn.Header>
 									<TextBlock Text="币种级参数"></TextBlock>
@@ -791,34 +723,6 @@
 								    Stretch="Fill" />
                             </WrapPanel>
                         </controls:KbButton>
-                        <controls:KbButton 
-							Margin="2 0"
-							Command="{Binding CurrentCoinKernel.SortDown}" ToolTip="下移" 
-							Background="Transparent" BorderThickness="0"
-							CornerRadius="2">
-                            <WrapPanel>
-                                <Path
-									Width="8"
-									Height="18"
-									Data="{StaticResource Icon_SortDown}"
-									Fill="{StaticResource IconFillColor}"
-									Stretch="Fill" />
-                            </WrapPanel>
-                        </controls:KbButton>
-                        <controls:KbButton 
-							Margin="2 0"
-							Command="{Binding CurrentCoinKernel.SortUp}" ToolTip="上移" 
-							Background="Transparent" BorderThickness="0"
-							CornerRadius="2">
-                            <WrapPanel>
-                                <Path
-									Width="8"
-									Height="18"
-									Data="{StaticResource Icon_SortUp}"
-									Fill="{StaticResource IconFillColor}"
-									Stretch="Fill" />
-                            </WrapPanel>
-                        </controls:KbButton>
                     </WrapPanel>
 					<Popup 
 						x:Name="PopupKernel" 

+ 1 - 3
src/AppViews0/Ucs/CoinPage.xaml.cs

@@ -80,12 +80,10 @@ namespace NTMiner.Views.Ucs {
             PopupKernel.Child = new KernelSelect(
                 new KernelSelectViewModel(coinVm, null, onOk: selectedResult => {
                     if (selectedResult != null) {
-                        int sortNumber = coinVm.CoinKernels.Count == 0 ? 1 : coinVm.CoinKernels.Max(a => a.SortNumber) + 1;
                         VirtualRoot.Execute(new AddCoinKernelCommand(new CoinKernelViewModel(Guid.NewGuid()) {
                             Args = string.Empty,
                             CoinId = coinVm.Id,
-                            KernelId = selectedResult.Id,
-                            SortNumber = sortNumber
+                            KernelId = selectedResult.Id
                         }));
                         PopupKernel.IsOpen = false;
                     }

+ 1 - 3
src/AppViews0/Ucs/KernelEdit.xaml.cs

@@ -70,12 +70,10 @@ namespace NTMiner.Views.Ucs {
                     if (selectedResult == null || selectedResult.Id == Guid.Empty) {
                         return;
                     }
-                    int sortNumber = selectedResult.CoinKernels.Count == 0 ? 1 : selectedResult.CoinKernels.Max(a => a.SortNumber) + 1;
                     VirtualRoot.Execute(new AddCoinKernelCommand(new CoinKernelViewModel(Guid.NewGuid()) {
                         Args = string.Empty,
                         CoinId = selectedResult.Id,
-                        KernelId = Vm.Id,
-                        SortNumber = sortNumber
+                        KernelId = Vm.Id
                     }));
                     PopupKernel.IsOpen = false;
                 }) {

+ 1 - 1
src/NTMiner.Core/Core/Profiles/MinerProfile.partials.CoinProfileSet.cs

@@ -60,7 +60,7 @@ namespace NTMiner.Core.Profiles {
                             }
                             string wallet = coin.TestWallet;
                             Guid coinKernelId = Guid.Empty;
-                            ICoinKernel coinKernel = root.CoinKernelSet.OrderBy(a => a.SortNumber).FirstOrDefault(a => a.CoinId == coinId);
+                            ICoinKernel coinKernel = root.CoinKernelSet.FirstOrDefault(a => a.CoinId == coinId);
                             if (coinKernel != null) {
                                 coinKernelId = coinKernel.GetId();
                             }

+ 0 - 2
src/NTMinerDataObjects/Core/CoinKernelData.cs

@@ -24,8 +24,6 @@ namespace NTMiner.Core {
 
         public bool IsSupportPool1 { get; set; }
 
-        public int SortNumber { get; set; }
-
         public Guid DualCoinGroupId { get; set; }
 
         public string Args { get; set; }

+ 0 - 1
src/NTMinerDataObjects/Core/ICoinKernel.cs

@@ -5,7 +5,6 @@ namespace NTMiner.Core {
     public interface ICoinKernel : IEntity<Guid> {
         Guid CoinId { get; }
         Guid KernelId { get; }
-        int SortNumber { get; }
         string Args { get; }
         string DualFullArgs { get; }
         Guid DualCoinGroupId { get; }