Fix DPI scaling issue in custom message boxes (Snex9x/QuickNES accuracy warnings).
This commit is contained in:
parent
7ef07bac02
commit
0dcb0b9bb4
|
@ -47,6 +47,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.ControlBox = false; // Do not set in designer (causes problems with auto scaling)
|
||||
this.messageLbl.Text = message;
|
||||
this.Text = title;
|
||||
this.m_sysIcon = icon;
|
||||
|
@ -58,7 +59,7 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
public void SetMessageToAutoSize()
|
||||
{
|
||||
this.messageLbl.AutoSize = true;
|
||||
this.messageLbl.MaximumSize = new Size(this.MaximumSize.Width - this.m_sysIcon.Width - 25, this.MaximumSize.Height);
|
||||
this.messageLbl.MaximumSize = new Size(this.MaximumSize.Width - this.m_sysIcon.Width - UIHelper.ScaleX(25), this.MaximumSize.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -220,11 +221,11 @@ namespace BizHawk.Client.EmuHawk.CustomControls
|
|||
|
||||
}
|
||||
|
||||
const int FORM_Y_MARGIN = 10;
|
||||
const int FORM_X_MARGIN = 16;
|
||||
const int BUTTON_SPACE = 5;
|
||||
const int CHECKBOX_SPACE = 15;
|
||||
const int TEXT_Y_MARGIN = 30;
|
||||
private static readonly int FORM_Y_MARGIN = UIHelper.ScaleY(10);
|
||||
private static readonly int FORM_X_MARGIN = UIHelper.ScaleX(16);
|
||||
private static readonly int BUTTON_SPACE = UIHelper.ScaleX(5);
|
||||
private static readonly int CHECKBOX_SPACE = UIHelper.ScaleX(15);
|
||||
private static readonly int TEXT_Y_MARGIN = UIHelper.ScaleY(30);
|
||||
|
||||
/// <summary>
|
||||
/// Auto fits the dialog box to fit the text and the buttons.
|
||||
|
|
|
@ -105,7 +105,6 @@
|
|||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.btn1;
|
||||
this.ClientSize = new System.Drawing.Size(485, 149);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.btn3);
|
||||
this.Controls.Add(this.chkBx);
|
||||
this.Controls.Add(this.btn1);
|
||||
|
|
|
@ -489,7 +489,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
new[] { "Switch", "Continue" },
|
||||
new[] { DialogResult.Yes, DialogResult.Cancel });
|
||||
|
||||
box.MaximumSize = new Size(475, 350);
|
||||
box.MaximumSize = UIHelper.Scale(new Size(475, 350));
|
||||
box.SetMessageToAutoSize();
|
||||
var result = box.ShowDialog();
|
||||
|
||||
|
@ -514,7 +514,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
new[] { "Switch", "Continue" },
|
||||
new[] { DialogResult.Yes, DialogResult.Cancel });
|
||||
|
||||
box.MaximumSize = new Size(475, 350);
|
||||
box.MaximumSize = UIHelper.Scale(new Size(475, 350));
|
||||
box.SetMessageToAutoSize();
|
||||
var result = box.ShowDialog();
|
||||
|
||||
|
|
|
@ -2,42 +2,19 @@
|
|||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public static class UIHelper
|
||||
{
|
||||
private static readonly AutoScaleMode _autoScaleMode = AutoScaleMode.Font;
|
||||
private static readonly SizeF _autoScaleBaseSize = new SizeF(6F, 13F);
|
||||
private static readonly SizeF _autoScaleCurrentSize = GetCurrentAutoScaleSize(_autoScaleMode);
|
||||
public static AutoScaleMode AutoScaleMode { get; } = AutoScaleMode.Font;
|
||||
|
||||
private static SizeF GetCurrentAutoScaleSize(AutoScaleMode autoScaleMode)
|
||||
{
|
||||
using (Form form = new Form())
|
||||
{
|
||||
form.AutoScaleMode = autoScaleMode;
|
||||
return form.CurrentAutoScaleDimensions;
|
||||
}
|
||||
}
|
||||
public static SizeF AutoScaleBaseSize { get; } = new SizeF(6F, 13F);
|
||||
|
||||
public static AutoScaleMode AutoScaleMode
|
||||
{
|
||||
get { return _autoScaleMode; }
|
||||
}
|
||||
public static SizeF AutoScaleCurrentSize { get; } = GetCurrentAutoScaleSize(AutoScaleMode);
|
||||
|
||||
public static SizeF AutoScaleBaseSize
|
||||
{
|
||||
get { return _autoScaleBaseSize; }
|
||||
}
|
||||
public static float AutoScaleFactorX { get; } = AutoScaleCurrentSize.Width / AutoScaleBaseSize.Width;
|
||||
|
||||
public static float AutoScaleFactorX
|
||||
{
|
||||
get { return _autoScaleCurrentSize.Width / _autoScaleBaseSize.Width; }
|
||||
}
|
||||
|
||||
public static float AutoScaleFactorY
|
||||
{
|
||||
get { return _autoScaleCurrentSize.Height / _autoScaleBaseSize.Height; }
|
||||
}
|
||||
public static float AutoScaleFactorY { get; } = AutoScaleCurrentSize.Height / AutoScaleBaseSize.Height;
|
||||
|
||||
public static int ScaleX(int size)
|
||||
{
|
||||
|
@ -58,5 +35,13 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
return new Size(ScaleX(s.Width), ScaleY(s.Height));
|
||||
}
|
||||
|
||||
private static SizeF GetCurrentAutoScaleSize(AutoScaleMode autoScaleMode)
|
||||
{
|
||||
using (var form = new Form { AutoScaleMode = autoScaleMode })
|
||||
{
|
||||
return form.CurrentAutoScaleDimensions;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,7 +332,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
new[] { "Switch", "Continue" },
|
||||
new[] { DialogResult.Yes, DialogResult.Cancel });
|
||||
|
||||
box.MaximumSize = new Size(475, 350);
|
||||
box.MaximumSize = UIHelper.Scale(new Size(475, 350));
|
||||
box.SetMessageToAutoSize();
|
||||
var result = box.ShowDialog();
|
||||
|
||||
|
@ -357,7 +357,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
new[] { "Switch", "Continue" },
|
||||
new[] { DialogResult.Yes, DialogResult.Cancel });
|
||||
|
||||
box.MaximumSize = new Size(475, 350);
|
||||
box.MaximumSize = UIHelper.Scale(new Size(475, 350));
|
||||
box.SetMessageToAutoSize();
|
||||
var result = box.ShowDialog();
|
||||
|
||||
|
|
Loading…
Reference in New Issue