protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.Clear(Parent.BackColor); G.FillPath(DesignFunctions.ToBrush(85, 85, 85), DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 3)); LinearGradientBrush BackgroundGradient = new LinearGradientBrush(new Point(0, 0), new Point(0, Height), Color.FromArgb(75, 130, 195), Color.FromArgb(40, 80, 135)); G.FillPath(BackgroundGradient, DesignFunctions.RoundRect(0, 1, (Width - 1) * _value / _maximum, Height - 3, 3)); G.DrawPath(DesignFunctions.ToPen(150, Color.Black), DesignFunctions.RoundRect(0, 1, (Width - 1) * _value / _maximum, Height - 3, 3)); if (_value > 0) { G.SmoothingMode = SmoothingMode.AntiAlias; G.SetClip(DesignFunctions.RoundRect(0, 0, (Width - 1) * _value / _maximum - 1, Height - 1, 3)); for (var i = 0; i <= (Width - 1) * _value / _maximum; i += 25) { G.DrawLine(new Pen(new SolidBrush(Color.FromArgb(35, Color.White)), 10F), new Point(i, 0 - 5), new Point(i + 25, Height + 10)); } G.ResetClip(); G.DrawLine(DesignFunctions.ToPen(100, Color.White), new Point(2, 1), new Point((Width - 3) * _value / _maximum - 3, 1)); G.SmoothingMode = SmoothingMode.None; } G.DrawPath(Pens.Gray, DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 3)); G.DrawPath(Pens.Black, DesignFunctions.RoundRect(0, 0, Width - 1, Height - 2, 3)); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.SmoothingMode = SmoothingMode.AntiAlias; if (Checked) { G.FillEllipse(new LinearGradientBrush(new Point(Height / 2, 0), new Point(Height / 2, Height), Color.FromArgb(75, 130, 195), Color.FromArgb(40, 80, 135)), new Rectangle(0, 0, Height - 1, Height - 1)); G.FillEllipse(DesignFunctions.ToBrush(150, Color.Black), new Rectangle(4, 4, Height - 9, Height - 9)); } else { if (MouseState == State.Over) { G.FillEllipse(new LinearGradientBrush(new Point(Height / 2, 0), new Point(Height / 2, Height), Color.FromArgb(75, 130, 195), Color.FromArgb(40, 80, 135)), new Rectangle(0, 0, Height - 1, Height - 1)); } else { G.FillEllipse(new LinearGradientBrush(new Point(Height / 2, 0), new Point(Height / 2, Height), Color.FromArgb(127, 127, 127), Color.FromArgb(93, 93, 93)), new Rectangle(0, 0, Height - 1, Height - 1)); } } G.DrawEllipse(DesignFunctions.ToPen(50, Color.White), new Rectangle(0, 1, Height - 1, Height - 2)); G.DrawEllipse(Pens.Black, new Rectangle(0, 0, Height - 1, Height - 1)); }
public void ReplaceItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { e.DrawBackground(); Graphics G = e.Graphics; try { G.FillRectangle(DesignFunctions.ToBrush(95, 95, 95), e.Bounds); G.DrawString(base.GetItemText(base.Items[e.Index]), e.Font, Brushes.LightGray, new Rectangle(e.Bounds.X + 4, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), new StringFormat { LineAlignment = StringAlignment.Center }); if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { LinearGradientBrush BackgroundGradient = new LinearGradientBrush(new Point(e.Bounds.X, e.Bounds.Y), new Point(e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1), Color.FromArgb(75, 130, 195), Color.FromArgb(40, 80, 135)); G.FillPath(BackgroundGradient, DesignFunctions.RoundRect(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1, 3)); G.DrawLine(DesignFunctions.ToPen(100, Color.White), new Point(e.Bounds.X, e.Bounds.Y + 1), new Point(e.Bounds.Width - 1, e.Bounds.Y + 1)); G.DrawPath(Pens.Gray, DesignFunctions.RoundRect(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1, 3)); G.DrawPath(Pens.Black, DesignFunctions.RoundRect(e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 2, 3)); G.DrawString(base.GetItemText(base.Items[e.Index]), e.Font, Brushes.White, new Rectangle(e.Bounds.X + 4, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), new StringFormat { LineAlignment = StringAlignment.Center }); } } catch { //Uh oh } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.Clear(Parent.BackColor); LinearGradientBrush BackgroundGradient = new LinearGradientBrush(new Point(0, 0), new Point(0, Height - 1), Color.FromArgb(75, 130, 195), Color.FromArgb(40, 80, 135)); G.FillPath(BackgroundGradient, DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 3)); G.DrawLine(DesignFunctions.ToPen(100, Color.White), new Point(2, 1), new Point(Width - 2, 1)); G.DrawPath(Pens.Gray, DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 3)); G.DrawPath(Pens.Black, DesignFunctions.RoundRect(0, 0, Width - 1, Height - 2, 3)); BackgroundGradient.Dispose(); Rectangle TriangleRectangle = new Rectangle(Width - 16, Height / 2 - 2, 8, 4); List <Point> TrianglePoints = new List <Point>(); TrianglePoints.Add(new Point(TriangleRectangle.X, TriangleRectangle.Y)); TrianglePoints.Add(new Point(TriangleRectangle.X + TriangleRectangle.Width, TriangleRectangle.Y)); TrianglePoints.Add(new Point((int)(TriangleRectangle.X + TriangleRectangle.Width / 2.0), TriangleRectangle.Y + TriangleRectangle.Height)); G.FillPolygon(Brushes.White, TrianglePoints.ToArray()); try { if (Items.Count > 0) { if (!(SelectedIndex == -1)) { G.DrawString(GetItemText(Items[SelectedIndex]), Font, Brushes.Black, new Rectangle(5, -1, Width - 20, Height), new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Near }); G.DrawString(GetItemText(Items[SelectedIndex]), Font, Brushes.White, new Rectangle(5, 0, Width - 20, Height), new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Near }); } else { G.DrawString(GetItemText(Items[0]), Font, Brushes.Black, new Rectangle(5, -1, Width - 20, Height), new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Near }); G.DrawString(GetItemText(Items[0]), Font, Brushes.White, new Rectangle(5, 0, Width - 20, Height), new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Near }); } } } catch { //Something went wrong, so we do nothing. } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.Clear(Parent.BackColor); LinearGradientBrush BackgroundGradient = new LinearGradientBrush(new Point(0, 0), new Point(0, Height), Color.Transparent, Color.Transparent); switch (MouseState) { case State.None: if (Checked) { BackgroundGradient.LinearColors = new Color[] { Color.FromArgb(75, 130, 195), Color.FromArgb(40, 80, 135) }; } else { BackgroundGradient.LinearColors = new Color[] { Color.FromArgb(127, 127, 127), Color.FromArgb(93, 93, 93) }; } break; case State.Over: BackgroundGradient.LinearColors = new Color[] { Color.FromArgb(75, 130, 195), Color.FromArgb(40, 80, 135) }; break; case State.Down: BackgroundGradient.LinearColors = new Color[] { Color.FromArgb(55, 110, 175), Color.FromArgb(40, 80, 135) }; break; } G.FillPath(BackgroundGradient, DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 2)); G.SmoothingMode = SmoothingMode.AntiAlias; if (Checked) { Rectangle c = new Rectangle(3, 2, Width - 7, Height - 7); G.DrawLine(new Pen(Brushes.Black, 2F), new Point(c.X, (int)(c.Y + c.Height / 2.0)), new Point((int)(c.X + c.Width / 2.0), c.Y + c.Height)); G.DrawLine(new Pen(Brushes.Black, 2F), new Point((int)(c.X + c.Width / 2.0), c.Y + c.Height), new Point(c.X + c.Width, c.Y)); } G.SmoothingMode = SmoothingMode.None; G.DrawLine(DesignFunctions.ToPen(100, Color.White), new Point(2, 1), new Point(Width - 3, 1)); G.DrawPath(Pens.Gray, DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 2)); G.DrawPath(Pens.Black, DesignFunctions.RoundRect(0, 0, Width - 1, Height - 2, 2)); BackgroundGradient.Dispose(); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.Clear(Parent.BackColor); G.SmoothingMode = SmoothingMode.AntiAlias; G.FillPath(DesignFunctions.ToBrush(10, Color.Black), DesignFunctions.RoundRect(0, 0, Width - 1, Height - 2, 5)); G.DrawPath(DesignFunctions.ToPen(50, Color.White), DesignFunctions.RoundRect(-1, -4, Width + 1, Height + 3, 5)); G.DrawPath(DesignFunctions.ToPen(50, Color.Black), DesignFunctions.RoundRect(0, 0, Width - 1, Height - 2, 5)); for (var i = 0; i <= 10; i++) { G.DrawPath(DesignFunctions.ToPen(50 / (i + 1), Color.Black), DesignFunctions.RoundRect(i, i, Width - 1 - (i * 2), Height - 2 - (i * 2), 5)); } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.Clear(Parent.BackColor); LinearGradientBrush BackgroundGradient = new LinearGradientBrush(new Point(0, 0), new Point(0, Height), Color.Transparent, Color.Transparent); switch (MouseState) { case State.None: BackgroundGradient.LinearColors = new Color[] { Color.FromArgb(127, 127, 127), Color.FromArgb(93, 93, 93) }; break; case State.Over: BackgroundGradient.LinearColors = new Color[] { Color.FromArgb(75, 130, 195), Color.FromArgb(40, 80, 135) }; break; case State.Down: BackgroundGradient.LinearColors = new Color[] { Color.FromArgb(55, 110, 175), Color.FromArgb(40, 80, 135) }; break; } G.FillPath(BackgroundGradient, DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 3)); G.DrawLine(DesignFunctions.ToPen(100, Color.White), new Point(2, 1), new Point(Width - 3, 1)); G.DrawPath(Pens.Gray, DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 3)); G.DrawPath(Pens.Black, DesignFunctions.RoundRect(0, 0, Width - 1, Height - 2, 3)); BackgroundGradient.Dispose(); G.DrawString(Text, new Font(Font.Name, Font.Size, FontStyle.Bold), Brushes.Black, new Rectangle(0, 0, Width - 1, Height - 1), new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); G.DrawString(Text, new Font(Font.Name, Font.Size, FontStyle.Bold), Brushes.White, new Rectangle(0, 1, Width - 1, Height - 1), new StringFormat() { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.Clear(BackColor); //Border G.DrawRectangle(Pens.DimGray, new Rectangle(1, 1, Width - 3, Height - 3)); G.DrawPath(Pens.Black, DesignFunctions.RoundRect(0, 0, Width - 1, Height - 1, 2)); //Title G.FillRectangle(DesignFunctions.ToBrush(78, 78, 78), new Rectangle(1, 1, Width - 2, 19)); G.FillRectangle(DesignFunctions.ToBrush(20, Color.White), new Rectangle(1, 1, Width - 2, 10)); G.DrawLine(DesignFunctions.ToPen(150, Color.Black), new Point(1, 19), new Point(Width - 2, 19)); G.DrawLine(DesignFunctions.ToPen(50, Color.White), new Point(1, 20), new Point(Width - 2, 20)); //Title Icon try { G.DrawIcon(_ico, new Rectangle(3, 3, 16, 16)); } catch (Exception ex) { MessageBox.Show(ex.Message); } //Title Text G.DrawString(Text, Font, DesignFunctions.ToBrush(120, Color.Black), new Rectangle(1, 0, Width - 2, 19), new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); G.DrawString(Text, Font, DesignFunctions.ToBrush(ForeColor), new Rectangle(1, 1, Width - 2, 19), new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); try { G.DrawRectangle(DesignFunctions.ToPen(Parent.FindForm().TransparencyKey), new Rectangle(0, 0, 1, 1)); G.DrawRectangle(DesignFunctions.ToPen(Parent.FindForm().TransparencyKey), new Rectangle(Width - 1, 0, 1, 1)); G.DrawRectangle(DesignFunctions.ToPen(Parent.FindForm().TransparencyKey), new Rectangle(0, Height - 1, 1, 1)); G.DrawRectangle(DesignFunctions.ToPen(Parent.FindForm().TransparencyKey), new Rectangle(Width - 1, Height - 1, 1, 1)); } catch (Exception ex) { MessageBox.Show(ex.Message); } G.SmoothingMode = SmoothingMode.AntiAlias; if ((new Rectangle(Width - 20, 5, 10, 10)).Contains(PointToClient(MousePosition))) { G.DrawLine(new Pen(Brushes.White, 2F), new Point(Width - 20, 7), new Point(Width - 13, 13)); G.DrawLine(new Pen(Brushes.White, 2F), new Point(Width - 20, 13), new Point(Width - 13, 7)); if (MouseButtons == MouseButtons.Left) { G.DrawLine(new Pen(Brushes.DarkGray, 2F), new Point(Width - 20, 7), new Point(Width - 13, 13)); G.DrawLine(new Pen(Brushes.DarkGray, 2F), new Point(Width - 20, 13), new Point(Width - 13, 7)); } } else { G.DrawLine(new Pen(Brushes.Gray, 2F), new Point(Width - 20, 7), new Point(Width - 13, 13)); G.DrawLine(new Pen(Brushes.Gray, 2F), new Point(Width - 20, 13), new Point(Width - 13, 7)); } }