This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathBasicButtonPopup.cs
80 lines (69 loc) · 2.11 KB
/
BasicButtonPopup.cs
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
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace AstroModLoader
{
public partial class BasicButtonPopup : Form
{
public string DisplayText;
public int ResultButton;
public string PageToVisit = "";
public BasicButtonPopup()
{
InitializeComponent();
}
private void BasicButtonPopup_Load(object sender, EventArgs e)
{
mainLabel.Text = DisplayText;
using (Graphics g = CreateGraphics())
{
SizeF sz = g.MeasureString(mainLabel.Text, mainLabel.Font);
this.Width = (int)(Math.Ceiling(sz.Width) * 1.4f);
mainLabel.Height = (int)Math.Ceiling(sz.Height) * 2;
this.Height = mainLabel.Location.Y + mainLabel.Height + button1.Height * 3;
}
if (this.Owner is Form1 parentForm) this.Text = parentForm.Text;
this.AdjustFormPosition();
AMLPalette.RefreshTheme(this);
mainLabel.Select();
}
private void BasicButtonPopup_KeyDown(object sender, KeyEventArgs e)
{
if (!string.IsNullOrEmpty(PageToVisit)) return;
if (button3.Visible) return;
if (e.KeyCode == Keys.Return)
{
ResultButton = 0;
this.Close();
}
else if (e.KeyCode == Keys.Escape)
{
ResultButton = 1;
this.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
ResultButton = 0;
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(PageToVisit))
{
ResultButton = 1;
this.Close();
}
else
{
Process.Start(PageToVisit);
}
}
private void button3_Click(object sender, EventArgs e)
{
ResultButton = 2;
this.Close();
}
}
}