Skip to content

Commit

Permalink
Version 3.13.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaskohl committed Sep 19, 2021
1 parent e38b6ce commit bdc3131
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
16 changes: 15 additions & 1 deletion CapsLockIndicatorV3/BetterCheckBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ public BetterCheckBox() : base()
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
}

protected override void OnMouseDown(MouseEventArgs mevent)
{
base.OnMouseDown(mevent);
if (_darkMode)
Invalidate();
}

protected override void OnMouseUp(MouseEventArgs mevent)
{
base.OnMouseUp(mevent);
if (_darkMode)
Invalidate();
}

protected override void OnPaint(PaintEventArgs e)
{
var bgColor = Parent?.BackColor ?? BackColor;
Expand All @@ -63,7 +77,7 @@ protected override void OnPaint(PaintEventArgs e)
}
else
{
var scaling = DPIHelper.GetScalingFactorPercent();
var scaling = DPIHelper.GetScalingFactorPercent(Handle);
var border = N_Border;
var background = N_Background;
var check = N_Check;
Expand Down
1 change: 1 addition & 0 deletions CapsLockIndicatorV3/BetterTabControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ protected override void OnCreateControl()
base.OnCreateControl();

FindUpDown();
ItemSize = new Size(ItemSize.Width, (int)(24 * DPIHelper.GetScalingFactorPercent(Handle)));
}

private void FlatTabControl_ControlAdded(object sender, ControlEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions CapsLockIndicatorV3/DPIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ private enum DeviceCap
DESKTOPVERTRES = 117
}

internal static decimal GetScalingFactorPercent()
internal static decimal GetScalingFactorPercent(IntPtr handle)
{
var g = Graphics.FromHwnd(IntPtr.Zero);
var g = Graphics.FromHwnd(handle);
try
{
var desktop = g.GetHdc();
Expand Down
2 changes: 1 addition & 1 deletion CapsLockIndicatorV3/IconPackBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private void IconPackBrowser_DarkModeChanged(object sender, EventArgs e)

ControlScheduleSetDarkMode(webBrowser1, dark);

webBrowser1.Navigate("https://cli.jonaskohl.de/icongallery/embedded.php?dark=" + (dark ? "true" : "false") + "&scale=" + ((int)(DPIHelper.GetScalingFactorPercent() * 100)).ToString());
webBrowser1.Navigate("https://cli.jonaskohl.de/icongallery/embedded.php?dark=" + (dark ? "true" : "false") + "&scale=" + ((int)(DPIHelper.GetScalingFactorPercent(Handle) * 100)).ToString());
}
}
}
12 changes: 8 additions & 4 deletions CapsLockIndicatorV3/IndicatorOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ public partial class IndicatorOverlay : Form
static extern int GetWindowLongInt(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong);
[DllImport("user32.dll")]
static extern int GetDpiForWindow(IntPtr hWnd);
//[DllImport("user32.dll")]
//static extern int GetDpiForWindow(IntPtr hWnd);

/*
static float GetDisplayScaleFactor(IntPtr windowHandle)
{
try
Expand All @@ -39,6 +40,7 @@ static float GetDisplayScaleFactor(IntPtr windowHandle)
return 1;
}
}
*/

const int GWL_EXSTYLE = -20;
const uint WS_EX_LAYERED = 0x80000;
Expand Down Expand Up @@ -111,7 +113,7 @@ void UpdatePosition()
{
Rectangle workingArea = Screen.GetWorkingArea(Cursor.Position);

var factor = GetDisplayScaleFactor(Handle);
//var factor = DPIHelper.GetScalingFactorPercent(Handle);

Size = new Size(
Width,
Expand Down Expand Up @@ -167,8 +169,10 @@ protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);

var factor = DPIHelper.GetScalingFactorPercent(Handle);

if (BorderSize > 0)
e.Graphics.DrawRectangle(new Pen(BorderColour, BorderSize), e.ClipRectangle);
e.Graphics.DrawRectangle(new Pen(BorderColour, (int)(BorderSize * factor)), e.ClipRectangle);

using (var sf = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
using (var b = new SolidBrush(contentLabel.ForeColor))
Expand Down
2 changes: 1 addition & 1 deletion CapsLockIndicatorV3/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public MainForm()
private void TabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
var sz = ClientSize;
sz.Height = (int)(int.Parse(tabControl1.SelectedTab.Tag.ToString()) * DPIHelper.GetScalingFactorPercent());
sz.Height = (int)(int.Parse(tabControl1.SelectedTab.Tag.ToString()) * DPIHelper.GetScalingFactorPercent(Handle));
ClientSize = sz;
}

Expand Down
4 changes: 2 additions & 2 deletions CapsLockIndicatorV3/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("3.13.4.0")]
[assembly: AssemblyFileVersion("3.13.4.0")]
[assembly: AssemblyVersion("3.13.5.0")]
[assembly: AssemblyFileVersion("3.13.5.0")]
[assembly: Guid ("6f54c357-0542-4d7d-9225-338bc3cd7834")]

0 comments on commit bdc3131

Please sign in to comment.