fix(docking): address final code quality issues in docking layout

This commit is contained in:
2026-03-28 23:03:32 +09:00
parent 2946b905c6
commit c8f24edfd8
2 changed files with 27 additions and 13 deletions

View File

@@ -95,22 +95,28 @@ public class DockingLayout : Control
throw new ArgumentException("targetGroup does not belong to this DockingLayout", nameof(targetGroup));
}
if (RootModule == null)
{
RootModule = new DockPanel();
}
if (targetGroup == null)
{
targetGroup = FindFirstDockGroup(RootModule as DockContainer);
if (targetGroup == null)
if (RootModule != null)
{
targetGroup = FindFirstDockGroup(RootModule as DockContainer);
if (targetGroup == null)
{
// Root is not a container, or contains no groups. Wrap it.
var newGroup = new DockGroup();
if (RootModule is DockDocument existingDoc)
{
RootModule = null; // Detach first
newGroup.AddChild(existingDoc);
}
RootModule = newGroup;
targetGroup = newGroup;
}
}
else
{
targetGroup = new DockGroup();
if (RootModule is DockContainer container)
{
container.AddChild(targetGroup);
}
RootModule = targetGroup;
}
}
@@ -191,8 +197,10 @@ public class DockingLayout : Control
}
}
private static DockGroup? FindFirstDockGroup(DockContainer container)
private static DockGroup? FindFirstDockGroup(DockContainer? container)
{
if (container == null) return null;
if (container is DockGroup group)
{
return group;