aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/StatusIcons/Volume.cs
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/StatusIcons/Volume.cs
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/StatusIcons/Volume.cs')
-rw-r--r--ShiftOS.WinForms/StatusIcons/Volume.cs67
1 files changed, 67 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/StatusIcons/Volume.cs b/ShiftOS.WinForms/StatusIcons/Volume.cs
new file mode 100644
index 0000000..329faf0
--- /dev/null
+++ b/ShiftOS.WinForms/StatusIcons/Volume.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using ShiftOS.Engine;
+using ShiftOS.WinForms.Controls;
+
+namespace ShiftOS.WinForms.StatusIcons
+{
+ [DefaultIcon("iconSpeaker")]
+ public partial class Volume : UserControl, IStatusIcon
+ {
+ public Volume()
+ {
+ InitializeComponent();
+ }
+
+ public void Setup()
+ {
+ lbvolume.Top = (this.Height - lbvolume.Height) / 2;
+ bool moving = false;
+ var prg = new ShiftedProgressBar();
+ prg.Tag = "ignoreal"; //Don't close AL or current widget when this control is clicked.
+ this.Controls.Add(prg);
+ prg.Height = this.Height / 3;
+ prg.Maximum = 100;
+ prg.Value = SaveSystem.CurrentSave.MusicVolume;
+ prg.Width = this.Width - lbvolume.Width - 50;
+ prg.Left = lbvolume.Left + lbvolume.Width + 15;
+ prg.Top = (this.Height - prg.Height) / 2;
+ prg.MouseDown += (o, a) =>
+ {
+ moving = true;
+ };
+
+ prg.MouseMove += (o, a) =>
+ {
+ if (moving)
+ {
+ int val = (int)linear(a.X, 0, prg.Width, 0, 100);
+ SaveSystem.CurrentSave.MusicVolume = val;
+ prg.Value = val;
+ }
+ };
+
+ prg.MouseUp += (o, a) =>
+ {
+ moving = false;
+ };
+ prg.Show();
+ }
+
+ static public double linear(double x, double x0, double x1, double y0, double y1)
+ {
+ if ((x1 - x0) == 0)
+ {
+ return (y0 + y1) / 2;
+ }
+ return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
+ }
+ }
+}