2019-04-18 20:04:58 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace RyzStudio.Windows.ThemedForms
|
|
|
|
|
{
|
|
|
|
|
public partial class ProgressBarInner : System.Windows.Forms.UserControl
|
|
|
|
|
{
|
|
|
|
|
protected int minimum = 0;
|
|
|
|
|
protected int maximum = 100;
|
|
|
|
|
protected int value = 0;
|
|
|
|
|
|
|
|
|
|
public ProgressBarInner() : base()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
this.Padding = new Padding(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Minimum
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return minimum;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (this.InvokeRequired)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(new MethodInvoker(() => {
|
|
|
|
|
setMinimum(value);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
setMinimum(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Maximum
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return maximum;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (this.InvokeRequired)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(new MethodInvoker(() => {
|
|
|
|
|
setMaximum(value);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
setMaximum(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Value
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (this.InvokeRequired)
|
|
|
|
|
{
|
|
|
|
|
this.Invoke(new MethodInvoker(() => {
|
|
|
|
|
setValue(value);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
setValue(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Color BarColour { get; set; } = Color.FromArgb(158, 225, 249);
|
|
|
|
|
|
|
|
|
|
public Color BarTextColour
|
|
|
|
|
{
|
|
|
|
|
get => label3.ForeColor;
|
|
|
|
|
set => label3.ForeColor = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnPaint(e);
|
|
|
|
|
|
|
|
|
|
Rectangle canvas = this.DisplayRectangle;
|
|
|
|
|
Graphics g = e.Graphics;
|
|
|
|
|
|
|
|
|
|
if (this.Value > 0)
|
|
|
|
|
{
|
|
|
|
|
decimal result = decimal.Divide(canvas.Width, this.Maximum) * this.Value;
|
|
|
|
|
|
|
|
|
|
canvas.Width = (int)Math.Round(result);
|
|
|
|
|
|
|
|
|
|
g.FillRectangle(new SolidBrush(this.BarColour), canvas);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-23 13:42:33 +00:00
|
|
|
|
protected void updateText() => RyzStudio.Windows.Forms.ThreadControl.SetText(label3, string.Format("{0}/{1}", this.Value.ToString(), this.Maximum.ToString()));
|
2019-04-18 20:04:58 +00:00
|
|
|
|
|
|
|
|
|
protected void setMinimum(int value)
|
|
|
|
|
{
|
|
|
|
|
int m = value;
|
|
|
|
|
if (m < 0)
|
|
|
|
|
{
|
|
|
|
|
m = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m > this.Maximum)
|
|
|
|
|
{
|
|
|
|
|
m = this.Maximum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.Value < m)
|
|
|
|
|
{
|
|
|
|
|
this.Value = m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.value > this.Maximum)
|
|
|
|
|
{
|
|
|
|
|
this.value = this.Maximum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
minimum = m;
|
|
|
|
|
updateText();
|
|
|
|
|
this.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void setMaximum(int value)
|
|
|
|
|
{
|
|
|
|
|
int m = value;
|
|
|
|
|
if (m < 0)
|
|
|
|
|
{
|
|
|
|
|
m = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m < this.Minimum)
|
|
|
|
|
{
|
|
|
|
|
m = this.Minimum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.Value > m)
|
|
|
|
|
{
|
|
|
|
|
this.Value = m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.value < this.Minimum)
|
|
|
|
|
{
|
|
|
|
|
this.value = this.Minimum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
maximum = m;
|
|
|
|
|
updateText();
|
|
|
|
|
this.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void setValue(int value)
|
|
|
|
|
{
|
|
|
|
|
int m = value;
|
|
|
|
|
if (m < this.Minimum)
|
|
|
|
|
{
|
|
|
|
|
m = this.Minimum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m > this.Maximum)
|
|
|
|
|
{
|
|
|
|
|
m = this.Maximum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.value = m;
|
|
|
|
|
updateText();
|
|
|
|
|
this.Invalidate();
|
|
|
|
|
}
|
2020-08-23 13:42:33 +00:00
|
|
|
|
|
2019-04-18 20:04:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|