Skip to content

Commit

Permalink
* Some more on #927
Browse files Browse the repository at this point in the history
  • Loading branch information
PWagner1 committed Feb 12, 2023
1 parent 7ebfc44 commit 219da67
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public ButtonSpecNavFormClose(KryptonNavigator navigator) : base(navigator, Pale

#region Implementation

/*
/// <summary>
/// Form Close Button Enabled: This will also Disable the System Menu `Close` BUT NOT the `Alt+F4` key action
/// </summary>
Expand All @@ -44,33 +43,35 @@ public bool Enabled
if (_enabled != value)
{
_enabled = value;
IntPtr hSystemMenu = PI.GetSystemMenu(KryptonForm.Handle, false);
IntPtr hSystemMenu = PI.GetSystemMenu(Navigator.Owner!.Handle, false);
if (hSystemMenu != IntPtr.Zero)
{
PI.EnableMenuItem(hSystemMenu, PI.SC_.CLOSE, _enabled ? PI.MF_.ENABLED : PI.MF_.DISABLED);
}
}
}
}
*/

#endregion

#region ButtonSpecNavFixed Implementation

public override bool GetVisible(PaletteBase palette)
{
throw new NotImplementedException();
}
// We do not show if the custom chrome is combined with composition,
// in which case the form buttons are handled by the composition
if (Navigator.Owner!.ApplyComposition && Navigator.Owner.ApplyCustomChrome)
{
return false;
}

public override ButtonCheckState GetChecked(PaletteBase palette)
{
throw new NotImplementedException();
// Have all buttons been turned off?
return Navigator.Owner.ControlBox && Navigator.Owner.CloseBox;
}

public override ButtonEnabled GetEnabled(PaletteBase palette)
{
throw new NotImplementedException();
}
public override ButtonCheckState GetChecked(PaletteBase palette) => ButtonCheckState.NotCheckButton;

public override ButtonEnabled GetEnabled(PaletteBase palette) => Navigator.Owner!.CloseBox && Enabled ? ButtonEnabled.True : ButtonEnabled.False;

#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ public class KryptonNavigator : VisualSimple,
private VisualPopupPage? _visualPopupPage;
private VisualPopupToolTip? _visualPopupToolTip;
private KryptonPage[]? _dragPages;
private KryptonForm? _owner;
private bool _forcedLayout;
private bool _layingOut;
private bool _pageDragging;
private bool _ignorePageVisibleChange;
private bool _allowTabFocus;
private bool _allowTabSelect;
private bool _tabHoverStarted;
private bool _controlKryptonFormFeatures;
private int _cachePageCount;
private int _cachePageVisibleCount;

Expand Down Expand Up @@ -507,6 +509,10 @@ public KryptonPage? SelectedPage
}
}

public KryptonForm? Owner { get => _owner; set => _owner = value ?? null; }

public bool ControlKryptonFormFeatures { get => _controlKryptonFormFeatures; set => _controlKryptonFormFeatures = value; }

/// <summary>
/// Gets access to the bar specific settings.
/// </summary>
Expand Down Expand Up @@ -1204,8 +1210,8 @@ protected override void OnMouseDown(MouseEventArgs e)
ViewBase? element = ViewManager?.Root?.ViewFromPoint(new Point(e.X, e.Y));

