protected override void OnPaint(PaintEventArgs pe) { pe.Graphics.InterpolationMode = InterpolationMode.Bilinear; pe.Graphics.PixelOffsetMode = PixelOffsetMode.Half; Rectangle r = ClientRectangle; int halfWidth = r.Width / 2; int halfHeight = r.Height / 2; var linearGradientBrush = new LinearGradientBrush(r, TopColor, BottomColor, LinearGradientMode.Vertical); pe.Graphics.FillRectangle(linearGradientBrush, r); int topY = 10; int BottomY = r.Height - 25; var font = new Font(this.Font, FontStyle.Bold); using (Brush br = new SolidBrush(AllColor.GrayScale(true).Inverse())) pe.Graphics.DrawString("ALL", font, br, new Point(halfWidth - 12, halfHeight - 10)); using (Brush br = new SolidBrush(TopColor.GrayScale(true).Inverse())) pe.Graphics.DrawString("T", font, br, new Point(halfWidth - 7, topY)); using (Brush br = new SolidBrush(BottomColor.GrayScale(true).Inverse())) pe.Graphics.DrawString("B", font, br, new Point(halfWidth - 7, BottomY)); topY = 0; BottomY = r.Height - 32; const int hitSize = 32; TopHit = new Rectangle(r.X, topY, r.Width, hitSize); BottomHit = new Rectangle(r.X, BottomY, r.Width, hitSize); AllHit = new Rectangle(r.X, halfHeight - 16, r.Width, hitSize); if (mouseLoc != Point.Empty) { if (AllHit.IsHit(mouseLoc)) { DrawSelectionOutline(pe, AllHit, AllColor); } if (TopHit.IsHit(mouseLoc)) { DrawSelectionOutline(pe, TopHit, TopColor); } if (BottomHit.IsHit(mouseLoc)) { DrawSelectionOutline(pe, BottomHit, BottomColor); } } // pe.Graphics.FillRectangle(linearGradientBrush, ClientRectangle); base.OnPaint(pe); }
protected override void OnPaint(PaintEventArgs pe) { pe.Graphics.InterpolationMode = InterpolationMode.Bilinear; pe.Graphics.PixelOffsetMode = PixelOffsetMode.Half; Rectangle r = ClientRectangle; int halfWidth = r.Width / 2; int halfHeight = r.Height / 2; int LeftX = 10; int RightX = r.Width - 30; int topY = 10; int BottomY = r.Height - 25; var linearGradientBrush = new LinearGradientBrush(r, TopColor, BottomColor, LinearGradientMode.Vertical); pe.Graphics.FillRectangle(linearGradientBrush, r); var font = new Font(this.Font, FontStyle.Bold); using (Brush br = new SolidBrush(AllColor.GrayScale(true).Inverse())) pe.Graphics.DrawString("ALL", font, br, new Point(halfWidth - 12, halfHeight - 10)); using (Brush br = new SolidBrush(TopColor.GrayScale(true).Inverse())) pe.Graphics.DrawString("T", font, br, new Point(halfWidth - 7, topY)); using (Brush br = new SolidBrush(BottomColor.GrayScale(true).Inverse())) pe.Graphics.DrawString("B", font, br, new Point(halfWidth - 7, BottomY)); // pe.Graphics.FillRectangle(linearGradientBrush, ClientRectangle); const int hitSize = 40; TopHit = new Rectangle(halfWidth - 10, topY, hitSize, hitSize); BottomHit = new Rectangle(halfWidth - 10, BottomY, hitSize, hitSize); AllHit = new Rectangle(halfWidth - 10, halfHeight - 10, hitSize, hitSize); base.OnPaint(pe); }