private void GetMoveToValues(out int marginLeft, out int marginTop, out int width, out int height) { Point point = ConsoleRectangle.TransformToAncestor(this).Transform(new Point(0, 0)); const int paddingLeft = 4; const int paddingRight = 5; marginLeft = paddingLeft + (int)point.X; marginTop = (int)point.Y; width = (int)this.ActualWidth - marginLeft - paddingRight; height = (int)ConsoleRectangle.ActualHeight; }
private void MoveConsoleWindow() { if (!this.IsLoaded) { return; } ConsoleWindow consoleWindow = ConsoleWindow.Instance; if (!this.IsVisible || this.WindowState == WindowState.Minimized) { consoleWindow.Hide(); return; } if (!consoleWindow.IsVisible) { consoleWindow.Show(); } if (consoleWindow.WindowState != this.WindowState) { consoleWindow.WindowState = this.WindowState; } // -2 -1是因为主窗口有圆角,但下层的控制台窗口不能透明所以不能圆角,把下层的控制台窗口的宽高缩小一点点从而避免看见下层控制台窗口的棱角 if (consoleWindow.Width != this.Width - 2) { consoleWindow.Width = this.Width - 2; } if (consoleWindow.Height != this.Height - 2) { consoleWindow.Height = this.Height - 2; } if (this.WindowState == WindowState.Normal) { if (consoleWindow.Left != this.Left + 1) { consoleWindow.Left = this.Left + 1; } if (consoleWindow.Top != this.Top + 1) { consoleWindow.Top = this.Top + 1; } } if (ConsoleRectangle != null && ConsoleRectangle.IsVisible) { Point point = ConsoleRectangle.TransformToAncestor(this).Transform(new Point(0, 0)); const int paddingLeft = 4; const int paddingRight = 5; int marginLeft = paddingLeft + (int)point.X; int width = (int)this.ActualWidth - marginLeft - paddingRight; consoleWindow.MoveWindow(marginLeft: marginLeft, marginTop: (int)point.Y, width, height: (int)ConsoleRectangle.ActualHeight); } }
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); } }
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); }
/// <summary> /// Write text in rectangle at top of console screen /// </summary> /// <param name="message">Text to display</param> public static void WriteHeader(string message) { var item = new ConsoleRectangle(message, 100, 1, new Point(0, 0)); item.Draw(); }