-
Notifications
You must be signed in to change notification settings - Fork 0
/
Confirm.cs
65 lines (57 loc) · 2.33 KB
/
Confirm.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
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Aku
{
public class Confirm : AkuForm
{
private const Int32 MinWidth = 240;
private const Int32 MinHeight = 140;
private const Int32 MaxButtonHeight = 40;
private AkuButton btnOk;
private AkuButton btnCancel;
private Label lblMessage;
private readonly String confirmMessage;
private DialogResult dialogResult;
public Confirm(String message) : base(ColorTranslator.FromHtml("#4c4f53"), ColorTranslator.FromHtml("#161a1f"), Color.Transparent)
{
confirmMessage = message;
Text = "Confirm";
MinimumSize = Size = new Size(MinWidth, MinHeight);
InitializeComponent();
}
private void InitializeComponent()
{
/*Graphics g = CreateGraphics();
SizeF textSize = g.MeasureString(confirmMessage, Font);*/
lblMessage = new Label();
lblMessage.Font = Font;
lblMessage.ForeColor = Color.White;
lblMessage.BackColor = Color.Transparent;
lblMessage.AutoSize = true;
lblMessage.Text = confirmMessage;
Int32 x = (Width/2) - (lblMessage.Width/2);
lblMessage.Location = new Point(x, MaxButtonHeight);
btnOk = new AkuButton(AkuColor.DefaultBeginColor);
btnOk.Location = new Point(0, Height - MaxButtonHeight);
btnOk.Name = "btnOk";
btnOk.Size = new Size((Width / 2) + 1, MaxButtonHeight);
btnOk.Text = "Ok";
btnOk.Click += (sender, args) => { dialogResult = DialogResult.OK; Close(); };
btnCancel = new AkuButton(AkuColor.DefaultBeginColor);
btnCancel.Location = new Point(btnOk.Width - 1, Height - MaxButtonHeight);
btnCancel.Name = "btnCancel";
btnCancel.Size = new Size((Width / 2), MaxButtonHeight);
btnCancel.Text = "Cancel";
btnCancel.Click += (sender, args) => { dialogResult = DialogResult.Cancel; Close(); };
Controls.Add(lblMessage);
Controls.Add(btnOk);
Controls.Add(btnCancel);
}
public new DialogResult ShowDialog(IWin32Window parent)
{
base.ShowDialog(parent);
return dialogResult;
}
}
}