fix GB and SNES graphics viewers (and maybe others) due to incorrect (non-100%) windows DPI scaling setting

This commit is contained in:
zeromus 2020-09-27 17:26:44 -04:00
parent f078709b6b
commit cfbc148975
2 changed files with 29 additions and 1 deletions
src/BizHawk.Client.EmuHawk

View File

@ -1,4 +1,6 @@
using System;
//TODO - this is redundant with RetainedViewportPanel. Someone needs to reconcile the two.
using System;
using System.ComponentModel;
using System.Drawing.Imaging;
using System.Drawing;
@ -15,6 +17,19 @@ namespace BizHawk.Client.EmuHawk
private bool _scaled;
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
{
int x = Location.X;
int y = Location.Y;
if (specified.HasFlag(BoundsSpecified.X))
x = (int)(x * factor.Width);
if (specified.HasFlag(BoundsSpecified.Y))
y = (int)(y * factor.Height);
var pt = new Point(x, y);
if (pt != Location)
Location = pt;
}
public BmpView()
{
if (DesignMode)

View File

@ -5,6 +5,19 @@ namespace BizHawk.Client.EmuHawk
{
public class SNESGraphicsViewer : RetainedViewportPanel
{
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
{
int x = Location.X;
int y = Location.Y;
if (specified.HasFlag(BoundsSpecified.X))
x = (int)(x * factor.Width);
if (specified.HasFlag(BoundsSpecified.Y))
y = (int)(y * factor.Height);
var pt = new Point(x, y);
if (pt != Location)
Location = pt;
}
public SNESGraphicsViewer()
{
SetStyle(ControlStyles.SupportsTransparentBackColor, true);