aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs
diff options
context:
space:
mode:
authorAShifter <[email protected]>2017-06-05 09:49:46 -0600
committerAShifter <[email protected]>2017-06-05 09:49:46 -0600
commit61c906e596145bbedd60725c6dcee68c34a27907 (patch)
treecd7a00d501affe96028bfb21a8dec90c2ee63f2c /ShiftOS.WinForms/Controls/ShiftedProgressBar.cs
parent66ea2cf2fdeeaa025bd22961a0400423233c505d (diff)
parent3e11eca70481841b6e2f2253d667944779cfd5fb (diff)
downloadshiftos_thereturn-61c906e596145bbedd60725c6dcee68c34a27907.tar.gz
shiftos_thereturn-61c906e596145bbedd60725c6dcee68c34a27907.tar.bz2
shiftos_thereturn-61c906e596145bbedd60725c6dcee68c34a27907.zip
Merge remote-tracking branch 'refs/remotes/shiftos-game/master'
Diffstat (limited to 'ShiftOS.WinForms/Controls/ShiftedProgressBar.cs')
-rw-r--r--ShiftOS.WinForms/Controls/ShiftedProgressBar.cs127
1 files changed, 98 insertions, 29 deletions
diff --git a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs
index e5a2c33..c5a6d05 100644
--- a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs
+++ b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs
@@ -31,6 +31,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using ShiftOS.Engine;
namespace ShiftOS.WinForms.Controls
{
@@ -46,7 +47,7 @@ namespace ShiftOS.WinForms.Controls
t.Interval = 100;
t.Tick += (o, a) =>
{
- if(this._style == ProgressBarStyle.Marquee)
+ if(this.Style == ProgressBarStyle.Marquee)
{
if(_marqueePos >= this.Width)
{
@@ -89,47 +90,115 @@ namespace ShiftOS.WinForms.Controls
}
}
- public ProgressBarStyle _style = ProgressBarStyle.Continuous;
-
public ProgressBarStyle Style
{
- get { return _style; }
- set { _style = value; this.Refresh(); }
+ get
+ {
+ return SkinEngine.LoadedSkin.ProgressBarStyle;
+ }
}
- private int _blocksize = 5;
-
public int BlockSize
{
- get { return _blocksize; }
- set
+ get
{
- _blocksize = value;
- this.Refresh();
+ return SkinEngine.LoadedSkin.ProgressBarBlockSize;
+ }
+ }
+
+ public Color RealBackColor
+ {
+ get
+ {
+ return SkinEngine.LoadedSkin.ProgressBarBackgroundColor;
+ }
+ }
+
+ public Image RealBackgroundImage
+ {
+ get
+ {
+ return SkinEngine.GetImage("progressbarbg");
+ }
+ }
+
+ public Image ProgressImage
+ {
+ get
+ {
+ return SkinEngine.GetImage("progress");
+ }
+ }
+
+ public Color ProgressColor
+ {
+ get
+ {
+ return SkinEngine.LoadedSkin.ProgressColor;
}
}
protected override void OnPaint(PaintEventArgs pe)
{
- pe.Graphics.Clear(Color.Black);
- switch (_style)
+ try
{
- case ProgressBarStyle.Continuous:
- double width = linear(this.Value, 0, this.Maximum, 0, this.Width);
- pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new RectangleF(0, 0, (float)width, this.Height));
- break;
- case ProgressBarStyle.Blocks:
- int block_count = this.Width / (this._blocksize + 2);
- int blocks = (int)linear(this.Value, 0, this.Maximum, 0, block_count);
- for(int i = 0; i < blocks - 1; i++)
- {
- int position = i * (_blocksize + 2);
- pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new Rectangle(position, 0, _blocksize, this.Height));
- }
- break;
- case ProgressBarStyle.Marquee:
- pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height));
- break;
+ pe.Graphics.Clear(this.RealBackColor);
+ if (RealBackgroundImage != null)
+ {
+ pe.Graphics.FillRectangle(new TextureBrush(RealBackgroundImage), new Rectangle(0, 0, this.Width, this.Height));
+ }
+ switch (Style)
+ {
+ case ProgressBarStyle.Continuous:
+ double width = linear(this.Value, 0, this.Maximum, 0, this.Width);
+ if (ProgressImage != null)
+ {
+ pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new RectangleF(0, 0, (float)width, this.Height));
+ }
+ else
+ {
+ pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new RectangleF(0, 0, (float)width, this.Height));
+ }
+ break;
+ case ProgressBarStyle.Blocks:
+ int block_count = this.Width / (this.BlockSize + 2);
+ int blocks = (int)linear(this.Value, 0, this.Maximum, 0, block_count);
+ for (int i = 0; i < blocks - 1; i++)
+ {
+ int position = i * (BlockSize + 2);
+ if (ProgressImage != null)
+ {
+ pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(position, 0, BlockSize, this.Height));
+
+ }
+ else
+ {
+ pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(position, 0, BlockSize, this.Height));
+ }
+ }
+ break;
+ case ProgressBarStyle.Marquee:
+ if (ProgressImage != null)
+ {
+ pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height));
+ }
+ else
+ {
+ pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height));
+ }
+ break;
+ }
+ }
+ catch
+ {
+ pe.Graphics.Clear(Color.Black);
+ string text = "Preview mode. This control can't be drawn without an initiated ShiftOS engine.";
+ SizeF sz = pe.Graphics.MeasureString(text, this.Font);
+ PointF loc = new PointF(
+ (this.Width - sz.Width) / 2,
+ (this.Height - sz.Height) / 2
+ );
+ pe.Graphics.DrawString(text, Font, new SolidBrush(Color.White), loc);
}
}