Apparently UserControls that are created dynamically need AutoScaleMode.Font. UserControls placed via the designer should use AutoScaleMode.Inherit. Actually it seems possible to get around the problems of dynamically created UserControls (including the need to manually scale the positions/sizes) by moving their creation into the constructor after InitializeComponent, adding SuspendLayout before InitializeComponent, and adding ResumeLayout after UserControl creation. But I don't want to risk moving the code around too much.

This commit is contained in:
jdpurcell 2014-12-31 05:34:21 +00:00
parent 008b35a93d
commit eacadc8e09
11 changed files with 35 additions and 16 deletions

View File

@ -6,8 +6,9 @@ namespace BizHawk.Client.Common
{
public static class UIHelper
{
private static SizeF _autoScaleBaseSize = new SizeF(6F, 13F);
private static SizeF _autoScaleCurrentSize = GetCurrentAutoScaleSize(AutoScaleMode.Font);
private static readonly AutoScaleMode _autoScaleMode = AutoScaleMode.Font;
private static readonly SizeF _autoScaleBaseSize = new SizeF(6F, 13F);
private static readonly SizeF _autoScaleCurrentSize = GetCurrentAutoScaleSize(_autoScaleMode);
private static SizeF GetCurrentAutoScaleSize(AutoScaleMode autoScaleMode)
{
@ -18,6 +19,16 @@ namespace BizHawk.Client.Common
}
}
public static AutoScaleMode AutoScaleMode
{
get { return _autoScaleMode; }
}
public static SizeF AutoScaleBaseSize
{
get { return _autoScaleBaseSize; }
}
public static float AutoScaleFactorX
{
get { return _autoScaleCurrentSize.Width / _autoScaleBaseSize.Width; }

View File

@ -84,7 +84,8 @@
//
// BizBoxInfoControl
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.CoreUrlLink);
this.Controls.Add(this.CorePortedLabel);
this.Controls.Add(this.CoreAuthorLabel);

View File

@ -136,7 +136,8 @@
//
// AnalogBindControl
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.buttonUnbind);
this.Controls.Add(this.buttonFlip);
this.Controls.Add(this.labelDeadzone);

View File

@ -50,7 +50,8 @@
//
// ControllerConfigPanel
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ContextMenuStrip = this.contextMenuStrip1;
this.Name = "ControllerConfigPanel";
this.Size = new System.Drawing.Size(203, 292);

View File

@ -52,7 +52,8 @@
//
// FileExtensionPreferencesPicker
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.PlatformDropdown);
this.Controls.Add(this.FileExtensionLabel);
this.Name = "FileExtensionPreferencesPicker";

View File

@ -79,7 +79,8 @@
//
// InputCompositeWidget
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.AutoScaleDimensions = new System.Drawing.SizeF(6, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.tableLayoutPanel1);
this.Name = "InputCompositeWidget";
this.Size = new System.Drawing.Size(492, 20);

View File

@ -44,7 +44,8 @@
//
// VirtualPad
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.PadBox);
this.Name = "VirtualPad";
this.Load += new System.EventHandler(this.VirtualPadControl_Load);

View File

@ -62,7 +62,6 @@ namespace BizHawk.Client.EmuHawk
PadBox.Text = _schema.DisplayName;
foreach (var button in _schema.Buttons)
{
// TODO: Size of all controls should ideally be scaled, only implemented on button for now
switch (button.Type)
{
case PadSchema.PadInputType.Boolean:
@ -86,7 +85,7 @@ namespace BizHawk.Client.EmuHawk
{
Name = button.Name,
Location = UIHelper.Scale(button.Location),
Size = new Size(button.MaxValue + 79, button.MaxValue + 9), // TODO: don't use hardcoded values here, at least make them defaults in the AnalogStick object itself
Size = UIHelper.Scale(new Size(button.MaxValue + 79, button.MaxValue + 9)), // TODO: don't use hardcoded values here, at least make them defaults in the AnalogStick object itself
RangeX = button.MaxValue,
RangeY = button.MaxValue // TODO ability to pass in a different Y max
});
@ -96,7 +95,7 @@ namespace BizHawk.Client.EmuHawk
{
Name = button.Name,
Location = UIHelper.Scale(button.Location),
Size = button.TargetSize,
Size = button.TargetSize, // TODO: Scale size without messing up X/Y range
XName = button.Name,
YName = button.SecondaryNames[0],
RangeX = button.MaxValue,
@ -109,7 +108,7 @@ namespace BizHawk.Client.EmuHawk
Name = button.Name,
DisplayName = button.DisplayName,
Location = UIHelper.Scale(button.Location),
Size = button.TargetSize,
Size = UIHelper.Scale(button.TargetSize),
MinValue = button.MinValue,
MaxValue = button.MaxValue
});
@ -120,7 +119,7 @@ namespace BizHawk.Client.EmuHawk
Name = button.Name,
//DisplayName = button.DisplayName,
Location = UIHelper.Scale(button.Location),
Size = button.TargetSize,
Size = UIHelper.Scale(button.TargetSize),
OwnerEmulator = button.OwnerEmulator
});
break;

View File

@ -65,7 +65,8 @@
//
// VirtualPadAnalogButton
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.ValueLabel);
this.Controls.Add(this.DisplayNameLabel);
this.Controls.Add(this.AnalogTrackBar);

View File

@ -175,7 +175,8 @@
//
// VirtualPadAnalogStick
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.MaxYNumeric);
this.Controls.Add(this.MaxXNumeric);
this.Controls.Add(this.MaxLabel);

View File

@ -110,7 +110,8 @@
//
// VirtualPadDiscManager
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.Controls.Add(this.btnInsert);
this.Controls.Add(this.groupBox1);