-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInfoDialog.cs
More file actions
166 lines (143 loc) · 4.29 KB
/
InfoDialog.cs
File metadata and controls
166 lines (143 loc) · 4.29 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
using System;
using System.Drawing;
using System.Windows.Forms;
namespace generalgff
{
sealed class InfoDialog
:
Form
{
#region cTor
/// <summary>
/// cTor.
/// </summary>
/// <param name="title"></param>
/// <param name="info"></param>
internal InfoDialog(string title, string info)
{
InitializeComponent();
Text = title;
la_Info.Text = info;
KeyDown += keydown_Copy;
switch (title)
{
case Globals.About:
KeyDown += keydown_Close;
break;
case Globals.Error:
System.Media.SystemSounds.Exclamation.Play();
bu_Okay.Text = "cancel";
break;
}
SuspendLayout();
int w = 0, wTest, h = 0, hTest;
string[] separators = { "\r\n", "\r", "\n" };
string[] lines = info.Split(separators, StringSplitOptions.None);
var size = new Size();
foreach (var line in lines)
{
size = TextRenderer.MeasureText(line, la_Info.Font);
if ((wTest = size.Width) > w)
w = wTest;
if ((hTest = size.Height) > h)
h = hTest;
}
w += la_Info.Padding.Left + la_Info.Padding.Right;
if (w < 250) w = 250;
la_Info.Height = h * lines.Length + la_Info.Padding.Top + la_Info.Padding.Bottom;
ClientSize = new Size(w, la_Info.Height + bu_Okay.Height);
bu_Okay.Location = new Point(w - bu_Okay.Width - 3, la_Info.Bottom + 6);
ResumeLayout();
}
#endregion cTor
#region Handlers
/// <summary>
/// Special handling for the About box - close on F2.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void keydown_Close(object sender, KeyEventArgs e)
{
switch (e.KeyData)
{
case Keys.F2:
Close();
break;
}
}
/// <summary>
/// Copys text to clipboard.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void keydown_Copy(object sender, KeyEventArgs e)
{
switch (e.KeyData)
{
case Keys.Control | Keys.C:
Clipboard.SetText(la_Info.Text);
break;
}
}
#endregion Handlers
#region Designer
Label la_Info;
Button bu_Okay;
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The
/// Forms designer might not be able to load this method if it was
/// changed manually.
/// </summary>
private void InitializeComponent()
{
this.bu_Okay = new System.Windows.Forms.Button();
this.la_Info = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// bu_Okay
//
this.bu_Okay.DialogResult = System.Windows.Forms.DialogResult.OK;
this.bu_Okay.Dock = System.Windows.Forms.DockStyle.Bottom;
this.bu_Okay.Location = new System.Drawing.Point(0, 30);
this.bu_Okay.Margin = new System.Windows.Forms.Padding(0);
this.bu_Okay.Name = "bu_Okay";
this.bu_Okay.Size = new System.Drawing.Size(244, 23);
this.bu_Okay.TabIndex = 1;
this.bu_Okay.Text = "ok";
this.bu_Okay.UseVisualStyleBackColor = true;
//
// la_Info
//
this.la_Info.Dock = System.Windows.Forms.DockStyle.Fill;
this.la_Info.ForeColor = System.Drawing.SystemColors.ControlText;
this.la_Info.Location = new System.Drawing.Point(0, 0);
this.la_Info.Margin = new System.Windows.Forms.Padding(0);
this.la_Info.Name = "la_Info";
this.la_Info.Padding = new System.Windows.Forms.Padding(5, 6, 8, 5);
this.la_Info.Size = new System.Drawing.Size(244, 30);
this.la_Info.TabIndex = 0;
this.la_Info.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// InfoDialog
//
this.AcceptButton = this.bu_Okay;
this.CancelButton = this.bu_Okay;
this.ClientSize = new System.Drawing.Size(244, 53);
this.Controls.Add(this.la_Info);
this.Controls.Add(this.bu_Okay);
this.Font = new System.Drawing.Font("Consolas", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ForeColor = System.Drawing.SystemColors.ControlText;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = global::GeneralGFF.Properties.Resources.generalgff_32;
this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "InfoDialog";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.ResumeLayout(false);
}
#endregion Designer
}
}