aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Engine/WindowManager/InfoboxTemplate.cs
blob: 54d2a0a902b576fa15c64f0585663a31b7859c2f (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.Drawing;
using System.IO;
using System.Media;
using System.Windows.Forms;
using ShiftOS.Engine.Properties;

namespace ShiftOS.Engine.WindowManager
{
	public partial class InfoboxTemplate : UserControl
    {
        public bool isOK = false;
        public bool isNo = false;
        public enum ButtonType
		{
			YesNo,
			OkCancel,
			Ok
		}

		public enum DialogResult
		{
			Yes,
			No,
			Cancel,
			Ok
		}
		Stream _str;

		public InfoboxTemplate(ButtonType type)
		{
			InitializeComponent();
			switch (type)
			{
				case ButtonType.Ok:
					btnOpt1.Text = "OK";
					btnOpt2.Hide();
					btnOpt1.Location = new Point(156, 163);
					break;
				case ButtonType.OkCancel:
					btnOpt1.Text = "OK";
					btnOpt2.Text = "Cancel";
					break;
				case ButtonType.YesNo:
					btnOpt1.Text = "Yes";
					btnOpt2.Text = "No";
					break;
			}
		}

		void btnOpt1_Click(object sender, EventArgs e)
		{
            isOK = true;
            MessageBox.Show("button was clicked");
            ParentForm?.Close();
		}

		void btnOpt2_Click(object sender, EventArgs e)
		{
			switch (btnOpt2.Text)
			{
				case "No":
                    isNo = true;
                    ParentForm?.Close();
                    break;
				case "Cancel":
                    isNo = true;
                    break;
			}
		}

		public void Play()
		{
			_str = Resources.infobox;
			var sp = new SoundPlayer(_str);
			sp.Play();
			sp.Stream.Position = 0;
		}

		void InfoboxTemplate_Load(object sender, EventArgs e)
        {
            Play();
            SizeAndLoad(label1.Size.Width, label1.Size.Width);
        }
        private Size SizeAndLoad(int x, int y)
        {
            this.Size = new Size(x, y);
            Left = (Screen.PrimaryScreen.Bounds.Width - Width) / 2;
            Top = (Screen.PrimaryScreen.Bounds.Top - Height) / 2;
            return Size;
        }
    }
}