public CalcConfigViewModels() { if (WpfUtil.IsInDesignMode) { return; } this.Save = new DelegateCommand(() => { NTMinerContext.Instance.CalcConfigSet.SaveCalcConfigs(this.CalcConfigVms.Select(a => CalcConfigData.Create(a)).ToList()); VirtualRoot.Execute(new CloseWindowCommand(this.Id)); }); this.Clear = new DelegateCommand(() => { var coins = NTMinerContext.Instance.ServerContext.CoinSet.AsEnumerable(); if (coins != null && coins.Any()) { List <CalcConfigViewModel> toRemoves = new List <CalcConfigViewModel>(); foreach (var calConfigVm in _calcConfigVms) { if (!coins.Any(a => a.Code == calConfigVm.CoinCode)) { toRemoves.Add(calConfigVm); } } if (toRemoves.Count != 0) { foreach (var item in toRemoves) { _calcConfigVms.Remove(item); } this.Save.Execute(null); VirtualRoot.Out.ShowSuccess("清理成功"); } else { VirtualRoot.Out.ShowSuccess("没有要清理的币种"); } } }); Refresh(); }
public CalcConfigViewModels() { if (WpfUtil.IsInDesignMode) { return; } this.Save = new DelegateCommand(() => { NTMinerContext.Instance.CalcConfigSet.SaveCalcConfigs(this.CalcConfigVms.Select(a => CalcConfigData.Create(a)).ToList()); VirtualRoot.Execute(new CloseWindowCommand(this.Id)); }); Refresh(); }