aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/StatusIcons/Volume.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/StatusIcons/Volume.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/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);
+ }
+ }
+}