Example #1
0
 public PoolSelectViewModel(CoinViewModel coin, PoolViewModel selected, Action <PoolViewModel> onOk, bool usedByPool1 = false)
 {
     _coin             = coin;
     _selectedResult   = selected;
     OnOk              = onOk;
     _usedByPool1      = usedByPool1;
     this.ClearKeyword = new DelegateCommand(() => {
         this.Keyword = string.Empty;
     });
 }
Example #2
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));
     });
 }
Example #3
0
 private MinerClientsViewModel()
 {
     this._mineStatusEnumItem = this.MineStatusEnumItems.FirstOrDefault(a => a.Value == MineStatus.All);
     this._mainCoin           = CoinViewModel.PleaseSelect;
     this._dualCoin           = CoinViewModel.PleaseSelect;
     this._selectedMineWork   = MineWorkViewModel.PleaseSelect;
     this._selectedMinerGroup = MinerGroupViewModel.PleaseSelect;
     this._mainCoinPool       = _mainCoin.OptionPools.First();
     this._dualCoinPool       = _dualCoin.OptionPools.First();
     this._mainCoinWallet     = WalletViewModel.PleaseSelect;
     this._dualCoinWallet     = WalletViewModel.PleaseSelect;
     this.PageUp = new DelegateCommand(() => {
         this.MinerClientPageIndex = this.MinerClientPageIndex - 1;
     });
     this.PageDown = new DelegateCommand(() => {
         this.MinerClientPageIndex = this.MinerClientPageIndex + 1;
     });
     this.PageFirst = new DelegateCommand(() => {
         this.MinerClientPageIndex = 1;
     });
     this.PageLast = new DelegateCommand(() => {
         this.MinerClientPageIndex = MinerClientPageCount;
     });
     this.PageRefresh = new DelegateCommand(() => {
         QueryMinerClients();
     });
     this.ManageCoin = new DelegateCommand <CoinViewModel>((coinVm) => {
         CoinPageViewModel.Current.CurrentCoin = coinVm;
         CoinPage.ShowWindow();
     });
     this.ManagePool = new DelegateCommand <CoinViewModel>((coinVm) => {
         this.ManageCoin.Execute(coinVm);
         CoinPageViewModel.Current.SwitchToPoolTab();
     });
     this.ManageWallet = new DelegateCommand <CoinViewModel>((coinVm) => {
         this.ManageCoin.Execute(coinVm);
         CoinPageViewModel.Current.SwitchToWalletTab();
     });
     System.Timers.Timer t = new System.Timers.Timer(50);
     t.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) => {
         if (this._logoRotateTransformAngle > 3600000)
         {
             this._logoRotateTransformAngle = 0;
         }
         this.LogoRotateTransformAngle += 50;
     };
     t.Start();
 }
Example #4
0
 public PoolViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (NTMinerRoot.Instance.PoolSet.Contains(this.Id))
         {
             VirtualRoot.Execute(new UpdatePoolCommand(this));
         }
         else
         {
             VirtualRoot.Execute(new AddPoolCommand(this));
         }
         CloseWindow?.Invoke();
     });
     this.Edit = new DelegateCommand <FormType?>((formType) => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         VirtualRoot.Execute(new PoolEditCommand(formType ?? FormType.Edit, this));
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         this.ShowDialog(message: $"您确定删除{this.Name}矿池吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new RemovePoolCommand(this.Id));
         }, icon: IconConst.IconConfirm);
     });
     this.SortUp = new DelegateCommand(() => {
         PoolViewModel upOne = AppContext.Instance.PoolVms.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;
             VirtualRoot.Execute(new UpdatePoolCommand(upOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdatePoolCommand(this));
             if (AppContext.Instance.CoinVms.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Pools));
                 coinVm.OnPropertyChanged(nameof(coinVm.OptionPools));
             }
         }
     });
     this.SortDown = new DelegateCommand(() => {
         PoolViewModel nextOne = AppContext.Instance.PoolVms.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;
             VirtualRoot.Execute(new UpdatePoolCommand(nextOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdatePoolCommand(this));
             if (AppContext.Instance.CoinVms.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Pools));
                 coinVm.OnPropertyChanged(nameof(coinVm.OptionPools));
             }
         }
     });
     this.ViewPoolIncome = new DelegateCommand <WalletViewModel>((wallet) => {
         if ((!this.IsUserMode && (wallet == null || string.IsNullOrEmpty(wallet.Address))) ||
             (this.IsUserMode && string.IsNullOrEmpty(this.PoolProfileVm.UserName)))
         {
             if (!string.IsNullOrEmpty(Website))
             {
                 Process.Start(Website);
             }
             return;
         }
         if (!string.IsNullOrEmpty(this.Url))
         {
             string url = this.Url;
             if (this.IsUserMode)
             {
                 url = url.Replace("{userName}", this.PoolProfileVm.UserName);
             }
             else
             {
                 url = url.Replace("{wallet}", wallet.Address);
             }
             url = url.Replace("{worker}", NTMinerRoot.Instance.MinerProfile.MinerName);
             Process.Start(url);
         }
     });
     this.OpenWebsite = new DelegateCommand(() => {
         if (string.IsNullOrEmpty(Website))
         {
             return;
         }
         Process.Start(Website);
     });
 }
