lolp1 / Overlay.NET

An easy-to-use overlay library written in C# by Jacob Kemple.
730 stars 87 forks source link

Window dpi > 96 positioning #21

Closed Rozzemak closed 5 years ago

Rozzemak commented 5 years ago

Issue is still here, and if you don´t have monitor with dpi > 96, there is no chance for you to replicate it. Changing resolution won´t do much good here. So quick fix in OverlayWindow: members

private readonly double _dpiX = (int)typeof(SystemParameters).GetProperty("DpiX", BindingFlags.NonPublic | BindingFlags.Static)?.GetValue(null, null);
private readonly double _dpiY = (int)typeof(SystemParameters).GetProperty("Dpi", BindingFlags.NonPublic | BindingFlags.Static)?.GetValue(null, null);

methods

public void Update() {
        this.Width = (double)this._targetWindow.Width * 96.0 / _dpiX;
        this.Height = (double)this._targetWindow.Height * 96.0 / _dpiY;
        this.Left = (double)this._targetWindow.X * 96.0 / _dpiX;
        this.Top = (double)this._targetWindow.Y * 96.0 / _dpiY;
}

edit: even width & height has to be corrected.

Rozzemak commented 5 years ago

So, i tested it now, and this fix indeed works. I had to clone your repo. (Resharper decompiler is must have for .NET... allowed me to see library code without having open git) PDB is nice thing :) .

lolp1 commented 5 years ago

So, i tested it now, and this fix indeed works. I had to clone your repo. (Resharper decompiler is must have for .NET... allowed me to see library code without having open git) PDB is nice thing :) .

Please make a pull request with changes if you could.

lolp1 commented 5 years ago

@Rozzemak Closing this for now as I do not intend to fix it my self, please do a pull request if you would like to contribute though.