salam rahi vase avaz kardane range in progressBar hast ???
begin lotfan
thanx
begin lotfan
thanx
No user |
Public Class imanProgressbar
Inherits Control
Dim _BorderColor As Color = Color.Black
Property BorderColor As Color
Get
Return _BorderColor
End Get
Set(ByVal value As Color)
_BorderColor = value
Invalidate()
End Set
End Property
Private _ShowPercentage As Boolean = False
Public Property ShowPercentage() As Boolean
Get
Return _ShowPercentage
End Get
Set(ByVal v As Boolean)
_ShowPercentage = v
Invalidate()
End Set
End Property
Dim _ProgressColor As Color = Color.FromArgb(10, 150, 40)
Property ProgressColor As Color
Get
Return _ProgressColor
End Get
Set(ByVal value As Color)
_ProgressColor = value
Invalidate()
End Set
End Property
Sub New()
SetStyle(ControlStyles.OptimizedDoubleBuffer Or ControlStyles.AllPaintingInWmPaint, True)
DoubleBuffered = True
End Sub
Dim _Val As Integer = 0
Property Value As Integer
Get
Return _Val
End Get
Set(ByVal v As Integer)
If v <= _Max Then _Val = v Else Throw New Exception("The entered value is not valid.")
Invalidate()
End Set
End Property
Dim _Max As Integer = 100
Property Maximum As Integer
Get
Return _Max
End Get
Set(ByVal value As Integer)
If value >= _Val Then _Max = value Else Throw New Exception("The entered value is not valid.")
End Set
End Property
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim G As Graphics = e.Graphics
Dim Progress As Double = (_Val / _Max) * (Width - 2)
G.Clear(BackColor)
G.FillRectangle(New SolidBrush(Color.FromArgb(20, Color.Black)), New Rectangle(0, 0, Width - 1, Height - 1))
If _ShowPercentage Then
G.DrawString(Convert.ToString(String.Concat(Value, "%")), Font, Brushes.Red, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
End If
If Progress > 0 Then G.FillRectangle(New SolidBrush(_ProgressColor), New Rectangle(1, 1, Progress, Height - 2))
G.DrawRectangle(New Pen(_BorderColor), New Rectangle(0, 0, Width - 1, Height - 1))
MyBase.OnPaint(e)
End Sub
End Class
public class imanProgressbar : Control {
private Color _BorderColor = Color.Black;
Color BorderColor {
get {
return _BorderColor;
}
set {
_BorderColor = value;
Invalidate();
}
}
private bool _ShowPercentage = false;
public bool ShowPercentage {
get {
return _ShowPercentage;
}
set {
_ShowPercentage = v;
Invalidate();
}
}
private Color _ProgressColor = Color.FromArgb(10, 150, 40);
Color ProgressColor {
get {
return _ProgressColor;
}
set {
_ProgressColor = value;
Invalidate();
}
}
imanProgressbar() {
SetStyle((ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint), true);
DoubleBuffered = true;
}
private int _Val = 0;
int Value {
get {
return _Val;
}
set {
if ((v <= _Max)) {
_Val = v;
}
else {
throw new Exception("The entered value is not valid.");
}
Invalidate();
}
}
private int _Max = 100;
int Maximum {
get {
return _Max;
}
set {
if ((value >= _Val)) {
_Max = value;
}
else {
throw new Exception("The entered value is not valid.");
}
}
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) {
Graphics G = e.Graphics;
double Progress = ((_Val / _Max)
* (Width - 2));
G.Clear(BackColor);
G.FillRectangle(new SolidBrush(Color.FromArgb(20, Color.Black)), new Rectangle(0, 0, (Width - 1), (Height - 1)));
if (_ShowPercentage) {
G.DrawString(Convert.ToString(string.Concat(Value, "%")), Font, Brushes.Red, new Rectangle(0, 0, (Width - 1), (Height - 1)), new StringFormat(), With, {, ., Alignment=StringAlignment.Center, ., LineAlignment=StringAlignment.Center);
}
if ((Progress > 0)) {
G.FillRectangle(new SolidBrush(_ProgressColor), new Rectangle(1, 1, Progress, (Height - 2)));
}
G.DrawRectangle(new Pen(_BorderColor), new Rectangle(0, 0, (Width - 1), (Height - 1)));
base.OnPaint(e);
}
}
aliqolami wrote:Component progressBar ro az koja mitonam peyda konam? search mikonam nist Help Me
thanx Az hame
|
|