1+ using BluePointLilac . Controls ;
2+ using BluePointLilac . Methods ;
3+ using ContextMenuManager . Methods ;
4+ using ContextMenuManager . Properties ;
5+ using System ;
6+ using System . Drawing ;
7+ using System . IO ;
8+ using System . Windows . Forms ;
9+
10+ namespace ContextMenuManager . Controls
11+ {
12+ internal sealed class AboutAppBox : Panel
13+ {
14+ public AboutAppBox ( )
15+ {
16+ SuspendLayout ( ) ;
17+ Dock = DockStyle . Fill ;
18+ BackColor = DarkModeHelper . FormBack ;
19+ Font = SystemFonts . MenuFont ;
20+ Font = new Font ( Font . FontFamily , Font . Size + 1F ) ;
21+
22+ // 重置所有控件属性,使用最简单可靠的设置
23+
24+ // 设置logo图片
25+ pbLogo . Image = Resources . Logo ;
26+ pbLogo . SizeMode = PictureBoxSizeMode . Zoom ;
27+ pbLogo . Size = new Size ( 100 , 100 ) ;
28+ pbLogo . Visible = true ;
29+
30+ // 设置标题标签
31+ lblTitle . Text = AppString . General . AppName ;
32+ lblTitle . Font = new Font ( Font . FontFamily , Font . Size + 3F , FontStyle . Bold ) ;
33+ lblTitle . ForeColor = Color . Orange ;
34+ lblTitle . TextAlign = ContentAlignment . MiddleCenter ;
35+ lblTitle . Size = new Size ( 400 , 30 ) ;
36+ lblTitle . Visible = true ;
37+
38+ // 设置描述标签 - 重写为更简单可靠的设置
39+ lblDescription . Text = AppString . About . Description ; // 使用多语言文本
40+ lblDescription . TextAlign = ContentAlignment . MiddleCenter ;
41+ lblDescription . Size = new Size ( 300 , 30 ) ; // 调整高度为30像素
42+ lblDescription . Visible = true ;
43+ lblDescription . ForeColor = DarkModeHelper . FormFore ;
44+ lblDescription . BackColor = Color . Transparent ;
45+ lblDescription . BorderStyle = BorderStyle . None ;
46+
47+ // 设置GitHub标签
48+ lblGitHub . Text = $ "{ AppString . About . GitHub } : https://github.com/Jack251970/ContextMenuManager"; // 使用多语言文本
49+ lblGitHub . TextAlign = ContentAlignment . MiddleCenter ;
50+ lblGitHub . ForeColor = Color . Orange ;
51+ lblGitHub . Cursor = Cursors . Hand ;
52+ lblGitHub . Size = new Size ( 400 , 20 ) ;
53+ lblGitHub . Visible = true ;
54+ lblGitHub . MouseDown += ( sender , e ) => ExternalProgram . OpenWebUrl ( "https://github.com/Jack251970/ContextMenuManager" ) ;
55+
56+ // 设置Gitee标签
57+ lblGitee . Text = $ "{ AppString . About . Gitee } : https://gitee.com/Jack251970/ContextMenuManager"; // 使用多语言文本
58+ lblGitee . TextAlign = ContentAlignment . MiddleCenter ;
59+ lblGitee . ForeColor = Color . Orange ;
60+ lblGitee . Cursor = Cursors . Hand ;
61+ lblGitee . Size = new Size ( 400 , 20 ) ;
62+ lblGitee . Visible = true ;
63+ lblGitee . MouseDown += ( sender , e ) => ExternalProgram . OpenWebUrl ( "https://gitee.com/Jack251970/ContextMenuManager" ) ;
64+
65+ // 设置许可证标签
66+ lblLicense . Text = $ "{ AppString . About . License } : GPL License"; // 使用多语言文本
67+ lblLicense . TextAlign = ContentAlignment . MiddleCenter ;
68+ lblLicense . Size = new Size ( 400 , 20 ) ;
69+ lblLicense . Visible = true ;
70+
71+ // 设置检查更新按钮
72+ btnCheckUpdate . Text = AppString . About . CheckUpdate ; // 使用多语言文本
73+ btnCheckUpdate . Size = new Size ( 120 , 30 ) ;
74+ btnCheckUpdate . BackColor = Color . Orange ;
75+ btnCheckUpdate . ForeColor = Color . White ;
76+ btnCheckUpdate . FlatStyle = FlatStyle . Flat ;
77+ btnCheckUpdate . FlatAppearance . BorderSize = 0 ;
78+ btnCheckUpdate . Cursor = Cursors . Hand ;
79+ btnCheckUpdate . Visible = true ;
80+ btnCheckUpdate . Click += ( sender , e ) => Updater . Update ( true ) ;
81+
82+ // 直接在面板上添加控件
83+ Controls . AddRange ( new Control [ ] { pbLogo , lblTitle , lblDescription , lblGitHub , lblGitee , lblLicense , btnCheckUpdate } ) ;
84+
85+ // 监听主题变化事件
86+ DarkModeHelper . ThemeChanged += OnThemeChanged ;
87+
88+ // 设置控件初始颜色
89+ UpdateControlColors ( ) ;
90+
91+ // 监听大小变化,调整控件位置和宽度(实现垂直居中)
92+ Resize += ( sender , e ) => {
93+ // 计算各个控件之间的间距
94+ const int spacingLogoTitle = 20 ;
95+ const int spacingTitleDesc = 10 ;
96+ const int spacingDescGitHub = 15 ;
97+ const int spacingGitHubGitee = 10 ;
98+ const int spacingGiteeLicense = 10 ;
99+ const int spacingLicenseBtn = 30 ;
100+
101+ // 计算总高度
102+ int totalHeight = pbLogo . Height + spacingLogoTitle +
103+ lblTitle . Height + spacingTitleDesc +
104+ lblDescription . Height + spacingDescGitHub +
105+ lblGitHub . Height + spacingGitHubGitee +
106+ lblGitee . Height + spacingGiteeLicense +
107+ lblLicense . Height + spacingLicenseBtn +
108+ btnCheckUpdate . Height ;
109+
110+ // 计算起始Y坐标,实现垂直居中
111+ int startY = ( Height - totalHeight ) / 2 ;
112+
113+ // 设置各个控件的位置
114+ pbLogo . Location = new Point ( ( Width - pbLogo . Width ) / 2 , startY ) ;
115+
116+ lblTitle . Location = new Point ( 0 , pbLogo . Bottom + spacingLogoTitle ) ;
117+ lblTitle . Width = Width ;
118+
119+ lblDescription . Location = new Point ( 50 , lblTitle . Bottom + spacingTitleDesc ) ;
120+ lblDescription . Width = Width - 100 ;
121+
122+ lblGitHub . Location = new Point ( 0 , lblDescription . Bottom + spacingDescGitHub ) ;
123+ lblGitHub . Width = Width ;
124+
125+ lblGitee . Location = new Point ( 0 , lblGitHub . Bottom + spacingGitHubGitee ) ;
126+ lblGitee . Width = Width ;
127+
128+ lblLicense . Location = new Point ( 0 , lblGitee . Bottom + spacingGiteeLicense ) ;
129+ lblLicense . Width = Width ;
130+
131+ btnCheckUpdate . Location = new Point ( ( Width - btnCheckUpdate . Width ) / 2 , lblLicense . Bottom + spacingLicenseBtn ) ;
132+ } ;
133+
134+ // 初始布局
135+ OnResize ( null ) ;
136+
137+ ResumeLayout ( ) ;
138+ }
139+
140+ private readonly PictureBox pbLogo = new ( ) ;
141+ private readonly Label lblTitle = new ( ) ;
142+ private readonly Label lblGitHub = new ( ) ;
143+ private readonly Label lblGitee = new ( ) ; // 添加Gitee标签
144+ private readonly Label lblLicense = new ( ) ;
145+ private readonly Label lblDescription = new ( ) ;
146+ private readonly Button btnCheckUpdate = new ( ) ;
147+
148+ public void LoadAboutInfo ( )
149+ {
150+ // 恢复使用多语言文本
151+ lblTitle . Text = AppString . General . AppName ;
152+
153+ // 手动加载About类的文本,确保它们被正确初始化
154+ string description = AppString . About . Description ;
155+ string gitHub = AppString . About . GitHub ;
156+ string gitee = AppString . About . Gitee ;
157+ string license = AppString . About . License ;
158+ string checkUpdate = AppString . About . CheckUpdate ;
159+
160+ // 添加默认值支持,确保即使语言文件加载失败也能正常显示
161+ if ( string . IsNullOrEmpty ( description ) ) description = "一个纯粹的Windows右键菜单管理器" ;
162+ if ( string . IsNullOrEmpty ( gitHub ) ) gitHub = "GitHub" ;
163+ if ( string . IsNullOrEmpty ( gitee ) ) gitee = "Gitee" ;
164+ if ( string . IsNullOrEmpty ( license ) ) license = "许可证" ;
165+ if ( string . IsNullOrEmpty ( checkUpdate ) ) checkUpdate = "检查更新" ;
166+
167+ // 设置控件文本
168+ lblDescription . Text = description ;
169+ lblGitHub . Text = $ "{ gitHub } : https://github.com/Jack251970/ContextMenuManager";
170+ lblGitee . Text = $ "{ gitee } : https://gitee.com/Jack251970/ContextMenuManager";
171+ lblLicense . Text = $ "{ license } : GPL License";
172+ btnCheckUpdate . Text = checkUpdate ;
173+
174+ // 确保控件可见
175+ Visible = true ;
176+ }
177+
178+ // 主题变化事件处理程序
179+ private void OnThemeChanged ( object sender , EventArgs e )
180+ {
181+ UpdateControlColors ( ) ;
182+ }
183+
184+ // 更新控件颜色以适应主题变化
185+ private void UpdateControlColors ( )
186+ {
187+ // 更新面板背景色
188+ BackColor = DarkModeHelper . FormBack ;
189+
190+ // 更新标签文字颜色
191+ lblTitle . ForeColor = Color . Orange ; // 保持橘色
192+ lblDescription . ForeColor = DarkModeHelper . FormFore ;
193+ lblGitHub . ForeColor = Color . Orange ; // 保持橘色
194+ lblGitee . ForeColor = Color . Orange ; // 保持橘色
195+ lblLicense . ForeColor = DarkModeHelper . FormFore ;
196+
197+ // 更新按钮颜色
198+ btnCheckUpdate . BackColor = Color . Orange ; // 保持橘色
199+ btnCheckUpdate . ForeColor = Color . White ; // 保持白色文字
200+ }
201+
202+ // 重写Dispose方法,取消订阅事件
203+ protected override void Dispose ( bool disposing )
204+ {
205+ if ( disposing )
206+ {
207+ DarkModeHelper . ThemeChanged -= OnThemeChanged ;
208+ }
209+ base . Dispose ( disposing ) ;
210+ }
211+ }
212+ }
0 commit comments