Login Register


N2Oxide ProgressBar [C# - GDI] filter_list
Author
Message
RE: N2Oxide ProgressBar [C# - GDI] #11
(04-15-2013, 04:21 AM)ArkPhaze Wrote: @Linuxephus - I've made another update to this progress bar look/style. It now is modified to show a visual display of the percentage too. This is the good sh*t:

[Image: QXm7KVw.png]

EDIT; Looks as though that separator is a bit low on the Y. Perhaps I'll bring that up a bit...

Code:
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 readonly Color _bgCrossColor = Color.FromArgb(20, 20, 20); private readonly Color _bgBottomShineColor = Color.FromArgb(45, 255, 255, 255); private readonly Color _indicatorColor = Color.FromArgb(255, 45, 255, 150); private const int IndicatorAlpha = 215; 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 void OnPaint(PaintEventArgs e) { base.OnPaint(e); BackColor = Color.Transparent; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; using (GraphicsPath gp = new GraphicsPath()) { // Draw Background Bottom Shine gp.AddLine(new Point(CurvePadding, 1), new Point(Width - CurvePadding, 1)); gp.AddCurve(new[] { new Point(Width - CurvePadding, 1), new Point(Width, Height / 2 - 1), new Point(Width - CurvePadding, Height) }, 1.2f); gp.AddLine(new Point(Width - CurvePadding, Height), new Point(CurvePadding, Height)); gp.CloseFigure(); e.Graphics.SetClip(gp); using (SolidBrush sb = new SolidBrush(_bgBottomShineColor)) e.Graphics.FillPath(sb, gp); gp.Reset(); // Draw Background Dark Gradient 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 - 2) }, 1.2f); gp.AddLine(new Point(Width - CurvePadding, Height - 2), new Point(CurvePadding, Height - 2)); 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, IndicatorPadding / 2 + 1, Width, Height), Color.FromArgb(IndicatorAlpha, _indicatorColor), Color.FromArgb(200, 0, 0, 0), 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) * progressPercent) - IndicatorPadding - CurvePadding + DispOffset, IndicatorPadding), new Point((int)((Width - DispOffset) * progressPercent) - IndicatorPadding + DispOffset, Height / 2), new Point((int)((Width - DispOffset) * progressPercent) - IndicatorPadding - CurvePadding + DispOffset, 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(); gp.AddRectangle(new Rectangle(DispOffset, 0, 2, Height - 2)); gp.CloseFigure(); e.Graphics.FillPath(lgb, gp); } e.Graphics.ResetClip(); // 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); } } }

Cleaned up the code some as well...

Yes, the space between the percentage counter and the progress bar could be narrowed another 5 clicks or so.
Otherwise, even better.

Reply

RE: N2Oxide ProgressBar [C# - GDI] #12
EDIT: Fixed...
[Image: KxNSj27.png]

{Code: UPDATED First Post}

(04-15-2013, 04:27 AM)Linuxephus Wrote: Yes, the space between the percentage counter and the progress bar could be narrowed another 5 clicks or so.
Otherwise, even better.

When you get to 100% it takes up nearly the full space - the width before the text.. So it's all even Smile

EDIT: More previews:
[Image: qL2bH67.png]

EDIT: I've added the colors as properties now so they can be configured via the IDE Properties window through the designer.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: N2Oxide ProgressBar [C# - GDI] #13
EDIT: Fixed...
[Image: KxNSj27.png]

{Code: UPDATED First Post}

(04-15-2013, 04:27 AM)Linuxephus Wrote: Yes, the space between the percentage counter and the progress bar could be narrowed another 5 clicks or so.
Otherwise, even better.

When you get to 100% it takes up nearly the full space - the width before the text.. So it's all even Smile

EDIT: More previews:
[Image: qL2bH67.png]

EDIT: I've added the colors as properties now so they can be configured via the IDE Properties window through the designer.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: N2Oxide ProgressBar [C# - GDI] #14
(04-15-2013, 04:21 AM)ArkPhaze Wrote:
(04-15-2013, 04:18 AM)Linuxephus Wrote:
(04-15-2013, 02:53 AM)ArkPhaze Wrote: You can change the alpha settings as well to get the style that you want:
[Image: OHfDpcG.png]

As well as the color and a few other things:
[Image: EvIzsof.png]

It was designed for darker backgrounds though.

Then that would go well with the dark backgrounds I already prefer on my workstations.

@Linuxephus - I've made another update to this progress bar look/style. It now is modified to show a visual display of the percentage too. This is the good sh*t:

[Image: QXm7KVw.png]

EDIT; Looks as though that separator is a bit low on the Y. Perhaps I'll bring that up a bit...

EDIT; Code Removed: Latest code here http://www.hackcommunity.com/Thread-N2Ox...#pid133097

Cleaned up the code some as well... I'm working on cleanup right now.

@Psycho_Coder - I think you will appreciate this for a GDI example.


Oh , thank you sir I've learned some cool effects from your last post on GDI and I will implement this as well and make something new , Thanks a lot you're a real help . Confusedmiling:Confusedmiling:Confusedmiling:Confusedmiling:
[Image: OilyCostlyEwe.gif]

Reply

RE: N2Oxide ProgressBar [C# - GDI] #15
(04-15-2013, 04:21 AM)ArkPhaze Wrote:
(04-15-2013, 04:18 AM)Linuxephus Wrote:
(04-15-2013, 02:53 AM)ArkPhaze Wrote: You can change the alpha settings as well to get the style that you want:
[Image: OHfDpcG.png]

As well as the color and a few other things:
[Image: EvIzsof.png]

It was designed for darker backgrounds though.

Then that would go well with the dark backgrounds I already prefer on my workstations.

@Linuxephus - I've made another update to this progress bar look/style. It now is modified to show a visual display of the percentage too. This is the good sh*t:

[Image: QXm7KVw.png]

EDIT; Looks as though that separator is a bit low on the Y. Perhaps I'll bring that up a bit...

EDIT; Code Removed: Latest code here http://www.hackcommunity.com/Thread-N2Ox...#pid133097

Cleaned up the code some as well... I'm working on cleanup right now.

@Psycho_Coder - I think you will appreciate this for a GDI example.


Oh , thank you sir I've learned some cool effects from your last post on GDI and I will implement this as well and make something new , Thanks a lot you're a real help . Confusedmiling:Confusedmiling:Confusedmiling:Confusedmiling:
[Image: OilyCostlyEwe.gif]

Reply

RE: N2Oxide ProgressBar [C# - GDI] #16
(04-15-2013, 04:41 AM)ArkPhaze Wrote: When you get to 100% it takes up nearly the full space - the width before-->>you meant the width after?<<-- the text.. So it's all even Smile

Eh...I assume you meant the space betwixt the text (percentage counter) and the start of the progress bar could be moved closer together by 5 clicks or so is what I was referring to.

Edit: Never mind @ArkPhaze, I just re-read your updated comment.
Duly noted and understood now.:thumbs:

Reply

RE: N2Oxide ProgressBar [C# - GDI] #17
(04-15-2013, 04:41 AM)ArkPhaze Wrote: When you get to 100% it takes up nearly the full space - the width before-->>you meant the width after?<<-- the text.. So it's all even Smile

Eh...I assume you meant the space betwixt the text (percentage counter) and the start of the progress bar could be moved closer together by 5 clicks or so is what I was referring to.

Edit: Never mind @ArkPhaze, I just re-read your updated comment.
Duly noted and understood now.:thumbs:

Reply

RE: N2Oxide ProgressBar [C# - GDI] #18
(04-15-2013, 04:52 AM)Linuxephus Wrote:
(04-15-2013, 04:41 AM)ArkPhaze Wrote: When you get to 100% it takes up nearly the full space - the width before-->>you meant the width after?<<-- the text.. So it's all even Smile

Eh...I assume you meant the space betwixt the text (percentage counter) and the start of the progress bar could be moved closer together by 5 clicks or so is what I was referring to.

Edit: Never mind @ArkPhaze, I just re-read your updated comment.
Duly noted and understood now.:thumbs:

Ahh, I see :ok:. At first you mentioned the text, so my head was thinking relative coordinates from the rectangular splitter I drew, and the text display, hence the value in between these 2 points. I meant the Y coordinate of the actual splitter/rectangle/line that splits the text and the progress indication bar itself though.

Who needs paid custom controls when you can draw your own though I'm thinking... ? lol I'm getting a good collection of my own just from my demos:
[Image: qOdyrpP.png]

Actually, my hard drive is full of other controls I have made that you guys haven't even seen yet as well.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: N2Oxide ProgressBar [C# - GDI] #19
(04-15-2013, 04:52 AM)Linuxephus Wrote:
(04-15-2013, 04:41 AM)ArkPhaze Wrote: When you get to 100% it takes up nearly the full space - the width before-->>you meant the width after?<<-- the text.. So it's all even Smile

Eh...I assume you meant the space betwixt the text (percentage counter) and the start of the progress bar could be moved closer together by 5 clicks or so is what I was referring to.

Edit: Never mind @ArkPhaze, I just re-read your updated comment.
Duly noted and understood now.:thumbs:

Ahh, I see :ok:. At first you mentioned the text, so my head was thinking relative coordinates from the rectangular splitter I drew, and the text display, hence the value in between these 2 points. I meant the Y coordinate of the actual splitter/rectangle/line that splits the text and the progress indication bar itself though.

Who needs paid custom controls when you can draw your own though I'm thinking... ? lol I'm getting a good collection of my own just from my demos:
[Image: qOdyrpP.png]

Actually, my hard drive is full of other controls I have made that you guys haven't even seen yet as well.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: N2Oxide ProgressBar [C# - GDI] #20
Wow, thats wicked especially the one with the stars and the progress bar, A Job well done Smile
Is GDI available in VB.NET?
My Blog: http://www.procurity.wordpress.com
Donations: 1HLjiSbnWMpeQU46eUVCrYdbkrtduX7snG

Reply







Users browsing this thread: