protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; g.SmoothingMode = SmoothingMode.HighQuality; g.Clear(Parent.BackColor); DrawingHelper dh = new DrawingHelper(); MultiLineHandler mlh = new MultiLineHandler(); int slope = Adjustments.Roundness; Rectangle mainRect = new Rectangle(0, 0, Width - 1, Height - 1); GraphicsPath mainPath = dh.RoundRect(mainRect, slope); Color bgColor = new Color(); Color borderColor = new Color(); Color textColor = new Color(); bgColor = dh.AdjustColor(BackColor, 30, DrawingHelper.ColorAdjustmentType.Lighten); ColorBlend bgCB = new ColorBlend(3); bgCB.Colors = new[] { bgColor, bgColor, dh.AdjustColor(bgColor, 15, DrawingHelper.ColorAdjustmentType.Darken) }; bgCB.Positions = new[] { 0.0F, 0.7F, 1.0F }; LinearGradientBrush bgLGB = new LinearGradientBrush(mainRect, Color.Transparent, Color.Transparent, 90.0F); bgLGB.InterpolationColors = bgCB; borderColor = dh.AdjustColor(bgColor, 20, DrawingHelper.ColorAdjustmentType.Darken); textColor = dh.AdjustColor(bgColor, 95, DrawingHelper.ColorAdjustmentType.Darken); g.FillPath(bgLGB, mainPath); g.DrawPath(new Pen(borderColor), mainPath); int descY = 0; if (Header != null) { g.DrawString(_header, _headerFont, new SolidBrush(textColor), new Point(8, 8)); descY = (int)(8 + g.MeasureString(_header, _headerFont).Height + 6); } else { descY = 8; } foreach (string line in mlh.GetLines(g, Text, Font, Width - 16)) { g.DrawString(line, Font, new SolidBrush(textColor), new Point(8, descY)); descY += 13; } if (_sizeByText) { Size = new Size(Width, 8 + descY + 4); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; g.SmoothingMode = SmoothingMode.HighQuality; g.Clear(Parent.BackColor); DrawingHelper dh = new DrawingHelper(); MultiLineHandler mlh = new MultiLineHandler(); int slope = Adjustments.Roundness; Rectangle mainRect = new Rectangle(0, 0, Width - 1, Height - 1); GraphicsPath mainPath = dh.RoundRect(mainRect, slope); ColorBlend backCB = new ColorBlend(3); backCB.Colors = new[] { Color.WhiteSmoke, Color.WhiteSmoke, Color.FromArgb(225, 230, 230) }; backCB.Positions = new[] { 0.0f, 0.75f, 1.0f }; LinearGradientBrush backLGB = new LinearGradientBrush(mainRect, Color.Black, Color.Black, 90.0F); backLGB.InterpolationColors = backCB; g.FillPath(backLGB, mainPath); SolidBrush textBrush = new SolidBrush(Color.FromArgb(50, 50, 50)); if (_image != null) { Rectangle imageRect = new Rectangle(12, 12, 48, 48); g.DrawImage(_image, imageRect); g.DrawString(_title, _titleFont, textBrush, new Point(12 + 48 + 4, (int)(12 + (48 / 2.0) - (g.MeasureString(_title, _titleFont).Height / 2.0)))); } else { g.DrawString(_title, _titleFont, textBrush, new Point(12, (int)(12 + (48 / 2.0) - (g.MeasureString(_title, _titleFont).Height / 2.0)))); } int descY = 12 + 48 + 14; textBrush = new SolidBrush(Color.FromArgb(120, 120, 120)); foreach (string line in mlh.GetLines(g, Text, Font, Width - 24)) { g.DrawString(line, Font, textBrush, new Point(12, descY)); descY += 13; } if (state == MouseState.Over) { g.FillPath(new SolidBrush(Color.FromArgb(10, Color.Black)), mainPath); } else if (state == MouseState.Down) { g.FillPath(new SolidBrush(Color.FromArgb(18, Color.Black)), mainPath); } LinearGradientBrush borderLGB = new LinearGradientBrush(new Rectangle(0, 0, Width, Height), Color.Silver, Color.Gainsboro, 90.0F); g.DrawPath(new Pen(borderLGB), mainPath); }