Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
dabe127
* Test
PWagner1 Sep 13, 2025
3ca5f5d
* #2480
PWagner1 Sep 13, 2025
92e903e
Merge branch 'alpha' into 648-revisited-V100
PWagner1 Sep 13, 2025
9a541d0
* Tidy up
PWagner1 Sep 13, 2025
be6803a
* Fix warnings
PWagner1 Sep 13, 2025
5f79c96
Update StartScreen.Designer.cs
PWagner1 Sep 14, 2025
2dc42ba
Merge branch 'alpha' into 648-revisited-V100
PWagner1 Sep 14, 2025
1b1f091
Merge branch 'alpha' into 648-revisited-V100
PWagner1 Sep 14, 2025
854ea55
* Fixes
PWagner1 Sep 16, 2025
ca56c9a
* Refinements
PWagner1 Sep 16, 2025
2d07546
Merge branch 'alpha' into 648-revisited-V100
PWagner1 Sep 17, 2025
7d90cc0
* Cleanup
PWagner1 Sep 17, 2025
55a7333
Update KryptonForm.cs
PWagner1 Sep 17, 2025
47a6f47
Merge branch 'alpha' of https://github.com/Krypton-Suite/Standard-Too…
PWagner1 Sep 17, 2025
56beb92
* Fix merge fallout chaos
PWagner1 Sep 17, 2025
9b194ab
* Tidy up code
PWagner1 Sep 18, 2025
37aa85d
Update KryptonForm.cs
PWagner1 Sep 18, 2025
55202cf
Update KryptonForm.cs
PWagner1 Sep 18, 2025
6b56604
Update KryptonForm.cs
PWagner1 Sep 18, 2025
35755a8
Merge branch 'alpha' into 648-revisited-V100
PWagner1 Sep 18, 2025
ee97985
* Cleaned up documentation
PWagner1 Sep 18, 2025
43b6d2d
Merge branch 'alpha' into 648-revisited-V100
PWagner1 Sep 22, 2025
cc0a80d
* Address feedback
PWagner1 Sep 22, 2025
c62e70e
* Address feedback
PWagner1 Sep 23, 2025
5f2f190
Update KryptonSystemMenu.cs
PWagner1 Sep 23, 2025
ac44733
* Cleaned up class
PWagner1 Sep 23, 2025
0c3895a
* Fixes for feedback
PWagner1 Sep 24, 2025
3db0b6e
* `ShowOnAltSpace` fixes
PWagner1 Sep 24, 2025
b3fc775
* Serialisation
PWagner1 Sep 25, 2025
baa087f
* Serialisation
PWagner1 Sep 25, 2025
f046228
Merge branch 'alpha' into 648-revisited-V100
PWagner1 Sep 26, 2025
34d4b0e
* More serialisation
PWagner1 Sep 26, 2025
8f404e8
Merge branch '648-revisited-V100' of https://github.com/Krypton-Suite…
PWagner1 Sep 26, 2025
30eb45f
Update KryptonSystemMenu.cs
PWagner1 Sep 28, 2025
b7575cc
Merge branch 'alpha' into 648-revisited-V100
PWagner1 Sep 28, 2025
15554f8
* Removed custom menu item feature
PWagner1 Sep 29, 2025
13fc6f4
* Fix `TestForm`
PWagner1 Sep 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Documents/Changelog/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
====

