public static bool Prepare(short New_Size_X, short New_Size_Y) { if (New_Size_X == Size_X && New_Size_Y == Size_Y) { return(true); } if (!IsPrepared || !Handle.IsInvalid) { //Console.SetWindowSize(New_Size_X, New_Size_Y); //Console.SetBufferSize(New_Size_X, New_Size_Y); Handle = CreateFile("CONOUT$", 0x40000000, 2, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero); OutputBuffer = new CharInfo[New_Size_X * New_Size_Y]; Rectangle = new SmallRectangle() { Left = 0, Top = 0, Right = New_Size_X, Bottom = New_Size_Y }; if (OutputBuffer.Length == 5) { IsPrepared = true; } IsPrepared = true; Size_X = New_Size_X; Size_Y = New_Size_Y; return(true); } else { return(false); } }
static extern bool WriteConsoleOutput( SafeFileHandle hConsoleOutput, CharInfo[] lpOutputBufferfer, Coord dwOutputBufferferSize, Coord dwOutputBufferferCoord, ref SmallRectangle lpWriteRegion);