/// <summary> /// Raises the <see cref="E:Paint" /> event. /// </summary> /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param> protected override void OnPaint(LCDPaintEventArgs e) { switch (Style) { case RectangleStyle.Bordered: for (var x = 1; x < Width - 1; x++) { e.Bitmap[x, 0] = true; e.Bitmap[x, Height - 1] = true; } for (var y = 0; y < Height; y++) { e.Bitmap[0, y] = true; e.Bitmap[Width - 1, y] = true; } break; case RectangleStyle.Filled: for (var x = 0; x < Width; x++) { for (var y = 0; y < Height; y++) { e.Bitmap[x, y] = true; } } break; } base.OnPaint(e); }
/// <summary> /// Raises the <see cref="E:Paint" /> event. /// </summary> /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param> protected override void OnPaint(LCDPaintEventArgs e) { var widthRadius = (Width - 1) / 2; var heightRadius = (Height - 1) / 2; var centerX = Width / 2; var centerY = Height / 2; var widthRadiusSq = widthRadius * widthRadius; var heightRadiusSq = heightRadius * heightRadius; for (int x = 0, y = heightRadius, sigma = 2 * heightRadiusSq + widthRadiusSq * (1 - 2 * heightRadius); heightRadiusSq *x <= widthRadiusSq *y; x++) { e.Bitmap[centerX + x, centerY + y] = true; e.Bitmap[centerX - x, centerY + y] = true; e.Bitmap[centerX + x, centerY - y] = true; e.Bitmap[centerX - x, centerY - y] = true; if (sigma >= 0) { sigma += 4 * widthRadiusSq * (1 - y); y--; } sigma += heightRadiusSq * ((4 * x) + 6); } for (int x = widthRadius, y = 0, sigma = 2 * widthRadiusSq + heightRadiusSq * (1 - 2 * widthRadius); widthRadiusSq *y <= heightRadiusSq *x; y++) { e.Bitmap[centerX + x, centerY + y] = true; e.Bitmap[centerX - x, centerY + y] = true; e.Bitmap[centerX + x, centerY - y] = true; e.Bitmap[centerX - x, centerY - y] = true; if (sigma >= 0) { sigma += 4 * heightRadiusSq * (1 - x); x--; } sigma += widthRadiusSq * ((4 * y) + 6); } base.OnPaint(e); }
/// <summary> /// Raises the <see cref="E:Paint" /> event. /// </summary> /// <param name="e">The <see cref="LogiFrame.LCDPaintEventArgs" /> instance containing the event data.</param> protected override void OnPaint(LCDPaintEventArgs e) { int barX, barY, barWidth, barHeight; switch (Style) { case BorderStyle.Border: barX = 1; barY = 1; barWidth = Width - 2; barHeight = Height - 2; break; case BorderStyle.BorderWithPadding: barX = 2; barY = 2; barWidth = Width - 4; barHeight = Height - 4; break; case BorderStyle.None: default: barX = 0; barY = 0; barWidth = Width; barHeight = Height; break; } if (Style == BorderStyle.Border || Style == BorderStyle.BorderWithPadding) { for (var x = 1; x < Width - 1; x++) { e.Bitmap[x, 0] = true; e.Bitmap[x, Height - 1] = true; } for (var y = 0; y < Height; y++) { e.Bitmap[0, y] = true; e.Bitmap[Width - 1, y] = true; } } var val = (float)(Value - Minimum) / (Maximum - Minimum); if (barWidth <= 0 || barHeight <= 0 || val <= 0) { base.OnPaint(e); return; } { int x, y, width, height; switch (Direction) { case ProgressBarDirection.Down: x = barX; y = barY; width = barWidth; height = (int)(barHeight * val); break; case ProgressBarDirection.Up: x = barX; height = (int)(barHeight * val); y = barY + barHeight - height; width = barWidth; break; case ProgressBarDirection.Right: default: x = barX; y = barY; width = (int)(barWidth * val); height = barHeight; break; case ProgressBarDirection.Left: y = barY; width = (int)(barWidth * val); x = barX + barWidth - width; height = barHeight; break; } for (var cx = x; cx < x + width; cx++) { for (var cy = y; cy < y + height; cy++) { e.Bitmap[cx, cy] = true; } } } base.OnPaint(e); }