## 2025-11-xx - Build 2511 (V10 - alpha) - November 2025
* Resolved [#2480](https://github.com/Krypton-Suite/Standard-Toolkit/issues/2480). `KryptonForm`'s 'InternalPanel' designer issues
* Resolved [#2512](https://github.com/Krypton-Suite/Standard-Toolkit/issues/2512), Added borders with straight corners (`LinearBorder2`) and adjusted the colors in the `KryptonRibbon` in the `Microsoft365` themes. Adjusted the design of the `RibbonQATButton`
* Implemented [#2503](https://github.com/Krypton-Suite/Standard-Toolkit/issues/2503), Add the ability to create zip files for binaries
* Implemented [#952](https://github.com/Krypton-Suite/Standard-Toolkit/issues/952), Place built NuGet packages into separate directory
Expand Down
572 changes: 347 additions & 225 deletions Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonForm.cs

Large diffs are not rendered by default.

Large diffs are not rendered by default.

254 changes: 93 additions & 161 deletions Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,38 @@ protected override void OnShown(EventArgs e)
// */
// base.OnClosing(e);
//}

/// <inheritdoc />
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
// Handle basic themed system menu keyboard shortcuts if enabled
// Only handle themed system menu shortcuts if ControlBox is true (same behavior as native system menu)
if (ControlBox && SystemMenuService is { UseSystemMenu: true })
{
// Handle Alt+Space to show the themed system menu (only if enabled)
if (keyData == (Keys.Alt | Keys.Space))
{
// Check if Alt+Space is enabled through the system menu service
if (SystemMenuService.ShowSystemMenuOnAltSpace)
{
ShowSystemMenuAtFormTopLeft();
return true;
}
}

// Handle Alt+F4 for close (let derived classes handle this)
if (keyData == (Keys.Alt | Keys.F4))
{
if (HandleSystemMenuKeyboardShortcut(keyData))
{
return true;
}
}
}

return base.ProcessCmdKey(ref msg, keyData);
}

#endregion

#region Protected Virtual
Expand Down Expand Up @@ -1330,7 +1362,7 @@ protected virtual bool OnWM_NCMOUSEMOVE(ref Message m)
/// <summary>
/// Process the WM_NCLBUTTONDOWN message when overriding window chrome.
/// </summary>
/// <param name="m">A Windows-based message.</param>4
/// <param name="m">A Windows-based message.</param>
/// <returns>True if the message was processed; otherwise false.</returns>
protected virtual bool OnWM_NCLBUTTONDOWN(ref Message m)
{
Expand Down Expand Up @@ -1641,134 +1673,6 @@ protected virtual void WindowChromeMouseLeave() =>

#endregion

#region Themed System Menu
/// <summary>
/// Gets access to the themed system menu for advanced customization.
/// </summary>
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual IKryptonThemedSystemMenu? KryptonSystemMenu => null;

/// <summary>
/// Gets or sets the themed system menu service for managing themed system menu functionality.
/// </summary>
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual KryptonThemedSystemMenuService? SystemMenuService { get; set; }

/// <summary>
/// Determines if the specified screen point is within the title bar area.
/// </summary>
/// <param name="screenPoint">The screen coordinates to test.</param>
/// <returns>True if the point is in the title bar area; otherwise false.</returns>
protected virtual bool IsInTitleBarArea(Point screenPoint) => false;

/// <summary>
/// Determines if the specified screen point is over the control buttons (min/max/close).
/// </summary>
/// <param name="screenPoint">The screen coordinates to test.</param>
/// <returns>True if the point is over control buttons; otherwise false.</returns>
protected virtual bool IsOnControlButtons(Point screenPoint) => false;

/// <summary>
/// Shows the themed system menu at the specified screen location.
/// </summary>
/// <param name="screenLocation">The screen coordinates where the menu should appear.</param>
protected virtual void ShowThemedSystemMenu(Point screenLocation) { }

/// <summary>
/// Shows the themed system menu at the form's top-left position.
/// </summary>
protected virtual void ShowThemedSystemMenuAtFormTopLeft() { }

/// <summary>
/// Handles keyboard shortcuts for the themed system menu.
/// </summary>
/// <param name="keyData">The key data to process.</param>
/// <returns>True if the shortcut was handled; otherwise false.</returns>
protected virtual bool HandleThemedSystemMenuKeyboardShortcut(Keys keyData) => false;

/// <summary>
/// Ensures proper form positioning based on StartPosition after custom chrome is applied.
/// </summary>
protected virtual void EnsureProperFormPositioning()
{
// Get the current screen
var screen = Screen.FromControl(this);
var needsRepositioning = false;

// Apply custom positioning based on StartPosition
switch (StartPosition)
{
case FormStartPosition.CenterScreen:
// Check if already centered
var expectedX = (screen.WorkingArea.Width - Width) / 2;
var expectedY = (screen.WorkingArea.Height - Height) / 2;

// Only reposition if significantly off-center (more than 10 pixels)
if (Math.Abs(Location.X - expectedX) > 10 || Math.Abs(Location.Y - expectedY) > 10)
{
needsRepositioning = true;
Location = new Point(expectedX, expectedY);
}
break;

case FormStartPosition.CenterParent:
// Center relative to parent form
if (Owner != null)
{
var x = Owner.Location.X + (Owner.Width - Width) / 2;
var y = Owner.Location.Y + (Owner.Height - Height) / 2;
Location = new Point(x, y);
}
break;

case FormStartPosition.WindowsDefaultLocation:
// Let Windows handle the default positioning
break;

case FormStartPosition.WindowsDefaultBounds:
// Let Windows handle the default positioning and sizing
break;
}

// If we repositioned, ensure the form is visible on screen
if (needsRepositioning)
{
// Ensure the form is fully visible on screen
var workingArea = screen.WorkingArea;
if (Right > workingArea.Right)
{
Location = new Point(workingArea.Right - Width, Location.Y);
}
if (Bottom > workingArea.Bottom)
{
Location = new Point(Location.X, workingArea.Bottom - Height);
}
if (Left < workingArea.Left)
{
Location = new Point(workingArea.Left, Location.Y);
}
if (Top < workingArea.Top)
{
Location = new Point(Location.X, workingArea.Top);
}
}
}

/// <summary>
/// Helper method to handle themed system menu shortcuts using the service.
/// </summary>
/// <param name="keyData">The key data to process.</param>
/// <returns>True if the shortcut was handled by the service; otherwise false.</returns>
protected bool HandleThemedSystemMenuShortcut(Keys keyData)
{
return SystemMenuService?.HandleKeyboardShortcut(keyData) ?? false;
}
#endregion

#region Implementation
private void OnGlobalPaletteChanged(object? sender, EventArgs e)
{
Expand Down Expand Up @@ -1843,6 +1747,66 @@ private void OnBaseChanged(object? sender, EventArgs e) =>
#endif
#endregion

#region Themed System Menu
/// <summary>
/// Gets access to the system menu for advanced customization.
/// </summary>
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual IKryptonSystemMenu? KryptonSystemMenu => null;

/// <summary>
/// Gets or sets the system menu service for managing themed system menu functionality.
/// </summary>
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual KryptonSystemMenuService? SystemMenuService { get; set; }

/// <summary>
/// Determines if the specified screen point is within the title bar area.
/// </summary>
/// <param name="screenPoint">The screen coordinates to test.</param>
/// <returns>True if the point is in the title bar area; otherwise false.</returns>
protected virtual bool IsInTitleBarArea(Point screenPoint) => false;

/// <summary>
/// Determines if the specified screen point is over the control buttons (min/max/close).
/// </summary>
/// <param name="screenPoint">The screen coordinates to test.</param>
/// <returns>True if the point is over control buttons; otherwise false.</returns>
protected virtual bool IsOnControlButtons(Point screenPoint) => false;

/// <summary>
/// Shows the themed system menu at the specified screen location.
/// </summary>
/// <param name="screenLocation">The screen coordinates where the menu should appear.</param>
protected virtual void ShowSystemMenu(Point screenLocation) { }

/// <summary>
/// Shows the themed system menu at the form's top-left position.
/// </summary>
protected virtual void ShowSystemMenuAtFormTopLeft() { }

/// <summary>
/// Handles keyboard shortcuts for the themed system menu.
/// </summary>
/// <param name="keyData">The key data to process.</param>
/// <returns>True if the shortcut was handled; otherwise false.</returns>
protected virtual bool HandleSystemMenuKeyboardShortcut(Keys keyData) => false;

/// <summary>
/// Helper method to handle themed system menu shortcuts using the service.
/// </summary>
/// <param name="keyData">The key data to process.</param>
/// <returns>True if the shortcut was handled by the service; otherwise false.</returns>
protected bool HandleSystemMenuShortcut(Keys keyData)
{
return SystemMenuService?.HandleKeyboardShortcut(keyData) ?? false;
}
#endregion

private void UpdateDpiFactors()
{
// Do not use the control dpi, as these values are being used to target the screen
Expand Down Expand Up @@ -1874,36 +1838,4 @@ private void InitializeComponent()
Name = "VisualForm";
ResumeLayout(false);
}

/// <summary>
/// Processes a command key.
/// </summary>
/// <param name="msg">A Message, passed by reference, that represents the window message to process.</param>
/// <param name="keyData">One of the Keys values that represents the key to process.</param>
/// <returns>True if the character was processed by the control; otherwise, false.</returns>
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
// Handle basic themed system menu keyboard shortcuts if enabled
// Only handle themed system menu shortcuts if ControlBox is true (same behavior as native system menu)
if (ControlBox && SystemMenuService is { UseThemedSystemMenu: true })
{
// Handle Alt+Space to show the themed system menu
if (keyData == (Keys.Alt | Keys.Space))
{
ShowThemedSystemMenuAtFormTopLeft();
return true;
}

// Handle Alt+F4 for close (let derived classes handle this)
if (keyData == (Keys.Alt | Keys.F4))
{
if (HandleThemedSystemMenuKeyboardShortcut(keyData))
{
return true;
}
}
}

return base.ProcessCmdKey(ref msg, keyData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -767,5 +767,6 @@ private void OnCMSClosed(object? sender, ToolStripDropDownClosedEventArgs e)
_cmsFinishDelegate = null;
}
}

#endregion
}
Loading