/// <summary> /// Handles the Paint event of the gradientPanel control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param> private void gradientPanel_Paint(object sender, PaintEventArgs e) { Size cs = gradientPanel.ClientSize; int xpad = Math.Max(Math.Max(markerWidth / 2, selMarkerWidth / 2), gradientBorderSize); int ytop = gradientBorderSize; int dx = cs.Width - 2 * xpad; int dy = cs.Height - 2 * gradientBorderSize - 3 - Math.Max(markerHeight, selMarkerHeight) - 2; if (dx < 1 || dy < 1) { return; // too small to draw anything } g = e.Graphics; Rectangle gr = new Rectangle(xpad, ytop, dx, dy); if (gr != gradientRect) { ClearGradientBrush(); gradientRect = gr; } yMarker = ytop + dy + gradientBorderSize + 3; AllocPensAndBrushes(); // Fill background + border with border color if (gradientBorderSize > 0) { Rectangle r = Rectangle.Inflate(gr, gradientBorderSize, gradientBorderSize); g.FillRectangle(borderBrush, r); } // Draw gradient gradientBrush.FillRectangle(g, gr, backGradientBrush); // Draw markers if (markers == null) { markers = new GraphicsPath[vals.Count]; } for (int s = 0; s < vals.Count; s++) { if (s != sel) { if (markers[s] == null) { markers[s] = AllocMarker(vals[s].Position); } DrawMarker(markers[s]); } } if (selMarker == null) { selMarker = AllocSelMarker(vals[sel].Position); } DrawSelMarker(selMarker); }
private void this_Paint(object sender, PaintEventArgs e) { if (blend != null) { if (br == null) { br = new LinearGradientBrush2(this.ClientRectangle, blend, mode); } br.FillRectangle(e.Graphics, this.ClientRectangle, SystemBrushes.Window); } }