Merge pull request #1277 from mattias-symphony/SDA-3413

Added DPI scaling for installer dialogs
This commit is contained in:
mattias-symphony 2021-10-26 11:05:11 +02:00 committed by GitHub
commit 0179c89c46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 69 additions and 4 deletions

View File

@ -101,13 +101,13 @@ namespace Symphony
// backgroundPanel
//
this.backgroundPanel.BackColor = System.Drawing.Color.White;
this.backgroundPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.backgroundPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.backgroundPanel.Controls.Add(this.closeButton);
this.backgroundPanel.Controls.Add(this.labelBody);
this.backgroundPanel.Controls.Add(this.labelHeader);
this.backgroundPanel.Location = new System.Drawing.Point(-3, -1);
this.backgroundPanel.Name = "backgroundPanel";
this.backgroundPanel.Size = new System.Drawing.Size(502, 309);
this.backgroundPanel.Size = new System.Drawing.Size(494, 270);
this.backgroundPanel.TabIndex = 10;
//
// labelBody
@ -144,6 +144,7 @@ namespace Symphony
//
// CloseDialog
//
this.BackColor = System.Drawing.Color.White;
this.ControlBox = false;
this.ClientSize = new System.Drawing.Size(494, 361);
this.Controls.Add(this.backgroundPanel);
@ -158,9 +159,26 @@ namespace Symphony
this.backgroundPanel.PerformLayout();
this.ResumeLayout(false);
ScaleForDPI(this.backgroundPanel);
foreach (System.Windows.Forms.Control control in this.backgroundPanel.Controls)
{
ScaleForDPI(control);
}
foreach (System.Windows.Forms.Control control in this.tableLayoutbackgroundPanel.Controls)
{
ScaleForDPI(control);
}
}
#endregion
void ScaleForDPI(System.Windows.Forms.Control control)
{
double factor = (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / System.Windows.SystemParameters.PrimaryScreenWidth);
control.Location = new System.Drawing.Point((int)(control.Location.X * factor), (int)(control.Location.Y * factor));
control.Size = new System.Drawing.Size((int)(control.Size.Width * factor), (int)(control.Size.Height * factor));
}
private System.Windows.Forms.Panel bottomPanel;
private System.Windows.Forms.TableLayoutPanel tableLayoutbackgroundPanel;
private System.Windows.Forms.Button next;

View File

@ -107,6 +107,7 @@ namespace Symphony
this.banner.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.banner.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.banner.BackColor = System.Drawing.Color.White;
this.banner.Location = new System.Drawing.Point(0, 0);
this.banner.Name = "banner";
@ -239,11 +240,33 @@ namespace Symphony
this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
foreach (System.Windows.Forms.Control control in this.Controls)
{
if (control != this.bottomPanel && control != this.topPanel && control != this.progress)
{
ScaleForDPI(control);
}
}
ScaleForDPIHeight(this.progress);
}
#endregion
void ScaleForDPI(System.Windows.Forms.Control control)
{
double factor = (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / System.Windows.SystemParameters.PrimaryScreenWidth);
control.Location = new System.Drawing.Point((int)(control.Location.X * factor), (int)(control.Location.Y * factor));
control.Size = new System.Drawing.Size((int)(control.Size.Width * factor), (int)(control.Size.Height * factor));
}
void ScaleForDPIHeight(System.Windows.Forms.Control control)
{
double factor = (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / System.Windows.SystemParameters.PrimaryScreenWidth);
control.Location = new System.Drawing.Point(control.Location.X, (int)(control.Location.Y * factor));
control.Size = new System.Drawing.Size(control.Size.Width, (int)(control.Size.Height * factor));
}
private System.Windows.Forms.PictureBox banner;
private System.Windows.Forms.Panel topPanel;
private System.Windows.Forms.Label dialogText;

View File

@ -1,6 +1,7 @@
//css_dir ..\WixSharpToolset\;
//css_ref System.Core.dll;
//css_ref System.Windows.Forms.dll;
//css_ref PresentationFramework.dll;
//css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll;
//css_ref WixSharp.UI.dll;
//css_imp WelcomeDialog.cs;
@ -269,6 +270,7 @@ class Script
// Use our own Symphony branded bitmap for installation dialogs
project.BannerImage = "Banner.jpg";
project.BackgroundImage = "Tabloid.jpg";
project.ValidateBackgroundImage = false;
// Define our own installation flow, using a mix of custom dialogs (defined in their own files) and built-in dialogs
project.ManagedUI = new ManagedUI();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

@ -105,14 +105,14 @@ namespace Symphony
// backgroundPanel
//
this.backgroundPanel.BackColor = System.Drawing.Color.White;
this.backgroundPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.backgroundPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.backgroundPanel.Controls.Add(this.panelInstallType);
this.backgroundPanel.Controls.Add(this.labelInstallType);
this.backgroundPanel.Controls.Add(this.labelBody);
this.backgroundPanel.Controls.Add(this.labelHeader);
this.backgroundPanel.Location = new System.Drawing.Point(-3, -1);
this.backgroundPanel.Name = "backgroundPanel";
this.backgroundPanel.Size = new System.Drawing.Size(502, 309);
this.backgroundPanel.Size = new System.Drawing.Size(494, 270);
this.backgroundPanel.TabIndex = 10;
//
// panelInstallType
@ -179,6 +179,7 @@ namespace Symphony
//
// WelcomeDialog
//
this.BackColor = System.Drawing.Color.White;
this.ControlBox = false;
this.ClientSize = new System.Drawing.Size(494, 361);
this.Controls.Add(this.backgroundPanel);
@ -195,9 +196,30 @@ namespace Symphony
this.panelInstallType.PerformLayout();
this.ResumeLayout(false);
ScaleForDPI( this.backgroundPanel );
foreach (System.Windows.Forms.Control control in this.backgroundPanel.Controls)
{
ScaleForDPI(control);
}
foreach (System.Windows.Forms.Control control in this.panelInstallType.Controls)
{
ScaleForDPI(control);
}
foreach (System.Windows.Forms.Control control in this.tableLayoutbackgroundPanel.Controls)
{
ScaleForDPI(control);
}
}
#endregion
void ScaleForDPI(System.Windows.Forms.Control control)
{
double factor = (System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / System.Windows.SystemParameters.PrimaryScreenWidth);
control.Location = new System.Drawing.Point((int)(control.Location.X * factor), (int)(control.Location.Y * factor));
control.Size = new System.Drawing.Size((int)(control.Size.Width * factor), (int)(control.Size.Height * factor));
}
private System.Windows.Forms.Panel bottomPanel;
private System.Windows.Forms.TableLayoutPanel tableLayoutbackgroundPanel;
private System.Windows.Forms.Button next;