예제 #1
0
 public CoinKernelViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (NTMinerRoot.Current.CoinKernelSet.Contains(this.Id))
         {
             Global.Execute(new UpdateCoinKernelCommand(this));
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand(() => {
         CoinKernelEdit.ShowEditWindow(this);
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         DialogWindow.ShowDialog(message: $"您确定删除{Kernel.Code}币种内核吗?", title: "确认", onYes: () => {
             Global.Execute(new RemoveCoinKernelCommand(this.Id));
             Kernel.OnPropertyChanged(nameof(Kernel.SupportedCoins));
         }, icon: "Icon_Confirm");
     });
     this.SortUp = new DelegateCommand(() => {
         CoinKernelViewModel upOne = CoinKernelViewModels.Current.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;
             Global.Execute(new UpdateCoinKernelCommand(upOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdateCoinKernelCommand(this));
             CoinViewModel coinVm;
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels));
             }
             this.Kernel.OnPropertyChanged(nameof(this.Kernel.CoinKernels));
             CoinViewModels.Current.OnPropertyChanged(nameof(CoinViewModels.MainCoins));
         }
     });
     this.SortDown = new DelegateCommand(() => {
         CoinKernelViewModel nextOne = CoinKernelViewModels.Current.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;
             Global.Execute(new UpdateCoinKernelCommand(nextOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdateCoinKernelCommand(this));
             CoinViewModel coinVm;
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels));
             }
             this.Kernel.OnPropertyChanged(nameof(this.Kernel.CoinKernels));
             CoinViewModels.Current.OnPropertyChanged(nameof(CoinViewModels.MainCoins));
         }
     });
 }
예제 #2
0
 public InputSegmentEditViewModel(CoinKernelViewModel coinKernelVm, InputSegmentViewModel segment)
 {
     _targetGpu   = segment.TargetGpu;
     _name        = segment.Name;
     _segment     = segment.Segment;
     _description = segment.Description;
     _isDefault   = segment.IsDefault;
     this.Save    = new DelegateCommand(() => {
         if (string.IsNullOrEmpty(this.Name))
         {
             throw new ValidationException("片段名不能为空");
         }
         segment.TargetGpu   = this.TargetGpu;
         segment.Name        = this.Name;
         segment.Segment     = this.Segment;
         segment.Description = this.Description;
         segment.IsDefault   = this.IsDefault;
         var existItem       = coinKernelVm.InputSegments.FirstOrDefault(a => a.Segment == segment.Segment);
         if (existItem == null)
         {
             coinKernelVm.InputSegments.Add(new InputSegment(segment));
         }
         else
         {
             existItem.Update(segment);
         }
         coinKernelVm.InputSegments = coinKernelVm.InputSegments.ToList();
         CloseWindow?.Invoke();
     });
 }
예제 #3
0
 public CoinKernelSelectViewModel(CoinViewModel coin, CoinKernelViewModel selected, Action <CoinKernelViewModel> onOk)
 {
     _coin             = coin;
     _selectedResult   = selected;
     OnOk              = onOk;
     this.ClearKeyword = new DelegateCommand(() => {
         this.Keyword = string.Empty;
     });
 }
