public ServerHostSelectViewModel(string selected, Action <ServerHostItem> onOk) { var data = NTMinerRegistry.GetControlCenterAddresses().ToList(); if (!data.Contains("127.0.0.1") && !data.Contains(NTKeyword.Localhost)) { data.Add("127.0.0.1"); } if (!data.Contains("server.ntminer.com:3339")) { data.Add("server.ntminer.com:3339"); } _serverHosts = data.Select(a => new ServerHostItem(a)).ToList(); _selectedResult = _serverHosts.FirstOrDefault(a => a.IpOrHost == selected); OnOk = onOk; this.Remove = new DelegateCommand <ServerHostItem>((serverHost) => { if (this.ServerHosts.Remove(serverHost)) { if (NTMinerRegistry.GetControlCenterAddress() == serverHost.IpOrHost) { NTMinerRegistry.SetControlCenterAddress(string.Empty); } this.ServerHosts = this.ServerHosts.ToList(); } }); }
public LoginWindowViewModel() { if (WpfUtil.IsInDesignMode) { return; } this._loginName = NTMinerRegistry.GetLoginName(); this._serverHost = NTMinerRegistry.GetControlCenterAddress(); this._isInnerIp = Net.IpUtil.IsInnerIp(_serverHost); }
public LoginWindowViewModel(string serverHost = null) { if (WpfUtil.IsInDesignMode) { return; } this._loginName = NTMinerRegistry.GetLoginName(); if (!string.IsNullOrEmpty(serverHost)) { this._serverHost = serverHost; } else { this._serverHost = NTMinerRegistry.GetControlCenterAddress(); } this._isInnerIp = Net.IpUtil.IsInnerIp(_serverHost); }