From 18cd6199f34ccd1cc9842cac62534ccc21440de2 Mon Sep 17 00:00:00 2001 From: Smurf-iv Date: Mon, 13 Sep 2021 18:33:43 +0100 Subject: [PATCH] - Make the MessageBoix be RTL and RightAlign aware - Fixes #313 - Demonstrates #343 --- Documents/Help/Changelog.md | 1 + .../Krypton.Navigator/Global/GlobalDeclarations.cs | 2 +- .../Krypton.Ribbon/Global/GlobalDeclarations.cs | 2 +- .../Krypton.Ribbon 2019.csproj.DotSettings | 2 -- .../KryptonMessageBoxForm.Designer.cs | 13 +++++++------ .../Controls Visuals/KryptonMessageBoxForm.cs | 9 ++++++++- .../Krypton.Toolkit/Global/GlobalDeclarations.cs | 2 +- 7 files changed, 19 insertions(+), 12 deletions(-) delete mode 100644 Source/Krypton Components/Krypton.Ribbon/Krypton.Ribbon 2019.csproj.DotSettings diff --git a/Documents/Help/Changelog.md b/Documents/Help/Changelog.md index 1d556a8af..cd3d7eb8a 100644 --- a/Documents/Help/Changelog.md +++ b/Documents/Help/Changelog.md @@ -9,6 +9,7 @@ - Sort out the Callback actions that were removed * Fixed [#316](https://github.com/Krypton-Suite/Standard-Toolkit/issues/316), Restore `KryptonKInputBox` layout to initial intent. * Fixed [#333](https://github.com/Krypton-Suite/Standard-Toolkit/issues/333), Krypton Form - ButtonSpec (And Icon), are Cut Off when maximised +* Fixed [#313](https://github.com/Krypton-Suite/Standard-Toolkit/issues/313), KryptonMessagebox is not RTL compliant ======= ## 2021-09-01 - Build 2109 - September 2021 (Canary) diff --git a/Source/Krypton Components/Krypton.Navigator/Global/GlobalDeclarations.cs b/Source/Krypton Components/Krypton.Navigator/Global/GlobalDeclarations.cs index 4bc310c89..ed395a30f 100644 --- a/Source/Krypton Components/Krypton.Navigator/Global/GlobalDeclarations.cs +++ b/Source/Krypton Components/Krypton.Navigator/Global/GlobalDeclarations.cs @@ -10,7 +10,7 @@ */ #endregion -// This file holds the global definitions > C# 10 +// This file holds the global definitions >= C# 10 global using System; global using System.Collections; diff --git a/Source/Krypton Components/Krypton.Ribbon/Global/GlobalDeclarations.cs b/Source/Krypton Components/Krypton.Ribbon/Global/GlobalDeclarations.cs index 75baee646..534323be8 100644 --- a/Source/Krypton Components/Krypton.Ribbon/Global/GlobalDeclarations.cs +++ b/Source/Krypton Components/Krypton.Ribbon/Global/GlobalDeclarations.cs @@ -10,7 +10,7 @@ */ #endregion -// This file holds the global definitions > C# 10 +// This file holds the global definitions >= C# 10 global using System; global using System.Collections; diff --git a/Source/Krypton Components/Krypton.Ribbon/Krypton.Ribbon 2019.csproj.DotSettings b/Source/Krypton Components/Krypton.Ribbon/Krypton.Ribbon 2019.csproj.DotSettings deleted file mode 100644 index 6162834d1..000000000 --- a/Source/Krypton Components/Krypton.Ribbon/Krypton.Ribbon 2019.csproj.DotSettings +++ /dev/null @@ -1,2 +0,0 @@ - - CSharp90 \ No newline at end of file diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.Designer.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.Designer.cs index b685306f9..a7744c039 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.Designer.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.Designer.cs @@ -54,7 +54,7 @@ private void InitializeComponent() this._messageText.Font = new System.Drawing.Font("Segoe UI", 9F); this._messageText.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(57)))), ((int)(((byte)(91))))); this._messageText.LabelStyle = Krypton.Toolkit.LabelStyle.NormalPanel; - this._messageText.Location = new System.Drawing.Point(64, 0); + this._messageText.Location = new System.Drawing.Point(0, 0); this._messageText.Margin = new System.Windows.Forms.Padding(5, 0, 0, 0); this._messageText.Name = "_messageText"; this._messageText.Size = new System.Drawing.Size(180, 51); @@ -65,7 +65,7 @@ private void InitializeComponent() // this._messageIcon.BackColor = System.Drawing.Color.Transparent; this._messageIcon.Dock = System.Windows.Forms.DockStyle.Fill; - this._messageIcon.Location = new System.Drawing.Point(10, 5); + this._messageIcon.Location = new System.Drawing.Point(190, 5); this._messageIcon.Margin = new System.Windows.Forms.Padding(10, 5, 5, 5); this._messageIcon.Name = "_messageIcon"; this._messageIcon.Size = new System.Drawing.Size(44, 41); @@ -108,7 +108,7 @@ private void InitializeComponent() this._button4.Margin = new System.Windows.Forms.Padding(0); this._button4.MinimumSize = new System.Drawing.Size(50, 26); this._button4.Name = "_button4"; - this._button4.Size = new System.Drawing.Size(50, 26); + this._button4.Size = new System.Drawing.Size(50, 28); this._button4.TabIndex = 2; this._button4.Values.Text = "B4"; this._button4.Visible = false; @@ -123,7 +123,7 @@ private void InitializeComponent() this._button3.Margin = new System.Windows.Forms.Padding(0); this._button3.MinimumSize = new System.Drawing.Size(50, 26); this._button3.Name = "_button3"; - this._button3.Size = new System.Drawing.Size(50, 26); + this._button3.Size = new System.Drawing.Size(50, 28); this._button3.TabIndex = 2; this._button3.Values.Text = "B3"; this._button3.Visible = false; @@ -138,7 +138,7 @@ private void InitializeComponent() this._button1.Margin = new System.Windows.Forms.Padding(0); this._button1.MinimumSize = new System.Drawing.Size(50, 26); this._button1.Name = "_button1"; - this._button1.Size = new System.Drawing.Size(50, 26); + this._button1.Size = new System.Drawing.Size(50, 28); this._button1.TabIndex = 0; this._button1.Values.Text = "B1"; this._button1.Visible = false; @@ -153,7 +153,7 @@ private void InitializeComponent() this._button2.Margin = new System.Windows.Forms.Padding(0); this._button2.MinimumSize = new System.Drawing.Size(50, 26); this._button2.Name = "_button2"; - this._button2.Size = new System.Drawing.Size(50, 26); + this._button2.Size = new System.Drawing.Size(50, 28); this._button2.TabIndex = 1; this._button2.Values.Text = "B2"; this._button2.Visible = false; @@ -195,6 +195,7 @@ private void InitializeComponent() this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "KryptonMessageBoxForm"; + this.RightToLeft = System.Windows.Forms.RightToLeft.Yes; this.ShowIcon = false; this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.cs index cdaac73ef..73f811e0a 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/KryptonMessageBoxForm.cs @@ -27,7 +27,7 @@ internal partial class KryptonMessageBoxForm : KryptonForm private readonly MessageBoxIcon _messageBoxIcon; private readonly MessageBoxDefaultButton _defaultButton; - private MessageBoxOptions _options; // TODO: What is this used for ? e.g. MessageBoxOptions.RTL + private MessageBoxOptions _options; // https://github.com/Krypton-Suite/Standard-Toolkit/issues/313 // If help information provided or we are not a service/default desktop application then grab an owner for showing the message box private readonly IWin32Window _showOwner; private readonly HelpInfo _helpInfo; @@ -88,6 +88,8 @@ internal KryptonMessageBoxForm(IWin32Window showOwner, string text, string capti _helpInfo = helpInfo; _showOwner = showOwner; + RightToLeftLayout = _options.HasFlag(MessageBoxOptions.RtlReading); + // Create the form contents InitializeComponent(); @@ -109,6 +111,11 @@ private void UpdateText() { Text = (string.IsNullOrEmpty(_caption) ? string.Empty : _caption.Split(Environment.NewLine.ToCharArray())[0]); _messageText.Text = _text; + _messageText.RightToLeft = _options.HasFlag(MessageBoxOptions.RightAlign) + ? RightToLeft.Yes + : _options.HasFlag(MessageBoxOptions.RtlReading) + ? RightToLeft.Inherit + : RightToLeft.No; } private void UpdateTextExtra(bool? showCtrlCopy) diff --git a/Source/Krypton Components/Krypton.Toolkit/Global/GlobalDeclarations.cs b/Source/Krypton Components/Krypton.Toolkit/Global/GlobalDeclarations.cs index 2e2500cbc..67c537ef5 100644 --- a/Source/Krypton Components/Krypton.Toolkit/Global/GlobalDeclarations.cs +++ b/Source/Krypton Components/Krypton.Toolkit/Global/GlobalDeclarations.cs @@ -10,7 +10,7 @@ */ #endregion -// This file holds the global definitions > C# 10 +// This file holds the global definitions >= C# 10 global using System; global using System.Collections;