public void TestMethod1() { lock (_locker) { NTMinerRegistry.SetIsRdpEnabled(true); Assert.IsTrue(NTMinerRegistry.GetIsRdpEnabled()); NTMinerRegistry.SetIsRdpEnabled(false); Assert.IsFalse(NTMinerRegistry.GetIsRdpEnabled()); } }
private void BuildPaths() { VirtualRoot.AddCmdPath <MinerClientActionCommand>(action: message => { #region try { switch (message.ActionType) { case MinerClientActionType.SwitchRadeonGpuOn: VirtualRoot.Execute(new SwitchRadeonGpuCommand(on: true)); break; case MinerClientActionType.SwitchRadeonGpuOff: VirtualRoot.Execute(new SwitchRadeonGpuCommand(on: false)); break; case MinerClientActionType.BlockWAU: VirtualRoot.Execute(new BlockWAUCommand()); break; default: break; } } catch (Exception e) { Logger.ErrorDebugLine(e); } #endregion }, location: this.GetType()); #region 处理显示主界面命令 VirtualRoot.AddCmdPath <ShowMainWindowCommand>(action: message => { UIThread.Execute(() => { _appViewFactory.ShowMainWindow(message.IsToggle, out Window _); // 使状态栏显示显示最新状态 if (NTMinerContext.Instance.IsMining) { var mainCoin = NTMinerContext.Instance.LockedMineContext.MainCoin; if (mainCoin == null) { return; } var coinShare = NTMinerContext.Instance.CoinShareSet.GetOrCreate(mainCoin.GetId()); VirtualRoot.RaiseEvent(new ShareChangedEvent(PathId.Empty, coinShare)); if ((NTMinerContext.Instance.LockedMineContext is IDualMineContext dualMineContext) && dualMineContext.DualCoin != null) { coinShare = NTMinerContext.Instance.CoinShareSet.GetOrCreate(dualMineContext.DualCoin.GetId()); VirtualRoot.RaiseEvent(new ShareChangedEvent(PathId.Empty, coinShare)); } AppRoot.GpuSpeedVms.Refresh(); } }); }, location: this.GetType()); #endregion #region 周期确保守护进程在运行 VirtualRoot.AddEventPath <Per1MinuteEvent>("周期确保守护进程在运行", LogEnum.DevConsole, action: message => { Daemon.DaemonUtil.RunNTMinerDaemon(); NoDevFee.NoDevFeeUtil.RunNTMinerNoDevFee(); }, location: this.GetType()); #endregion #region 开始和停止挖矿后 VirtualRoot.AddEventPath <StartingMineEvent>("开始挖矿时更新挖矿按钮状态", LogEnum.DevConsole, action: message => { AppRoot.MinerProfileVm.IsMining = true; // 因为无界面模式不一定会构建挖矿状态按钮,所以放在这里而不放在挖矿按钮的VM中 StartStopMineButtonViewModel.Instance.BtnStopText = "正在挖矿"; }, location: this.GetType()); VirtualRoot.AddEventPath <MineStartedEvent>("启动1080ti小药丸、启动DevConsole? 更新挖矿按钮状态", LogEnum.DevConsole, action: message => { // 启动DevConsole if (NTMinerContext.IsUseDevConsole) { var mineContext = message.MineContext; string poolIp = mineContext.MainCoinPool.GetIp(); string consoleTitle = mineContext.MainCoinPool.Server; Daemon.DaemonUtil.RunDevConsoleAsync(poolIp, consoleTitle); } OhGodAnETHlargementPill.OhGodAnETHlargementPillUtil.Start(); }, location: this.GetType()); VirtualRoot.AddEventPath <MineStopedEvent>("停止挖矿后停止1080ti小药丸 挖矿停止后更新界面挖矿状态", LogEnum.DevConsole, action: message => { AppRoot.MinerProfileVm.IsMining = false; // 因为无界面模式不一定会构建挖矿状态按钮,所以放在这里而不放在挖矿按钮的VM中 StartStopMineButtonViewModel.Instance.BtnStopText = "尚未开始"; OhGodAnETHlargementPill.OhGodAnETHlargementPillUtil.Stop(); }, location: this.GetType()); #endregion #region 处理禁用win10系统更新 VirtualRoot.AddCmdPath <BlockWAUCommand>(action: message => { NTMiner.Windows.WindowsUtil.BlockWAU().ContinueWith(t => { if (t.Exception == null) { VirtualRoot.ThisLocalInfo(nameof(App), "禁用windows系统更新成功", OutEnum.Success); } else { VirtualRoot.ThisLocalError(nameof(App), "禁用windows系统更新失败", OutEnum.Error); } }); }, location: this.GetType()); #endregion #region 优化windows VirtualRoot.AddCmdPath <Win10OptimizeCommand>(action: message => { NTMiner.Windows.WindowsUtil.Win10Optimize(e => { if (e == null) { VirtualRoot.ThisLocalInfo(nameof(App), "优化Windows成功", OutEnum.Success); } else { VirtualRoot.ThisLocalError(nameof(App), "优化Windows失败", OutEnum.Error); } }); }, location: this.GetType()); #endregion #region 处理开启A卡计算模式 VirtualRoot.AddCmdPath <SwitchRadeonGpuCommand>(action: message => { if (NTMinerContext.Instance.GpuSet.GpuType == GpuType.AMD) { AppRoot.SwitchRadeonGpu(message.On); } }, location: this.GetType()); #endregion #region 处理A卡驱动签名 VirtualRoot.AddCmdPath <AtikmdagPatcherCommand>(action: message => { if (NTMinerContext.Instance.GpuSet.GpuType == GpuType.AMD) { AppRoot.OpenAtikmdagPatcher(); } }, location: this.GetType()); #endregion #region 启用或禁用windows远程桌面 VirtualRoot.AddCmdPath <EnableRemoteDesktopCommand>(action: message => { if (NTMinerRegistry.GetIsRdpEnabled()) { return; } string msg = "确定启用Windows远程桌面吗?"; DialogWindow.ShowSoftDialog(new DialogWindowViewModel( message: msg, title: "确认", onYes: () => { NTMinerRegistry.SetIsRdpEnabled(true); Firewall.AddRdpRule(); })); }, location: this.GetType()); #endregion #region 启用或禁用windows开机自动登录 VirtualRoot.AddCmdPath <EnableOrDisableWindowsAutoLoginCommand>(action: message => { if (NTMiner.Windows.OS.Instance.IsAutoAdminLogon) { return; } if (NTMiner.Windows.OS.Instance.IsGEWindows2004) { WindowsAutoLogon.ShowWindow(); } else { VirtualRoot.Execute(new UnTopmostCommand()); NTMiner.Windows.Cmd.RunClose("control", "userpasswords2"); } }, location: this.GetType()); #endregion }