예제 #4
0
 private void Init()
 {
     VirtualRoot.On <CoinAddedEvent>("添加了币种后刷新VM内存", LogEnum.DevConsole,
                                     action: (message) => {
         _dicById.Add(message.Source.GetId(), new CoinViewModel(message.Source));
         MinerProfileViewModel.Current.OnPropertyChanged(nameof(MinerProfileViewModel.Current.CoinVm));
         AllPropertyChanged();
         CoinPageViewModel.Current.OnPropertyChanged(nameof(CoinPageViewModel.List));
     }).AddToCollection(NTMinerRoot.Current.ContextHandlers);
     VirtualRoot.On <CoinRemovedEvent>("移除了币种后刷新VM内存", LogEnum.DevConsole,
                                       action: message => {
         _dicById.Remove(message.Source.GetId());
         MinerProfileViewModel.Current.OnPropertyChanged(nameof(MinerProfileViewModel.Current.CoinVm));
         AllPropertyChanged();
         CoinPageViewModel.Current.OnPropertyChanged(nameof(CoinPageViewModel.List));
     }).AddToCollection(NTMinerRoot.Current.ContextHandlers);
     VirtualRoot.On <CoinUpdatedEvent>("更新了币种后刷新VM内存", LogEnum.DevConsole,
                                       action: message => {
         CoinViewModel coinVm = _dicById[message.Source.GetId()];
         bool justAsDualCoin  = coinVm.JustAsDualCoin;
         coinVm.Update(message.Source);
         coinVm.TestWalletVm.Address = message.Source.TestWallet;
         coinVm.OnPropertyChanged(nameof(coinVm.Wallets));
         coinVm.OnPropertyChanged(nameof(coinVm.WalletItems));
         if (MinerProfileViewModel.Current.CoinId == message.Source.GetId())
         {
             MinerProfileViewModel.Current.OnPropertyChanged(nameof(MinerProfileViewModel.Current.CoinVm));
         }
         CoinKernelViewModel coinKernelVm = MinerProfileViewModel.Current.CoinVm.CoinKernel;
         if (coinKernelVm != null &&
             coinKernelVm.CoinKernelProfile.SelectedDualCoin != null &&
             coinKernelVm.CoinKernelProfile.SelectedDualCoin.GetId() == message.Source.GetId())
         {
             coinKernelVm.CoinKernelProfile.OnPropertyChanged(nameof(coinKernelVm.CoinKernelProfile.SelectedDualCoin));
         }
         if (justAsDualCoin != coinVm.JustAsDualCoin)
         {
             OnPropertyChanged(nameof(MainCoins));
         }
     }).AddToCollection(NTMinerRoot.Current.ContextHandlers);
     foreach (var item in NTMinerRoot.Current.CoinSet)
     {
         _dicById.Add(item.GetId(), new CoinViewModel(item));
     }
 }
 public EnvironmentVariableEditViewModel(CoinKernelViewModel coinKernelViewModel, EnvironmentVariable environmentVariable)
 {
     _key      = environmentVariable.Key;
     _value    = environmentVariable.Value;
     this.Save = new DelegateCommand(() => {
         if (string.IsNullOrEmpty(this.Key))
         {
             throw new ValidationException("变量名不能为空");
         }
         environmentVariable.Key   = this.Key;
         environmentVariable.Value = this.Value;
         if (!coinKernelViewModel.EnvironmentVariables.Contains(environmentVariable))
         {
             coinKernelViewModel.EnvironmentVariables.Add(environmentVariable);
         }
         coinKernelViewModel.EnvironmentVariables = coinKernelViewModel.EnvironmentVariables.ToList();
         CloseWindow?.Invoke();
     });
 }
예제 #6
0
 public InputSegmentEditViewModel(CoinKernelViewModel coinKernelVm, InputSegment segment)
 {
     _name        = segment.Name;
     _segment     = segment.Segment;
     _description = segment.Description;
     this.Save    = new DelegateCommand(() => {
         if (string.IsNullOrEmpty(this.Name))
         {
             throw new ValidationException("片段名不能为空");
         }
         segment.Name        = this.Name;
         segment.Segment     = this.Segment;
         segment.Description = this.Description;
         if (!coinKernelVm.InputSegments.Contains(segment))
         {
             coinKernelVm.InputSegments.Add(segment);
         }
         coinKernelVm.InputSegments = coinKernelVm.InputSegments.ToList();
         CloseWindow?.Invoke();
     });
 }
