namespace ConsoleDisplay.Driver.Virtual { public class VirtualDisplay : IDisplay { private List BulbList; public VirtualDisplay(int iWidth, int iHeight) { Width = iWidth; Height = iHeight; BulbList = new List(); h_Init(iWidth, iHeight); IsEnabled = true; } private void h_Init(int width, int height) { for (int ii = 0; ii < width; ii++) { for (int jj = 0; jj < height; jj++) { BulbList.Add(new VirtualBulb(ii, jj)); } } } public int Width { get; } public int Height { get; } public bool IsEnabled { get; } public void Reset() { for (int jj = 0; jj < BulbList.Count; jj++) { BulbList[jj].IsEnabled = false; } } public void Set(int iX, int iY, bool bState) { VirtualBulb vb = h_GetBulb(iX, iY); if (vb == null) return; vb.IsEnabled = bState; } private VirtualBulb h_GetBulb(int iX, int iY) { for (int jj = 0; jj < BulbList.Count; jj++) { if (BulbList[jj].X == iX && BulbList[jj].Y == iY) { return BulbList[jj]; } } return null; } public bool Get(int iX, int iY) { VirtualBulb vb = h_GetBulb(iX, iY); if (vb == null) return false; return vb.IsEnabled; } } }