-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbout.cs
More file actions
253 lines (229 loc) · 9.65 KB
/
About.cs
File metadata and controls
253 lines (229 loc) · 9.65 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
using System.Diagnostics;
namespace super_toolbox
{
public partial class AboutForm : Form
{
private string browserSettingsFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "browser.txt");
public AboutForm()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.Sizable;
this.MaximizeBox = true;
this.MinimizeBox = true;
this.StartPosition = FormStartPosition.CenterParent;
this.Text = "关于-超级工具箱";
this.Size = new Size(420, 410);
this.MinimumSize = new Size(400, 380);
SetupAboutContent();
}
private void SetupAboutContent()
{
var lblTitle = new Label
{
Text = "超级工具箱",
Font = new Font("微软雅黑", 16, FontStyle.Bold),
ForeColor = Color.DarkBlue,
Location = new Point(25, 15),
AutoSize = true,
Anchor = AnchorStyles.Top | AnchorStyles.Left
};
Controls.Add(lblTitle);
var lblVersion = new Label
{
Text = $"版本:{Application.ProductVersion}",
Font = new Font("微软雅黑", 9),
ForeColor = Color.Gray,
Location = new Point(25, 50),
AutoSize = true,
Anchor = AnchorStyles.Top | AnchorStyles.Left
};
Controls.Add(lblVersion);
var lblDescription = new Label
{
Text = "一个功能强大的游戏解包工具箱和管理器\r\n\r\n" +
"包含上百种提取器、转换器、压缩/解压器和打包器",
Font = new Font("微软雅黑", 9),
ForeColor = Color.Black,
Location = new Point(25, 80),
Size = new Size(350, 80),
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right
};
Controls.Add(lblDescription);
var btnBrowserSetting = new Button
{
Text = "设置默认浏览器",
Font = new Font("微软雅黑", 9),
ForeColor = Color.White,
BackColor = Color.FromArgb(76, 175, 80),
Location = new Point(25, 170),
Size = new Size(150, 30),
FlatStyle = FlatStyle.Flat,
Cursor = Cursors.Hand,
Anchor = AnchorStyles.Top | AnchorStyles.Left
};
btnBrowserSetting.FlatAppearance.BorderSize = 0;
btnBrowserSetting.Click += BtnBrowserSetting_Click;
Controls.Add(btnBrowserSetting);
var lblBrowserInfo = new Label
{
Text = GetBrowserDisplayText(),
Font = new Font("微软雅黑", 8),
ForeColor = Color.Gray,
Location = new Point(180, 176),
AutoSize = true,
Anchor = AnchorStyles.Top | AnchorStyles.Left
};
Controls.Add(lblBrowserInfo);
var btnDocs = new Button
{
Text = "查看详细说明文档",
Font = new Font("微软雅黑", 10, FontStyle.Bold),
ForeColor = Color.Blue,
BackColor = Color.LightBlue,
Location = new Point(25, 210),
Size = new Size(350, 40),
FlatStyle = FlatStyle.Flat,
Cursor = Cursors.Hand,
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right
};
btnDocs.FlatAppearance.BorderColor = Color.Blue;
btnDocs.FlatAppearance.BorderSize = 1;
btnDocs.Click += (s, e) => OpenUrlWithBrowser("https://www.bilibili.com/opus/1173419824498343952#reply46226415", "详细说明文档");
Controls.Add(btnDocs);
var lblDonorsTitle = new Label
{
Text = "❤️感谢以下朋友的赞助支持,排名不分先后,有遗漏的请私信通知我❤️",
Font = new Font("微软雅黑", 9, FontStyle.Bold),
ForeColor = Color.FromArgb(255, 128, 0),
Location = new Point(25, 265),
AutoSize = true,
Anchor = AnchorStyles.Top | AnchorStyles.Left
};
Controls.Add(lblDonorsTitle);
string[] donors = new string[]
{"御坂银蛇","azoa9","卡柯卡基","紅い瞳に","一年小舞","紧差菊I吴克","水落清秋","明天就不开始","次元狸","苏子瑜o","-梦幻的月夜-","木木木木木酱","叶子三分青","枝江与卿长存我心","苏格拉没UD","帅气逼人小鱼干","煤洋洋","紫林旧主","Encore_Requiem","春是哈鲁","1231陌墨","阳离子21","膻糊椒","贝利亚","甜萌雪团","西红柿真秦","謙巽很努力","黑之断罪米兰达","丶自在有情","Mor75afe","杜绝所有","花小灵a","不雷死它警长","上古龙神","杏子酱Kyouko","nanxia2018","潜匿007","wjei5267","疑似正派","析析沐shi",
};
var listDonors = new ListBox
{
Location = new Point(25, 290),
Size = new Size(350, 70),
Font = new Font("微软雅黑", 8),
BorderStyle = BorderStyle.FixedSingle,
BackColor = Color.FromArgb(250, 250, 250),
SelectionMode = SelectionMode.None,
Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right
};
foreach (var donor in donors)
{
listDonors.Items.Add("❤" + donor);
}
Controls.Add(listDonors);
var lblAuthor = new Label
{
Text = "超级工具箱-持续更新中",
Font = new Font("微软雅黑", 8),
ForeColor = Color.DarkGray,
Location = new Point(25, 370),
AutoSize = true,
Anchor = AnchorStyles.Bottom | AnchorStyles.Left
};
Controls.Add(lblAuthor);
}
private string? GetSavedBrowserPath()
{
try
{
if (File.Exists(browserSettingsFile))
{
return File.ReadAllText(browserSettingsFile).Trim();
}
}
catch { }
return null;
}
private string GetBrowserDisplayText()
{
string? browserPath = GetSavedBrowserPath();
if (!string.IsNullOrEmpty(browserPath) && File.Exists(browserPath))
{
return $"当前浏览器:{Path.GetFileNameWithoutExtension(browserPath)}";
}
return "当前浏览器:系统默认";
}
private void SaveBrowserPath(string browserPath)
{
try
{
File.WriteAllText(browserSettingsFile, browserPath);
}
catch (Exception ex)
{
MessageBox.Show($"保存浏览器设置失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void SelectAndSaveBrowser()
{
using (OpenFileDialog dialog = new OpenFileDialog())
{
dialog.Title = "选择默认浏览器";
dialog.Filter = "浏览器程序|*.exe";
dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
if (dialog.ShowDialog() == DialogResult.OK)
{
SaveBrowserPath(dialog.FileName);
MessageBox.Show($"已设置默认浏览器为:{Path.GetFileNameWithoutExtension(dialog.FileName)}",
"设置成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
foreach (Control ctrl in Controls)
{
if (ctrl is Label && ctrl.Location.Y == 176 && ctrl.Location.X == 180)
{
ctrl.Text = GetBrowserDisplayText();
break;
}
}
}
}
}
private void BtnBrowserSetting_Click(object? sender, EventArgs e)
{
SelectAndSaveBrowser();
}
private void OpenUrlWithBrowser(string url, string resourceName)
{
try
{
string? browserPath = GetSavedBrowserPath();
if (!string.IsNullOrEmpty(browserPath) && File.Exists(browserPath))
{
Process.Start(new ProcessStartInfo
{
FileName = browserPath,
Arguments = url,
UseShellExecute = true
});
}
else
{
Process.Start(new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
});
}
}
catch (Exception ex)
{
var result = MessageBox.Show(
$"打开浏览器失败:{ex.Message}\n\n是否要重新设置浏览器?",
"错误",
MessageBoxButtons.YesNo,
MessageBoxIcon.Error);
if (result == DialogResult.Yes)
{
SelectAndSaveBrowser();
OpenUrlWithBrowser(url, resourceName);
}
}
}
}
}