Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();
            EventHandler changeNotiCenterWindowLocation = NotiCenterWindow.CreateNotiCenterWindowLocationManager(this);

            this.LocationChanged += changeNotiCenterWindowLocation;
        }
Beispiel #2
0
        private MinerClientsWindow()
        {
            Width            = SystemParameters.FullPrimaryScreenWidth * 0.95;
            Height           = SystemParameters.FullPrimaryScreenHeight * 0.95;
            this.DataContext = Vm;
            this.DataContext = AppContext.Instance.MinerClientsWindowVm;
            InitializeComponent();
            this.WindowContextEventPath <Per1SecondEvent>("刷新倒计时秒表", LogEnum.None,
                                                          action: message => {
                var minerClients = Vm.MinerClients.ToArray();
                if (Vm.CountDown > 0)
                {
                    Vm.CountDown = Vm.CountDown - 1;
                    foreach (var item in minerClients)
                    {
                        item.OnPropertyChanged(nameof(item.LastActivedOnText));
                    }
                }
            });
            this.WindowContextEventPath <Per10SecondEvent>("周期刷新在线客户端列表", LogEnum.DevConsole,
                                                           action: message => {
                AppContext.Instance.MinerClientsWindowVm.QueryMinerClients();
            });
            EventHandler changeNotiCenterWindowLocation = NotiCenterWindow.CreateNotiCenterWindowLocationManager(this);

            this.Activated       += changeNotiCenterWindowLocation;
            this.LocationChanged += changeNotiCenterWindowLocation;
            AppContext.Instance.MinerClientsWindowVm.QueryMinerClients();
            Write.UserLine("小提示:鼠标配合ctrl和shift可以多选矿机", ConsoleColor.Yellow);
        }
        public MainWindow()
        {
#if DEBUG
            VirtualRoot.Stopwatch.Restart();
#endif
            UIThread.StartTimer();
            InitializeComponent();
            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
        }
Beispiel #4
0
        public LoginWindow()
        {
            EventHandler changeNotiCenterWindowLocation = NotiCenterWindow.CreateNotiCenterWindowLocationManager(this);

            this.Activated       += changeNotiCenterWindowLocation;
            this.LocationChanged += changeNotiCenterWindowLocation;
            InitializeComponent();
            this.PbPassword.Focus();
        }
        private ChartsWindow()
        {
            Width  = SystemParameters.FullPrimaryScreenWidth * 0.95;
            Height = SystemParameters.FullPrimaryScreenHeight * 0.95;
            InitializeComponent();
            EventHandler changeNotiCenterWindowLocation = NotiCenterWindow.CreateNotiCenterWindowLocationManager(this);

            this.Activated       += changeNotiCenterWindowLocation;
            this.LocationChanged += changeNotiCenterWindowLocation;
            #region 总算力
            this.On <Per10SecondEvent>("周期刷新总算力图", LogEnum.DevConsole,
                                       action: message => {
                RefreshTotalSpeedChart(limit: 1);
            });
            RefreshTotalSpeedChart(limit: 60);
            #endregion
        }
Beispiel #6
0
        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
        }
