public MainWindow() { this.MinHeight = 430; this.MinWidth = 640; this.Width = AppStatic.MainWindowWidth; this.Height = AppStatic.MainWindowHeight; #if DEBUG Write.Stopwatch.Restart(); #endif UIThread.StartTimer(); InitializeComponent(); NTMinerRoot.RefreshArgsAssembly.Invoke(); if (Design.IsInDesignMode) { return; } this.StateChanged += (s, e) => { if (Vm.MinerProfile.IsShowInTaskbar) { ShowInTaskbar = true; } else { if (WindowState == WindowState.Minimized) { ShowInTaskbar = false; } else { ShowInTaskbar = true; } } }; this.SizeChanged += (object sender, SizeChangedEventArgs e) => { if (e.WidthChanged) { const double width = 800; if (e.NewSize.Width < width) { Collapse(); } else if (e.NewSize.Width >= width) { Expand(); } } }; this.ConsoleRectangle.SizeChanged += (object sender, SizeChangedEventArgs e) => { ReSizeConsoleWindow(); }; EventHandler changeNotiCenterWindowLocation = NotiCenterWindow.CreateNotiCenterWindowLocationManager(this); this.Activated += changeNotiCenterWindowLocation; this.LocationChanged += changeNotiCenterWindowLocation; if (DevMode.IsDevMode) { this.On <ServerJsonVersionChangedEvent>("开发者模式展示ServerJsonVersion", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { Vm.ServerJsonVersion = Vm.GetServerJsonVersion(); }); }); } this.On <PoolDelayPickedEvent>("从内核输出中提取了矿池延时时展示到界面", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { if (message.IsDual) { Vm.StateBarVm.DualPoolDelayText = message.PoolDelayText; } else { Vm.StateBarVm.PoolDelayText = message.PoolDelayText; } }); }); this.On <MineStartedEvent>("开始挖矿后将清空矿池延时", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { Vm.StateBarVm.PoolDelayText = string.Empty; Vm.StateBarVm.DualPoolDelayText = string.Empty; }); }); this.On <MineStopedEvent>("停止挖矿后将清空矿池延时", LogEnum.DevConsole, action: message => { UIThread.Execute(() => { Vm.StateBarVm.PoolDelayText = string.Empty; Vm.StateBarVm.DualPoolDelayText = string.Empty; }); }); this.On <Per1MinuteEvent>("挖矿中时自动切换为无界面模式 和 守护进程状态显示", LogEnum.DevConsole, action: message => { if (NTMinerRoot.IsUiVisible && NTMinerRoot.GetIsAutoNoUi() && NTMinerRoot.Instance.IsMining) { if (NTMinerRoot.MainWindowRendedOn.AddMinutes(NTMinerRoot.GetAutoNoUiMinutes()) < message.Timestamp) { VirtualRoot.Execute(new CloseMainWindowCommand($"界面展示{NTMinerRoot.GetAutoNoUiMinutes()}分钟后自动切换为无界面模式,可在选项页调整配置")); } } Vm.RefreshDaemonStateBrush(); }); #if DEBUG Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor"); #endif }