Example #1
0
 private void BtnMinerClientFinder_Click(object sender, RoutedEventArgs e)
 {
     if (this.MinerClientFinderIcon.Visibility == Visibility.Visible)
     {
         Process process = Process.GetProcessesByName(NTKeyword.MinerClientFinderProcessName).FirstOrDefault();
         if (process == null)
         {
             this.MinerClientFinderIcon.Visibility        = Visibility.Collapsed;
             this.MinerClientFinderLoadingIcon.Visibility = Visibility.Visible;
             // 这里的逻辑是每100毫秒检查一次MinerClientFinder进程是否存在,每检查一次将loading图标
             // 旋转30度,如果MinerClientFinder进程存在了或者已经检查了3秒钟了则停止检查。
             VirtualRoot.SetInterval(
                 per: TimeSpan.FromMilliseconds(100),
                 perCallback: () => {
                 UIThread.Execute(() => () => {
                     ((RotateTransform)this.MinerClientFinderLoadingIcon.RenderTransform).Angle += 30;
                 });
             },
                 stopCallback: () => {
                 UIThread.Execute(() => () => {
                     this.MinerClientFinderIcon.Visibility        = Visibility.Visible;
                     this.MinerClientFinderLoadingIcon.Visibility = Visibility.Collapsed;
                     ((RotateTransform)this.MinerClientFinderLoadingIcon.RenderTransform).Angle = 0;
                 });
             },
                 timeout: TimeSpan.FromSeconds(3),
                 requestStop: () => {
                 return(Process.GetProcessesByName(NTKeyword.MinerClientFinderProcessName).FirstOrDefault() != null);
             }
                 );
         }
     }
 }
Example #2
0
 public ToolboxViewModel()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     this.SwitchRadeonGpu = new DelegateCommand(() => {
         if (MinerProfileViewModel.Instance.IsMining)
         {
             VirtualRoot.Out.ShowInfo("请先停止挖矿");
             return;
         }
         var config = new DialogWindowViewModel(
             isConfirmNo: true,
             btnNoToolTip: "注意:关闭计算模式挖矿算力会减半",
             message: $"过程大概需要花费5到10秒钟", title: "确认", onYes: () => {
             VirtualRoot.Execute(new SwitchRadeonGpuCommand(on: true));
         }, onNo: () => {
             VirtualRoot.Execute(new SwitchRadeonGpuCommand(on: false));
             return(true);
         }, btnYesText: "开启计算模式", btnNoText: "关闭计算模式");
         this.ShowSoftDialog(config);
     });
     this.AtikmdagPatcher = new DelegateCommand(() => {
         if (MinerProfileViewModel.Instance.IsMining)
         {
             VirtualRoot.Out.ShowInfo("请先停止挖矿");
             return;
         }
         VirtualRoot.Execute(new AtikmdagPatcherCommand());
     });
     this.RegCmdHere = new DelegateCommand(() => {
         if (IsRegedCmdHere)
         {
             this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定移除windows右键上下文菜单中的\"命令行\"菜单吗?", title: "确认", onYes: () => {
                 Task.Factory.StartNew(() => {
                     VirtualRoot.Execute(new UnRegCmdHereCommand());
                     OnPropertyChanged(nameof(IsRegedCmdHere));
                 });
             }, btnYesText: "移除"));
         }
         else
         {
             this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定在windows右键上下文菜单中添加\"命令行\"菜单吗?", title: "确认", onYes: () => {
                 Task.Factory.StartNew(() => {
                     this.IsWinCmdLoading = true;
                     VirtualRoot.SetInterval(per: TimeSpan.FromMilliseconds(100), perCallback: () => {
                         this.WinCmdLodingIconAngle += 30;
                     }, stopCallback: () => {
                         this.IsWinCmdLoading = false;
                         OnPropertyChanged(nameof(IsRegedCmdHere));
                     }, timeout: TimeSpan.FromSeconds(6), requestStop: () => {
                         return(IsRegedCmdHere);
                     });
                     VirtualRoot.Execute(new RegCmdHereCommand());
                 });
             }, btnYesText: "添加"));
         }
     });
     this.BlockWAU = new DelegateCommand(() => {
         this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定禁用Windows系统更新吗?禁用后可在Windows服务中找到Windows Update手动启用。", title: "确认", onYes: () => {
             VirtualRoot.Execute(new BlockWAUCommand());
         }, helpUrl: "https://www.cnblogs.com/ntminer/p/12155769.html"));
     });
     this.Win10Optimize = new DelegateCommand(() => {
         this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定面向挖矿优化windows吗?", title: "确认", onYes: () => {
             VirtualRoot.Execute(new Win10OptimizeCommand());
         }, helpUrl: "https://www.cnblogs.com/ntminer/p/12155773.html"));
     });
     this.EnableWindowsRemoteDesktop = new DelegateCommand(() => {
         VirtualRoot.Execute(new EnableWindowsRemoteDesktopCommand());
     });
     this.WindowsAutoLogon = new DelegateCommand(() => {
         VirtualRoot.Execute(new EnableOrDisableWindowsAutoLoginCommand());
     });
     this.OpenDevmgmt = new DelegateCommand(() => {
         Process.Start("devmgmt.msc");
     });
     this.OpenEventvwr = new DelegateCommand(() => {
         Process.Start("eventvwr.msc", "/c:Application");
     });
 }