Skip to content

Commit

Permalink
**Breaking Change** KryptonMessageBox does not obey tab characters …
Browse files Browse the repository at this point in the history
…like `MessageBox`

  - The optional `ContentAlignment` for a `KryptonMessageBox.Show` command is no longer possible.

#1424
  • Loading branch information
Smurf-IV committed Apr 27, 2024
1 parent bd73018 commit 3d25e5a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 129 deletions.
1 change: 1 addition & 0 deletions Documents/Help/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
=======

## 2024-11-xx - Build 2411 - November 2024
* Resolved [#1424](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1424), **Breaking Change** `KryptonMessageBox` does not obey tab characters like `MessageBox`
* Resolved [#1381](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1381), **[Regression]** Docking Persistence broken since build ##.23.10.303
* Resolved [#1301](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1301), **[Regression]** When Maximised - intergrated KryptonRibbon has titlebar issues
* Resolved [#1383](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1383), Closing last Page in undocked page group prevents addition of further Pages via `KryptonDockingManager.AddToWorkspace` (fix courtesy of [stizler](https://github.com/stigzler))
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ Follow the links to see the different objects and layouts that this framework al

## V90.## (2024-11-xx - Build 2411 - November 2024)
There are list of changes that have occurred during the development of the V90.## version
- [#1424](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1424), **Breaking Change** `KryptonMessageBox` does not obey tab characters like `MessageBox`
- The optional `ContentAlignment` for a `KryptonMessageBox.Show` command is no longer possible.
- [#1356](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1356), AppButton colours don't change while switching themes
- See https://github.com/Krypton-Suite/Standard-Toolkit/issues/1356#issuecomment-2039412890
- `RibbonAppButton` has become `RibbonFileAppButton`
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
*/
#endregion

using ContentAlignment = System.Drawing.ContentAlignment;

namespace Krypton.Toolkit
{
internal partial class VisualMessageBoxRtlAwareForm : KryptonForm
{
#region Instance Fields

private readonly bool _showHelpButton;
private readonly string _text;
private readonly string _caption;
private readonly string? _text;
private readonly string? _caption;
private readonly string _applicationPath;
private readonly KryptonMessageBoxButtons _buttons;
private readonly KryptonMessageBoxIcon _kryptonMessageBoxIcon;
Expand All @@ -37,7 +35,6 @@ internal partial class VisualMessageBoxRtlAwareForm : KryptonForm
private readonly MessageBoxContentAreaType? _contentAreaType;
private readonly KryptonCommand? _linkLabelCommand;
private readonly ProcessStartInfo? _linkLaunchArgument;
private readonly ContentAlignment? _messageTextAlignment;
private readonly LinkArea _contentLinkArea;

private KryptonMessageBoxResult _messageBoxResult;
Expand All @@ -62,7 +59,7 @@ public VisualMessageBoxRtlAwareForm()
InitializeComponent();
}

public VisualMessageBoxRtlAwareForm(IWin32Window? showOwner, string text, string caption,
public VisualMessageBoxRtlAwareForm(IWin32Window? showOwner, string? text, string? caption,
KryptonMessageBoxButtons buttons,
KryptonMessageBoxIcon icon,
KryptonMessageBoxDefaultButton defaultButton,
Expand All @@ -74,7 +71,6 @@ public VisualMessageBoxRtlAwareForm(IWin32Window? showOwner, string text, string
KryptonCommand? linkLabelCommand,
ProcessStartInfo? linkLaunchArgument,
LinkArea? contentLinkArea,
ContentAlignment? messageTextAlignment,
bool? forceUseOfOperatingSystemIcons,
bool? showCloseButton)
{
Expand All @@ -95,7 +91,6 @@ public VisualMessageBoxRtlAwareForm(IWin32Window? showOwner, string text, string
? new LinkArea(0, 0)
: contentLinkArea ?? new LinkArea(0, text.Length);
_linkLaunchArgument = linkLaunchArgument ?? new ProcessStartInfo();
_messageTextAlignment = messageTextAlignment ?? ContentAlignment.MiddleLeft;
_forceUseOfOperatingSystemIcons = forceUseOfOperatingSystemIcons ?? false;
_showCloseButton = showCloseButton ?? true;

Expand All @@ -110,7 +105,6 @@ public VisualMessageBoxRtlAwareForm(IWin32Window? showOwner, string text, string
UpdateHelp();
UpdateTextExtra(showCtrlCopy);
UpdateContentAreaType(contentAreaType);
UpdateContentAreaTextAlignment(contentAreaType, messageTextAlignment);
UpdateContentLinkArea(contentLinkArea);

// Finally calculate and set form sizing
Expand All @@ -133,7 +127,6 @@ public VisualMessageBoxRtlAwareForm(KryptonMessageBoxData messageBoxData)
UpdateHelp(_messageBoxData.ShowHelpButton);
UpdateTextExtra(_messageBoxData.ShowCtrlCopy);
UpdateContentAreaType(_messageBoxData.MessageContentAreaType);
UpdateContentAreaTextAlignment(_messageBoxData.MessageContentAreaType, _messageBoxData.MessageTextAlignment);
UpdateContentLinkArea(_messageBoxData.ContentLinkArea);

ShowCloseButton(_messageBoxData.ShowCloseButton);
Expand Down Expand Up @@ -353,7 +346,7 @@ private void UpdateIcon(KryptonMessageBoxIcon icon)
break;
case KryptonMessageBoxIcon.WindowsLogo:
// Because Windows 11 displays a generic application icon,
// we need to rely on a image instead
// we need to rely on an image instead
if (OSUtilities.IsWindowsEleven)
{
_messageIcon.Image = MessageBoxImageResources.Windows11;
Expand Down Expand Up @@ -549,7 +542,7 @@ private void UpdateIcon()
break;
case KryptonMessageBoxIcon.WindowsLogo:
// Because Windows 11 displays a generic application icon,
// we need to rely on a image instead
// we need to rely on an image instead
if (OSUtilities.IsWindowsEleven)
{
_messageIcon.Image = MessageBoxImageResources.Windows11;
Expand Down Expand Up @@ -1060,7 +1053,7 @@ private Size UpdateButtonsSizing()
// Start positioning buttons 10 pixels from right edge
var right = _panelButtons.Right - GlobalStaticValues.GLOBAL_BUTTON_PADDING;

var left = _panelButtons.Left - GlobalStaticValues.GLOBAL_BUTTON_PADDING;
//var left = _panelButtons.Left - GlobalStaticValues.GLOBAL_BUTTON_PADDING;

// If Button4 is visible
if (_button4.Enabled)
Expand Down Expand Up @@ -1191,24 +1184,6 @@ private void UpdateContentAreaType(MessageBoxContentAreaType? contentAreaType)
}
}

private void UpdateContentAreaTextAlignment(MessageBoxContentAreaType? contentAreaType, ContentAlignment? messageTextAlignment)
{
switch (contentAreaType)
{
case MessageBoxContentAreaType.Normal:
kwlblMessageText.TextAlign = messageTextAlignment ?? ContentAlignment.MiddleLeft;
break;
case MessageBoxContentAreaType.LinkLabel:
klwlblMessageText.TextAlign = messageTextAlignment ?? ContentAlignment.MiddleLeft;
break;
case null:
kwlblMessageText.TextAlign = messageTextAlignment ?? ContentAlignment.MiddleLeft;
break;
default:
throw new ArgumentOutOfRangeException(nameof(contentAreaType), contentAreaType, null);
}
}

private void UpdateContentLinkArea(LinkArea? contentLinkArea)
{
if (contentLinkArea != null)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

// ReSharper disable InconsistentNaming
// ReSharper disable UnusedParameter.Local
using ContentAlignment = System.Drawing.ContentAlignment;
using Timer = System.Windows.Forms.Timer;

namespace Krypton.Toolkit
{
Expand All @@ -22,8 +20,8 @@ internal partial class VisualMessageBoxForm : KryptonForm
#region Instance Fields

private readonly bool _showHelpButton;
private readonly string _text;
private readonly string _caption;
private readonly string? _text;
private readonly string? _caption;
private readonly string _applicationPath;
private readonly KryptonMessageBoxButtons _buttons;
private readonly KryptonMessageBoxIcon _kryptonMessageBoxIcon;
Expand All @@ -42,7 +40,6 @@ internal partial class VisualMessageBoxForm : KryptonForm
private readonly MessageBoxContentAreaType? _contentAreaType;
private readonly KryptonCommand? _linkLabelCommand;
private readonly ProcessStartInfo? _linkLaunchArgument;
private readonly ContentAlignment? _messageTextAlignment;
private readonly LinkArea _contentLinkArea;

private KryptonMessageBoxResult _messageBoxResult;
Expand All @@ -68,7 +65,7 @@ public VisualMessageBoxForm()
}


internal VisualMessageBoxForm(IWin32Window? showOwner, string text, string caption,
internal VisualMessageBoxForm(IWin32Window? showOwner, string? text, string? caption,
KryptonMessageBoxButtons buttons,
KryptonMessageBoxIcon icon,
KryptonMessageBoxDefaultButton defaultButton,
Expand All @@ -80,7 +77,6 @@ internal VisualMessageBoxForm(IWin32Window? showOwner, string text, string capti
KryptonCommand? linkLabelCommand,
ProcessStartInfo? linkLaunchArgument,
LinkArea? contentLinkArea,
ContentAlignment? messageTextAlignment,
bool? forceUseOfOperatingSystemIcons,
bool? showCloseButton)
{
Expand All @@ -101,7 +97,6 @@ internal VisualMessageBoxForm(IWin32Window? showOwner, string text, string capti
? new LinkArea(0, 0)
: contentLinkArea ?? new LinkArea(0, text.Length);
_linkLaunchArgument = linkLaunchArgument ?? new ProcessStartInfo();
_messageTextAlignment = messageTextAlignment ?? ContentAlignment.MiddleLeft;
_forceUseOfOperatingSystemIcons = forceUseOfOperatingSystemIcons ?? false;
_showCloseButton = showCloseButton ?? true;

Expand All @@ -116,7 +111,6 @@ internal VisualMessageBoxForm(IWin32Window? showOwner, string text, string capti
UpdateHelp();
UpdateTextExtra(showCtrlCopy);
UpdateContentAreaType(contentAreaType);
UpdateContentAreaTextAlignment(contentAreaType, messageTextAlignment);
UpdateContentLinkArea(contentLinkArea);

// Finally calculate and set form sizing
Expand All @@ -143,7 +137,6 @@ public VisualMessageBoxForm(KryptonMessageBoxData messageBoxData)
UpdateHelp(_messageBoxData.ShowHelpButton);
UpdateTextExtra(_messageBoxData.ShowCtrlCopy);
UpdateContentAreaType(_messageBoxData.MessageContentAreaType);
UpdateContentAreaTextAlignment(_messageBoxData.MessageContentAreaType, _messageBoxData.MessageTextAlignment);
UpdateContentLinkArea(_messageBoxData.ContentLinkArea);

ShowCloseButton(_messageBoxData.ShowCloseButton);
Expand All @@ -156,7 +149,7 @@ public VisualMessageBoxForm(KryptonMessageBoxData messageBoxData)

#region Implementation

private void UpdateText(string caption, string? text, MessageBoxOptions options, MessageBoxContentAreaType? contentAreaType)
private void UpdateText(string? caption, string? text, MessageBoxOptions options, MessageBoxContentAreaType? contentAreaType)
{
// Set the text of the form
Text = string.IsNullOrEmpty(caption) ? string.Empty : caption.Split(Environment.NewLine.ToCharArray())[0];
Expand Down Expand Up @@ -376,7 +369,7 @@ private void UpdateIcon(KryptonMessageBoxIcon icon)
break;
case KryptonMessageBoxIcon.WindowsLogo:
// Because Windows 11 displays a generic application icon,
// we need to rely on a image instead
// we need to rely on an image instead
if (OSUtilities.IsWindowsEleven)
{
_messageIcon.Image = MessageBoxImageResources.Windows11;
Expand Down Expand Up @@ -572,7 +565,7 @@ private void UpdateIcon()
break;
case KryptonMessageBoxIcon.WindowsLogo:
// Because Windows 11 displays a generic application icon,
// we need to rely on a image instead
// we need to rely on an image instead
if (OSUtilities.IsWindowsEleven)
{
_messageIcon.Image = MessageBoxImageResources.Windows11;
Expand Down Expand Up @@ -610,9 +603,7 @@ private void UpdateIcon()
break;
}
}

_messageIcon.Visible = (_kryptonMessageBoxIcon != KryptonMessageBoxIcon.None);

}

private void UpdateButtons()
Expand Down Expand Up @@ -999,7 +990,6 @@ private void LaunchHelp()
{
// Do nothing if failure to send to Parent
}

}

private void UpdateSizing(IWin32Window? showOwner)
Expand All @@ -1023,7 +1013,6 @@ private Size UpdateMessageSizing(IWin32Window? showOwner)
SizeF scaledMonitorSize = screen!.Bounds.Size;
scaledMonitorSize.Width *= 2 / 3.0f;
scaledMonitorSize.Height *= 0.95f;
kwlblMessageText.UpdateFont();
SizeF messageSize = g.MeasureString(_text, kwlblMessageText.Font, scaledMonitorSize);
// SKC: Don't forget to add the TextExtra into the calculation
SizeF captionSize = g.MeasureString($@"{_caption} {TextExtra}", kwlblMessageText.Font, scaledMonitorSize);
Expand Down Expand Up @@ -1083,7 +1072,7 @@ private Size UpdateButtonsSizing()
// Start positioning buttons 10 pixels from right edge
var right = _panelButtons.Right - GlobalStaticValues.GLOBAL_BUTTON_PADDING;

var left = _panelButtons.Left - GlobalStaticValues.GLOBAL_BUTTON_PADDING;
//var left = _panelButtons.Left - GlobalStaticValues.GLOBAL_BUTTON_PADDING;

// If Button4 is visible
if (_button4.Enabled)
Expand Down Expand Up @@ -1138,7 +1127,6 @@ private void AnyKeyDown(object sender, KeyEventArgs e)

const string DIVIDER = @"---------------------------";
const string BUTTON_TEXT_SPACER = @" ";

// Pressing Ctrl+C should copy message text into the clipboard
var sb = new StringBuilder();

Expand Down Expand Up @@ -1214,24 +1202,6 @@ private void UpdateContentAreaType(MessageBoxContentAreaType? contentAreaType)
}
}

private void UpdateContentAreaTextAlignment(MessageBoxContentAreaType? contentAreaType, ContentAlignment? messageTextAlignment)
{
switch (contentAreaType)
{
case MessageBoxContentAreaType.Normal:
kwlblMessageText.TextAlign = messageTextAlignment ?? ContentAlignment.MiddleLeft;
break;
case MessageBoxContentAreaType.LinkLabel:
klwlblMessageText.TextAlign = messageTextAlignment ?? ContentAlignment.MiddleLeft;
break;
case null:
kwlblMessageText.TextAlign = messageTextAlignment ?? ContentAlignment.MiddleLeft;
break;
default:
throw new ArgumentOutOfRangeException(nameof(contentAreaType), contentAreaType, null);
}
}

private void UpdateContentLinkArea(LinkArea? contentLinkArea)
{
if (contentLinkArea != null)
Expand Down
Loading

0 comments on commit 3d25e5a

Please sign in to comment.