Exemple #1
0
        private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selectedItem = ((TabControl)sender).SelectedItem;

            if (selectedItem == TabItemToolbox)
            {
                if (ToolboxContainer.Child == null)
                {
                    ToolboxContainer.Child = new Toolbox();
                }
            }
            else if (selectedItem == TabItemMinerProfileOption)
            {
                if (MinerProfileOptionContainer.Child == null)
                {
                    MinerProfileOptionContainer.Child = new MinerProfileOption();
                }
            }
            NTMinerConsole.ShowWindow(NTMinerConsole.Show(), 0);
            if (selectedItem == TabItemLog)
            {
                TimeSpan.FromMilliseconds(200).Delay().ContinueWith(t => {
                    NTMinerConsole.ShowWindow(NTMinerConsole.Show(), 1);
                });
            }
        }
Exemple #2
0
        private void MoveConsoleWindow()
        {
            if (!this.IsLoaded)
            {
                return;
            }
            ConsoleWindow consoleWindow = ConsoleWindow.Instance;

            if (!this.IsVisible || this.WindowState == WindowState.Minimized)
            {
                consoleWindow.Hide();
                NTMinerConsole.Hide();
                return;
            }
            if (!consoleWindow.IsVisible)
            {
                consoleWindow.Show();
            }
            if (MainArea.SelectedItem == ConsoleTabItem)
            {
                NTMinerConsole.Show();
            }
            if (consoleWindow.WindowState != this.WindowState)
            {
                consoleWindow.WindowState = this.WindowState;
            }
            if (consoleWindow.Width != this.Width)
            {
                consoleWindow.Width = this.Width;
            }
            if (consoleWindow.Height != this.Height)
            {
                consoleWindow.Height = this.Height;
            }
            if (this.WindowState == WindowState.Normal)
            {
                if (consoleWindow.Left != this.Left)
                {
                    consoleWindow.Left = this.Left;
                }
                if (consoleWindow.Top != this.Top)
                {
                    consoleWindow.Top = this.Top;
                }
            }
            if (ConsoleRectangle != null && ConsoleRectangle.IsVisible)
            {
                Point point = ConsoleRectangle.TransformToAncestor(this).Transform(new Point(0, 0));
                consoleWindow.MoveWindow(marginLeft: (int)point.X, marginTop: (int)point.Y, height: (int)ConsoleRectangle.ActualHeight);
            }
        }
Exemple #3
0
        private void ReSizeConsoleWindow()
        {
            IntPtr console = NTMinerConsole.Show();
            Point  point   = ConsoleRectangle.TransformToAncestor(this).Transform(new Point(0, 0));

            if (_isFirst)
            {
                IntPtr parent = new WindowInteropHelper(this).Handle;
                NativeMethods.SetParent(console, parent);
                NativeMethods.SetWindowLong(console, NativeMethods.GWL_STYLE, NativeMethods.WS_VISIBLE);
                _isFirst = false;
            }
            int width  = (int)ConsoleRectangle.ActualWidth - 1;
            int height = (int)ConsoleRectangle.ActualHeight;

            NTMinerConsole.MoveWindow(console, (int)point.X, (int)point.Y, width, height, true);
        }
Exemple #4
0
        public void MoveWindow(int marginLeft, int marginTop, int height)
        {
            if (!this.IsLoaded)
            {
                return;
            }
            const int paddingLeft  = 4;
            const int paddingRight = 5;
            int       width        = (int)this.ActualWidth - paddingLeft - paddingRight - marginLeft;

            if (width < 0)
            {
                width = 0;
            }
            if (_marginLeft == marginLeft && _marginTop == marginTop && _height == height && _width == width)
            {
                return;
            }
            _marginLeft = marginLeft;
            _marginTop  = marginTop;
            _height     = height;
            _width      = width;
            // 如果没有ConsoleBgRectangle的话鼠标会点击到桌面上
            if (ConsoleBgRectangle.Width != width)
            {
                ConsoleBgRectangle.Width = width;
            }
            if (ConsoleBgRectangle.Height != height)
            {
                ConsoleBgRectangle.Height = height;
            }
            if ((int)ConsoleBgRectangle.Margin.Top != marginTop)
            {
                ConsoleBgRectangle.Margin = new Thickness(0, marginTop, 1, 0);
            }
            IntPtr console = NTMinerConsole.Show();

            SafeNativeMethods.MoveWindow(console, paddingLeft + marginLeft, marginTop, width, height, true);
        }