private void OpenMainCoinPool1Popup() { var coinVm = Vm.MinerProfile.CoinVm; if (coinVm == null || coinVm.CoinProfile == null) { return; } var popup = PopupMainCoinPool1; popup.IsOpen = true; var selected = coinVm.CoinProfile.MainCoinPool1; PoolSelectViewModel vm = null; // 如果服务器上下文刷新了则视图模型一定不等,因为上下文刷新后服务器视图模型会清空重建 bool newVm = popup.Child == null || ((PoolSelectViewModel)((PoolSelect)popup.Child).DataContext).Coin != coinVm; if (newVm) { vm = new PoolSelectViewModel(coinVm, selected, onOk: selectedResult => { if (selectedResult != null) { if (coinVm.CoinProfile.MainCoinPool1 != selectedResult) { coinVm.CoinProfile.MainCoinPool1 = selectedResult; } else { selectedResult.OnPropertyChanged(nameof(selectedResult.Name)); } popup.IsOpen = false; } }, usedByPool1: true) { HideView = new DelegateCommand(() => { popup.IsOpen = false; }) }; } if (popup.Child == null) { popup.Child = new PoolSelect(vm); } else if (newVm) { ((PoolSelect)popup.Child).DataContext = vm; } else { ((PoolSelect)popup.Child).Vm.SelectedResult = selected; } }
private void OpenDualCoinPoolPopup() { var coinVm = Vm.CoinVm.CoinKernel.CoinKernelProfile.SelectedDualCoin; if (coinVm == null || coinVm.CoinProfile == null) { return; } var popup = PopupDualCoinPool; popup.IsOpen = true; var selected = coinVm.CoinProfile.DualCoinPool; PoolSelectViewModel vm = null; // 如果服务器上下文刷新了则视图模型一定不等,因为上下文刷新后服务器视图模型会清空重建 bool newVm = popup.Child == null || ((PoolSelectViewModel)((PoolSelect)popup.Child).DataContext).Coin != coinVm; if (newVm) { vm = new PoolSelectViewModel(coinVm, selected, onOk: selectedResult => { if (selectedResult != null) { if (coinVm.CoinProfile.DualCoinPool != selectedResult) { coinVm.CoinProfile.DualCoinPool = selectedResult; } popup.IsOpen = false; } }) { HideView = new DelegateCommand(() => { popup.IsOpen = false; }) }; } if (popup.Child == null) { popup.Child = new PoolSelect(vm); } else if (newVm) { ((PoolSelect)popup.Child).DataContext = vm; } else { ((PoolSelect)popup.Child).Vm.SelectedResult = selected; } }
public PoolSelect(PoolSelectViewModel vm) { this.DataContext = vm; InitializeComponent(); }