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 // backgroundPanel
// //
this.backgroundPanel.BackColor = System.Drawing.Color.White; 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.closeButton);
this.backgroundPanel.Controls.Add(this.labelBody); this.backgroundPanel.Controls.Add(this.labelBody);
this.backgroundPanel.Controls.Add(this.labelHeader); this.backgroundPanel.Controls.Add(this.labelHeader);
this.backgroundPanel.Location = new System.Drawing.Point(-3, -1); this.backgroundPanel.Location = new System.Drawing.Point(-3, -1);
this.backgroundPanel.Name = "backgroundPanel"; 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; this.backgroundPanel.TabIndex = 10;
// //
// labelBody // labelBody
@ -144,6 +144,7 @@ namespace Symphony
// //
// CloseDialog // CloseDialog
// //
this.BackColor = System.Drawing.Color.White;
this.ControlBox = false; this.ControlBox = false;
this.ClientSize = new System.Drawing.Size(494, 361); this.ClientSize = new System.Drawing.Size(494, 361);
this.Controls.Add(this.backgroundPanel); this.Controls.Add(this.backgroundPanel);
@ -158,9 +159,26 @@ namespace Symphony
this.backgroundPanel.PerformLayout(); this.backgroundPanel.PerformLayout();
this.ResumeLayout(false); 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 #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.Panel bottomPanel;
private System.Windows.Forms.TableLayoutPanel tableLayoutbackgroundPanel; private System.Windows.Forms.TableLayoutPanel tableLayoutbackgroundPanel;
private System.Windows.Forms.Button next; 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) 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.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.banner.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.banner.BackColor = System.Drawing.Color.White; this.banner.BackColor = System.Drawing.Color.White;
this.banner.Location = new System.Drawing.Point(0, 0); this.banner.Location = new System.Drawing.Point(0, 0);
this.banner.Name = "banner"; this.banner.Name = "banner";
@ -239,11 +240,33 @@ namespace Symphony
this.tableLayoutPanel1.PerformLayout(); this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); 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 #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.PictureBox banner;
private System.Windows.Forms.Panel topPanel; private System.Windows.Forms.Panel topPanel;
private System.Windows.Forms.Label dialogText; private System.Windows.Forms.Label dialogText;

View File

@ -1,6 +1,7 @@
//css_dir ..\WixSharpToolset\; //css_dir ..\WixSharpToolset\;
//css_ref System.Core.dll; //css_ref System.Core.dll;
//css_ref System.Windows.Forms.dll; //css_ref System.Windows.Forms.dll;
//css_ref PresentationFramework.dll;
//css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll; //css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll;
//css_ref WixSharp.UI.dll; //css_ref WixSharp.UI.dll;
//css_imp WelcomeDialog.cs; //css_imp WelcomeDialog.cs;
@ -269,6 +270,7 @@ class Script
// Use our own Symphony branded bitmap for installation dialogs // Use our own Symphony branded bitmap for installation dialogs
project.BannerImage = "Banner.jpg"; project.BannerImage = "Banner.jpg";
project.BackgroundImage = "Tabloid.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 // Define our own installation flow, using a mix of custom dialogs (defined in their own files) and built-in dialogs
project.ManagedUI = new ManagedUI(); 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 // backgroundPanel
// //
this.backgroundPanel.BackColor = System.Drawing.Color.White; 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.panelInstallType);
this.backgroundPanel.Controls.Add(this.labelInstallType); this.backgroundPanel.Controls.Add(this.labelInstallType);
this.backgroundPanel.Controls.Add(this.labelBody); this.backgroundPanel.Controls.Add(this.labelBody);
this.backgroundPanel.Controls.Add(this.labelHeader); this.backgroundPanel.Controls.Add(this.labelHeader);
this.backgroundPanel.Location = new System.Drawing.Point(-3, -1); this.backgroundPanel.Location = new System.Drawing.Point(-3, -1);
this.backgroundPanel.Name = "backgroundPanel"; 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; this.backgroundPanel.TabIndex = 10;
// //
// panelInstallType // panelInstallType
@ -179,6 +179,7 @@ namespace Symphony
// //
// WelcomeDialog // WelcomeDialog
// //
this.BackColor = System.Drawing.Color.White;
this.ControlBox = false; this.ControlBox = false;
this.ClientSize = new System.Drawing.Size(494, 361); this.ClientSize = new System.Drawing.Size(494, 361);
this.Controls.Add(this.backgroundPanel); this.Controls.Add(this.backgroundPanel);
@ -195,9 +196,30 @@ namespace Symphony
this.panelInstallType.PerformLayout(); this.panelInstallType.PerformLayout();
this.ResumeLayout(false); 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 #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.Panel bottomPanel;
private System.Windows.Forms.TableLayoutPanel tableLayoutbackgroundPanel; private System.Windows.Forms.TableLayoutPanel tableLayoutbackgroundPanel;
private System.Windows.Forms.Button next; private System.Windows.Forms.Button next;