Example #1
0
 public WalletViewModel(Guid id)
 {
     _id       = id;
     this.Edit = new DelegateCommand(() => {
         WalletEdit.ShowEditWindow(this);
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (this.IsTestWallet)
         {
             return;
         }
         DialogWindow.ShowDialog(message: $"您确定删除{this.Name}钱包吗?", title: "确认", onYes: () => {
             Global.Execute(new RemoveWalletCommand(this.Id));
         }, icon: "Icon_Confirm");
     });
     this.SortUp = new DelegateCommand(() => {
         WalletViewModel upOne = WalletViewModels.Current.WalletList.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 UpdateWalletCommand(upOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdateWalletCommand(this));
             CoinViewModel coinVm;
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Wallets));
             }
         }
     });
     this.SortDown = new DelegateCommand(() => {
         WalletViewModel nextOne = WalletViewModels.Current.WalletList.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 UpdateWalletCommand(nextOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdateWalletCommand(this));
             CoinViewModel coinVm;
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Wallets));
             }
         }
     });
 }
Example #2
0
 public WalletSelectViewModel(CoinViewModel coin, bool isDualCoin, WalletViewModel selected, Action <WalletViewModel> onSelectedChanged)
 {
     _coin              = coin;
     _isDualCoin        = isDualCoin;
     _selectedResult    = selected;
     _onSelectedChanged = onSelectedChanged;
     if (_isDualCoin)
     {
         this.AddWallet = _coin.CoinProfile.AddDualCoinWallet;
     }
     else
     {
         this.AddWallet = _coin.CoinProfile.AddWallet;
     }
 }
Example #3
0
 public WalletSelectViewModel(CoinViewModel coin, bool isDualCoin, WalletViewModel selected, Action <WalletViewModel> onOk)
 {
     _coin           = coin;
     _isDualCoin     = isDualCoin;
     _selectedResult = selected;
     OnOk            = onOk;
     this.AddWallet  = new DelegateCommand(() => {
         this.HideView.Execute(null);
         if (_isDualCoin)
         {
             _coin.CoinProfile.AddDualCoinWallet.Execute(null);
         }
         else
         {
             _coin.CoinProfile.AddWallet.Execute(null);
         }
     });
 }
Example #4
0
 public WalletViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (!this.IsTestWallet)
         {
             IWallet wallet;
             if (NTMinerRoot.Instance.MinerProfile.TryGetWallet(this.Id, out wallet))
             {
                 VirtualRoot.Execute(new UpdateWalletCommand(this));
             }
             else
             {
                 VirtualRoot.Execute(new AddWalletCommand(this));
             }
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand <FormType?>((formType) => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         VirtualRoot.Execute(new WalletEditCommand(formType ?? FormType.Edit, this));
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (this.IsTestWallet)
         {
             return;
         }
         this.ShowDialog(message: $"您确定删除{this.Name}钱包吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new RemoveWalletCommand(this.Id));
         }, icon: IconConst.IconConfirm);
     });
     this.SortUp = new DelegateCommand(() => {
         WalletViewModel upOne = AppContext.Instance.WalletVms.GetUpOne(this.CoinId, this.SortNumber);
         if (upOne != null)
         {
             int sortNumber   = upOne.SortNumber;
             upOne.SortNumber = this.SortNumber;
             VirtualRoot.Execute(new UpdateWalletCommand(upOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdateWalletCommand(this));
             CoinViewModel coinVm;
             if (AppContext.Instance.CoinVms.TryGetCoinVm(this.CoinId, out coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Wallets));
                 coinVm.OnPropertyChanged(nameof(coinVm.WalletItems));
             }
         }
     });
     this.SortDown = new DelegateCommand(() => {
         WalletViewModel nextOne = AppContext.Instance.WalletVms.GetNextOne(this.CoinId, this.SortNumber);
         if (nextOne != null)
         {
             int sortNumber     = nextOne.SortNumber;
             nextOne.SortNumber = this.SortNumber;
             VirtualRoot.Execute(new UpdateWalletCommand(nextOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdateWalletCommand(this));
             CoinViewModel coinVm;
             if (AppContext.Instance.CoinVms.TryGetCoinVm(this.CoinId, out coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Wallets));
                 coinVm.OnPropertyChanged(nameof(coinVm.WalletItems));
             }
         }
     });
 }
Example #5
0
 public WalletViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (!this.IsTestWallet)
         {
             IWallet wallet;
             if (NTMinerRoot.Current.MinerProfile.TryGetWallet(this.Id, out wallet))
             {
                 VirtualRoot.Execute(new UpdateWalletCommand(this));
             }
             else
             {
                 VirtualRoot.Execute(new AddWalletCommand(this));
             }
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand <FormType?>((formType) => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         WalletEdit.ShowWindow(formType ?? FormType.Edit, this);
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (this.IsTestWallet)
         {
             return;
         }
         DialogWindow.ShowDialog(message: $"您确定删除{this.Name}钱包吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new RemoveWalletCommand(this.Id));
         }, icon: IconConst.IconConfirm);
     });
     this.SortUp = new DelegateCommand(() => {
         WalletViewModel upOne = WalletViewModels.Current.WalletList.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 UpdateWalletCommand(upOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdateWalletCommand(this));
             CoinViewModel coinVm;
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Wallets));
                 coinVm.OnPropertyChanged(nameof(coinVm.WalletItems));
             }
         }
     });
     this.SortDown = new DelegateCommand(() => {
         WalletViewModel nextOne = WalletViewModels.Current.WalletList.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 UpdateWalletCommand(nextOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdateWalletCommand(this));
             CoinViewModel coinVm;
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Wallets));
                 coinVm.OnPropertyChanged(nameof(coinVm.WalletItems));
             }
         }
     });
 }