Example #5
0
        public MinerClientsWindowViewModel(bool isInDesignMode = true)
        {
            if (Design.IsInDesignMode || isInDesignMode)
            {
                return;
            }
            var  appSettings   = NTMinerRoot.Instance.ServerAppSettingSet;
            Guid columnsShowId = ColumnsShowData.PleaseSelect.Id;

            if (appSettings.TryGetAppSetting("ColumnsShowId", out IAppSetting columnsShowAppSetting) && columnsShowAppSetting.Value != null)
            {
                if (Guid.TryParse(columnsShowAppSetting.Value.ToString(), out Guid guid))
                {
                    columnsShowId = guid;
                }
            }
            if (appSettings.TryGetAppSetting("FrozenColumnCount", out IAppSetting frozenColumnCountAppSetting) && frozenColumnCountAppSetting.Value != null)
            {
                if (int.TryParse(frozenColumnCountAppSetting.Value.ToString(), out int frozenColumnCount))
                {
                    _frozenColumnCount = frozenColumnCount;
                }
            }
            if (appSettings.TryGetAppSetting("MaxTemp", out IAppSetting maxTempAppSetting) && maxTempAppSetting.Value != null)
            {
                if (uint.TryParse(maxTempAppSetting.Value.ToString(), out uint maxTemp))
                {
                    _maxTemp = maxTemp;
                }
            }
            if (appSettings.TryGetAppSetting("MinTemp", out IAppSetting minTempAppSetting) && minTempAppSetting.Value != null)
            {
                if (uint.TryParse(minTempAppSetting.Value.ToString(), out uint minTemp))
                {
                    _minTemp = minTemp;
                }
            }
            if (appSettings.TryGetAppSetting("RejectPercent", out IAppSetting rejectPercentAppSetting) && rejectPercentAppSetting.Value != null)
            {
                if (int.TryParse(rejectPercentAppSetting.Value.ToString(), out int rejectPercent))
                {
                    _rejectPercent = rejectPercent;
                }
            }
            this._columnsShow = this.ColumnsShows.List.FirstOrDefault(a => a.Id == columnsShowId);
            if (this._columnsShow == null)
            {
                this._columnsShow = this.ColumnsShows.List.FirstOrDefault();
            }
            this._mineStatusEnumItem = EnumSet.MineStatusEnumItems.FirstOrDefault(a => a.Value == MineStatus.All);
            this._coinVm             = CoinViewModel.PleaseSelect;
            this._selectedMineWork   = MineWorkViewModel.PleaseSelect;
            this._selectedMinerGroup = MinerGroupViewModel.PleaseSelect;
            this._pool = string.Empty;
            // 至少会有一个PleaseSelect所以可以First
            this._poolVm       = _coinVm.OptionPools.First();
            this._wallet       = string.Empty;
            this.OneKeySetting = new DelegateCommand(() => {
                VirtualRoot.Execute(new ShowMinerClientSettingCommand(new MinerClientSettingViewModel(this.SelectedMinerClients)));
            }, CanCommand);
            this.OneKeyMinerNames = new DelegateCommand(() => {
                if (this.SelectedMinerClients.Length == 1)
                {
                    var selectedMinerClient = this.SelectedMinerClients[0];
                    Wpf.Util.ShowInputDialog("群控矿工名 注意:重新开始挖矿时生效", selectedMinerClient.MinerName, null, minerName => {
                        selectedMinerClient.MinerName = minerName;
                        NotiCenterWindowViewModel.Instance.Manager.ShowSuccessMessage("设置群控矿工名成功,重新开始挖矿时生效。");
                    });
                    return;
                }
                MinerNamesSeterViewModel vm = new MinerNamesSeterViewModel(
                    prefix: "miner",
                    suffix: "01",
                    namesByObjectId: this.SelectedMinerClients.Select(a => new Tuple <string, string>(a.Id, string.Empty)).ToList());
                VirtualRoot.Execute(new ShowMinerNamesSeterCommand(vm));
                if (vm.IsOk)
                {
                    this.CountDown = 10;
                    Server.ControlCenterService.UpdateClientsAsync(nameof(MinerClientViewModel.MinerName), vm.NamesByObjectId.ToDictionary(a => a.Item1, a => (object)a.Item2), callback: (response, e) => {
                        if (!response.IsSuccess())
                        {
                            Write.UserFail(response.ReadMessage(e));
                        }
                        else
                        {
                            foreach (var kv in vm.NamesByObjectId)
                            {
                                var item = this.SelectedMinerClients.FirstOrDefault(a => a.Id == kv.Item1);
                                if (item != null)
                                {
                                    item.UpdateMinerName(kv.Item2);
                                }
                            }
                            QueryMinerClients();
                        }
                    });
                }
            }, CanCommand);
            this.OneKeyWindowsLoginName = new DelegateCommand(() => {
                Wpf.Util.ShowInputDialog("远程桌面用户名", string.Empty, null, loginName => {
                    foreach (var item in SelectedMinerClients)
                    {
                        item.WindowsLoginName = loginName;
                    }
                    NotiCenterWindowViewModel.Instance.Manager.ShowSuccessMessage("设置远程桌面用户名成功,双击矿机可打开远程桌面。");
                });
            }, CanCommand);
            this.OneKeyWindowsLoginPassword = new DelegateCommand(() => {
                Wpf.Util.ShowInputDialog("远程桌面密码", string.Empty, null, password => {
                    foreach (var item in SelectedMinerClients)
                    {
                        item.WindowsPassword = password;
                    }
                    NotiCenterWindowViewModel.Instance.Manager.ShowSuccessMessage("设置远程桌面密码成功,双击矿机可打开远程桌面。");
                });
            }, CanCommand);
            this.EditMineWork = new DelegateCommand(() => {
                this.SelectedMinerClients[0].SelectedMineWork.Edit.Execute(null);
            }, () => OnlySelectedOne() && this.SelectedMinerClients[0].SelectedMineWork != null &&
                                                    this.SelectedMinerClients[0].SelectedMineWork != MineWorkViewModel.PleaseSelect);
            this.OneKeyWork = new DelegateCommand <MineWorkViewModel>((work) => {
                foreach (var item in SelectedMinerClients)
                {
                    item.SelectedMineWork = work;
                }
            });
            this.OneKeyGroup = new DelegateCommand <MinerGroupViewModel>((group) => {
                foreach (var item in SelectedMinerClients)
                {
                    item.SelectedMinerGroup = group;
                }
            });
            this.OneKeyOverClock = new DelegateCommand(() => {
                if (this.SelectedMinerClients.Length == 1)
                {
                    VirtualRoot.Execute(new ShowGpuProfilesPageCommand(this));
                }
            }, OnlySelectedOne);
            this.OneKeyUpgrade = new DelegateCommand <NTMinerFileData>((ntminerFileData) => {
                this.ShowDialog(message: "确定升级到该版本吗?", title: "确认", onYes: () => {
                    foreach (var item in SelectedMinerClients)
                    {
                        Server.MinerClientService.UpgradeNTMinerAsync(item, ntminerFileData.FileName, (response, e) => {
                            if (!response.IsSuccess())
                            {
                                Write.UserFail($"{item.MinerName} {item.MinerIp} {response.ReadMessage(e)}");
                            }
                        });
                    }
                }, icon: IconConst.IconConfirm);
            }, (ntminerFileData) => this.SelectedMinerClients != null && this.SelectedMinerClients.Length != 0);
            this.AddMinerClient = new DelegateCommand(() => {
                VirtualRoot.Execute(new ShowMinerClientAddCommand());
            });
            this.RemoveMinerClients = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    this.ShowDialog(message: $"确定删除选中的矿机吗?", title: "确认", onYes: () => {
                        this.CountDown = 10;
                        Server.ControlCenterService.RemoveClientsAsync(SelectedMinerClients.Select(a => a.Id).ToList(), (response, e) => {
                            if (!response.IsSuccess())
                            {
                                Write.UserFail(response.ReadMessage(e));
                            }
                            else
                            {
                                QueryMinerClients();
                            }
                        });
                    }, icon: IconConst.IconConfirm);
                }
            }, CanCommand);
            this.RefreshMinerClients = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    Server.ControlCenterService.RefreshClientsAsync(SelectedMinerClients.Select(a => a.Id).ToList(), (response, e) => {
                        if (!response.IsSuccess())
                        {
                            Write.UserFail(response.ReadMessage(e));
                        }
                        else
                        {
                            foreach (var data in response.Data)
                            {
                                var item = MinerClients.FirstOrDefault(a => a.Id == data.Id);
                                if (item != null)
                                {
                                    item.Update(data);
                                }
                            }
                        }
                    });
                }
            }, CanCommand);
            this.RestartWindows = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    this.ShowDialog(message: $"确定重启选中的电脑吗?", title: "确认", onYes: () => {
                        foreach (var item in SelectedMinerClients)
                        {
                            Server.MinerClientService.RestartWindowsAsync(item, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    Write.UserFail(response.ReadMessage(e));
                                }
                            });
                        }
                    }, icon: IconConst.IconConfirm);
                }
            }, CanCommand);
            this.ShutdownWindows = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    this.ShowDialog(message: $"确定关闭选中的电脑吗?", title: "确认", onYes: () => {
                        foreach (var item in SelectedMinerClients)
                        {
                            Server.MinerClientService.ShutdownWindowsAsync(item, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    Write.UserFail(response.ReadMessage(e));
                                }
                            });
                        }
                    }, icon: IconConst.IconConfirm);
                }
            }, CanCommand);
            this.RestartNTMiner = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    this.ShowDialog(message: $"确定重启选中的挖矿客户端吗?", title: "确认", onYes: () => {
                        foreach (var item in SelectedMinerClients)
                        {
                            Server.MinerClientService.RestartNTMinerAsync(item, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    Write.UserFail(response.ReadMessage(e));
                                }
                            });
                        }
                    }, icon: IconConst.IconConfirm);
                }
            }, CanCommand);
            this.StartMine = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    foreach (var item in SelectedMinerClients)
                    {
                        item.IsMining = true;
                        Server.MinerClientService.StartMineAsync(item, item.WorkId, (response, e) => {
                            if (!response.IsSuccess())
                            {
                                Write.UserFail($"{item.MinerIp} {response.ReadMessage(e)}");
                            }
                        });
                        Server.ControlCenterService.UpdateClientAsync(item.Id, nameof(item.IsMining), item.IsMining, null);
                    }
                }
            }, CanCommand);
            this.StopMine = new DelegateCommand(() => {
                if (SelectedMinerClients.Length == 0)
                {
                    ShowNoRecordSelected();
                }
                else
                {
                    this.ShowDialog(message: $"确定将选中的矿机停止挖矿吗?", title: "确认", onYes: () => {
                        foreach (var item in SelectedMinerClients)
                        {
                            item.IsMining = false;
                            Server.MinerClientService.StopMineAsync(item, (response, e) => {
                                if (!response.IsSuccess())
                                {
                                    Write.UserFail($"{item.MinerIp} {response.ReadMessage(e)}");
                                }
                            });
                            Server.ControlCenterService.UpdateClientAsync(item.Id, nameof(item.IsMining), item.IsMining, null);
                        }
                    }, icon: IconConst.IconConfirm);
                }
            }, CanCommand);
            this.PageUp = new DelegateCommand(() => {
                this.MinerClientPageIndex = this.MinerClientPageIndex - 1;
            });
            this.PageDown = new DelegateCommand(() => {
                this.MinerClientPageIndex = this.MinerClientPageIndex + 1;
            });
            this.PageFirst = new DelegateCommand(() => {
                this.MinerClientPageIndex = 1;
            });
            this.PageLast = new DelegateCommand(() => {
                this.MinerClientPageIndex = MinerClientPageCount;
            });
            this.PageRefresh = new DelegateCommand(QueryMinerClients);
        }
