protected override void OnPaint(PaintEventArgs e) { //back color is used for the gap for the pressing animation Color color = HyacinthPalette.GetStyleColor(HyacinthColorStyle.Black); // default color based on style config if (this.useCustomBackground) { color = this.BackColor; } e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.CompositingQuality = CompositingQuality.HighQuality; //Pressed if (!this.isPressed) { e.Graphics.Clear(color); } else { e.Graphics.Clear(this.Parent.BackColor); using (SolidBrush solidBrush = new SolidBrush(color)) { Point[] points = new Point[4] { new Point(0, 0), new Point(this.Width - 1, 2), new Point(this.Width - 1, this.Height - 2), new Point(0, this.Height) }; e.Graphics.FillPolygon((Brush)solidBrush, points); } } }
protected override void OnPaintBackground(PaintEventArgs e) { base.OnPaintBackground(e); Color color = HyacinthPalette.BackColor.Form(HyacinthThemeStyle.Default); Color foreColor = HyacinthPalette.ForeColor.Form(HyacinthThemeStyle.Default); e.Graphics.Clear(color); using (SolidBrush styleBrush = HyacinthPalette.GetStyleBrush(HyacinthColorStyle.Black)) { Rectangle rect = new Rectangle(0, 0, this.Width, 5); e.Graphics.FillRectangle((Brush)styleBrush, rect); } if (this.BorderStyle != HyacinthBorderStyle.None) { using (Pen pen = new Pen(HyacinthPalette.BorderColor.Form(HyacinthThemeStyle.Default))) e.Graphics.DrawLines(pen, new Point[4] { new Point(0, 5), new Point(0, this.Height - 1), new Point(this.Width - 1, this.Height - 1), new Point(this.Width - 1, 5) }); } //if (!this.displayHeader) // return; //TextRenderingHint textRenderingHint = e.Graphics.TextRenderingHint; //e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; SmoothingMode smoothingMode = e.Graphics.SmoothingMode; e.Graphics.SmoothingMode = SmoothingMode.HighQuality; //Rectangle bounds = new Rectangle(20, 20, this.ClientRectangle.Width - 40, 40); //TextFormatFlags flags = TextFormatFlags.EndEllipsis | this.GetTextFormatFlags(); //TextRenderer.DrawText((IDeviceContext)e.Graphics, this.Text, MetroFonts.Title, bounds, foreColor, flags); //e.Graphics.TextRenderingHint = textRenderingHint; e.Graphics.SmoothingMode = smoothingMode; }