|
You last visited: Today at 13:36
Advertisement
Creating custom progressbar [help]
Discussion on Creating custom progressbar [help] within the .NET Languages forum part of the Coders Den category.
09/12/2016, 13:15
|
#1
|
elite*gold: 22
Join Date: Sep 2015
Posts: 951
Received Thanks: 81
|
Creating custom progressbar [help]
Hi everyone, i was messing around and cant find how i'll start creating my progressbar. I got a launcher design, and the progress bar is there.
So my idea is take the progressbar background from design and set it in c# one, and edit the green updating to a texture.
Can anyone explain me this better?
|
|
|
09/12/2016, 17:20
|
#2
|
dotCom
elite*gold: 9842
Join Date: Mar 2009
Posts: 16,840
Received Thanks: 4,675
|
General Coding -> .NET Languages
#moved…
|
|
|
09/12/2016, 19:59
|
#3
|
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
|
There is a designer for custom controls aka user controls.
Just use the graphics library to load the pic and resize / snip it. there are builtin functions for this.
this might be helpful (isn't runable cause i used the forms designer)
Code:
public partial class FlatProgressBar : UserControl
{
public enum Mode
{
None,
Percentage,
Progress,
Number
}
private Mode _displayMode = Mode.Percentage;
private float _Max = 100;
private Color _progressBarColor = Color.Blue;
private float _value;
public FlatProgressBar()
{
Min = 0;
InitializeComponent();
}
[Category("ProgressBar")]
public float Value
{
get { return _value; }
set
{
_value = value;
Invalidate();
}
}
[Category("ProgressBar")]
public Color ProgressBarColor
{
get { return _progressBarColor; }
set
{
_progressBarColor = value;
Invalidate();
}
}
[Category("ProgressBar")]
public Mode DisplayMode
{
get { return _displayMode; }
set
{
_displayMode = value;
Invalidate();
}
}
[Category("ProgressBar")]
public float Min { get; set; }
[Category("ProgressBar")]
public float Max
{
get { return _Max; }
set { _Max = value; }
}
private void FlatProgressBar_Paint(object sender, PaintEventArgs e)
{
var gfx = e.Graphics;
var fontBrush = new SolidBrush(ForeColor);
if (_value == 0)
{
switch (_displayMode)
{
case Mode.None:
break;
case Mode.Number:
gfx.DrawString("0", Font, fontBrush, new PointF(2, ClientRectangle.Height/2 - Font.Size + 1.5f));
break;
case Mode.Percentage:
gfx.DrawString("0%", Font, fontBrush, new PointF(2, ClientRectangle.Height/2 - Font.Size + 1.5f));
break;
case Mode.Progress:
gfx.DrawString("0 / " + Max, Font, fontBrush,
new PointF(2, ClientRectangle.Height / 2.0f - Font.Size + 1.5f));
break;
}
return;
}
var brush = new SolidBrush(_progressBarColor);
var percentage = _value/_Max;
var rect = new Rectangle(0, 0, (int) (ClientSize.Width*percentage), ClientRectangle.Height);
gfx.FillRectangle(brush, rect);
switch (_displayMode)
{
case Mode.None:
break;
case Mode.Number:
gfx.DrawString(_value.ToString(), Font, fontBrush,
new PointF(2, ClientRectangle.Height / 2.0f - Font.Size + 1.5f));
break;
case Mode.Percentage:
gfx.DrawString((int) (percentage*100.0f) + "%", Font, fontBrush,
new PointF(2, ClientRectangle.Height / 2.0f - Font.Size + 1.5f));
break;
case Mode.Progress:
gfx.DrawString(_value + " / " + _Max, Font, fontBrush,
new PointF(2, ClientRectangle.Height / 2.0f - Font.Size + 1.5f));
break;
}
fontBrush.Dispose();
brush.Dispose();
}
}
|
|
|
09/12/2016, 20:24
|
#4
|
elite*gold: 22
Join Date: Sep 2015
Posts: 951
Received Thanks: 81
|
Thanks but what you do on that case? Draw it? Cuz i dont wanna draw any style or colour, i wanna change completly the background of loader and change as you told the progress bar incrementing the image as i think it does with the draw.
|
|
|
09/12/2016, 23:11
|
#5
|
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
|
the FlatProgressBar_Paint method gets called every time the ui need a refresh. also if the progress changed. You can snip the picture to the percentage with very easy math.
You dont want to change the entire background. you just want to draw a small part of the picture into you custom control.
if i understand you right.
so this can be done with the graphics object from PaintEventArgs
|
|
|
09/13/2016, 08:19
|
#6
|
elite*gold: 22
Join Date: Sep 2015
Posts: 951
Received Thanks: 81
|
Thanks for help, i'll take a look into it!
|
|
|
09/14/2016, 20:03
|
#7
|
elite*gold: 67
Join Date: Aug 2014
Posts: 1,323
Received Thanks: 928
|
Don't do it in WinForms and use WPF instead. WPF can do that out of the box, you can simply add an image to the progressbar...
|
|
|
09/14/2016, 20:17
|
#8
|
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
|
Quote:
Originally Posted by Xio.
Don't do it in WinForms and use WPF instead. WPF can do that out of the box, you can simply add an image to the progressbar...
|
What he want's cant be done out of the box. Also you need to expect he migth not be familiar to wpf or has a WinForms code base
|
|
|
09/14/2016, 21:56
|
#9
|
elite*gold: 22
Join Date: Sep 2015
Posts: 951
Received Thanks: 81
|
Most of people and tutorials i found, just explain to draw colours inside the bar and not change the style of progress bar with a image and inside of the image, the value to a image not a color.
|
|
|
09/15/2016, 09:50
|
#10
|
elite*gold: 67
Join Date: Aug 2014
Posts: 1,323
Received Thanks: 928
|
Quote:
Originally Posted by »FlutterShy™
What he want's cant be done out of the box. Also you need to expect he migth not be familiar to wpf or has a WinForms code base
|
That's why you posted winforms code eh?
|
|
|
09/15/2016, 15:47
|
#11
|
elite*gold: 22
Join Date: Sep 2015
Posts: 951
Received Thanks: 81
|
What you mean Xio?
|
|
|
09/15/2016, 19:26
|
#12
|
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
|
Quote:
Originally Posted by Xio.
That's why you posted winforms code eh?
|
I would call it a "safe bet" to post winforms code.
A lot of people are still using winforms and old net frameworks.
and in this case it was the right choice.
So what exactly do you want now?
|
|
|
09/15/2016, 20:01
|
#13
|
elite*gold: 67
Join Date: Aug 2014
Posts: 1,323
Received Thanks: 928
|
Quote:
Originally Posted by Proxynear
What you mean Xio?
|
I mean doing it the proper way, start here, then figure it out on your own, you're a dekaron developer (whatever that is) or so you claim, if you don't know how to solve problems you're nothing more than a wannabe
Without telling us  there is little we can do for you. If you simply want the solution - good luck finding someone who's going to write down the code just for you, for free.
Quote:
Originally Posted by »FlutterShy™
I would call it a "safe bet" to post winforms code.
A lot of people are still using winforms and old net frameworks.
and in this case it was the right choice.
So what exactly do you want now?
|
|
|
|
09/15/2016, 22:59
|
#14
|
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
|
Quote:
Originally Posted by Xio.
~Snip~
|
He has a WinForms codebase and is not a professional. Wpf overkill here
|
|
|
09/15/2016, 23:26
|
#15
|
elite*gold: 22
Join Date: Sep 2015
Posts: 951
Received Thanks: 81
|
Btw i appreciate the help, but Flutter is helping me out with that yes and im not using wpf
|
|
|
 |
Similar Threads
|
[Selling] I am Catching/Creating new custom accs and more for you!
07/19/2016 - Pokemon Trading - 3 Replies
Closed.
|
Is Creating custom client that hard?
12/25/2013 - CO2 Private Server - 15 Replies
I am so interested to figure this out because if i get the answers i am looking for i can challenge my self one day to start this project.
like to recreate to whole client, what is the top important things to be change?
i know that the engine can stay since its 2.5 d and if the information i have its c3 engine? and let me know if everyone is allow to use this.
but the whole items and everything need to be rebuild. same with maps and music monsters etc etc.
remove the conquer.exe and...
|
[Release] Automated Webpage for Creating Custom Pet Messages
08/18/2011 - Mabinogi Hacks, Bots, Cheats & Exploits - 23 Replies
http://i55.tinypic.com/2n24ck0.jpg
After seeing this kind of page made at Kept After Class Talking Pets in Mabinogi and the fact that it's out dated due to the creators no longer playing Mabinogi I thought I'd recreate the page and include the all the pets even ones that haven't been added to the NA Mabinogi servers.
The page simply allows one to create customized xmls for pets in Mabinogi with up to 4 of your own random chat messages using the say_to_all_immediate for each of the pet...
|
[HELP Programming] LUA: Creating custom channel & speak
01/24/2011 - World of Warcraft - 0 Replies
Hi all,
I want to create in a wow addon a custom channel and use it like a chat in the addon (like a msn, and other people can't see this or can join only with password).
Please, help me :)
|
Pmg2mqo And Mqo2pmg; Essential Tool for Creating Custom Model
06/12/2009 - Mabinogi - 1 Replies
Since these haven't been put up yet and it seems we are getting at least some interest in creating custom content from other people than just myself I decided to upload them.
These are used to convert pmg's to mqo and vice versa, for editing in Metaseq.
These should not be used for when you want to edit clothing as they break joint data, currently I know of no way to fix this.
To use.
Convert to mqo- Drag both the .frm and .pmg onto the pmg2mqo.exe at the same time. Make sure you are...
|
All times are GMT +1. The time now is 13:37.
|
|