/// <returns> /// X coordinate of right edge of dialog /// </returns> protected int GetRight() { return(Formatting.ConvertCoord(right, Console.WindowWidth)); }
/// <returns> /// Y coordinate of bottom edge of dialog /// </returns> protected int GetBottom() { return(Formatting.ConvertCoord(bottom, Console.WindowHeight)); }
/// <returns> /// Y coordinate of top edge of dialog /// </returns> protected int GetTop() { return(Formatting.ConvertCoord(top, Console.WindowHeight)); }
/// <returns> /// X coordinate of left edge of dialog /// </returns> protected int GetLeft() { return(Formatting.ConvertCoord(left, Console.WindowWidth)); }
private bool validY(int y) { y = Formatting.ConvertCoord(y, Console.WindowHeight); return(y >= 0 && y < Console.WindowHeight); }
private bool validX(int x) { x = Formatting.ConvertCoord(x, Console.WindowWidth); return(x >= 0 && x < Console.WindowWidth); }
private void Draw(int right, int top) { if (options.Count > 0) { right = Formatting.ConvertCoord(right, Console.WindowWidth); top = Formatting.ConvertCoord(top, Console.WindowHeight); Console.CursorVisible = false; // Space, vertical line, space, options, space, vertical line, space int w = longestLength + 6; // Horizontal lines before and after the options int h = options.Count + 2; Console.BackgroundColor = ConsoleTheme.Current.MenuBg; Console.ForegroundColor = ConsoleTheme.Current.MenuFg; string fullHorizLine = new string(Symbols.horizLine, longestLength + 2); for (int index = -1, y = top; y < top + h; ++index, ++y) { Console.SetCursorPosition(right - w + 1, y); // Left padding Console.Write(" "); if (index < 0) { // Draw top line Console.Write(Symbols.upperLeftCorner + fullHorizLine + Symbols.upperRightCorner); } else if (index >= options.Count) { // Draw bottom line Console.Write(Symbols.lowerLeftCorner + fullHorizLine + Symbols.lowerRightCorner); } else { ConsoleMenuOption opt = options[index]; if (opt == null) { // Draw separator Console.Write(Symbols.leftTee + fullHorizLine + Symbols.rightTee); } else { // Draw menu option Console.Write(Symbols.vertLine); if (!opt.Enabled) { Console.ForegroundColor = ConsoleTheme.Current.MenuDisabledFg; } if (index == selectedOption) { // Draw highlighted menu option Console.BackgroundColor = ConsoleTheme.Current.MenuSelectedBg; Console.Write(" " + AnnotatedCaption(opt) + " "); Console.BackgroundColor = ConsoleTheme.Current.MenuBg; } else { // Draw normal menu option Console.Write(" " + AnnotatedCaption(opt) + " "); } if (!opt.Enabled) { Console.ForegroundColor = ConsoleTheme.Current.MenuFg; } Console.Write(Symbols.vertLine); } } // Right padding Console.Write(" "); } ConsoleDialog.DrawShadow(right - w + 1, top, right, top + h - 1); DrawFooter(); Console.SetCursorPosition(right - longestLength - 3, top + selectedOption + 1); Console.CursorVisible = true; } }