Beispiel #1
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));
     }
 }
Beispiel #2
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));
     }
 }