private void Update1() { int x = _random.Next(0, _ledContext.Size.Width); int y = _random.Next(0, _ledContext.Size.Height); _ledContext.SetColor(new Point(x, y), _colorList[_random.Next(_colorList.Count - 1)]); }
private void SetColorByPosition(MouseEventArgs e) { if (e.Button == MouseButtons.None) { return; } var control = this; int xInterval = control.Size.Width / _panelSize.Width; int yInterval = control.Size.Height / _panelSize.Height; int x = e.X / xInterval; int y = e.Y / yInterval; if (x >= 0 && x < _panelSize.Width && y >= 0 && y < _panelSize.Height) { Color color = e.Button == MouseButtons.Right ? Color.Black : Color.FromArgb(0, 0, 128); _context.SetColor(new Point(x, y), color); } }