private ConsoleBuffer(int width, int height, BufferUnitInfo[,] bufferData) { _width = width; _height = height; _buffer = bufferData; UnitCount = _buffer.Length; }
/// <summary> /// Loads buffer data from a file and returns it as a ConsoleBuffer object. /// </summary> /// <param name="path">The path to the buffer file.</param> /// <returns></returns> public static ConsoleBuffer FromFile(string path) { using (BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open))) { int width = reader.ReadInt32(); int height = reader.ReadInt32(); BufferUnitInfo[,] bufferData = new BufferUnitInfo[height, width]; BufferUnitInfo temp = new BufferUnitInfo(); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { temp._attrs = reader.ReadInt16(); temp.CharData = reader.ReadChar(); bufferData[j, i] = temp; } } return(new ConsoleBuffer(width, height, bufferData)); } }
/// <summary> /// Loads buffer data from a file and returns it as a ConsoleBuffer object. /// </summary> /// <param name="path">The path to the buffer file.</param> /// <returns></returns> public static ConsoleBuffer FromFile(string path) { using(BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open))) { int width = reader.ReadInt32(); int height = reader.ReadInt32(); BufferUnitInfo[,] bufferData = new BufferUnitInfo[height, width]; BufferUnitInfo temp = new BufferUnitInfo(); for(int i = 0; i < width; i++) for(int j = 0; j < height; j++) { temp._attrs = reader.ReadInt16(); temp.CharData = reader.ReadChar(); bufferData[j, i] = temp; } return new ConsoleBuffer(width, height, bufferData); } }