private void FpsHandler() { var leds = _ledContext.GetLeds(); string data = _protocol.Convert(leds); SendText(data); RefreshView(); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); var control = this; Bitmap bmp = new Bitmap(control.Size.Width, control.Size.Height); Graphics g = Graphics.FromImage(bmp); int xInterval = control.Size.Width / _panelSize.Width; int yInterval = control.Size.Height / _panelSize.Height; var leds = _context.GetLeds(); for (int j = 0; j < _panelSize.Height; j++) { for (int i = 0; i < _panelSize.Width; i++) { SolidBrush myBrush = new SolidBrush(leds[j, i]); g.FillRectangle(myBrush, i * xInterval, j * yInterval, xInterval, yInterval); myBrush.Dispose(); } } // horizontal lines for (int i = 1; i < _panelSize.Width; i++) { g.DrawLine(_pen, new Point(i * xInterval, 0), new Point(i * xInterval, Size.Height)); } // vertical lines for (int i = 1; i < _panelSize.Height; i++) { g.DrawLine(_pen, new Point(0, i * yInterval), new Point(Size.Width, i * yInterval)); } e.Graphics.DrawImage(bmp, 0, 0, bmp.Width, bmp.Height); bmp.Dispose(); g.Dispose(); }