コード例 #1
0
 public PoolViewModel(Guid id)
 {
     _id       = id;
     this.Edit = new DelegateCommand(() => {
         PoolEdit.ShowEditWindow(this);
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         DialogWindow.ShowDialog(message: $"您确定删除{this.Name}矿池吗?", title: "确认", onYes: () => {
             Global.Execute(new RemovePoolCommand(this.Id));
         }, icon: "Icon_Confirm");
     });
     this.SortUp = new DelegateCommand(() => {
         PoolViewModel upOne = PoolViewModels.Current.AllPools.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 UpdatePoolCommand(upOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdatePoolCommand(this));
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Pools));
                 coinVm.OnPropertyChanged(nameof(coinVm.OptionPools));
             }
         }
     });
     this.SortDown = new DelegateCommand(() => {
         PoolViewModel nextOne = PoolViewModels.Current.AllPools.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 UpdatePoolCommand(nextOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdatePoolCommand(this));
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Pools));
                 coinVm.OnPropertyChanged(nameof(coinVm.OptionPools));
             }
         }
     });
     this.ViewPoolIncome = new DelegateCommand <WalletViewModel>((wallet) => {
         Process.Start(this.Url.Replace("{wallet}", wallet.Address));
     });
 }
コード例 #2
0
ファイル: PoolViewModel.cs プロジェクト: ouguochong/ntminer
 public PoolViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (NTMinerRoot.Current.PoolSet.Contains(this.Id))
         {
             Global.Execute(new UpdatePoolCommand(this));
         }
         else
         {
             Global.Execute(new AddPoolCommand(this));
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand(() => {
         PoolEdit.ShowEditWindow(this);
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         DialogWindow.ShowDialog(message: $"您确定删除{this.Name}矿池吗?", title: "确认", onYes: () => {
             Global.Execute(new RemovePoolCommand(this.Id));
         }, icon: "Icon_Confirm");
     });
     this.SortUp = new DelegateCommand(() => {
         PoolViewModel upOne = PoolViewModels.Current.AllPools.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 UpdatePoolCommand(upOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdatePoolCommand(this));
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Pools));
                 coinVm.OnPropertyChanged(nameof(coinVm.OptionPools));
             }
         }
     });
     this.SortDown = new DelegateCommand(() => {
         PoolViewModel nextOne = PoolViewModels.Current.AllPools.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 UpdatePoolCommand(nextOne));
             this.SortNumber = sortNumber;
             Global.Execute(new UpdatePoolCommand(this));
             if (CoinViewModels.Current.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Pools));
                 coinVm.OnPropertyChanged(nameof(coinVm.OptionPools));
             }
         }
     });
     this.ViewPoolIncome = new DelegateCommand <WalletViewModel>((wallet) => {
         if (!string.IsNullOrEmpty(this.Url))
         {
             string url = this.Url;
             if (this.IsUserMode)
             {
                 url = url.Replace("{userName}", this.PoolProfileVm.UserName);
                 url = url.Replace("{worker}", NTMinerRoot.Current.MinerProfile.MinerName);
             }
             else
             {
                 url = url.Replace("{wallet}", wallet.Address);
                 url = url.Replace("{worker}", NTMinerRoot.Current.MinerProfile.MinerName);
             }
             Process.Start(url);
         }
     });
 }