File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 352
352
<Compile Include =" Utils\ArtifactUtils.cs" />
353
353
<Compile Include =" Utils\Common.cs" />
354
354
<Compile Include =" Utils\GuiRedirect.cs" />
355
+ <Compile Include =" Utils\HighDPIUtil.cs" />
355
356
<Compile Include =" Utils\KeyGo.cs" />
356
357
<Compile Include =" Utils\HotKeyItem.cs" />
357
358
<Compile Include =" Utils\HttpHelper.cs" />
Original file line number Diff line number Diff line change @@ -71,6 +71,12 @@ private static int Main(string[] args)
71
71
if ( result != - 1 )
72
72
return result ;
73
73
74
+ // 开启高DPI支持
75
+ if ( Environment . OSVersion . Version . Major >= 6 ) // 至少需要Vista系统
76
+ {
77
+ HighDPIUtil . SetDpiAwareness ( ) ;
78
+ }
79
+
74
80
Application . EnableVisualStyles ( ) ;
75
81
Application . SetCompatibleTextRenderingDefault ( false ) ;
76
82
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Runtime . InteropServices ;
5
+ using System . Text ;
6
+ using System . Threading . Tasks ;
7
+
8
+ namespace GrasscutterTools . Utils
9
+ {
10
+ internal class HighDPIUtil
11
+ {
12
+ public static void SetDpiAwareness ( )
13
+ {
14
+ var dpiAwareness = ProcessDpiAwareness . PerMonitorDpiAware ;
15
+ var hresult = SetProcessDpiAwareness ( dpiAwareness ) ;
16
+ if ( hresult != 0 )
17
+ {
18
+ throw new System . ComponentModel . Win32Exception ( hresult ) ;
19
+ }
20
+ }
21
+
22
+ [ DllImport ( "shcore.dll" ) ]
23
+ private static extern int SetProcessDpiAwareness ( ProcessDpiAwareness value ) ;
24
+
25
+ private enum ProcessDpiAwareness
26
+ {
27
+ DpiUnaware = 0 ,
28
+ SystemDpiAware = 1 ,
29
+ PerMonitorDpiAware = 2
30
+ }
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments