/// <summary> /// Constructor of the MatrixCode object. /// </summary> /// <param name="width">Width of the window.</param> /// <param name="height">Height of the window.</param> /// <param name="updateChar">Method to use for updating a character.</param> /// <param name="colorsets">Array of ColourSets to use. First colour in the set is used at the start.</param> public MatrixCode(int width, int height, CharUpdateDelegate updateChar, ColorSet[] colorsets) { if (colorsets.Length < 1) { throw new ArgumentException("The array of ColorSets can not be empty!"); } WINDOW_WIDTH = width; WINDOW_HEIGHT = height; Colors = colorsets; CurrentColor = colorsets[0]; Random r = new Random(); _charGrid = new char[WINDOW_WIDTH, WINDOW_HEIGHT]; _lines = new MatrixLine[WINDOW_WIDTH]; for (int x = 0; x < WINDOW_WIDTH; x++) { MatrixLine line = new MatrixLine(x, this, r); line.CharUpdateEvent += updateChar; _lines[x] = line; for (int y = 0; y < WINDOW_HEIGHT; y++) { _charGrid[x, y] = GetLetter(r); updateChar(x, y, _charGrid[x, y], -1); } } }
/// <summary> /// Constructor of the MatrixCode object. /// </summary> /// <param name="width">Width of the window.</param> /// <param name="height">Height of the window.</param> /// <param name="updateChar">Method to use for updating a character.</param> /// <param name="colorsets">ColourSet to use.</param> public MatrixCode(int width, int height, CharUpdateDelegate updateChar, ColorSet colorset) : this(width, height, updateChar, new ColorSet[] { colorset }) { }