예제 #7
0
 public InputSegmentEditViewModel(CoinKernelViewModel coinKernelVm, InputSegmentViewModel segment)
 {
     _old         = segment;
     segment      = new InputSegmentViewModel(segment);
     _targetGpu   = segment.TargetGpu;
     _name        = segment.Name;
     _segment     = segment.Segment;
     _description = segment.Description;
     _isDefault   = segment.IsDefault;
     this.Save    = new DelegateCommand(() => {
         if (string.IsNullOrEmpty(this.Name))
         {
             throw new ValidationException("片段名不能为空");
         }
         segment.TargetGpu   = this.TargetGpu;
         segment.Name        = this.Name;
         segment.Segment     = this.Segment;
         segment.Description = this.Description;
         segment.IsDefault   = this.IsDefault;
         bool isUpdate       = !string.IsNullOrEmpty(_old.Name);
         if (isUpdate)
         {
             var existItem = coinKernelVm.InputSegments.FirstOrDefault(a => a.Name == _old.Name && a.Segment == _old.Segment);
             if (existItem != null)
             {
                 existItem.Update(segment);
             }
         }
         else
         {
             coinKernelVm.InputSegments.Add(new InputSegment(segment));
         }
         coinKernelVm.InputSegments = coinKernelVm.InputSegments.ToList();
         VirtualRoot.Execute(new CloseWindowCommand(this.Id));
     });
 }
예제 #8
0
 public CoinKernelViewModel(Guid id)
 {
     _id = id;
     _environmentVariables       = new List <EnvironmentVariable>();
     this.AddEnvironmentVariable = new DelegateCommand(() => {
         EnvironmentVariableEdit.ShowWindow(this, new EnvironmentVariable());
     });
     this.EditEnvironmentVariable = new DelegateCommand <EnvironmentVariable>(environmentVariable => {
         EnvironmentVariableEdit.ShowWindow(this, environmentVariable);
     });
     this.RemoveEnvironmentVariable = new DelegateCommand <EnvironmentVariable>(environmentVariable => {
         DialogWindow.ShowDialog(message: $"您确定删除环境变量{environmentVariable.Key}吗?", title: "确认", onYes: () => {
             this.EnvironmentVariables.Remove(environmentVariable);
             EnvironmentVariables = EnvironmentVariables.ToList();
         }, icon: IconConst.IconConfirm);
     });
     this.Save = new DelegateCommand(() => {
         if (NTMinerRoot.Current.CoinKernelSet.Contains(this.Id))
         {
             VirtualRoot.Execute(new UpdateCoinKernelCommand(this));
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand <FormType?>((formType) => {
         CoinKernelEdit.ShowWindow(formType ?? FormType.Edit, this);
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         DialogWindow.ShowDialog(message: $"您确定删除{Kernel.Code}币种内核吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new RemoveCoinKernelCommand(this.Id));
             Kernel.OnPropertyChanged(nameof(Kernel.SupportedCoins));
         }, icon: IconConst.IconConfirm);
     });
     this.SortUp = new DelegateCommand(() => {
         CoinKernelViewModel upOne = CoinKernelViewModels.Current.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));
             CoinViewModel coinVm;
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels));
             }
             this.Kernel.OnPropertyChanged(nameof(this.Kernel.CoinKernels));
             CoinViewModels.Current.OnPropertyChanged(nameof(CoinViewModels.MainCoins));
         }
     });
     this.SortDown = new DelegateCommand(() => {
         CoinKernelViewModel nextOne = CoinKernelViewModels.Current.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));
             CoinViewModel coinVm;
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels));
             }
             this.Kernel.OnPropertyChanged(nameof(this.Kernel.CoinKernels));
             CoinViewModels.Current.OnPropertyChanged(nameof(CoinViewModels.MainCoins));
         }
     });
 }
