Skip to content

Commit e0be8ed

Browse files
committed
Refactor
1 parent 84871e5 commit e0be8ed

File tree

12 files changed

+15
-40
lines changed

12 files changed

+15
-40
lines changed

.vs/QuickLibrary/v16/.suo

12.5 KB
Binary file not shown.
0 Bytes
Binary file not shown.

QuickLibrary/DialogMan.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ public static DialogResult ShowConfirm(
1919
{
2020
YesNoForm ynf = new YesNoForm(messageText, yesBtnText, yesBtnImage, showNoBtn, noBtnText, noBtnImage, windowTitle, darkMode);
2121
ynf.Owner = owner;
22-
return ynf.ShowDialog();
22+
DialogResult dr = ynf.ShowDialog();
23+
ynf.Dispose();
24+
return dr;
2325
}
2426

2527
public static DialogResult ShowInfo(
@@ -31,7 +33,9 @@ public static DialogResult ShowInfo(
3133
{
3234
OkForm of = new OkForm(messageText, windowTitle, darkMode);
3335
of.Owner = owner;
34-
return of.ShowDialog();
36+
DialogResult dr = of.ShowDialog();
37+
of.Dispose();
38+
return dr;
3539
}
3640
}
3741
}

QuickLibrary/NativeMan.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,7 @@ public struct SHELLEXECUTEINFO
169169
public static string GetMessageBoxText(DialogBoxCommandID messageId)
170170
{
171171
string str = Marshal.PtrToStringAuto(MB_GetString((int)messageId));
172-
if (str[0] == '&')
173-
{
174-
str = str.Substring(1, str.Length - 1);
175-
}
172+
if (str[0] == '&') str = str.Substring(1, str.Length - 1);
176173
return str;
177174
}
178175

QuickLibrary/OkForm.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ public OkForm(string messageText, string windowTitle, bool darkMode = false)
3333

3434
private void OkForm_KeyDown(object sender, KeyEventArgs e)
3535
{
36-
if (e.KeyCode == Keys.Escape)
37-
{
38-
Close();
39-
}
36+
if (e.KeyCode == Keys.Escape) Close();
4037
}
4138

4239
private void okBtn_Click(object sender, EventArgs e)

QuickLibrary/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.5.5")]
36-
[assembly: AssemblyFileVersion("2.5.5")]
35+
[assembly: AssemblyVersion("2.5.6")]
36+
[assembly: AssemblyFileVersion("2.5.6")]
3737
[assembly: NeutralResourcesLanguage("en")]

QuickLibrary/YesNoForm.cs

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,15 @@ internal YesNoForm(
2222
(new DropShadow()).ApplyShadows(this);
2323
SetDraggableControls(new List<Control>() { titleLabel });
2424

25-
if (yesBtnText.Length == 0)
26-
{
27-
yesBtn.Text = NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDYES);
28-
}
29-
else
30-
{
31-
yesBtn.Text = yesBtnText;
32-
}
25+
yesBtn.Text = yesBtnText.Length == 0 ? NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDYES) : yesBtnText;
3326
if (yesBtnImage != null)
3427
{
3528
yesBtn.Image = yesBtnImage;
3629
yesBtn.TextAlign = ContentAlignment.MiddleRight;
3730
yesBtn.Text = " " + yesBtn.Text;
3831
}
3932

40-
if (noBtnText.Length == 0)
41-
{
42-
noBtn.Text = NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDNO);
43-
}
44-
else
45-
{
46-
noBtn.Text = noBtnText;
47-
}
33+
noBtn.Text = noBtnText.Length == 0 ? NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDNO) : noBtnText;
4834
if (noBtnImage != null)
4935
{
5036
noBtn.Image = noBtnImage;
@@ -58,14 +44,8 @@ internal YesNoForm(
5844
textBox.BackColor = BackColor;
5945
textBox.Text = messageText;
6046

61-
if (showNoBtn)
62-
{
63-
noBtn.Visible = true;
64-
}
65-
else
66-
{
67-
Size = new Size(Size.Width, Size.Height - noBtn.Height - 10);
68-
}
47+
if (showNoBtn) noBtn.Visible = true;
48+
else Size = new Size(Size.Width, Size.Height - noBtn.Height - 10);
6949

7050
infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
7151

@@ -83,10 +63,7 @@ internal YesNoForm(
8363

8464
private void YesNoForm_KeyDown(object sender, KeyEventArgs e)
8565
{
86-
if (e.KeyCode == Keys.Escape)
87-
{
88-
Close();
89-
}
66+
if (e.KeyCode == Keys.Escape) Close();
9067
}
9168

9269
private void yesBtn_Click(object sender, EventArgs e)
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)