本文整理汇总了C#中CONSOLE_SCREEN_BUFFER_INFO类的典型用法代码示例。如果您正苦于以下问题:C# CONSOLE_SCREEN_BUFFER_INFO类的具体用法?C# CONSOLE_SCREEN_BUFFER_INFO怎么用?C# CONSOLE_SCREEN_BUFFER_INFO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CONSOLE_SCREEN_BUFFER_INFO类属于命名空间,在下文中一共展示了CONSOLE_SCREEN_BUFFER_INFO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ColorConsole
// Constructor.
public ColorConsole()
{
ConsoleInfo = new CONSOLE_SCREEN_BUFFER_INFO();
ConsoleOutputLocation = new COORD();
hConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsoleHandle, ref ConsoleInfo);
OriginalColors = ConsoleInfo.wAttributes;
}
示例2: ColorConsole
public ColorConsole()
{
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
if(IsHandleValid())
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo = new CONSOLE_SCREEN_BUFFER_INFO();
GetConsoleScreenBufferInfo(hStdout, ref csbiInfo);
attributes = csbiInfo.wAttributes;
}
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-msnet-netz-compressor-madebits,代码行数:10,代码来源:ColorConsole.cs
示例3: Clear
public static void Clear()
{
int hWrittenChars = 0;
CONSOLE_SCREEN_BUFFER_INFO strConsoleInfo = new CONSOLE_SCREEN_BUFFER_INFO();
COORD Home;
Home.x = Home.y = 0;
GetConsoleScreenBufferInfo(hConsoleHandle, ref strConsoleInfo);
FillConsoleOutputCharacter(hConsoleHandle, EMPTY, strConsoleInfo.dwSize.x * strConsoleInfo.dwSize.y, Home, ref hWrittenChars);
SetConsoleCursorPosition(hConsoleHandle, Home);
}
示例4: ConsoleEx
static ConsoleEx()
{
// Grab input and output buffer handles
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
hConsoleInput = GetStdHandle(STD_INPUT_HANDLE);
if (hConsoleOutput == INVALID_HANDLE_VALUE || hConsoleInput == INVALID_HANDLE_VALUE)
throw new ApplicationException("Unable to obtain buffer handle during initialization.");
// Get information about the console window characteristics.
ConsoleInfo = new CONSOLE_SCREEN_BUFFER_INFO();
//ConsoleOutputLocation = new COORD();
GetConsoleScreenBufferInfo(hConsoleOutput, ref ConsoleInfo);
OriginalConsolePen = ConsoleInfo.wAttributes;
// Disable wrapping at the end of a line (ENABLE_WRAP_AT_EOL_INPUT); this enables rectangles
// to be drawn that fill the screen without the window scrolling.
SetConsoleMode(hConsoleOutput,
(int) OutputModeFlags.ENABLE_PROCESSED_OUTPUT);
}
示例5: GetConsoleWindowWidth
/// <summary>
/// Returns the number of columns in the current console window
/// </summary>
/// <returns>Returns the number of columns in the current console window</returns>
public static int GetConsoleWindowWidth()
{
int screenWidth;
CONSOLE_SCREEN_BUFFER_INFO csbi = new CONSOLE_SCREEN_BUFFER_INFO();
int rc;
rc = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), ref csbi);
screenWidth = csbi.dwSize.x;
return screenWidth;
}
示例6: GetConsoleScreenBufferInfo
public static extern int GetConsoleScreenBufferInfo(int hConsoleOutput,
ref CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
示例7: GetConsoleScreenBufferInfo
private static extern bool GetConsoleScreenBufferInfo(
IntPtr consoleHandle,
out CONSOLE_SCREEN_BUFFER_INFO bufferInfo);
示例8: RemoveIntensity
/// <summary>
/// Decreases forground color intensity
/// </summary>
internal static void RemoveIntensity()
{
CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo = new CONSOLE_SCREEN_BUFFER_INFO();
GetConsoleScreenBufferInfo(hConsoleOut, ref ConsoleInfo);
SetConsoleTextAttribute(hConsoleOut, (ushort)(ConsoleInfo.wAttributes & (~FR_INTENSITY)));
}
示例9: GetConsoleScreenBufferInfo
private static extern bool GetConsoleScreenBufferInfo(IntPtr hConsoleOutput,
ref CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
示例10: GetConsoleWindowWidth
/// <summary>
/// Returns the number of columns in the current console window
/// </summary>
/// <returns>Returns the number of columns in the current console window</returns>
public static int GetConsoleWindowWidth()
{
int screenWidth;
CONSOLE_SCREEN_BUFFER_INFO csbi = new CONSOLE_SCREEN_BUFFER_INFO();
// If the function succeeds, the return value is nonzero.
int rc = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), ref csbi);
if (rc == 0){
throw new ApplicationException ("Unable to obtain console width");
}
screenWidth = csbi.dwSize.x;
return screenWidth;
}
示例11: GetConsoleScreenBufferInfo
internal static bool GetConsoleScreenBufferInfo(IntPtr consoleHandle, out ConsoleControl.CONSOLE_SCREEN_BUFFER_INFO consoleScreenBufferInfo)
{
ConsoleControl.CONSOLE_SCREEN_BUFFER_INFO c = new CONSOLE_SCREEN_BUFFER_INFO();
c.BufferSize.X = (short)Console.BufferWidth;
c.BufferSize.Y = (short)Console.BufferHeight;
c.CursorPosition.X = (short)Console.CursorLeft;
c.CursorPosition.Y = (short)Console.CursorTop;
c.MaxWindowSize.X = (short)Console.LargestWindowWidth;
c.MaxWindowSize.Y = (short)Console.LargestWindowHeight;
consoleScreenBufferInfo = c;
return true;
}
示例12: Move
/// <summary>
/// Moves the console cursor to the specified location on the screen.
/// </summary>
/// <param name="x">X co-ordinate for desired location (typically 0 to 79)</param>
/// <param name="y">Y co-ordinate for desired location (typically 0 to 24)</param>
public static void Move(int x, int y)
{
// Check that parameters specified are sane
CONSOLE_SCREEN_BUFFER_INFO strConsoleInfo = new CONSOLE_SCREEN_BUFFER_INFO();
GetConsoleScreenBufferInfo(hConsoleOutput, ref strConsoleInfo);
if (x >= strConsoleInfo.dwSize.x || x < 0)
throw new ArgumentOutOfRangeException("x", x,
"The co-ordinates specified must be within the dimensions of the window.");
if (y >= strConsoleInfo.dwSize.y || y < 0)
throw new ArgumentOutOfRangeException("y", y,
"The co-ordinates specified must be within the dimensions of the window.");
COORD cursorLocation;
cursorLocation.x = (short)x;
cursorLocation.y = (short)y;
SetConsoleCursorPosition(hConsoleOutput, cursorLocation);
}
示例13: Clear
/// <summary>
/// Clears screen.
/// </summary>
public static void Clear()
{
int hWrittenChars = 0;
CONSOLE_SCREEN_BUFFER_INFO strConsoleInfo = new CONSOLE_SCREEN_BUFFER_INFO();
COORD Home;
Home.x = Home.y = 0;
if (GetConsoleScreenBufferInfo(hConsoleOutput, ref strConsoleInfo) == 0)
{
// If the device does not support GetConsoleScreenBufferInfo, then try just
// writing ^L (ASCII control code for Form Feed) to the screen. This may
// work for some scenarios such as using telnet to access a remote console.
Console.Write('\x0c'); // ^L
return;
}
FillConsoleOutputCharacter(hConsoleOutput, EMPTY,
strConsoleInfo.dwSize.x * strConsoleInfo.dwSize.y, Home, ref hWrittenChars);
FillConsoleOutputAttribute(hConsoleOutput, CurrentConsolePen,
strConsoleInfo.dwSize.x * strConsoleInfo.dwSize.y, Home, ref hWrittenChars);
SetConsoleCursorPosition(hConsoleOutput, Home);
}
示例14: GetConsoleScreenBufferInfo
internal static extern bool GetConsoleScreenBufferInfo(IntPtr hConsoleOutput,
out CONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
示例15: get_console_buffer
private CONSOLE_SCREEN_BUFFER_INFO get_console_buffer()
{
var defaultConsoleBuffer = new CONSOLE_SCREEN_BUFFER_INFO
{
dwSize = new COORD(),
dwCursorPosition = new COORD(),
dwMaximumWindowSize = new COORD(),
srWindow = new SMALL_RECT(),
wAttributes = 0,
};
if (!is_windows()) return defaultConsoleBuffer;
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (GetConsoleScreenBufferInfo(GetStdHandle(StdHandle.StdOut), out csbi))
{
// if the console buffer exists
return csbi;
}
return defaultConsoleBuffer;
}