예제 #9
0
 public CoinKernelViewModel(Guid id)
 {
     _id = id;
     this.AddEnvironmentVariable = new DelegateCommand(() => {
         VirtualRoot.Execute(new EnvironmentVariableEditCommand(this, new EnvironmentVariable()));
     });
     this.EditEnvironmentVariable = new DelegateCommand <EnvironmentVariable>(environmentVariable => {
         VirtualRoot.Execute(new EnvironmentVariableEditCommand(this, environmentVariable));
     });
     this.RemoveEnvironmentVariable = new DelegateCommand <EnvironmentVariable>(environmentVariable => {
         this.ShowDialog(message: $"您确定删除环境变量{environmentVariable.Key}吗?", title: "确认", onYes: () => {
             this.EnvironmentVariables.Remove(environmentVariable);
             EnvironmentVariables = EnvironmentVariables.ToList();
         }, icon: IconConst.IconConfirm);
     });
     this.AddSegment = new DelegateCommand(() => {
         VirtualRoot.Execute(new InputSegmentEditCommand(this, new InputSegment()));
     });
     this.EditSegment = new DelegateCommand <InputSegment>((segment) => {
         VirtualRoot.Execute(new InputSegmentEditCommand(this, segment));
     });
     this.RemoveSegment = new DelegateCommand <InputSegment>((segment) => {
         this.ShowDialog(message: $"您确定删除片段{segment.Name}吗?", title: "确认", onYes: () => {
             this.InputSegments.Remove(segment);
             InputSegments = InputSegments.ToList();
         }, icon: IconConst.IconConfirm);
     });
     this.RemoveFileWriter = new DelegateCommand <FileWriterViewModel>((writer) => {
         this.ShowDialog(message: $"您确定删除文件书写器{writer.Name}吗?", title: "确认", onYes: () => {
             this.FileWriterVms.Remove(writer);
             List <Guid> writerIds = new List <Guid>(this.FileWriterIds);
             writerIds.Remove(writer.Id);
             this.FileWriterIds = writerIds;
         }, icon: IconConst.IconConfirm);
     });
     this.RemoveFragmentWriter = new DelegateCommand <FragmentWriterViewModel>((writer) => {
         this.ShowDialog(message: $"您确定删除文件书写器{writer.Name}吗?", title: "确认", onYes: () => {
             this.FragmentWriterVms.Remove(writer);
             List <Guid> writerIds = new List <Guid>(this.FragmentWriterIds);
             writerIds.Remove(writer.Id);
             this.FragmentWriterIds = writerIds;
         }, icon: IconConst.IconConfirm);
     });
     this.Save = new DelegateCommand(() => {
         if (NTMinerRoot.Instance.CoinKernelSet.Contains(this.Id))
         {
             VirtualRoot.Execute(new UpdateCoinKernelCommand(this));
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand <FormType?>((formType) => {
         VirtualRoot.Execute(new CoinKernelEditCommand(formType ?? FormType.Edit, this));
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         this.ShowDialog(message: $"您确定删除{Kernel.Code}币种内核吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new RemoveCoinKernelCommand(this.Id));
             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));
         }
     });
 }
예제 #10
0
 private CoinViewModels()
 {
     if (Design.IsInDesignMode)
     {
         return;
     }
     Global.Access <CoinAddedEvent>(
         Guid.Parse("1ee6e72d-d98f-42ab-8732-dcee2e42f4b8"),
         "添加了币种后刷新VM内存",
         LogEnum.Log,
         action: (message) => {
         _dicById.Add(message.Source.GetId(), new CoinViewModel(message.Source));
         MinerProfileViewModel.Current.OnPropertyChanged(nameof(MinerProfileViewModel.Current.CoinVm));
         OnPropertyChanged(nameof(AllCoins));
         OnPropertyChanged(nameof(MainCoins));
         CoinPageViewModel.Current.OnPropertyChanged(nameof(CoinPageViewModel.List));
         OnPropertyChanged(nameof(PleaseSelect));
         OnPropertyChanged(nameof(DualPleaseSelect));
     });
     Global.Access <CoinRemovedEvent>(
         Guid.Parse("6c966862-6dfa-4473-94b5-1133a16180a1"),
         "移除了币种后刷新VM内存",
         LogEnum.Log,
         action: message => {
         _dicById.Remove(message.Source.GetId());
         MinerProfileViewModel.Current.OnPropertyChanged(nameof(MinerProfileViewModel.Current.CoinVm));
         OnPropertyChanged(nameof(AllCoins));
         OnPropertyChanged(nameof(MainCoins));
         CoinPageViewModel.Current.OnPropertyChanged(nameof(CoinPageViewModel.List));
         OnPropertyChanged(nameof(PleaseSelect));
         OnPropertyChanged(nameof(DualPleaseSelect));
     });
     Global.Access <CoinUpdatedEvent>(
         Guid.Parse("114c90e5-6a0a-4aa4-9ba8-5ed603286c51"),
         "更新了币种后刷新VM内存",
         LogEnum.Log,
         action: message => {
         CoinViewModel coinVm = _dicById[message.Source.GetId()];
         bool justAsDualCoin  = coinVm.JustAsDualCoin;
         coinVm.Update(message.Source);
         coinVm.TestWalletVm.Address = message.Source.TestWallet;
         coinVm.OnPropertyChanged(nameof(coinVm.Wallets));
         if (MinerProfileViewModel.Current.CoinId == message.Source.GetId())
         {
             MinerProfileViewModel.Current.OnPropertyChanged(nameof(MinerProfileViewModel.Current.CoinVm));
         }
         CoinKernelViewModel coinKernelVm = MinerProfileViewModel.Current.CoinVm.CoinKernel;
         if (coinKernelVm != null &&
             coinKernelVm.CoinKernelProfile.SelectedDualCoin != null &&
             coinKernelVm.CoinKernelProfile.SelectedDualCoin.GetId() == message.Source.GetId())
         {
             coinKernelVm.CoinKernelProfile.OnPropertyChanged(nameof(coinKernelVm.CoinKernelProfile.SelectedDualCoin));
         }
         if (justAsDualCoin != coinVm.JustAsDualCoin)
         {
             OnPropertyChanged(nameof(MainCoins));
         }
     });
     foreach (var item in NTMinerRoot.Current.CoinSet)
     {
         _dicById.Add(item.GetId(), new CoinViewModel(item));
     }
 }
예제 #11
0
 private void Init()
 {
     VirtualRoot.On <CoinKernelAddedEvent>("添加了币种内核后刷新VM内存", LogEnum.DevConsole,
                                           action: (message) => {
         var coinKernelVm = new CoinKernelViewModel(message.Source);
         _dicById.Add(message.Source.GetId(), coinKernelVm);
         OnPropertyChanged(nameof(AllCoinKernels));
         CoinViewModel coinVm;
         if (CoinViewModels.Current.TryGetCoinVm(message.Source.CoinId, out coinVm))
         {
             coinVm.OnPropertyChanged(nameof(CoinViewModel.CoinKernel));
             coinVm.OnPropertyChanged(nameof(CoinViewModel.CoinKernels));
             coinVm.OnPropertyChanged(nameof(CoinViewModel.IsSupported));
         }
         var kernelVm = coinKernelVm.Kernel;
         if (kernelVm != null)
         {
             kernelVm.OnPropertyChanged(nameof(kernelVm.IsSupported));
             kernelVm.OnPropertyChanged(nameof(kernelVm.IsNvidiaIconVisible));
             kernelVm.OnPropertyChanged(nameof(kernelVm.IsAMDIconVisible));
             kernelVm.OnPropertyChanged(nameof(kernelVm.CoinKernels));
             kernelVm.OnPropertyChanged(nameof(kernelVm.CoinVms));
             kernelVm.OnPropertyChanged(nameof(kernelVm.SupportedCoinVms));
             kernelVm.OnPropertyChanged(nameof(kernelVm.SupportedCoins));
         }
     }).AddToCollection(NTMinerRoot.Current.ContextHandlers);
     VirtualRoot.On <CoinKernelUpdatedEvent>("更新了币种内核后刷新VM内存", LogEnum.DevConsole,
                                             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)
         {
             var coinKernels = AllCoinKernels.Where(a => a.KernelId == entity.Id);
             foreach (var coinKernel in coinKernels)
             {
                 CoinViewModel coinVm;
                 if (CoinViewModels.Current.TryGetCoinVm(coinKernel.CoinId, out coinVm))
                 {
                     coinVm.OnPropertyChanged(nameof(coinVm.IsSupported));
                     coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels));
                 }
                 coinKernel.Kernel.OnPropertyChanged(nameof(coinKernel.Kernel.IsSupported));
             }
             var kernelVm = entity.Kernel;
             kernelVm.OnPropertyChanged(nameof(kernelVm.IsNvidiaIconVisible));
             kernelVm.OnPropertyChanged(nameof(kernelVm.IsAMDIconVisible));
             kernelVm.OnPropertyChanged(nameof(kernelVm.CoinKernels));
         }
         if (dualCoinGroupId != entity.DualCoinGroupId)
         {
             entity.OnPropertyChanged(nameof(entity.DualCoinGroup));
         }
         if (sortNumber != entity.SortNumber)
         {
             CoinViewModel coinVm;
             if (CoinViewModels.Current.TryGetCoinVm(entity.CoinId, out coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels));
             }
         }
     }).AddToCollection(NTMinerRoot.Current.ContextHandlers);
     VirtualRoot.On <CoinKernelRemovedEvent>("移除了币种内核后刷新VM内存", LogEnum.DevConsole,
                                             action: (message) => {
         CoinKernelViewModel coinKernelVm;
         if (_dicById.TryGetValue(message.Source.GetId(), out coinKernelVm))
         {
             _dicById.Remove(message.Source.GetId());
             OnPropertyChanged(nameof(AllCoinKernels));
             CoinViewModel coinVm;
             if (CoinViewModels.Current.TryGetCoinVm(message.Source.CoinId, out coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(CoinViewModel.CoinKernel));
                 coinVm.OnPropertyChanged(nameof(CoinViewModel.CoinKernels));
                 coinVm.OnPropertyChanged(nameof(CoinViewModel.IsSupported));
             }
             var kernelVm = coinKernelVm.Kernel;
             kernelVm.OnPropertyChanged(nameof(kernelVm.IsSupported));
             kernelVm.OnPropertyChanged(nameof(kernelVm.IsNvidiaIconVisible));
             kernelVm.OnPropertyChanged(nameof(kernelVm.IsAMDIconVisible));
             kernelVm.OnPropertyChanged(nameof(kernelVm.CoinKernels));
             kernelVm.OnPropertyChanged(nameof(kernelVm.CoinVms));
             kernelVm.OnPropertyChanged(nameof(kernelVm.SupportedCoinVms));
             kernelVm.OnPropertyChanged(nameof(kernelVm.SupportedCoins));
         }
     }).AddToCollection(NTMinerRoot.Current.ContextHandlers);
     foreach (var item in NTMinerRoot.Current.CoinKernelSet)
     {
         _dicById.Add(item.GetId(), new CoinKernelViewModel(item));
     }
 }
