Exemple #1
0
        public MainWindow()
        {
#if DEBUG
            VirtualRoot.Stopwatch.Restart();
#endif
            UIThread.StartTimer();
            InitializeComponent();
            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 = 720;
                    if (e.NewSize.Width < width)
                    {
                        foreach (var tabItem in this.MainTab.Items.OfType <MainTabItem>())
                        {
                            tabItem.Margin = new Thickness(0);
                        }
                    }
                    else if (e.NewSize.Width >= width)
                    {
                        foreach (var tabItem in this.MainTab.Items.OfType <MainTabItem>())
                        {
                            tabItem.Margin = new Thickness(8, 0, 8, 0);
                        }
                    }
                }
            };
            EventHandler changeNotiCenterWindowLocation = NotiCenterWindow.CreateNotiCenterWindowLocationManager(this);
            this.Activated       += changeNotiCenterWindowLocation;
            this.LocationChanged += changeNotiCenterWindowLocation;
            if (DevMode.IsDevMode)
            {
                this.On <ServerJsonVersionChangedEvent>("开发者模式展示ServerJsonVersion", LogEnum.DevConsole,
                                                        action: message => {
                    Vm.ServerJsonVersion = Vm.GetServerJsonVersion();
                });
            }
#if DEBUG
            Write.DevWarn($"耗时{VirtualRoot.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
        }
Exemple #2
0
        public MainWindow()
        {
#if DEBUG
            VirtualRoot.Stopwatch.Restart();
#endif
            UIThread.StartTimer();
            InitializeComponent();
            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();
                    }
                }
            };
            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());
                    }
                }
            });
#if DEBUG
            Write.DevWarn($"耗时{VirtualRoot.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
        }