aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Controls
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-05-31 19:23:40 -0400
committerMichael <[email protected]>2017-05-31 19:23:40 -0400
commit324104eb0b8650969b2205404e3ad83401fb100e (patch)
treee1345eb1aee68d33eb16aaed57e9567e06a0fdf7 /ShiftOS.WinForms/Controls
parentb0da30bbde2bb198850ea45dc0006762b23f99a3 (diff)
downloadshiftos_thereturn-324104eb0b8650969b2205404e3ad83401fb100e.tar.gz
shiftos_thereturn-324104eb0b8650969b2205404e3ad83401fb100e.tar.bz2
shiftos_thereturn-324104eb0b8650969b2205404e3ad83401fb100e.zip
volume control slider and other goodies
Diffstat (limited to 'ShiftOS.WinForms/Controls')
-rw-r--r--ShiftOS.WinForms/Controls/ShiftedProgressBar.cs88
1 files changed, 51 insertions, 37 deletions
diff --git a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs
index ceaff02..c5a6d05 100644
--- a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs
+++ b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs
@@ -140,51 +140,65 @@ namespace ShiftOS.WinForms.Controls
protected override void OnPaint(PaintEventArgs pe)
{
- pe.Graphics.Clear(this.RealBackColor);
- if(RealBackgroundImage != null)
+ try
{
- 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);
+ 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 Rectangle(position, 0, BlockSize, this.Height));
+ 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(position, 0, BlockSize, this.Height));
+ pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(_marqueePos, 0, this.Width / 4, 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;
+ 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);
}
}