예제 #12
0
 public bool TryGetCoinKernelVm(Guid id, out CoinKernelViewModel vm)
 {
     return(_dicById.TryGetValue(id, out vm));
 }
예제 #13
0
 private CoinKernelViewModels()
 {
     Global.Access <CoinKernelAddedEvent>(
         Guid.Parse("b3d7280d-3107-4730-a111-f34dd5cf4ede"),
         "添加了币种内核后刷新VM内存",
         LogEnum.Log, action: (message) => {
         var coinKernelVm = new CoinKernelViewModel(message.Source);
         _dicById.Add(message.Source.GetId(), coinKernelVm);
         OnPropertyChanged(nameof(AllCoinKernels));
         CoinViewModel coinVm;
         if (CoinViewModels.Current.TryGetCoinVm(message.Source.CoinId, out coinVm))
         {
             coinVm.OnPropertyChanged(nameof(CoinViewModel.CoinKernel));
             coinVm.OnPropertyChanged(nameof(CoinViewModel.CoinKernels));
             coinVm.OnPropertyChanged(nameof(CoinViewModel.IsSupported));
         }
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.IsSupported));
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.IsNvidiaIconVisible));
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.IsAMDIconVisible));
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.CoinKernels));
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.CoinVms));
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.SupportedCoinVms));
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.SupportedCoins));
     });
     Global.Access <CoinKernelUpdatedEvent>(
         Guid.Parse("48afedd3-5005-46a2-ae23-3f6f99a77683"),
         "更新了币种内核后刷新VM内存",
         LogEnum.Log,
         action: (message) => {
         CoinKernelViewModel entity = _dicById[message.Source.GetId()];
         var supportedGpu           = entity.SupportedGpu;
         Guid dualCoinGroupId       = entity.DualCoinGroupId;
         entity.Update(message.Source);
         if (supportedGpu != entity.SupportedGpu)
         {
             var coinKernels = AllCoinKernels.Where(a => a.KernelId == entity.Id);
             foreach (var coinKernel in coinKernels)
             {
                 CoinViewModel coinVm;
                 if (CoinViewModels.Current.TryGetCoinVm(coinKernel.CoinId, out coinVm))
                 {
                     coinVm.OnPropertyChanged(nameof(coinVm.IsSupported));
                     coinVm.OnPropertyChanged(nameof(coinVm.CoinKernels));
                 }
                 coinKernel.Kernel.OnPropertyChanged(nameof(coinKernel.Kernel.IsSupported));
             }
             entity.Kernel.OnPropertyChanged(nameof(entity.Kernel.IsNvidiaIconVisible));
             entity.Kernel.OnPropertyChanged(nameof(entity.Kernel.IsAMDIconVisible));
             entity.Kernel.OnPropertyChanged(nameof(entity.Kernel.CoinKernels));
         }
         if (dualCoinGroupId != entity.DualCoinGroupId)
         {
             entity.OnPropertyChanged(nameof(entity.DualCoinGroup));
         }
     });
     Global.Access <CoinKernelRemovedEvent>(
         Guid.Parse("0a2937bc-bb9c-4369-92b1-3c41eeb170ce"),
         "移除了币种内核后刷新VM内存",
         LogEnum.Log,
         action: (message) => {
         var coinKernelVm = _dicById[message.Source.GetId()];
         _dicById.Remove(message.Source.GetId());
         OnPropertyChanged(nameof(AllCoinKernels));
         CoinViewModel coinVm;
         if (CoinViewModels.Current.TryGetCoinVm(message.Source.CoinId, out coinVm))
         {
             coinVm.OnPropertyChanged(nameof(CoinViewModel.CoinKernel));
             coinVm.OnPropertyChanged(nameof(CoinViewModel.CoinKernels));
             coinVm.OnPropertyChanged(nameof(CoinViewModel.IsSupported));
         }
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.IsSupported));
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.IsNvidiaIconVisible));
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.IsAMDIconVisible));
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.CoinKernels));
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.CoinVms));
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.SupportedCoinVms));
         coinKernelVm.Kernel.OnPropertyChanged(nameof(coinKernelVm.Kernel.SupportedCoins));
     });
     foreach (var item in NTMinerRoot.Current.CoinKernelSet)
     {
         _dicById.Add(item.GetId(), new CoinKernelViewModel(item));
     }
 }