void Gray_PaintHook(System.Windows.Forms.PaintEventArgs e) { G.Clear(Color.FromArgb(51, 51, 51)); G.SmoothingMode = SmoothingMode.AntiAlias; G.FillPath(DesignFunctions.ToBrush(20, 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 (int 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)); } }
/// <summary> /// Grays the on paint. /// </summary> /// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param> private void GrayOnPaint(System.Windows.Forms.PaintEventArgs e) { //Bitmap B = new Bitmap(Width, Height); Graphics G = e.Graphics; G.SmoothingMode = Smoothing; G.Clear(Parent.BackColor); dynamic progressWidth = Convert.ToInt32(Value * (1 / Maximum) * Width); 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, progressWidth - 1, Height - 3, 3)); G.DrawPath(DesignFunctions.ToPen(150, Color.Black), DesignFunctions.RoundRect(0, 1, progressWidth - 1, Height - 3, 3)); if (Value > 0) { G.SmoothingMode = SmoothingMode.AntiAlias; G.SetClip(DesignFunctions.RoundRect(0, 0, progressWidth - 1, Height - 1, 3)); for (int i = 0; i <= progressWidth - 1; i += 25) { G.DrawLine(new Pen(new SolidBrush(Color.FromArgb(35, Color.White)), 10), 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(Convert.ToInt32((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)); //e.Graphics.DrawImage(B, 0, 0); //G.Dispose(); //B.Dispose(); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param> private void AresioOnPaint(System.Windows.Forms.PaintEventArgs e) { Graphics G = e.Graphics; Rectangle aresioBar = new Rectangle(10, 10, Width - 21, Height - 21); G.Clear(Parent.BackColor); G.SmoothingMode = SmoothingMode.AntiAlias; DesignFunctions.PillStyle styles = new DesignFunctions.PillStyle(); styles.Left = true; styles.Right = true; //Background LinearGradientBrush BackLinear = new LinearGradientBrush(new Point(0, Convert.ToInt32((Height / 2) - (Track.Height / 2))), new Point(0, Convert.ToInt32((Height / 2) + (Track.Height / 2))), Color.FromArgb(50, Color.Black), Color.Transparent); //G.FillPath(BackLinear, RoundRect(0, CInt((Height / 2) - 4), Width - 1, 8, 3)) G.FillPath(BackLinear, (GraphicsPath)DesignFunctions.Pill(0, Convert.ToInt32(Height / 2 - Track.Height / 2), Width - 1, Track.Height - 2, new DesignFunctions.PillStyle { Left = true, Right = true })); G.FillPath(BackLinear, (GraphicsPath)DesignFunctions.Pill(0, Convert.ToInt32(Height / 2 - Track.Height / 2), Width - 1, Track.Height - 2, new DesignFunctions.PillStyle { Left = true, Right = true })); G.DrawPath(DesignFunctions.ToPen(50, Color.Black), (GraphicsPath)DesignFunctions.Pill(0, Convert.ToInt32(Height / 2 - Track.Height / 2), Width - 1, Track.Height - 2, new DesignFunctions.PillStyle { Left = true, Right = true })); BackLinear.Dispose(); //Fill if (ToggleLocation > 0) { G.FillPath(new LinearGradientBrush(new Point(0, Convert.ToInt32((Height / 2) - Track.Height / 2)), new Point(1, Convert.ToInt32((Height / 2) + Track.Height / 2)), Color.FromArgb(250, 200, 70), Color.FromArgb(250, 160, 40)), (GraphicsPath)DesignFunctions.Pill(1, Convert.ToInt32((Height / 2) - Track.Height / 2), Convert.ToInt32(aresioBar.Width * (ToggleLocation / 100)) + Convert.ToInt32(Track.Width / 2), Track.Height - 3, new DesignFunctions.PillStyle { Left = true, Right = true })); G.DrawPath(DesignFunctions.ToPen(100, Color.White), (GraphicsPath)DesignFunctions.Pill(1, Convert.ToInt32((Height / 2) - Track.Height / 2 + 1), Convert.ToInt32(aresioBar.Width * (ToggleLocation / 100)) + Convert.ToInt32(Track.Width / 2), Track.Height - 5, new DesignFunctions.PillStyle { Left = true, Right = true })); } if (Checked) { G.DrawString("ON", new Font("Arial", 6, FontStyle.Bold), DesignFunctions.ToBrush(150, Color.Black), new Rectangle(0, -1, Width - Track.Width + Track.Width / 3, Height), new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } else { G.DrawString("OFF", new Font("Arial", 6, FontStyle.Bold), DesignFunctions.ToBrush(150, Color.Black), new Rectangle(Track.Width - Track.Width / 3, -1, Width - Track.Width + Track.Width / 3, Height), new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } //Button G.FillEllipse(Brushes.White, aresioBar.X + Convert.ToInt32(aresioBar.Width * (ToggleLocation / 100)) - Convert.ToInt32(Track.Width / 2), aresioBar.Y + Convert.ToInt32((aresioBar.Height / 2)) - Convert.ToInt32(Track.Height / 2), Track.Width, Track.Height); G.DrawEllipse(DesignFunctions.ToPen(50, Color.Black), aresioBar.X + Convert.ToInt32(aresioBar.Width * (ToggleLocation / 100) - Convert.ToInt32(Track.Width / 2)), aresioBar.Y + Convert.ToInt32((aresioBar.Height / 2)) - Convert.ToInt32(Track.Height / 2), Track.Width, Track.Height); }