From b2fd51d6d4695e746c8dcb9d5fe2f729c7b09339 Mon Sep 17 00:00:00 2001 From: Peter Stranak Date: Tue, 16 Feb 2021 11:54:00 +0100 Subject: [PATCH 1/7] Ignore ReSharper caches --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f377c2268..81aa46ce0 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ packages paket.dependencies paket.dependencies.locked .vs +_ReSharper.Caches UpgradeLog.htm Samples/Java/swis-client/\.settings/ From 0b99881ae6b7b8ed7176dff88cf639f3a43f01bd Mon Sep 17 00:00:00 2001 From: Peter Stranak Date: Tue, 16 Feb 2021 12:34:57 +0100 Subject: [PATCH 2/7] Implement support for HiDPI displays --- .../FindReplace/FindReplaceDialog.Designer.cs | 3 +- .../FindReplace/FindReplaceDialog.cs | 1 + Src/SwqlStudio/About.Designer.cs | 3 +- Src/SwqlStudio/About.cs | 2 ++ Src/SwqlStudio/CrudTab.cs | 2 ++ .../DocumentationContent.Designer.cs | 7 ++-- Src/SwqlStudio/DocumentationContent.cs | 2 ++ Src/SwqlStudio/EntityClassGraphForm.cs | 2 ++ Src/SwqlStudio/MainForm.cs | 1 + Src/SwqlStudio/NewConnection.cs | 2 ++ Src/SwqlStudio/QueryParameters.cs | 3 ++ Src/SwqlStudio/QueryTab.cs | 7 ++-- Src/SwqlStudio/TabTemplate.cs | 6 ++++ Src/SwqlStudio/Utils/DpiHelper.cs | 35 +++++++++++++++++++ 14 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 Src/SwqlStudio/Utils/DpiHelper.cs diff --git a/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.Designer.cs b/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.Designer.cs index cf880f8f0..67f12caed 100644 --- a/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.Designer.cs +++ b/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.Designer.cs @@ -1614,7 +1614,6 @@ private void InitializeComponent() this.ClientSize = new System.Drawing.Size(488, 292); this.Controls.Add(this.tabAll); this.Controls.Add(this.statusStrip); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; this.KeyPreview = true; this.MaximizeBox = false; @@ -1811,4 +1810,4 @@ private void InitializeComponent() private System.Windows.Forms.Button btnFindPreviousR; private System.Windows.Forms.Button btnFindNextR; } -} \ No newline at end of file +} diff --git a/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.cs b/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.cs index 965c9397f..403a2a047 100644 --- a/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.cs +++ b/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.cs @@ -30,6 +30,7 @@ public partial class FindReplaceDialog : Form public FindReplaceDialog() { + SwqlStudio.Utils.DpiHelper.FixFont(this); InitializeComponent(); _autoPosition = true; diff --git a/Src/SwqlStudio/About.Designer.cs b/Src/SwqlStudio/About.Designer.cs index b08c83785..681c83f9d 100644 --- a/Src/SwqlStudio/About.Designer.cs +++ b/Src/SwqlStudio/About.Designer.cs @@ -37,7 +37,6 @@ private void InitializeComponent() this.label1.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.label1.Font = new System.Drawing.Font("Segoe UI", 9F); this.label1.Location = new System.Drawing.Point(12, 9); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(367, 78); @@ -80,4 +79,4 @@ private void InitializeComponent() private System.Windows.Forms.Label label1; private System.Windows.Forms.Button button1; } -} \ No newline at end of file +} diff --git a/Src/SwqlStudio/About.cs b/Src/SwqlStudio/About.cs index e793e10fa..fc63b7484 100644 --- a/Src/SwqlStudio/About.cs +++ b/Src/SwqlStudio/About.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Reflection; using System.Windows.Forms; +using SwqlStudio.Utils; namespace SwqlStudio { @@ -8,6 +9,7 @@ public partial class About : Form { public About() { + DpiHelper.FixFont(this); InitializeComponent(); var assembly = Assembly.GetEntryAssembly(); diff --git a/Src/SwqlStudio/CrudTab.cs b/Src/SwqlStudio/CrudTab.cs index e968bbb91..0eb2ac52b 100644 --- a/Src/SwqlStudio/CrudTab.cs +++ b/Src/SwqlStudio/CrudTab.cs @@ -3,6 +3,7 @@ using System.Windows.Forms; using SolarWinds.InformationService.Contract2; using SwqlStudio.Metadata; +using SwqlStudio.Utils; namespace SwqlStudio { @@ -18,6 +19,7 @@ public CrudTab(CrudOperation operation) { _operation = operation; InitializeComponent(); + DpiHelper.FixRowHeight(propertiesDataGridView); } public Entity Entity diff --git a/Src/SwqlStudio/DocumentationContent.Designer.cs b/Src/SwqlStudio/DocumentationContent.Designer.cs index c5928ec26..598194140 100644 --- a/Src/SwqlStudio/DocumentationContent.Designer.cs +++ b/Src/SwqlStudio/DocumentationContent.Designer.cs @@ -37,7 +37,7 @@ private void InitializeComponent() this.itemTypeLabel.AutoSize = true; this.itemTypeLabel.Dock = System.Windows.Forms.DockStyle.Top; this.itemTypeLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.itemTypeLabel.Location = new System.Drawing.Point(5, 5); + this.itemTypeLabel.Location = new System.Drawing.Point(0, 0); this.itemTypeLabel.Name = "itemTypeLabel"; this.itemTypeLabel.Padding = new System.Windows.Forms.Padding(3); this.itemTypeLabel.Size = new System.Drawing.Size(6, 19); @@ -47,10 +47,10 @@ private void InitializeComponent() // this.docTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; this.docTextBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.docTextBox.Location = new System.Drawing.Point(5, 24); + this.docTextBox.Location = new System.Drawing.Point(0, 19); this.docTextBox.Name = "docTextBox"; this.docTextBox.ReadOnly = true; - this.docTextBox.Size = new System.Drawing.Size(274, 232); + this.docTextBox.Size = new System.Drawing.Size(284, 242); this.docTextBox.TabIndex = 3; this.docTextBox.Text = ""; // @@ -62,7 +62,6 @@ private void InitializeComponent() this.Controls.Add(this.docTextBox); this.Controls.Add(this.itemTypeLabel); this.Name = "DocumentationContent"; - this.Padding = new System.Windows.Forms.Padding(5); this.Text = "Documentation"; this.ResumeLayout(false); this.PerformLayout(); diff --git a/Src/SwqlStudio/DocumentationContent.cs b/Src/SwqlStudio/DocumentationContent.cs index b1e4285c2..ca0a8ee59 100644 --- a/Src/SwqlStudio/DocumentationContent.cs +++ b/Src/SwqlStudio/DocumentationContent.cs @@ -1,4 +1,5 @@ using System.Windows.Forms; +using SwqlStudio.Utils; using WeifenLuo.WinFormsUI.Docking; namespace SwqlStudio @@ -7,6 +8,7 @@ public partial class DocumentationContent : DockContent { public DocumentationContent() { + DpiHelper.FixFont(this); InitializeComponent(); } diff --git a/Src/SwqlStudio/EntityClassGraphForm.cs b/Src/SwqlStudio/EntityClassGraphForm.cs index 41ca6b6a0..9ef7da880 100644 --- a/Src/SwqlStudio/EntityClassGraphForm.cs +++ b/Src/SwqlStudio/EntityClassGraphForm.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Windows.Forms; using SolarWinds.InformationService.InformationServiceClient; +using SwqlStudio.Utils; namespace SwqlStudio { @@ -8,6 +9,7 @@ public partial class EntityClassGraphForm : Form { public EntityClassGraphForm(EntityClassGraph entityClassGraph) { + DpiHelper.FixFont(this); InitializeComponent(); LoadTree(entityClassGraph); diff --git a/Src/SwqlStudio/MainForm.cs b/Src/SwqlStudio/MainForm.cs index 42eb9f738..e03aabbf0 100644 --- a/Src/SwqlStudio/MainForm.cs +++ b/Src/SwqlStudio/MainForm.cs @@ -39,6 +39,7 @@ public ConnectionInfo SelectedConnection public MainForm() { + DpiHelper.FixFont(this); InitializeComponent(); InitializeDockPanel(); diff --git a/Src/SwqlStudio/NewConnection.cs b/Src/SwqlStudio/NewConnection.cs index bce73706d..f12d98321 100644 --- a/Src/SwqlStudio/NewConnection.cs +++ b/Src/SwqlStudio/NewConnection.cs @@ -1,5 +1,6 @@ using System; using System.Windows.Forms; +using SwqlStudio.Utils; namespace SwqlStudio { @@ -7,6 +8,7 @@ internal partial class NewConnection : Form { public NewConnection() { + DpiHelper.FixFont(this); InitializeComponent(); cmbServer.Items.AddRange(ConnectionHistory.PreviousServers); diff --git a/Src/SwqlStudio/QueryParameters.cs b/Src/SwqlStudio/QueryParameters.cs index df535173e..98e75d88a 100644 --- a/Src/SwqlStudio/QueryParameters.cs +++ b/Src/SwqlStudio/QueryParameters.cs @@ -3,6 +3,7 @@ using System.Drawing; using System.Linq; using SolarWinds.InformationService.Contract2; +using SwqlStudio.Utils; using WeifenLuo.WinFormsUI.Docking; namespace SwqlStudio @@ -27,7 +28,9 @@ public bool AllowSetParameters public QueryParameters() { + DpiHelper.FixFont(this); InitializeComponent(); + DpiHelper.FixRowHeight(parametersGrid); parametersGrid.DataSource = new BindingList(); AllowSetParameters = true; } diff --git a/Src/SwqlStudio/QueryTab.cs b/Src/SwqlStudio/QueryTab.cs index 31ec79995..bf8748c1f 100644 --- a/Src/SwqlStudio/QueryTab.cs +++ b/Src/SwqlStudio/QueryTab.cs @@ -15,6 +15,7 @@ using SwqlStudio.Playback; using SwqlStudio.Properties; using SwqlStudio.Subscriptions; +using SwqlStudio.Utils; namespace SwqlStudio { @@ -62,6 +63,8 @@ public QueryTab() { InitializeComponent(); nullFont = new Font(dataGridView1.DefaultCellStyle.Font, dataGridView1.DefaultCellStyle.Font.Style | FontStyle.Italic); + DpiHelper.FixRowHeight(dataGridView1); + DpiHelper.FixRowHeight(dataGridView2); ShowTabs(Tabs.Results); Disposed += QueryTabDisposed; AddRunContextMenu(); @@ -476,9 +479,9 @@ private void queryWorker_RunWorkerCompleted(object sender, System.ComponentModel } } - private static void AutoResizeColumns(DataGridView grid) + private void AutoResizeColumns(DataGridView grid) { - const int maxSize = 200; + int maxSize = base.LogicalToDeviceUnits(200); const int widthFudgeFactor = 25; int[] preferredSizes = new int[grid.ColumnCount]; diff --git a/Src/SwqlStudio/TabTemplate.cs b/Src/SwqlStudio/TabTemplate.cs index a77a95b63..840280b00 100644 --- a/Src/SwqlStudio/TabTemplate.cs +++ b/Src/SwqlStudio/TabTemplate.cs @@ -1,4 +1,5 @@ using System.Windows.Forms; +using SwqlStudio.Utils; namespace SwqlStudio { @@ -20,5 +21,10 @@ public virtual bool AllowsChangeConnection { get { return true; } } + + public TabTemplate() + { + DpiHelper.FixFont(this); + } } } diff --git a/Src/SwqlStudio/Utils/DpiHelper.cs b/Src/SwqlStudio/Utils/DpiHelper.cs new file mode 100644 index 000000000..4fa34be6f --- /dev/null +++ b/Src/SwqlStudio/Utils/DpiHelper.cs @@ -0,0 +1,35 @@ +using System.Drawing; +using System.Windows.Forms; + +namespace SwqlStudio.Utils +{ + internal static class DpiHelper + { + /// + /// Sets the currently used system UI font as the default font for the + /// + /// Usually a + /// This is needed because dimensions of the default font are used to calculate a proper DPI scaling ratio of child elements of the . + /// And the .Net Framework uses "Microsoft Sans Serif", 8.25F" from Windows 2.0, regardless of what the OS actually uses. This messes up the calculation. + /// This has been reportedly fixed in .Net Core and .Net 5. + public static void FixFont(Control control) + { + control.Font = SystemFonts.MessageBoxFont; + } + + /// + /// Adjusts the default row height in a + /// + /// The default row height is defined as the height of the default font + 9 pixels. + /// However, because the default font in .Net Framework is "Microsoft Sans Serif", 8.25F", it's too small for fonts like "Segoe UI, 9F", + /// especially when DPI scaling is involved. + /// This method, when called after , forces the recalculation of the height. + /// This has been reportedly fixed in .Net Core and .Net 5. + public static void FixRowHeight(DataGridView dataGridView) + { + // Instead of "dataGridView.DefaultCellStyle.Font.Height" we could just hardcode "SystemFonts.MessageBoxFont". That way, this method would not depend + // on a previous call to "FixFont". But this is a bit more universal solution. + dataGridView.RowTemplate.Height = dataGridView.DefaultCellStyle.Font.Height + 9; + } + } +} From 42cb6109343fe770d96b10e0fdf2817cd1320919 Mon Sep 17 00:00:00 2001 From: Peter Stranak Date: Tue, 16 Feb 2021 21:49:02 +0100 Subject: [PATCH 3/7] Improve comment in DpiHelper --- Src/SwqlStudio/Utils/DpiHelper.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Src/SwqlStudio/Utils/DpiHelper.cs b/Src/SwqlStudio/Utils/DpiHelper.cs index 4fa34be6f..851b1172e 100644 --- a/Src/SwqlStudio/Utils/DpiHelper.cs +++ b/Src/SwqlStudio/Utils/DpiHelper.cs @@ -9,8 +9,10 @@ internal static class DpiHelper /// Sets the currently used system UI font as the default font for the /// /// Usually a - /// This is needed because dimensions of the default font are used to calculate a proper DPI scaling ratio of child elements of the . - /// And the .Net Framework uses "Microsoft Sans Serif", 8.25F" from Windows 2.0, regardless of what the OS actually uses. This messes up the calculation. + /// This is needed because dimensions of the default font are used to calculate a proper DPI scaling ratio of the 's child elements. + /// .Net Framework tries to use "MS Sans Serif" from Windows 3.1, which isn't available anymore. So the system automatically replaces it with "Microsoft Sans Serif", + /// or sometimes with "Tahoma". But those are also too old. And if there are elements using also other fonts, like "Segoe UI", it messes up the calculation. + /// So, instead of hard-coding a specific font, let's use whatever the OS prefers to use for its own dialogs. /// This has been reportedly fixed in .Net Core and .Net 5. public static void FixFont(Control control) { @@ -21,13 +23,13 @@ public static void FixFont(Control control) /// Adjusts the default row height in a /// /// The default row height is defined as the height of the default font + 9 pixels. - /// However, because the default font in .Net Framework is "Microsoft Sans Serif", 8.25F", it's too small for fonts like "Segoe UI, 9F", + /// However, because the default font in .Net Framework is "MS Sans Serif 8.25F", it's too small for fonts like "Segoe UI, 9F", /// especially when DPI scaling is involved. /// This method, when called after , forces the recalculation of the height. /// This has been reportedly fixed in .Net Core and .Net 5. public static void FixRowHeight(DataGridView dataGridView) { - // Instead of "dataGridView.DefaultCellStyle.Font.Height" we could just hardcode "SystemFonts.MessageBoxFont". That way, this method would not depend + // Instead of "dataGridView.DefaultCellStyle.Font.Height" we could just hard-code "SystemFonts.MessageBoxFont". That way, this method would not depend // on a previous call to "FixFont". But this is a bit more universal solution. dataGridView.RowTemplate.Height = dataGridView.DefaultCellStyle.Font.Height + 9; } From 20593a463b046d4bfcf07326387d30294e4fb2f3 Mon Sep 17 00:00:00 2001 From: Peter Stranak Date: Sat, 20 Feb 2021 23:13:35 +0100 Subject: [PATCH 4/7] Fix DPI scaling for obsolete entities in ObjectTree --- .../ObjectExplorer/ObjectExplorer.cs | 2 +- Src/SwqlStudio/Utils/DpiHelper.cs | 36 ++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Src/SwqlStudio/ObjectExplorer/ObjectExplorer.cs b/Src/SwqlStudio/ObjectExplorer/ObjectExplorer.cs index d77e4c059..7144ca82f 100644 --- a/Src/SwqlStudio/ObjectExplorer/ObjectExplorer.cs +++ b/Src/SwqlStudio/ObjectExplorer/ObjectExplorer.cs @@ -38,7 +38,7 @@ internal class ObjectExplorer : Control private ImageList objectExplorerImageList; private System.ComponentModel.IContainer components; private TreeNode _dragNode; - private readonly TreeNodesBuilder treeNodesBuilder = new TreeNodesBuilder(DefaultFont); + private readonly TreeNodesBuilder treeNodesBuilder = new TreeNodesBuilder(DpiHelper.DefaultFont); public event TreeViewEventHandler SelectionChanged; public ITabsFactory TabsFactory { get; set; } diff --git a/Src/SwqlStudio/Utils/DpiHelper.cs b/Src/SwqlStudio/Utils/DpiHelper.cs index 851b1172e..ba17c55e2 100644 --- a/Src/SwqlStudio/Utils/DpiHelper.cs +++ b/Src/SwqlStudio/Utils/DpiHelper.cs @@ -3,33 +3,45 @@ namespace SwqlStudio.Utils { + /// + /// A helper class for supporting font and DPI scaling + /// + /// + /// This dimensions of the default font are used to calculate a proper DPI scaling ratio of elements. .Net Framework tries to use "MS Sans Serif" + /// from Windows 3.1, which isn't available anymore. So the system automatically replaces it with "Microsoft Sans Serif", or sometimes with "Tahoma". + /// But those are too old and don't match with Windows UI fonts. And if there are elements using also other fonts, like "Segoe UI", it messes up the calculation. + /// That can happen especially when a different font is used for rendering than for the DPI scaling calculation. + /// This should not be needed anymore in .Net Core 3.1 and .Net 5: https://github.com/dotnet/winforms/pull/656 + /// internal static class DpiHelper { /// - /// Sets the currently used system UI font as the default font for the + /// The default font used in SWQL Studio dialogs + /// + /// Returns the default font used by the OS. + /// + public static readonly Font DefaultFont = SystemFonts.MessageBoxFont; + + /// + /// Sets the as the default font for the /// /// Usually a - /// This is needed because dimensions of the default font are used to calculate a proper DPI scaling ratio of the 's child elements. - /// .Net Framework tries to use "MS Sans Serif" from Windows 3.1, which isn't available anymore. So the system automatically replaces it with "Microsoft Sans Serif", - /// or sometimes with "Tahoma". But those are also too old. And if there are elements using also other fonts, like "Segoe UI", it messes up the calculation. - /// So, instead of hard-coding a specific font, let's use whatever the OS prefers to use for its own dialogs. - /// This has been reportedly fixed in .Net Core and .Net 5. + /// This is needed to correctly calculate a proper DPI scaling ratio of the and its child elements. + /// It forces the to sync the fonts used for its rendering and DPI scaling calculation. + /// This should be called in the 's constructor. public static void FixFont(Control control) { - control.Font = SystemFonts.MessageBoxFont; + control.Font = DefaultFont; } /// /// Adjusts the default row height in a /// /// The default row height is defined as the height of the default font + 9 pixels. - /// However, because the default font in .Net Framework is "MS Sans Serif 8.25F", it's too small for fonts like "Segoe UI, 9F", - /// especially when DPI scaling is involved. - /// This method, when called after , forces the recalculation of the height. - /// This has been reportedly fixed in .Net Core and .Net 5. + /// This method, when called after , forces the recalculation of the height. public static void FixRowHeight(DataGridView dataGridView) { - // Instead of "dataGridView.DefaultCellStyle.Font.Height" we could just hard-code "SystemFonts.MessageBoxFont". That way, this method would not depend + // Instead of "dataGridView.DefaultCellStyle.Font.Height" we could just hard-code "DefaultFont". That way, this method would not depend // on a previous call to "FixFont". But this is a bit more universal solution. dataGridView.RowTemplate.Height = dataGridView.DefaultCellStyle.Font.Height + 9; } From 391a48474b510575b6a6873b720cf850209b95ab Mon Sep 17 00:00:00 2001 From: Peter Stranak Date: Sat, 20 Feb 2021 23:14:18 +0100 Subject: [PATCH 5/7] Fix DPI scaling for search status bar --- .../FindReplace/FindReplaceDialog.Designer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.Designer.cs b/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.Designer.cs index 67f12caed..b5bb6cdb3 100644 --- a/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.Designer.cs +++ b/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.Designer.cs @@ -962,6 +962,7 @@ private void InitializeComponent() // // statusStrip // + this.statusStrip.AutoSize = false; this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.lblStatus}); this.statusStrip.Location = new System.Drawing.Point(0, 270); From f326259ccaeb44cea10a888194da6fa72fd0c32f Mon Sep 17 00:00:00 2001 From: Peter Stranak Date: Sat, 20 Feb 2021 23:15:03 +0100 Subject: [PATCH 6/7] Fix font in entity documentation --- Src/SwqlStudio/DocumentationContent.Designer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Src/SwqlStudio/DocumentationContent.Designer.cs b/Src/SwqlStudio/DocumentationContent.Designer.cs index 598194140..3cff4a015 100644 --- a/Src/SwqlStudio/DocumentationContent.Designer.cs +++ b/Src/SwqlStudio/DocumentationContent.Designer.cs @@ -1,4 +1,6 @@ -namespace SwqlStudio +using SwqlStudio.Utils; + +namespace SwqlStudio { partial class DocumentationContent { @@ -36,7 +38,7 @@ private void InitializeComponent() // this.itemTypeLabel.AutoSize = true; this.itemTypeLabel.Dock = System.Windows.Forms.DockStyle.Top; - this.itemTypeLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.itemTypeLabel.Font = new System.Drawing.Font(DpiHelper.DefaultFont, System.Drawing.FontStyle.Bold); this.itemTypeLabel.Location = new System.Drawing.Point(0, 0); this.itemTypeLabel.Name = "itemTypeLabel"; this.itemTypeLabel.Padding = new System.Windows.Forms.Padding(3); From d5d5f6f37ef7d3b4e33add27d3fb0a5b3d3b3452 Mon Sep 17 00:00:00 2001 From: Peter Stranak Date: Sun, 21 Feb 2021 12:24:39 +0100 Subject: [PATCH 7/7] Revert to using the original fonts Instead of using the OS font (e.g. Segoe UI) everywhere, use the original mixture of different fonts in different dialogs. It improves the rendering of spacing between elements without having to recalculate the whole layout manually to fit the OS font. --- .../FindReplace/FindReplaceDialog.Designer.cs | 1 + .../FindReplace/FindReplaceDialog.cs | 2 +- Src/SwqlStudio/About.Designer.cs | 13 +++++++------ Src/SwqlStudio/About.cs | 6 +++--- Src/SwqlStudio/Utils/DpiHelper.cs | 6 +++--- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.Designer.cs b/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.Designer.cs index b5bb6cdb3..0c11b5eab 100644 --- a/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.Designer.cs +++ b/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.Designer.cs @@ -1615,6 +1615,7 @@ private void InitializeComponent() this.ClientSize = new System.Drawing.Size(488, 292); this.Controls.Add(this.tabAll); this.Controls.Add(this.statusStrip); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; this.KeyPreview = true; this.MaximizeBox = false; diff --git a/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.cs b/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.cs index 403a2a047..d0181c46e 100644 --- a/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.cs +++ b/Src/SwqlStudio/3rdParty/ScintillaNET-FindReplaceDialog/FindReplace/FindReplaceDialog.cs @@ -30,7 +30,7 @@ public partial class FindReplaceDialog : Form public FindReplaceDialog() { - SwqlStudio.Utils.DpiHelper.FixFont(this); + this.Font = new Font("Tahoma", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); InitializeComponent(); _autoPosition = true; diff --git a/Src/SwqlStudio/About.Designer.cs b/Src/SwqlStudio/About.Designer.cs index 681c83f9d..9d7d542c6 100644 --- a/Src/SwqlStudio/About.Designer.cs +++ b/Src/SwqlStudio/About.Designer.cs @@ -37,9 +37,9 @@ private void InitializeComponent() this.label1.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.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Location = new System.Drawing.Point(14, 10); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(367, 78); + this.label1.Size = new System.Drawing.Size(428, 90); this.label1.TabIndex = 0; this.label1.Text = "SWQL Studio\r\nversion {0}\r\n\r\n{1}\r\n"; // @@ -47,9 +47,9 @@ private void InitializeComponent() // this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.button1.DialogResult = System.Windows.Forms.DialogResult.OK; - this.button1.Location = new System.Drawing.Point(304, 90); + this.button1.Location = new System.Drawing.Point(355, 104); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.Size = new System.Drawing.Size(87, 27); this.button1.TabIndex = 1; this.button1.Text = "OK"; this.button1.UseVisualStyleBackColor = true; @@ -57,11 +57,12 @@ private void InitializeComponent() // About // this.AcceptButton = this.button1; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(391, 125); + this.ClientSize = new System.Drawing.Size(456, 144); this.Controls.Add(this.button1); this.Controls.Add(this.label1); + this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; diff --git a/Src/SwqlStudio/About.cs b/Src/SwqlStudio/About.cs index fc63b7484..ff04d14f2 100644 --- a/Src/SwqlStudio/About.cs +++ b/Src/SwqlStudio/About.cs @@ -1,7 +1,7 @@ -using System.Linq; +using System.Drawing; +using System.Linq; using System.Reflection; using System.Windows.Forms; -using SwqlStudio.Utils; namespace SwqlStudio { @@ -9,7 +9,7 @@ public partial class About : Form { public About() { - DpiHelper.FixFont(this); + this.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); InitializeComponent(); var assembly = Assembly.GetEntryAssembly(); diff --git a/Src/SwqlStudio/Utils/DpiHelper.cs b/Src/SwqlStudio/Utils/DpiHelper.cs index ba17c55e2..aea05ba63 100644 --- a/Src/SwqlStudio/Utils/DpiHelper.cs +++ b/Src/SwqlStudio/Utils/DpiHelper.cs @@ -18,9 +18,9 @@ internal static class DpiHelper /// /// The default font used in SWQL Studio dialogs /// - /// Returns the default font used by the OS. - /// - public static readonly Font DefaultFont = SystemFonts.MessageBoxFont; + /// Returns the default .Net font. + /// Microsoft Sans Serif, 8.25F + public static readonly Font DefaultFont = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); /// /// Sets the as the default font for the