From eacadc8e095534e3e2e67472e773c48037b285db Mon Sep 17 00:00:00 2001 From: jdpurcell Date: Wed, 31 Dec 2014 05:34:21 +0000 Subject: [PATCH] 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. --- BizHawk.Client.Common/UIHelper.cs | 15 +++++++++++++-- .../BizBoxInfoControl.Designer.cs | 3 ++- .../AnalogBindControl.Designer.cs | 3 ++- .../ControllerConfigPanel.Designer.cs | 3 ++- .../FileExtensionPreferencesPicker.Designer.cs | 3 ++- .../config/InputCompositeWidget.Designer.cs | 3 ++- .../tools/VirtualPads/VirtualPad.Designer.cs | 3 ++- .../tools/VirtualPads/VirtualPad.cs | 9 ++++----- .../controls/VirtualPadAnalogButton.Designer.cs | 3 ++- .../controls/VirtualPadAnalogStick.Designer.cs | 3 ++- .../controls/VirtualPadDiscManager.Designer.cs | 3 ++- 11 files changed, 35 insertions(+), 16 deletions(-) diff --git a/BizHawk.Client.Common/UIHelper.cs b/BizHawk.Client.Common/UIHelper.cs index b7d6d2ae0a..d8fa55b34e 100644 --- a/BizHawk.Client.Common/UIHelper.cs +++ b/BizHawk.Client.Common/UIHelper.cs @@ -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; } diff --git a/BizHawk.Client.EmuHawk/BizBoxInfoControl.Designer.cs b/BizHawk.Client.EmuHawk/BizBoxInfoControl.Designer.cs index 80a392fb24..ca31f873c6 100644 --- a/BizHawk.Client.EmuHawk/BizBoxInfoControl.Designer.cs +++ b/BizHawk.Client.EmuHawk/BizBoxInfoControl.Designer.cs @@ -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); diff --git a/BizHawk.Client.EmuHawk/config/ControllerConfig/AnalogBindControl.Designer.cs b/BizHawk.Client.EmuHawk/config/ControllerConfig/AnalogBindControl.Designer.cs index 3e85a96433..efb3f91f95 100644 --- a/BizHawk.Client.EmuHawk/config/ControllerConfig/AnalogBindControl.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/ControllerConfig/AnalogBindControl.Designer.cs @@ -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); diff --git a/BizHawk.Client.EmuHawk/config/ControllerConfig/ControllerConfigPanel.Designer.cs b/BizHawk.Client.EmuHawk/config/ControllerConfig/ControllerConfigPanel.Designer.cs index be908f1c57..1a17a0b9cf 100644 --- a/BizHawk.Client.EmuHawk/config/ControllerConfig/ControllerConfigPanel.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/ControllerConfig/ControllerConfigPanel.Designer.cs @@ -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); diff --git a/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.Designer.cs b/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.Designer.cs index 5cadd50227..f4032be5c6 100644 --- a/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/FileExtensionPreferencesPicker.Designer.cs @@ -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"; diff --git a/BizHawk.Client.EmuHawk/config/InputCompositeWidget.Designer.cs b/BizHawk.Client.EmuHawk/config/InputCompositeWidget.Designer.cs index a85afeb63f..1ae0e2729b 100644 --- a/BizHawk.Client.EmuHawk/config/InputCompositeWidget.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/InputCompositeWidget.Designer.cs @@ -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); diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.Designer.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.Designer.cs index 140a1ee2c9..69225196c5 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.Designer.cs @@ -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); diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs index 1474fcf93f..66b4638b38 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/VirtualPad.cs @@ -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; diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogButton.Designer.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogButton.Designer.cs index 2d1cb36f20..949872c5b9 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogButton.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogButton.Designer.cs @@ -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); diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.Designer.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.Designer.cs index 0d61e24cc3..12da64bb8d 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadAnalogStick.Designer.cs @@ -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); diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadDiscManager.Designer.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadDiscManager.Designer.cs index 53b4985150..1e4a0d11ef 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadDiscManager.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadDiscManager.Designer.cs @@ -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);