Skip to content

Commit 12df39b

Browse files
committed
Version 3.13.4.0
1 parent 9defef1 commit 12df39b

18 files changed

Lines changed: 1137 additions & 709 deletions

CapsLockIndicatorV3/BetterCheckBox.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected override void OnPaint(PaintEventArgs e)
6363
}
6464
else
6565
{
66-
66+
var scaling = DPIHelper.GetScalingFactorPercent();
6767
var border = N_Border;
6868
var background = N_Background;
6969
var check = N_Check;
@@ -89,14 +89,14 @@ protected override void OnPaint(PaintEventArgs e)
8989
check = H_Check;
9090
}
9191

92-
const int boxSize = 13;
93-
const int boxRectInnerMargin = 2;
94-
const int checkPenWidth = 2;
95-
const int textMargin = 3;
92+
int boxSize = (int)(13 * scaling);
93+
int boxRectInnerMargin = (int)(2 * scaling);
94+
int checkPenWidth = (int)(2 * scaling);
95+
int textMargin = (int)(3 * scaling);
9696

9797
var boxY = Height / 2 - boxSize / 2;
9898

99-
var boxRect = new Rectangle(0, boxY, 13, 13);
99+
var boxRect = new Rectangle(0, boxY, boxSize, boxSize);
100100
var boxRectPen = boxRect;
101101
var boxRectInner = boxRect;
102102
--boxRectPen.Width;

CapsLockIndicatorV3/BetterTabControl.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ internal void DrawControl(Graphics g)
217217

218218
internal void DrawTab(Graphics g, TabPage tabPage, int nIndex)
219219
{
220-
var tr = this.GetTabRect(nIndex);
220+
var tr = GetTabRectDPI(nIndex);
221221
Rectangle recBounds = tr;
222222
recBounds.Y -= 2;
223223
recBounds.Height += 2;
@@ -329,6 +329,21 @@ internal void DrawTab(Graphics g, TabPage tabPage, int nIndex)
329329
}
330330
}
331331

332+
private Rectangle GetTabRectDPI(int nIndex)
333+
{
334+
var rect = GetTabRect(nIndex);
335+
/*
336+
var scale = DPIHelper.GetScalingFactorPercent();
337+
rect = new Rectangle(
338+
(int)(rect.X * scale),
339+
(int)(rect.Y * scale),
340+
(int)(rect.Width * scale),
341+
(int)(rect.Height * scale)
342+
);
343+
*/
344+
return rect;
345+
}
346+
332347
internal void DrawIcons(Graphics g)
333348
{
334349
if (!_darkMode)
@@ -368,7 +383,7 @@ internal void DrawIcons(Graphics g)
368383
{
369384
if (this.TabCount > 0)
370385
{
371-
Rectangle r3 = this.GetTabRect(0);
386+
Rectangle r3 = GetTabRectDPI(0);
372387
if (r3.Left < TabControlArea.Left)
373388
g.DrawImage(img, r1);
374389
else
@@ -385,7 +400,7 @@ internal void DrawIcons(Graphics g)
385400
{
386401
if (this.TabCount > 0)
387402
{
388-
Rectangle r3 = this.GetTabRect(this.TabCount - 1);
403+
Rectangle r3 = GetTabRectDPI(this.TabCount - 1);
389404
if (r3.Right > (TabControlArea.Width - r0.Width))
390405
g.DrawImage(img, r2);
391406
else
@@ -439,7 +454,7 @@ protected override void OnMouseMove(MouseEventArgs e)
439454
var index = -1;
440455
for (var i = 0; i < TabCount; ++i)
441456
{
442-
var rect = GetTabRect(i);
457+
var rect = GetTabRectDPI(i);
443458
if (rect.Contains(pos))
444459
{
445460
index = i;

CapsLockIndicatorV3/CapsLockIndicatorV3.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
<Compile Include="DownloadDialog.Designer.cs">
115115
<DependentUpon>DownloadDialog.cs</DependentUpon>
116116
</Compile>
117+
<Compile Include="DPIHelper.cs" />
117118
<Compile Include="DropDownLocale.cs" />
118119
<Compile Include="ExtensionMethods.cs" />
119120
<Compile Include="FirstRunDialog.cs">

CapsLockIndicatorV3/DPIHelper.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Drawing;
4+
using System.Linq;
5+
using System.Runtime.InteropServices;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace CapsLockIndicatorV3
10+
{
11+
internal static class DPIHelper
12+
{
13+
[DllImport("gdi32.dll")]
14+
static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
15+
16+
private enum DeviceCap
17+
{
18+
VERTRES = 10,
19+
LOGPIXELSY = 90,
20+
DESKTOPVERTRES = 117
21+
}
22+
23+
internal static decimal GetScalingFactorPercent()
24+
{
25+
var g = Graphics.FromHwnd(IntPtr.Zero);
26+
try
27+
{
28+
var desktop = g.GetHdc();
29+
var LogicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.VERTRES);
30+
var PhysicalScreenHeight = GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES);
31+
var logpixelsy = GetDeviceCaps(desktop, (int)DeviceCap.LOGPIXELSY);
32+
var screenScalingFactor = PhysicalScreenHeight / (decimal)LogicalScreenHeight;
33+
var dpiScalingFactor = logpixelsy / 96.0M;
34+
35+
return dpiScalingFactor;
36+
}
37+
finally
38+
{
39+
g?.ReleaseHdc();
40+
}
41+
}
42+
}
43+
}

CapsLockIndicatorV3/IconPackBrowser.Designer.cs

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CapsLockIndicatorV3/IconPackBrowser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ private void IconPackBrowser_DarkModeChanged(object sender, EventArgs e)
244244

245245
ControlScheduleSetDarkMode(webBrowser1, dark);
246246

247-
webBrowser1.Navigate("https://cli.jonaskohl.de/icongallery/embedded.php?dark=" + (dark ? "true" : "false"));
247+
webBrowser1.Navigate("https://cli.jonaskohl.de/icongallery/embedded.php?dark=" + (dark ? "true" : "false") + "&scale=" + ((int)(DPIHelper.GetScalingFactorPercent() * 100)).ToString());
248248
}
249249
}
250250
}

CapsLockIndicatorV3/IndicatorOverlay.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)