Beispiel #7
0
        public MainWindow()
        {
            this.MinHeight = 430;
            this.MinWidth  = 640;
            this.Width     = AppStatic.MainWindowWidth;
            this.Height    = AppStatic.MainWindowHeight;
#if DEBUG
            Write.Stopwatch.Restart();
#endif
            UIThread.StartTimer();
            ConsoleWindow.Instance.OnSplashHided = MoveConsoleWindow;
            this.Owner = ConsoleWindow.Instance;
            InitializeComponent();
            this.MainArea.SelectionChanged += (sender, e) => {
                var selectedItem = MainArea.SelectedItem;
                if (selectedItem == TabItemToolbox)
                {
                    if (ToolboxContainer.Child == null)
                    {
                        ToolboxContainer.Child = new Toolbox();
                    }
                }
                else if (selectedItem == TabItemMinerProfileOption)
                {
                    if (MinerProfileOptionContainer.Child == null)
                    {
                        MinerProfileOptionContainer.Child = new MinerProfileOption();
                    }
                }
            };
            _borderBrush = this.BorderBrush;
            NTMinerRoot.RefreshArgsAssembly.Invoke();
            if (Design.IsInDesignMode)
            {
                return;
            }
            ToogleLeft();
            this.IsVisibleChanged += (sender, e) => {
                if (this.IsVisible)
                {
                    NTMinerRoot.IsUiVisible        = true;
                    NTMinerRoot.MainWindowRendedOn = DateTime.Now;
                }
                else
                {
                    NTMinerRoot.IsUiVisible = false;
                }
                MoveConsoleWindow();
            };
            this.ConsoleRectangle.IsVisibleChanged += (sender, e) => {
                MoveConsoleWindow();
            };
            this.StateChanged += (s, e) => {
                if (Vm.MinerProfile.IsShowInTaskbar)
                {
                    ShowInTaskbar = true;
                }
                else
                {
                    if (WindowState == WindowState.Minimized)
                    {
                        ShowInTaskbar = false;
                    }
                    else
                    {
                        ShowInTaskbar = true;
                    }
                }
                if (WindowState == WindowState.Maximized)
                {
                    ResizeCursors.Visibility = Visibility.Collapsed;
                    this.BorderBrush         = WpfUtil.BlackBrush;
                }
                else
                {
                    ResizeCursors.Visibility = Visibility.Visible;
                    this.BorderBrush         = _borderBrush;
                }
                MoveConsoleWindow();
            };
            this.SizeChanged += (s, e) => {
                if (!ConsoleRectangle.IsVisible)
                {
                    ConsoleWindow.Instance.Hide();
                }
            };
            this.ConsoleRectangle.SizeChanged += (s, e) => {
                MoveConsoleWindow();
            };
            EventHandler changeNotiCenterWindowLocation = NotiCenterWindow.CreateNotiCenterWindowLocationManager(this);
            this.Activated += (sender, e) => {
                changeNotiCenterWindowLocation(sender, e);
                NotiCenterWindow.Instance.SwitchOwner(this);
            };
            this.LocationChanged += (sender, e) => {
                MoveConsoleWindow();
                changeNotiCenterWindowLocation(sender, e);
            };
            VirtualRoot.BuildCmdPath <CloseMainWindowCommand>(action: message => {
                UIThread.Execute(() => {
                    if (NTMinerRoot.Instance.MinerProfile.IsCloseMeanExit)
                    {
                        VirtualRoot.Execute(new CloseNTMinerCommand());
                        return;
                    }
                    this.Close();
                    VirtualRoot.Out.ShowSuccess(message.Message, "开源矿工");
                });
            });
            if (DevMode.IsDevMode)
            {
                this.WindowContextEventPath <ServerJsonVersionChangedEvent>("开发者模式展示ServerJsonVersion", LogEnum.DevConsole,
                                                                            action: message => {
                    UIThread.Execute(() => {
                        Vm.ServerJsonVersion = NTMinerRoot.Instance.GetServerJsonVersion();
                    });
                });
            }
            this.WindowContextEventPath <PoolDelayPickedEvent>("从内核输出中提取了矿池延时时展示到界面", LogEnum.DevConsole,
                                                               action: message => {
                UIThread.Execute(() => {
                    if (message.IsDual)
                    {
                        Vm.StateBarVm.DualPoolDelayText = message.PoolDelayText;
                    }
                    else
                    {
                        Vm.StateBarVm.PoolDelayText = message.PoolDelayText;
                    }
                });
            });
            this.WindowContextEventPath <MineStartedEvent>("开始挖矿后将清空矿池延时", LogEnum.DevConsole,
                                                           action: message => {
                UIThread.Execute(() => {
                    Vm.StateBarVm.PoolDelayText     = string.Empty;
                    Vm.StateBarVm.DualPoolDelayText = string.Empty;
                });
            });
            this.WindowContextEventPath <MineStopedEvent>("停止挖矿后将清空矿池延时", LogEnum.DevConsole,
                                                          action: message => {
                UIThread.Execute(() => {
                    Vm.StateBarVm.PoolDelayText     = string.Empty;
                    Vm.StateBarVm.DualPoolDelayText = string.Empty;
                });
            });
            this.WindowContextEventPath <Per1MinuteEvent>("挖矿中时自动切换为无界面模式 和 守护进程状态显示", LogEnum.DevConsole,
                                                          action: message => {
                if (NTMinerRoot.IsUiVisible && NTMinerRoot.Instance.MinerProfile.IsAutoNoUi && NTMinerRoot.Instance.IsMining)
                {
                    if (NTMinerRoot.MainWindowRendedOn.AddMinutes(NTMinerRoot.Instance.MinerProfile.AutoNoUiMinutes) < message.Timestamp)
                    {
                        VirtualRoot.Execute(new CloseMainWindowCommand($"界面展示{NTMinerRoot.Instance.MinerProfile.AutoNoUiMinutes}分钟后自动切换为无界面模式,可在选项页调整配置"));
                    }
                }
                Vm.RefreshDaemonStateBrush();
            });
            RefreshCpu();
#if DEBUG
            Write.DevTimeSpan($"耗时{Write.Stopwatch.ElapsedMilliseconds}毫秒 {this.GetType().Name}.ctor");
#endif
        }