// Ask the view builder if pressing the element needs to give us focus
if (ViewBuilder != null
&& element != null
if (ViewBuilder != null
&& element != null
&& ViewBuilder.GiveNavigatorFocus(element)
)
{
Expand Down Expand Up @@ -1237,7 +1243,7 @@ protected override bool ProcessKeyPreview(ref Message m)
if (CommonHelper.IsShiftKeyPressed)
{
// If the focus has been moved to a page that does not have the focus
if (SelectedPage is { ContainsFocus: false } )
if (SelectedPage is { ContainsFocus: false })
{
// We need to force another TAB+SHIFT to move the focus backwards
foreach (KryptonPage page in Pages)
Expand Down Expand Up @@ -1292,7 +1298,7 @@ protected override bool ProcessDialogKey(Keys keyData)
{
// CONTROL tabbing around the pages in the navigator
// is handled in a view specific way
if (ViewBuilder != null)
if (ViewBuilder != null)
handled = ViewBuilder.ProcessDialogKey(keyData);
}
}
Expand Down Expand Up @@ -2190,6 +2196,8 @@ private void AssignDefaultFields()
_allowTabFocus = true;
_allowTabSelect = true;
UseMnemonic = true;
_owner = null;
_controlKryptonFormFeatures = false;
}

private void CreatePageCollection()
Expand Down Expand Up @@ -2896,7 +2904,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e)
{
// Do not show tooltips when the form we are in does not have focus
Form? topForm = FindForm();
if (topForm is { ContainsFocus: false } )
if (topForm is { ContainsFocus: false })
{
return;
}
Expand Down Expand Up @@ -2995,7 +3003,7 @@ private void OnStartHover(object sender, ToolTipEventArgs e)
{
// We do not provide hover support when the form does not have the focus
Form? topForm = FindForm();
if (topForm is { ContainsFocus: false } )
if (topForm is { ContainsFocus: false })
{
return;
}
Expand Down Expand Up @@ -3133,9 +3141,9 @@ internal bool SelectNextPageControl(bool forward, bool onlyCurrentPage)
else
{
// We can only be the next control if we accept the focus
if (ViewBuilder != null
&& ((next != this)
|| ((next == this)
if (ViewBuilder != null
&& ((next != this)
|| ((next == this)
&& ViewBuilder.CanFocus)
)
)
Expand Down Expand Up @@ -3221,7 +3229,7 @@ private bool NextOnUnselectedKryptonPage(Control? next)
next = next.Parent;

// Keep going until we reach the top of the parent chain
}
}

// Did not find the control is on a KryptonPage, so definitely not on an unselected KryptonPage
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
[assembly: Dependency(nameof(System), LoadHint.Always)]
[assembly: Dependency("System.Drawing", LoadHint.Always)]
[assembly: Dependency("System.Windows.Forms", LoadHint.Always)]
[assembly: Dependency("Krypton.Toolkit", LoadHint.Always)]
[assembly: Dependency("Krypton.Toolkit", LoadHint.Always)]
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@
[assembly: Dependency(@"System.Drawing", LoadHint.Always)]
[assembly: Dependency(@"System.Windows.Forms", LoadHint.Always)]
[assembly: Dependency(@"Krypton.Toolkit", LoadHint.Always)]
[assembly: InternalsVisibleTo(@"Krypton.Toolkit, PublicKey=a87e673e9ecb6e8e", AllInternalsVisible = true)]
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@
[assembly: Dependency(nameof(System), LoadHint.Always)]
[assembly: Dependency(@"System.Drawing", LoadHint.Always)]
[assembly: Dependency(@"System.Windows.Forms", LoadHint.Always)]

[assembly: InternalsVisibleTo(@"Krypton.Navigator, PublicKey=a87e673e9ecb6e8e", AllInternalsVisible = true)]
[assembly: InternalsVisibleTo(@"Krypton.Ribbon, PublicKey=a87e673e9ecb6e8e", AllInternalsVisible = true)]
29 changes: 10 additions & 19 deletions Source/Krypton Components/Krypton.Toolkit/Rendering/ThemeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,14 @@ private static PaletteMode ReturnPaletteMode(string themeName)
/// <summary>Returns the palette mode.</summary>
/// <param name="paletteMode">The palette mode manager.</param>
/// <returns>The selected <see cref="PaletteMode"/>.</returns>
private static PaletteMode ReturnPaletteMode(PaletteMode paletteMode)
{
return paletteMode;
}
private static PaletteMode ReturnPaletteMode(PaletteMode paletteMode) => paletteMode;

/// <summary>
/// Applies the theme.
/// </summary>
/// <param name="themeName">Name of the theme.</param>
/// <param name="manager">The manager.</param>
public static void ApplyTheme(string themeName, KryptonManager manager)
{
ApplyTheme(_supportedThemes.GetByFirst(themeName), manager);
}
public static void ApplyTheme(string themeName, KryptonManager manager) => ApplyTheme(_supportedThemes.GetByFirst(themeName), manager);

/// <summary>
/// Sets the theme.
Expand All @@ -143,14 +137,14 @@ public static void SetTheme(string themeName, KryptonManager manager)
/// <summary>
/// Returns the palette mode manager as string.
/// </summary>
/// <param name="PaletteMode">The palette mode manager.</param>
/// <param name="paletteMode">The palette mode manager.</param>
/// <param name="manager">The manager.</param>
/// <returns>The chosen theme as a string.</returns>
public static string ReturnPaletteModeAsString(PaletteMode PaletteMode, KryptonManager manager = null)
public static string ReturnPaletteModeAsString(PaletteMode paletteMode, KryptonManager? manager)
{
var paletteMode = manager?.GlobalPaletteMode ?? PaletteMode;
var mode = manager?.GlobalPaletteMode ?? paletteMode;

return _supportedThemes.GetBySecond(paletteMode);
return _supportedThemes.GetBySecond(mode);
}

/// <summary>
Expand Down Expand Up @@ -213,12 +207,12 @@ public static string ReturnPaletteModeAsString(PaletteMode paletteMode)
/// Applies the global theme.
/// </summary>
/// <param name="manager">The manager.</param>
/// <param name="PaletteMode">The palette mode manager.</param>
public static void ApplyGlobalTheme(KryptonManager manager, PaletteMode PaletteMode)
/// <param name="paletteMode">The palette mode manager.</param>
public static void ApplyGlobalTheme(KryptonManager manager, PaletteMode paletteMode)
{
try
{
manager.GlobalPaletteMode = PaletteMode;
manager.GlobalPaletteMode = paletteMode;
}
catch (Exception exc)
{
Expand All @@ -231,10 +225,7 @@ public static void ApplyGlobalTheme(KryptonManager manager, PaletteMode PaletteM
/// </summary>
/// <param name="target">The target.</param>
/// <param name="excludePartials">do not include any string containing</param>
public static void PropagateThemeSelector(KryptonComboBox target, params string[] excludePartials)
{
AddToCollection(target.Items, excludePartials);
}
public static void PropagateThemeSelector(KryptonComboBox target, params string[] excludePartials) => AddToCollection(target.Items, excludePartials);

private static void AddToCollection(IList target, string[] excludes)
{
Expand Down

0 comments on commit 219da67

Please sign in to comment.