Example #6
0
 public PoolViewModel(Guid id)
 {
     _id       = id;
     this.Save = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         if (NTMinerContext.Instance.ServerContext.PoolSet.Contains(this.Id))
         {
             VirtualRoot.Execute(new UpdatePoolCommand(this));
         }
         else
         {
             VirtualRoot.Execute(new AddPoolCommand(this));
         }
         VirtualRoot.Execute(new CloseWindowCommand(this.Id));
     });
     this.Edit = new DelegateCommand <FormType?>((formType) => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         VirtualRoot.Execute(new EditPoolCommand(formType ?? FormType.Edit, this));
     });
     this.Remove = new DelegateCommand(() => {
         if (this.Id == Guid.Empty)
         {
             return;
         }
         this.ShowSoftDialog(new DialogWindowViewModel(message: $"您确定删除{this.Name}矿池吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new RemovePoolCommand(this.Id));
         }));
     });
     this.SortUp = new DelegateCommand(() => {
         PoolViewModel upOne = AppRoot.PoolVms.AllPools.GetUpOne(SortNumber, a => a.CoinId == CoinId);
         if (upOne != null)
         {
             int sortNumber   = upOne.SortNumber;
             upOne.SortNumber = this.SortNumber;
             VirtualRoot.Execute(new UpdatePoolCommand(upOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdatePoolCommand(this));
             if (AppRoot.CoinVms.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Pools));
                 coinVm.OnPropertyChanged(nameof(coinVm.OptionPools));
             }
         }
     });
     this.SortDown = new DelegateCommand(() => {
         PoolViewModel nextOne = AppRoot.PoolVms.AllPools.GetNextOne(SortNumber, a => a.CoinId == CoinId);
         if (nextOne != null)
         {
             int sortNumber     = nextOne.SortNumber;
             nextOne.SortNumber = this.SortNumber;
             VirtualRoot.Execute(new UpdatePoolCommand(nextOne));
             this.SortNumber = sortNumber;
             VirtualRoot.Execute(new UpdatePoolCommand(this));
             if (AppRoot.CoinVms.TryGetCoinVm(this.CoinId, out CoinViewModel coinVm))
             {
                 coinVm.OnPropertyChanged(nameof(coinVm.Pools));
                 coinVm.OnPropertyChanged(nameof(coinVm.OptionPools));
             }
         }
     });
     this.ViewPoolIncome = new DelegateCommand(() => {
         bool openWebsite = string.IsNullOrEmpty(this.Url);
         var wallet       = Wallet;
         if (!openWebsite)
         {
             if (this.IsUserMode)
             {
                 var poolProfile = this.PoolProfileVm;
                 if (poolProfile == null || string.IsNullOrEmpty(poolProfile.UserName))
                 {
                     openWebsite = true;
                 }
             }
             else
             {
                 if (wallet == null || string.IsNullOrEmpty(wallet.Address))
                 {
                     openWebsite = true;
                 }
             }
         }
         if (openWebsite)
         {
             if (!string.IsNullOrEmpty(Website))
             {
                 VirtualRoot.Execute(new UnTopmostCommand());
                 Process.Start(Website);
             }
             return;
         }
         string url = this.Url;
         if (this.IsUserMode)
         {
             url = url.Replace("{userName}", this.PoolProfileVm.UserName);
         }
         else
         {
             url = url.Replace("{wallet}", wallet.Address);
         }
         url = url.Replace("{worker}", NTMinerContext.Instance.MinerProfile.MinerName);
         VirtualRoot.Execute(new UnTopmostCommand());
         Process.Start(url);
     });
 }
Example #7
0
 public PoolSelectViewModel(CoinViewModel coin, PoolViewModel selected, Action <PoolViewModel> onOk)
 {
     _coin           = coin;
     _selectedResult = selected;
     OnOk            = onOk;
 }
Example #8
0
 public PoolSelectViewModel(CoinViewModel coin, PoolViewModel selected, Action <PoolViewModel> onSelectedChanged)
 {
     _coin              = coin;
     _selectedResult    = selected;
     _onSelectedChanged = onSelectedChanged;
 }
Example #9
0
 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);
         }
     });
 }
Example #10
0
 public bool TryGetPoolVm(Guid poolId, out PoolViewModel poolVm)
 {
     return(_dicById.TryGetValue(poolId, out poolVm));
 }