From 1d54f32ef3b075dda119833bd52ec1831abd0013 Mon Sep 17 00:00:00 2001 From: Mbucari Date: Tue, 1 Aug 2023 11:55:23 -0600 Subject: [PATCH] Fix DPI scaling bug (#692) --- ...DirectoryOrCustomSelectControl.Designer.cs | 19 +++++++------------ .../Dialogs/DirectoryOrCustomSelectControl.cs | 9 +++++++-- .../DirectorySelectControl.Designer.cs | 9 ++++----- .../Dialogs/LibationFilesDialog.Designer.cs | 10 +++++----- .../Dialogs/SettingsDialog.Designer.cs | 16 +++++++--------- 5 files changed, 30 insertions(+), 33 deletions(-) diff --git a/Source/LibationWinForms/Dialogs/DirectoryOrCustomSelectControl.Designer.cs b/Source/LibationWinForms/Dialogs/DirectoryOrCustomSelectControl.Designer.cs index cd2843d6..ff3e1b87 100644 --- a/Source/LibationWinForms/Dialogs/DirectoryOrCustomSelectControl.Designer.cs +++ b/Source/LibationWinForms/Dialogs/DirectoryOrCustomSelectControl.Designer.cs @@ -49,7 +49,7 @@ namespace LibationWinForms.Dialogs // customDirectoryRb // customDirectoryRb.AutoSize = true; - customDirectoryRb.Location = new System.Drawing.Point(2, 62); + customDirectoryRb.Location = new System.Drawing.Point(3, 58); customDirectoryRb.Name = "customDirectoryRb"; customDirectoryRb.Size = new System.Drawing.Size(14, 13); customDirectoryRb.TabIndex = 2; @@ -58,18 +58,16 @@ namespace LibationWinForms.Dialogs // // customTb // - customTb.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - customTb.Location = new System.Drawing.Point(22, 58); + customTb.Location = new System.Drawing.Point(23, 56); customTb.Name = "customTb"; - customTb.Size = new System.Drawing.Size(588, 23); + customTb.Size = new System.Drawing.Size(606, 23); customTb.TabIndex = 3; // // customBtn // - customBtn.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; - customBtn.Location = new System.Drawing.Point(616, 58); + customBtn.Location = new System.Drawing.Point(635, 55); customBtn.Name = "customBtn"; - customBtn.Size = new System.Drawing.Size(41, 27); + customBtn.Size = new System.Drawing.Size(26, 23); customBtn.TabIndex = 4; customBtn.Text = "..."; customBtn.UseVisualStyleBackColor = true; @@ -77,12 +75,9 @@ namespace LibationWinForms.Dialogs // // directorySelectControl // - directorySelectControl.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - directorySelectControl.AutoSize = true; directorySelectControl.Location = new System.Drawing.Point(23, 0); - directorySelectControl.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); directorySelectControl.Name = "directorySelectControl"; - directorySelectControl.Size = new System.Drawing.Size(635, 55); + directorySelectControl.Size = new System.Drawing.Size(637, 50); directorySelectControl.TabIndex = 5; // // DirectoryOrCustomSelectControl @@ -95,7 +90,7 @@ namespace LibationWinForms.Dialogs Controls.Add(customDirectoryRb); Controls.Add(knownDirectoryRb); Name = "DirectoryOrCustomSelectControl"; - Size = new System.Drawing.Size(660, 88); + Size = new System.Drawing.Size(660, 80); Load += DirectoryOrCustomSelectControl_Load; ResumeLayout(false); PerformLayout(); diff --git a/Source/LibationWinForms/Dialogs/DirectoryOrCustomSelectControl.cs b/Source/LibationWinForms/Dialogs/DirectoryOrCustomSelectControl.cs index 7ec89fc5..5edab385 100644 --- a/Source/LibationWinForms/Dialogs/DirectoryOrCustomSelectControl.cs +++ b/Source/LibationWinForms/Dialogs/DirectoryOrCustomSelectControl.cs @@ -37,11 +37,16 @@ namespace LibationWinForms.Dialogs if (directory != Configuration.KnownDirectories.None) selectDir(directory, null); } + protected override void OnResize(EventArgs e) { base.OnResize(e); - //For some reason anchors don't work when the parent form scales up, even with AutoScale - directorySelectControl.Width = customTb.Width = Width; + //Workaround for anchoring bug in user controls + //https://github.com/dotnet/winforms/issues/6381 + customBtn.Location = new System.Drawing.Point(Width - customBtn.Width, customTb.Location.Y); + customBtn.Height = customTb.Height; + directorySelectControl.Width = Width - directorySelectControl.Location.X; + customTb.Width = Width - customTb.Location.X - customBtn.Width - customTb.Margin.Left; } /// set selection diff --git a/Source/LibationWinForms/Dialogs/DirectorySelectControl.Designer.cs b/Source/LibationWinForms/Dialogs/DirectorySelectControl.Designer.cs index 36324ce5..4e56481f 100644 --- a/Source/LibationWinForms/Dialogs/DirectorySelectControl.Designer.cs +++ b/Source/LibationWinForms/Dialogs/DirectorySelectControl.Designer.cs @@ -35,7 +35,7 @@ namespace LibationWinForms.Dialogs // // directoryComboBox // - directoryComboBox.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; + directoryComboBox.Dock = System.Windows.Forms.DockStyle.Top; directoryComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; directoryComboBox.FormattingEnabled = true; directoryComboBox.Location = new System.Drawing.Point(0, 0); @@ -46,8 +46,8 @@ namespace LibationWinForms.Dialogs // // textBox1 // - textBox1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - textBox1.Location = new System.Drawing.Point(0, 29); + textBox1.Dock = System.Windows.Forms.DockStyle.Bottom; + textBox1.Location = new System.Drawing.Point(0, 26); textBox1.Name = "textBox1"; textBox1.ReadOnly = true; textBox1.Size = new System.Drawing.Size(814, 23); @@ -57,11 +57,10 @@ namespace LibationWinForms.Dialogs // AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - AutoSize = true; Controls.Add(textBox1); Controls.Add(directoryComboBox); Name = "DirectorySelectControl"; - Size = new System.Drawing.Size(814, 55); + Size = new System.Drawing.Size(814, 49); Load += DirectorySelectControl_Load; ResumeLayout(false); PerformLayout(); diff --git a/Source/LibationWinForms/Dialogs/LibationFilesDialog.Designer.cs b/Source/LibationWinForms/Dialogs/LibationFilesDialog.Designer.cs index c326e676..1deb9775 100644 --- a/Source/LibationWinForms/Dialogs/LibationFilesDialog.Designer.cs +++ b/Source/LibationWinForms/Dialogs/LibationFilesDialog.Designer.cs @@ -48,7 +48,7 @@ // cancelBtn.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; cancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; - cancelBtn.Location = new System.Drawing.Point(832, 118); + cancelBtn.Location = new System.Drawing.Point(832, 119); cancelBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); cancelBtn.Name = "cancelBtn"; cancelBtn.Size = new System.Drawing.Size(88, 27); @@ -60,7 +60,7 @@ // saveBtn // saveBtn.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; - saveBtn.Location = new System.Drawing.Point(714, 118); + saveBtn.Location = new System.Drawing.Point(736, 119); saveBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); saveBtn.Name = "saveBtn"; saveBtn.Size = new System.Drawing.Size(88, 27); @@ -73,9 +73,9 @@ // libationFilesSelectControl.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; libationFilesSelectControl.Location = new System.Drawing.Point(14, 28); - libationFilesSelectControl.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); + libationFilesSelectControl.Margin = new System.Windows.Forms.Padding(6); libationFilesSelectControl.Name = "libationFilesSelectControl"; - libationFilesSelectControl.Size = new System.Drawing.Size(906, 88); + libationFilesSelectControl.Size = new System.Drawing.Size(906, 81); libationFilesSelectControl.TabIndex = 1; // // LibationFilesDialog @@ -83,7 +83,7 @@ AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; AutoSize = true; - ClientSize = new System.Drawing.Size(933, 164); + ClientSize = new System.Drawing.Size(933, 158); Controls.Add(libationFilesSelectControl); Controls.Add(cancelBtn); Controls.Add(saveBtn); diff --git a/Source/LibationWinForms/Dialogs/SettingsDialog.Designer.cs b/Source/LibationWinForms/Dialogs/SettingsDialog.Designer.cs index 92bd78c3..bed7a552 100644 --- a/Source/LibationWinForms/Dialogs/SettingsDialog.Designer.cs +++ b/Source/LibationWinForms/Dialogs/SettingsDialog.Designer.cs @@ -339,11 +339,10 @@ // inProgressSelectControl // inProgressSelectControl.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - inProgressSelectControl.AutoSize = true; - inProgressSelectControl.Location = new System.Drawing.Point(7, 68); + inProgressSelectControl.Location = new System.Drawing.Point(6, 85); inProgressSelectControl.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); inProgressSelectControl.Name = "inProgressSelectControl"; - inProgressSelectControl.Size = new System.Drawing.Size(830, 55); + inProgressSelectControl.Size = new System.Drawing.Size(830, 49); inProgressSelectControl.TabIndex = 19; // // logsBtn @@ -359,11 +358,10 @@ // booksSelectControl // booksSelectControl.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; - booksSelectControl.AutoSize = true; - booksSelectControl.Location = new System.Drawing.Point(8, 38); + booksSelectControl.Location = new System.Drawing.Point(6, 37); booksSelectControl.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); booksSelectControl.Name = "booksSelectControl"; - booksSelectControl.Size = new System.Drawing.Size(830, 102); + booksSelectControl.Size = new System.Drawing.Size(832, 102); booksSelectControl.TabIndex = 2; // // loggingLevelLbl @@ -617,7 +615,7 @@ // saveMetadataToFileCbox // saveMetadataToFileCbox.AutoSize = true; - saveMetadataToFileCbox.Location = new System.Drawing.Point(482, 415); + saveMetadataToFileCbox.Location = new System.Drawing.Point(482, 428); saveMetadataToFileCbox.Name = "saveMetadataToFileCbox"; saveMetadataToFileCbox.Size = new System.Drawing.Size(165, 19); saveMetadataToFileCbox.TabIndex = 22; @@ -627,7 +625,7 @@ // useCoverAsFolderIconCb // useCoverAsFolderIconCb.AutoSize = true; - useCoverAsFolderIconCb.Location = new System.Drawing.Point(7, 415); + useCoverAsFolderIconCb.Location = new System.Drawing.Point(7, 428); useCoverAsFolderIconCb.Name = "useCoverAsFolderIconCb"; useCoverAsFolderIconCb.Size = new System.Drawing.Size(180, 19); useCoverAsFolderIconCb.TabIndex = 22; @@ -641,7 +639,7 @@ inProgressFilesGb.Controls.Add(inProgressSelectControl); inProgressFilesGb.Location = new System.Drawing.Point(6, 281); inProgressFilesGb.Name = "inProgressFilesGb"; - inProgressFilesGb.Size = new System.Drawing.Size(842, 128); + inProgressFilesGb.Size = new System.Drawing.Size(842, 141); inProgressFilesGb.TabIndex = 21; inProgressFilesGb.TabStop = false; inProgressFilesGb.Text = "In progress files";