本文整理汇总了C#中System.Console.WindowLeft属性的典型用法代码示例。如果您正苦于以下问题:C# Console.WindowLeft属性的具体用法?C# Console.WindowLeft怎么用?C# Console.WindowLeft使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Console
的用法示例。
在下文中一共展示了Console.WindowLeft属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
public class Example
{
public static void Main()
{
ConsoleKeyInfo key;
bool moved = false;
Console.BufferWidth += 4;
Console.Clear();
ShowConsoleStatistics();
do
{
key = Console.ReadKey(true);
if (key.Key == ConsoleKey.LeftArrow)
{
int pos = Console.WindowLeft - 1;
if (pos >= 0 && pos + Console.WindowWidth <= Console.BufferWidth)
{
Console.WindowLeft = pos;
moved = true;
}
}
else if (key.Key == ConsoleKey.RightArrow)
{
int pos = Console.WindowLeft + 1;
if (pos + Console.WindowWidth <= Console.BufferWidth)
{
Console.WindowLeft = pos;
moved = true;
}
}
if (moved)
{
ShowConsoleStatistics();
moved = false;
}
Console.WriteLine();
} while (true);
}
private static void ShowConsoleStatistics()
{
Console.WriteLine("Console statistics:");
Console.WriteLine(" Buffer: {0} x {1}", Console.BufferHeight, Console.BufferWidth);
Console.WriteLine(" Window: {0} x {1}", Console.WindowHeight, Console.WindowWidth);
Console.WriteLine(" Window starts at {0}.", Console.WindowLeft);
Console.WriteLine("Press <- or -> to move window, Ctrl+C to exit.");
}
}