aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.cs
blob: 543529acea76e85f522243e0a553be5b853cbc2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
using ShiftOS.Engine.WindowManager;

namespace ShiftOS.Main.ShiftOS.Apps.ShifterStuff
{
	public partial class SelectColor : UserControl
	{
		int _colorType1;
		int _colorType2;
		int _colorType3;
		Color _finalColor;

		public SelectColor()
		{
			InitializeComponent();
		}

		Color SetColor()
		{
			_colorType1 = int.Parse(redUpDown.Value.ToString(CultureInfo.InvariantCulture));
			_colorType2 = int.Parse(greenUpDown.Value.ToString(CultureInfo.InvariantCulture));
			_colorType3 = int.Parse(blueUpDown.Value.ToString(CultureInfo.InvariantCulture));
			try
			{
				_finalColor = Color.FromArgb(_colorType1, _colorType2, _colorType3);


				foreach (var window in ShiftWm.Windows)
				{
					window.Invoke(new Action(() => window.titleBar.BackColor = _finalColor));
				}


				ShiftWm.StartInfoboxSession(
					"Success!",
					$"Changed color to:\r\n{_colorType1}, {_colorType2}, {_colorType3}.",
					InfoboxTemplate.ButtonType.Ok);
			}
			catch (Exception)
			{
				ShiftWm.StartInfoboxSession("Error!", "An error occured while setting the color.", InfoboxTemplate.ButtonType.Ok);
			}
			return _finalColor;
		}

		void btnSetColor_Click(object sender, EventArgs e)
		{
			SetColor();
		}
	}
}