N2Oxide ProgressBar [C# - GDI] 04-14-2013, 11:51 PM
#1
Here's another GDI control I wrote in C#.
Previews:
![[Image: KxNSj27.png]](http://i.imgur.com/KxNSj27.png)
EDIT: More previews:
![[Image: qL2bH67.png]](http://i.imgur.com/qL2bH67.png)
*Edited to curve the first part instead of making it square.
![[Image: K54a6ei.gif]](http://i.imgur.com/K54a6ei.gif)
Code:
Enjoy
Previews:
![[Image: KxNSj27.png]](http://i.imgur.com/KxNSj27.png)
EDIT: More previews:
![[Image: qL2bH67.png]](http://i.imgur.com/qL2bH67.png)
*Edited to curve the first part instead of making it square.
![[Image: K54a6ei.gif]](http://i.imgur.com/K54a6ei.gif)
Code:
Code:
// N2Oxide Progress Bar
// Author: ArkPhaze (c) 2013
// Site: HackCommunity.com
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace N2Oxide
{
class N2OxideProgBar : ProgressBar
{
private const int MaxHeight = 18;
private const int CurvePadding = 4;
private const int IndicatorPadding = 5;
private const int DispOffset = 40;
private Color _bgCrossColor = Color.FromArgb(20, 20, 20);
public Color BgCrossColor
{
get { return _bgCrossColor; }
set { _bgCrossColor = value; }
}
private Color _bgBottomShineColor = Color.FromArgb(255, 255, 255);
public Color BgBottomShineColor
{
get { return _bgBottomShineColor; }
set { _bgBottomShineColor = value; }
}
private Color _indicatorColor = Color.FromArgb(255, 180, 80, 255);
public Color IndicatorColor
{
get { return _indicatorColor; }
set { _indicatorColor = value; }
}
private int _indicatorAlpha = 230;
public int IndicatorAlpha
{
get { return _indicatorAlpha; }
set { _indicatorAlpha = value; }
}
public N2OxideProgBar()
{
DoubleBuffered = true;
Size = new Size(120, MaxHeight);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
}
protected override sealed bool DoubleBuffered
{
get { return base.DoubleBuffered; }
set { base.DoubleBuffered = value; }
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
BackColor = Color.Transparent;
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
using (GraphicsPath gp = new GraphicsPath())
{
// Draw Background Bottom Shine
gp.AddCurve(new[] { new Point(CurvePadding, 0), new Point(0, Height / 2 - 1), new Point(CurvePadding, Height) }, 1.2f);
gp.AddLine(new Point(CurvePadding, 0), new Point(Width - CurvePadding, 0));
gp.AddCurve(new[] { new Point(Width - CurvePadding, 0), new Point(Width, Height / 2 - 1), new Point(Width - CurvePadding, Height) }, 1.0f);
gp.AddLine(new Point(Width - CurvePadding, Height), new Point(CurvePadding, Height));
gp.CloseFigure();
using (SolidBrush sb = new SolidBrush(_bgBottomShineColor))
e.Graphics.FillPath(sb, gp);
gp.Reset();
// Draw Background Dark Gradient
int lineThickness = 2;
gp.AddCurve(new[] { new Point(CurvePadding, 0), new Point(0, Height / 2 - 1), new Point(CurvePadding, Height - lineThickness) }, 1.2f);
gp.AddLine(new Point(CurvePadding, 0), new Point(Width - CurvePadding, 0));
gp.AddCurve(new[] { new Point(Width - CurvePadding, 0), new Point(Width, Height / 2 - 1), new Point(Width - CurvePadding, Height - lineThickness) }, 1.0f);
gp.AddLine(new Point(Width - CurvePadding, Height - lineThickness), new Point(CurvePadding, Height - lineThickness));
gp.CloseFigure();
using (HatchBrush hg = new HatchBrush(HatchStyle.DarkDownwardDiagonal, _bgCrossColor))
e.Graphics.FillPath(hg, gp);
gp.Reset();
// Draw Front Progress Indicator
double progressPercent = (double)Value / Maximum;
using (LinearGradientBrush lgb = new LinearGradientBrush(new Rectangle(0, 0, Width, Height), Color.FromArgb(IndicatorAlpha, _indicatorColor), Color.FromArgb(50, _indicatorColor), 90f))
{
if (progressPercent > 0)
{
gp.AddLine(new Point(DispOffset + 2, IndicatorPadding),
new Point((int)((Width - DispOffset) * progressPercent) - IndicatorPadding + DispOffset, IndicatorPadding));
gp.AddCurve(
new[]
{
new Point((int)((Width - DispOffset - IndicatorPadding - 2) * progressPercent) - CurvePadding + DispOffset + 2, IndicatorPadding),
new Point((int)((Width - DispOffset - IndicatorPadding - 2) * progressPercent) + DispOffset + 2, Height / 2),
new Point((int)((Width - DispOffset - IndicatorPadding - 2) * progressPercent) - CurvePadding + DispOffset + 2, Height - IndicatorPadding)
}, 1.2f);
gp.AddLine(new Point((int)((Width - DispOffset) * progressPercent) - IndicatorPadding + DispOffset, Height - IndicatorPadding),
new Point(DispOffset + 2, Height - IndicatorPadding));
gp.CloseFigure();
e.Graphics.FillPath(lgb, gp);
gp.Reset();
}
// Draw Splitter
e.Graphics.FillRectangle(lgb, new Rectangle(DispOffset, 1, 2, Height - 3));
}
// Draw Percent Display
string percent = Value + "%";
SizeF fontSize = e.Graphics.MeasureString(percent, Font);
e.Graphics.DrawString(percent, Font, Brushes.LightGray, 5, Height / 2 - fontSize.Height / 2);
}
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
Size = new Size(Size.Width, MaxHeight);
}
}
}Enjoy
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)

![[Image: OHfDpcG.png]](http://i.imgur.com/OHfDpcG.png)
![[Image: EvIzsof.png]](http://i.imgur.com/EvIzsof.png)
![[Image: QXm7KVw.png]](http://i.imgur.com/QXm7KVw.png)