protected override void OnPaint(PaintEventArgs e) { Graphics G = e.Graphics; Rectangle ItemBoundsRect = new Rectangle(); G.Clear(Parent.BackColor); for (int TabIndex = 0; TabIndex <= TabCount - 1; TabIndex++) { ItemBoundsRect = GetTabRect(TabIndex); if (!(TabIndex == SelectedIndex)) { G.DrawString(TabPages[TabIndex].Text, new Font(Font.Name, Font.Size - 2, FontStyle.Bold), new SolidBrush(Color.FromArgb(80, 76, 76)), new Rectangle(GetTabRect(TabIndex).Location, GetTabRect(TabIndex).Size), new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); } } // Draw container rectangle G.FillPath(new SolidBrush(Color.FromArgb(247, 246, 246)), RoundRectangle.RoundRect(0, 23, Width - 1, Height - 24, 2)); G.DrawPath(new Pen(Color.FromArgb(201, 198, 195)), RoundRectangle.RoundRect(0, 23, Width - 1, Height - 24, 2)); for (int ItemIndex = 0; ItemIndex <= TabCount - 1; ItemIndex++) { ItemBoundsRect = GetTabRect(ItemIndex); if (ItemIndex == SelectedIndex) { // Draw header tabs G.DrawPath(new Pen(Color.FromArgb(201, 198, 195)), RoundRectangle.RoundedTopRect(new Rectangle(new Point(ItemBoundsRect.X - 2, ItemBoundsRect.Y - 2), new Size(ItemBoundsRect.Width + 3, ItemBoundsRect.Height)), 7)); G.FillPath(new SolidBrush(Color.FromArgb(247, 246, 246)), RoundRectangle.RoundedTopRect(new Rectangle(new Point(ItemBoundsRect.X - 1, ItemBoundsRect.Y - 1), new Size(ItemBoundsRect.Width + 2, ItemBoundsRect.Height)), 7)); try { G.DrawString(TabPages[ItemIndex].Text, new Font(Font.Name, Font.Size - 1, FontStyle.Bold), new SolidBrush(Color.FromArgb(80, 76, 76)), new Rectangle(GetTabRect(ItemIndex).Location, GetTabRect(ItemIndex).Size), new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }); TabPages[ItemIndex].BackColor = Color.FromArgb(247, 246, 246); } catch { } } } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.Clear(Parent.BackColor); G.SmoothingMode = SmoothingMode.AntiAlias; TrackThumb = new Rectangle(8, 10, Width - 16, 2); PipeBorder = RoundRectangle.RoundRect(1, 8, Width - 3, 5, 2); try { this.ValueDrawer = (int)Math.Round(((double)(this._Value - this._Minimum) / (double)(this._Maximum - this._Minimum)) * (double)(this.Width - 11)); } catch (Exception) { } TrackBarHandleRect = new Rectangle(ValueDrawer, 0, 10, 20); G.SetClip(PipeBorder); // Set the clipping region of this Graphics to the specified GraphicsPath G.FillPath(new SolidBrush(Color.FromArgb(221, 221, 221)), PipeBorder); FillValue = RoundRectangle.RoundRect(1, 8, TrackBarHandleRect.X + TrackBarHandleRect.Width - 4, 5, 2); G.ResetClip(); // Reset the clip region of this Graphics to an infinite region G.SmoothingMode = SmoothingMode.HighQuality; G.DrawPath(new Pen(Color.FromArgb(200, 200, 200)), PipeBorder); // Draw pipe border G.FillPath(new SolidBrush(Color.FromArgb(217, 99, 50)), FillValue); G.FillEllipse(new SolidBrush(Color.FromArgb(244, 244, 244)), this.TrackThumb.X + (int)Math.Round(unchecked ((double)this.TrackThumb.Width * ((double)this.Value / (double)this.Maximum))) - (int)Math.Round((double)this.ThumbSize.Width / 2.0), this.TrackThumb.Y + (int)Math.Round((double)this.TrackThumb.Height / 2.0) - (int)Math.Round((double)this.ThumbSize.Height / 2.0), this.ThumbSize.Width, this.ThumbSize.Height); G.DrawEllipse(new Pen(Color.FromArgb(180, 180, 180)), this.TrackThumb.X + (int)Math.Round(unchecked ((double)this.TrackThumb.Width * ((double)this.Value / (double)this.Maximum))) - (int)Math.Round((double)this.ThumbSize.Width / 2.0), this.TrackThumb.Y + (int)Math.Round((double)this.TrackThumb.Height / 2.0) - (int)Math.Round((double)this.ThumbSize.Height / 2.0), this.ThumbSize.Width, this.ThumbSize.Height); if (_DrawValueString == true) { G.DrawString(System.Convert.ToString(ValueToSet), Font, Brushes.DimGray, 1, 20); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); LinearGradientBrush LGB = default(LinearGradientBrush); GraphicsPath GP = default(GraphicsPath); e.Graphics.Clear(Parent.BackColor); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; // Create a curvy border GP = RoundRectangle.RoundRect(0, 0, Width - 1, Height - 1, 5); // Fills the body of the rectangle with a gradient LGB = new LinearGradientBrush(ClientRectangle, Color.FromArgb(253, 252, 252), Color.FromArgb(239, 237, 236), 90.0F); e.Graphics.SetClip(GP); e.Graphics.FillRectangle(LGB, ClientRectangle); e.Graphics.ResetClip(); // Draw rectangle border e.Graphics.DrawPath(new Pen(Color.FromArgb(180, 180, 180)), GP); // Draw string e.Graphics.DrawString(Text, Font, new SolidBrush(Color.FromArgb(76, 76, 97)), new Rectangle(3, 0, Width - 20, Height), new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Near }); e.Graphics.DrawString("6", new Font("Marlett", 13, FontStyle.Regular), new SolidBrush(Color.FromArgb(119, 119, 118)), new Rectangle(3, 0, Width - 4, Height), new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Far }); e.Graphics.DrawLine(new Pen(Color.FromArgb(224, 222, 220)), Width - 24, 4, Width - 24, this.Height - 5); e.Graphics.DrawLine(new Pen(Color.FromArgb(250, 249, 249)), Width - 25, 4, Width - 25, this.Height - 5); GP.Dispose(); LGB.Dispose(); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.SmoothingMode = SmoothingMode.HighQuality; G.Clear(Parent.BackColor); int SwitchXLoc = 3; Rectangle ControlRectangle = new Rectangle(0, 0, Width - 1, Height - 1); GraphicsPath ControlPath = RoundRectangle.RoundRect(ControlRectangle, 4); LinearGradientBrush BackgroundLGB = default(LinearGradientBrush); if (_Toggled) { SwitchXLoc = 37; BackgroundLGB = new LinearGradientBrush(ControlRectangle, Color.FromArgb(231, 108, 58), Color.FromArgb(236, 113, 63), 90.0F); } else { SwitchXLoc = 0; BackgroundLGB = new LinearGradientBrush(ControlRectangle, Color.FromArgb(208, 208, 208), Color.FromArgb(226, 226, 226), 90.0F); } // Fill inside background gradient G.FillPath(BackgroundLGB, ControlPath); // Draw string switch (ToggleType) { case _Type.OnOff: if (Toggled) { G.DrawString("ON", new Font("Segoe UI", 12, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 18, (float)(Bar.Y + 13.5), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } else { G.DrawString("OFF", new Font("Segoe UI", 12, FontStyle.Regular), Brushes.DimGray, Bar.X + 59, (float)(Bar.Y + 13.5), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } break; case _Type.YesNo: if (Toggled) { G.DrawString("YES", new Font("Segoe UI", 12, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 18, (float)(Bar.Y + 13.5), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } else { G.DrawString("NO", new Font("Segoe UI", 12, FontStyle.Regular), Brushes.DimGray, Bar.X + 59, (float)(Bar.Y + 13.5), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } break; case _Type.IO: if (Toggled) { G.DrawString("I", new Font("Segoe UI", 12, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 18, (float)(Bar.Y + 13.5), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } else { G.DrawString("O", new Font("Segoe UI", 12, FontStyle.Regular), Brushes.DimGray, Bar.X + 59, (float)(Bar.Y + 13.5), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } break; } Rectangle SwitchRectangle = new Rectangle(SwitchXLoc, 0, Width - 38, Height); GraphicsPath SwitchPath = RoundRectangle.RoundRect(SwitchRectangle, 4); LinearGradientBrush SwitchButtonLGB = new LinearGradientBrush(SwitchRectangle, Color.FromArgb(253, 253, 253), Color.FromArgb(240, 238, 237), LinearGradientMode.Vertical); // Fill switch background gradient G.FillPath(SwitchButtonLGB, SwitchPath); // Draw borders if (_Toggled == true) { G.DrawPath(new Pen(Color.FromArgb(185, 89, 55)), SwitchPath); G.DrawPath(new Pen(Color.FromArgb(185, 89, 55)), ControlPath); } else { G.DrawPath(new Pen(Color.FromArgb(181, 181, 181)), SwitchPath); G.DrawPath(new Pen(Color.FromArgb(181, 181, 181)), ControlPath); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Bitmap B = new Bitmap(Width, Height); Graphics G = Graphics.FromImage(B); G.Clear(Color.Transparent); G.SmoothingMode = SmoothingMode.HighQuality; GP1 = RoundRectangle.RoundRect(new Rectangle(0, 0, Width - 1, Height - 1), 4); GP2 = RoundRectangle.RoundRect(new Rectangle(1, 1, Width - 3, Height - 3), 4); R1 = new Rectangle(0, 2, Width - 1, Height - 1); GB1 = new LinearGradientBrush(R1, Color.FromArgb(255, 255, 255), Color.FromArgb(230, 230, 230), 90f); // Draw inside background G.FillRectangle(new SolidBrush(Color.FromArgb(244, 241, 243)), R1); G.SetClip(GP1); G.FillPath(new SolidBrush(Color.FromArgb(244, 241, 243)), RoundRectangle.RoundRect(new Rectangle(1, 1, Width - 3, Height / 2 - 2), 4)); I1 = (int)Math.Round(((double)(this._Value - this._Minimum) / (double)(this._Maximum - this._Minimum)) * (double)(this.Width - 3)); if (I1 > 1) { GP3 = RoundRectangle.RoundRect(new Rectangle(1, 1, I1, Height - 3), 4); R2 = new Rectangle(1, 1, I1, Height - 3); GB2 = new LinearGradientBrush(R2, Color.FromArgb(214, 89, 37), Color.FromArgb(223, 118, 75), 90f); // Fill the value with its gradient G.FillPath(GB2, GP3); // Draw diagonal lines if (_DrawHatch == true) { for (var i = 0; i <= (Width - 1) * _Maximum / _Value; i += 20) { G.DrawLine(new Pen(new SolidBrush(Color.FromArgb(25, Color.White)), 10.0F), new Point(System.Convert.ToInt32(i), 0), new Point((int)(i - 10), Height)); } } G.SetClip(GP3); G.SmoothingMode = SmoothingMode.None; G.SmoothingMode = SmoothingMode.AntiAlias; G.ResetClip(); } // Draw value as a string string DrawString = Convert.ToString(Convert.ToInt32(Value)) + "%"; int textX = (int)(this.Width - G.MeasureString(DrawString, Font).Width - 1); int textY = (int)((this.Height / 2) - (System.Convert.ToInt32(G.MeasureString(DrawString, Font).Height / 2) - 2)); if (_ShowPercentage == true) { switch (ValueAlignment) { case Alignment.Right: G.DrawString(DrawString, new Font("Segoe UI", 8), Brushes.DimGray, new Point(textX, textY)); break; case Alignment.Center: G.DrawString(DrawString, new Font("Segoe UI", 8), Brushes.DimGray, new Rectangle(0, 0, Width, Height + 2), new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); break; } } // Draw border G.DrawPath(new Pen(Color.FromArgb(180, 180, 180)), GP2); e.Graphics.DrawImage((Image)(B.Clone()), 0, 0); G.Dispose(); B.Dispose(); }