Skip to content

Commit

Permalink
- Make sure ClientSize is not forced to the calculated min
Browse files Browse the repository at this point in the history
- Some tinkering with nullables
- Start investigation into 1153

#1152
  • Loading branch information
Smurf-IV committed Oct 22, 2023
1 parent 491ce3a commit 6bc917e
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 47 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 @@
=======

## 2023-11-14 - Build 2311 - November 2023
* Resolved [#1152](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1152), Unable to resize control dragged from Navigator via KryptonDockingManager.FloatingWindowAdding event.
* Resolved [#1146](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1146), Krypton.Navigator throws exception in Initialise when attempting to EndInit().
* Implemented [#1009](https://github.com/Krypton-Suite/Standard-Toolkit/issues/1009), Powered by Krypton Toolkit button
* Implemented [#508](https://github.com/Krypton-Suite/Standard-Toolkit/issues/508), Application Menus should fit well when using dark/light modes
Expand Down
12 changes: 12 additions & 0 deletions Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.sln
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Issue Templates", "Issue Te
..\..\.github\ISSUE_TEMPLATE\post-a-question.md = ..\..\.github\ISSUE_TEMPLATE\post-a-question.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bug1091", "..\..\..\Bug1091\Bug1091\Bug1091.csproj", "{7419FDE6-988C-402C-AC53-2035A9D7B7B9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Canary|Any CPU = Canary|Any CPU
Expand Down Expand Up @@ -180,6 +182,16 @@ Global
{6CFB046A-0239-4395-BA64-C4DBDD19AFE4}.Nightly|Any CPU.Build.0 = Debug|Any CPU
{6CFB046A-0239-4395-BA64-C4DBDD19AFE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CFB046A-0239-4395-BA64-C4DBDD19AFE4}.Release|Any CPU.Build.0 = Release|Any CPU
{7419FDE6-988C-402C-AC53-2035A9D7B7B9}.Canary|Any CPU.ActiveCfg = Debug|Any CPU
{7419FDE6-988C-402C-AC53-2035A9D7B7B9}.Canary|Any CPU.Build.0 = Debug|Any CPU
{7419FDE6-988C-402C-AC53-2035A9D7B7B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7419FDE6-988C-402C-AC53-2035A9D7B7B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7419FDE6-988C-402C-AC53-2035A9D7B7B9}.Installer|Any CPU.ActiveCfg = Debug|Any CPU
{7419FDE6-988C-402C-AC53-2035A9D7B7B9}.Installer|Any CPU.Build.0 = Debug|Any CPU
{7419FDE6-988C-402C-AC53-2035A9D7B7B9}.Nightly|Any CPU.ActiveCfg = Debug|Any CPU
{7419FDE6-988C-402C-AC53-2035A9D7B7B9}.Nightly|Any CPU.Build.0 = Debug|Any CPU
{7419FDE6-988C-402C-AC53-2035A9D7B7B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7419FDE6-988C-402C-AC53-2035A9D7B7B9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ private void OnFloatspaceCellAdding(object sender, WorkspaceCellEventArgs e)
var childMinSize = e.Cell.GetMinSize();
MinimumSize = new Size(Math.Max(MinimumSize.Width, childMinSize.Width) + 20,
Math.Max(MinimumSize.Height, childMinSize.Height) + 20);
ClientSize = MinimumSize;
}

private void OnFloatspaceCellRemoved(object sender, WorkspaceCellEventArgs e) => e.Cell.TabVisibleCountChanged -= OnTabVisibleCountChanged;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2067,7 +2067,7 @@ public virtual bool ShowPageContextMenuRequest([DisallowNull] KryptonPage? page,
// Use events to determine which pages should be switched
var switchUniqueNames = new List<string>();
var switchPages = new List<KryptonPage>();
string selectedPage = null;
string? selectedPage = null;
foreach (var uniqueName in uniqueNames)
{
// Does the provided unique name exist and is in the required 'docked' state
Expand Down Expand Up @@ -2104,7 +2104,7 @@ public virtual bool ShowPageContextMenuRequest([DisallowNull] KryptonPage? page,
}

// Still any pages to be switched?
if (switchUniqueNames.Count > 0)
if (switchUniqueNames.Any())
{
// Find a floating element that is the target for the switching
KryptonDockingFloating? floating = FindDockingFloating(selectedPage ?? switchUniqueNames[0]);
Expand Down Expand Up @@ -2194,7 +2194,7 @@ public virtual bool ShowPageContextMenuRequest([DisallowNull] KryptonPage? page,
// Use events to determine which pages should be switched
var switchUniqueNames = new List<string>();
var switchPages = new List<KryptonPage>();
string selectedPage = null;
string? selectedPage = null;
foreach (var uniqueName in uniqueNames)
{
// Does the provided unique name exist and is in the required 'floating' state
Expand Down Expand Up @@ -2231,7 +2231,7 @@ public virtual bool ShowPageContextMenuRequest([DisallowNull] KryptonPage? page,
}

// Still any pages to be switched?
if (switchUniqueNames.Count > 0)
if (switchUniqueNames.Any())
{
using var update = new DockingMultiUpdate(this);
// Convert the pages to placeholders so they can be returned to the same location
Expand Down Expand Up @@ -2278,7 +2278,7 @@ public virtual bool ShowPageContextMenuRequest([DisallowNull] KryptonPage? page,
}

// Any pages that need default positioning because they could not be restored?
if (defaultPages.Count > 0)
if (defaultPages.Any())
{
// Cannot switch to docked unless we can find a docked element as the target
KryptonDockingEdgeDocked? edgeDocked = FindDockingEdgeDocked(defaultSelectedPage != null ? defaultSelectedPage.UniqueName : defaultPages[0].UniqueName);
Expand Down Expand Up @@ -2336,7 +2336,7 @@ public virtual bool ShowPageContextMenuRequest([DisallowNull] KryptonPage? page,
// Use events to determine which pages should be switched
var switchUniqueNames = new List<string>();
var switchPages = new List<KryptonPage>();
string selectedPage = null;
string? selectedPage = null;
foreach (var uniqueName in uniqueNames)
{
// Does the provided unique name exist and is in the required 'floating' state
Expand Down Expand Up @@ -2366,7 +2366,7 @@ public virtual bool ShowPageContextMenuRequest([DisallowNull] KryptonPage? page,
}

// Still any pages to be switched?
if (switchUniqueNames.Count > 0)
if (switchUniqueNames.Any())
{
// Find a floating element that is the target for the switching
KryptonDockingFloating? floating = FindDockingFloating(selectedPage ?? switchUniqueNames[0]);
Expand Down Expand Up @@ -2453,7 +2453,7 @@ public virtual bool ShowPageContextMenuRequest([DisallowNull] KryptonPage? page,
}

// Any pages that actually need to be switched?
if (switchPages.Count > 0)
if (switchPages.Any())
{
using var update = new DockingMultiUpdate(this);
// Remove the pages from the auto hidden group
Expand Down Expand Up @@ -2499,7 +2499,7 @@ public virtual bool ShowPageContextMenuRequest([DisallowNull] KryptonPage? page,
RemoveControlStorePages(edgeDocked, uniqueNames, false, true);

// Do we have some pages that still need adding?
if (defaultPages.Count > 0)
if (defaultPages.Any())
{
// Place them all inside a new dockspace
KryptonDockingDockspace newDockspace = edgeDocked.AppendDockspace();
Expand Down Expand Up @@ -3051,7 +3051,7 @@ public virtual void DoDragDrop(Point screenPoint, Point elementOffset, Control c
}

// Cannot drag an empty collection
if (pages.Count == 0)
if (!pages.Any())
{
throw new ArgumentOutOfRangeException(nameof(pages), @"collection cannot be empty");
}
Expand All @@ -3063,7 +3063,7 @@ public virtual void DoDragDrop(Point screenPoint, Point elementOffset, Control c
};

var atLeastOneFloating = false;
KryptonPage firstFloatingPage = null!;
KryptonPage firstFloatingPage = null!; // this is protected by the `atLeastOneFloating` local var.
foreach (KryptonPage? page in pages.Where(static page => page is not KryptonStorePage))
{
// Cannot drag a null page reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public KryptonNavigator Navigator
/// <summary>
/// Gets access to the view manager instance.
/// </summary>
public ViewManager? ViewManager
public ViewManager ViewManager
{
[DebuggerStepThrough]
get;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ internal class ViewBuilderGroup : ViewBuilderBase
/// <param name="manager">Reference to current manager.</param>
/// <param name="redirector">Palette redirector.</param>
public override void Construct(KryptonNavigator navigator,
ViewManager manager,
PaletteRedirect? redirector)
[DisallowNull] ViewManager manager,
[DisallowNull] PaletteRedirect redirector)
{
// Let base class perform common operations
base.Construct(navigator, manager, redirector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ internal class ViewBuilderHeaderGroup : ViewBuilderBase
/// <param name="navigator">Reference to navigator instance.</param>
/// <param name="manager">Reference to current manager.</param>
/// <param name="redirector">Palette redirector.</param>
public override void Construct(KryptonNavigator navigator,
ViewManager manager,
PaletteRedirect? redirector)
public override void Construct([DisallowNull] KryptonNavigator navigator,
[DisallowNull] ViewManager manager,
[DisallowNull] PaletteRedirect redirector)
{
// Let base class perform common operations
base.Construct(navigator, manager, redirector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ internal abstract class ViewBuilderItemBase : ViewBuilderBase
{
#region Instance Fields
protected PageToNavCheckItem? _pageLookup;
protected ButtonSpecManagerBase _buttonManager;
protected ViewDrawPanel _drawPanel;
protected ViewDrawCanvas _drawGroup;
protected ButtonSpecManagerBase? _buttonManager;
protected ViewDrawPanel? _drawPanel;
protected ViewDrawCanvas? _drawGroup;
protected ViewLayoutDocker _layoutBarDocker;
protected ViewLayoutBar _layoutBar;
protected ViewLayoutViewport _layoutBarViewport;
Expand All @@ -38,9 +38,9 @@ internal abstract class ViewBuilderItemBase : ViewBuilderBase
/// <param name="navigator">Reference to navigator instance.</param>
/// <param name="manager">Reference to current manager.</param>
/// <param name="redirector">Palette redirector.</param>
public override void Construct(KryptonNavigator navigator,
ViewManager manager,
PaletteRedirect? redirector)
public override void Construct([DisallowNull] KryptonNavigator navigator,
[DisallowNull] ViewManager manager,
[DisallowNull] PaletteRedirect redirector)
{
// Let base class perform common operations
base.Construct(navigator, manager, redirector);
Expand All @@ -58,7 +58,7 @@ public override void Construct(KryptonNavigator navigator,
PostCreate();

// Force buttons to be recreated in the headers
_buttonManager.RecreateButtons();
_buttonManager?.RecreateButtons();

// Canvas becomes the new root
ViewManager.Root = _newRoot;
Expand Down Expand Up @@ -208,7 +208,7 @@ public override void PageEnabledStateChanged(KryptonPage? page)
public override ButtonSpec? ButtonSpecFromView(ViewBase element)
{
// Check the set of navigator level button specs
ButtonSpec bs = (_buttonManager.ButtonSpecFromView(element));
ButtonSpec? bs = (_buttonManager?.ButtonSpecFromView(element));

// Check each page level button spec
if ((bs == null) && (_pageLookup != null))
Expand Down Expand Up @@ -310,7 +310,7 @@ public override void UpdateStatePalettes()
_layoutBar.SetMetrics(paletteCommon.Bar);
_layoutBarViewport.SetMetrics(paletteCommon.Bar);

_buttonManager.SetDockerMetrics(_layoutBarDocker, paletteCommon.Bar);
_buttonManager?.SetDockerMetrics(_layoutBarDocker, paletteCommon.Bar);

// Let base class perform common actions
base.UpdateStatePalettes();
Expand Down Expand Up @@ -414,7 +414,7 @@ public override void PerformNextAction(DirectionButtonAction action, KryptonPage
// Tell the viewport to shift to next area
_layoutBarViewport.MoveNext();

_buttonManager.RecreateButtons();
_buttonManager?.RecreateButtons();

// Need to layout and paint to effect change
Navigator.PerformNeedPaint(true);
Expand Down Expand Up @@ -468,7 +468,7 @@ public override void PerformPreviousAction(DirectionButtonAction action, Krypton
// Tell the viewport to shift to previous area
_layoutBarViewport.MovePrevious();

_buttonManager.RecreateButtons();
_buttonManager?.RecreateButtons();

// Need to layout and paint to effect change
Navigator.PerformNeedPaint(true);
Expand Down Expand Up @@ -703,7 +703,6 @@ protected virtual void CreateButtonSpecManager() =>
Navigator.CreateToolStripRenderer,
NeedPaintDelegate)
{

// Hook up the tooltip manager so that tooltips can be generated
ToolTipManager = Navigator.ToolTipManager
};
Expand Down Expand Up @@ -737,7 +736,7 @@ protected virtual void DestructCheckItemView()
_layoutBarViewport.AnimateStep -= OnViewportAnimation;

// Remove the old root from the canvas
_drawPanel.Clear();
_drawPanel?.Clear();
}

/// <summary>
Expand Down Expand Up @@ -881,7 +880,7 @@ protected override void OnViewBuilderPropertyChanged(object sender, PropertyChan
case @"ItemAlignment":
_layoutBar.ItemAlignment = Navigator.Bar.ItemAlignment;
_layoutBarViewport.Alignment = Navigator.Bar.ItemAlignment;
_buttonManager.RecreateButtons();
_buttonManager?.RecreateButtons();
Navigator.PerformNeedPaint(true);
break;
case @"ItemMinimumSize":
Expand All @@ -907,7 +906,7 @@ protected override void OnViewBuilderPropertyChanged(object sender, PropertyChan
case @"ContextButtonDisplay":
case @"CloseButtonDisplay":
case nameof(ButtonDisplayLogic):
_buttonManager.RecreateButtons();
_buttonManager?.RecreateButtons();
Navigator.PerformNeedPaint(true);
break;
case @"CheckButtonStyleBar":
Expand Down Expand Up @@ -1008,7 +1007,7 @@ private void UpdateButtonsAndPalette()
UpdateStatePalettes();

// Ensure buttons are recreated to reflect different page
_buttonManager.RecreateButtons();
_buttonManager?.RecreateButtons();
}

private void UpdateSelectedPageFocus()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,15 @@ public void SeparatorNotMoved()
/// <param name="navigator">Reference to navigator instance.</param>
/// <param name="manager">Reference to current manager.</param>
/// <param name="redirector">Palette redirector.</param>
public override void Construct(KryptonNavigator navigator,
ViewManager manager,
[DisallowNull] PaletteRedirect? redirector)
public override void Construct([DisallowNull] KryptonNavigator navigator,
[DisallowNull] ViewManager manager,
[DisallowNull] PaletteRedirect redirector)
{
// Let base class perform common operations
base.Construct(navigator, manager, redirector);

// Get the current root element
_oldRoot = ViewManager?.Root as ViewLayoutPageShow;
_oldRoot = ViewManager.Root as ViewLayoutPageShow;

// Create and initialize all objects
if (ViewManager != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ internal class ViewBuilderPanel : ViewBuilderBase
/// <param name="navigator">Reference to navigator instance.</param>
/// <param name="manager">Reference to current manager.</param>
/// <param name="redirector">Palette redirector.</param>
public override void Construct(KryptonNavigator navigator,
ViewManager manager,
PaletteRedirect? redirector)
public override void Construct([DisallowNull] KryptonNavigator navigator,
[DisallowNull] ViewManager manager,
[DisallowNull] PaletteRedirect? redirector)
{
// Let base class perform common operations
if (redirector != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ protected class PageToButtonEdge : Dictionary<KryptonPage, ViewDrawBorderEdge> {
/// <param name="navigator">Reference to navigator instance.</param>
/// <param name="manager">Reference to current manager.</param>
/// <param name="redirector">Palette redirector.</param>
public override void Construct(KryptonNavigator navigator,
ViewManager manager,
PaletteRedirect? redirector)
public override void Construct([DisallowNull] KryptonNavigator navigator,
[DisallowNull] ViewManager manager,
[DisallowNull] PaletteRedirect redirector)
{
// Let base class perform common operations
base.Construct(navigator, manager, redirector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ public PaletteBase? Palette
if (_localPalette != value)
{
// Remember the starting palette
PaletteBase old = _localPalette;
PaletteBase? old = _localPalette;

// Use the provided palette value
SetPalette(value);
Expand Down Expand Up @@ -1592,7 +1592,7 @@ protected override void OnLayout(LayoutEventArgs levent)
#endregion

#region Internal
internal PaletteRedirect? Redirector
internal PaletteRedirect Redirector
{
[DebuggerStepThrough]
get;
Expand Down Expand Up @@ -2525,7 +2525,7 @@ private void SetPalette(PaletteBase? palette)
private void PaintTransparentBackground(Graphics g, Rectangle clipRect)
{
// Get the parent control for transparent drawing purposes
Control parent = TransparentParent;
Control? parent = TransparentParent;

// Do we have a parent control and we need to paint background?
if ((parent != null) && NeedTransparentPaint)
Expand Down
1 change: 1 addition & 0 deletions Source/Krypton Components/TestForm/TestForm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<TargetFrameworks>net48</TargetFrameworks>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 6bc917e

Please sign in to comment.