aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Main/ShiftOS/Apps/ShifterStuff/SelectColor.cs
blob: 9062947b07582d2ee5556dbdfe5f491fc64d9984 (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
55
56
57
58
59
60
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.WindowManager;

namespace ShiftOS.Main.ShiftOS.Apps
{
    public partial class SelectColor : UserControl
    {
        ShiftWM shiftWM = new ShiftWM();
        Color finalColor;
        int colorType1;
        int colorType2;
        int colorType3;
        public SelectColor()
        {
            InitializeComponent();
            
        }

        private void btnSetColor_Click(object sender, EventArgs e)
        {
            try
            {
                colorType1 = Convert.ToInt32(textBox1.Text);
                colorType2 = Convert.ToInt32(textBox2.Text);
                colorType3 = Convert.ToInt32(textBox3.Text);
            }
            catch(Exception ex)
            {
                shiftWM.StartInfoboxSession("Error!", "Failed to parse integer. Error:\n" + ex, InfoboxTemplate.buttonType.OK);
            }
            
            if (colorType1 > 255 || colorType2 > 255 || colorType3 > 255)
            {
                shiftWM.StartInfoboxSession("Error!", "A value cannot be greater than 255!", InfoboxTemplate.buttonType.OK);
            }
            else
            {
                try
                {
                    ShiftWindow sw = new ShiftWindow();
                    finalColor = Color.FromArgb(colorType1, colorType2, colorType3);
                    this.BackColor = finalColor;
                    shiftWM.StartInfoboxSession("Success!", "Changed color to:\n" + colorType1.ToString() + ", " + colorType2.ToString() + ", " + colorType3.ToString() + ".", InfoboxTemplate.buttonType.OK);
                }
                catch (Exception ex)
                {
                    shiftWM.StartInfoboxSession("Error!", "An error occured while setting the color.", InfoboxTemplate.buttonType.OK);
                }
            }
        }
    }
}