Skip to content

Commit

Permalink
Merge pull request #327 from AndersChen123/master
Browse files Browse the repository at this point in the history
Add default width and height of LayoutAnchorable
  • Loading branch information
Dirkster99 authored Feb 12, 2022
2 parents 3308372 + 0d2782c commit 01ebaca
Showing 1 changed file with 45 additions and 8 deletions.
53 changes: 45 additions & 8 deletions source/Components/AvalonDock/Layout/LayoutAnchorable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,20 @@ public void ToggleAutoHide()
case AnchorSide.Right:
if (parentGroup.Root.RootPanel.Orientation == Orientation.Horizontal)
{
previousContainer = new LayoutAnchorablePane { DockMinWidth = AutoHideMinWidth };
previousContainer = new LayoutAnchorablePane
{
DockMinWidth = AutoHideMinWidth,
DockMinHeight = AutoHideMinHeight
};
parentGroup.Root.RootPanel.Children.Add(previousContainer);
}
else
{
previousContainer = new LayoutAnchorablePane();
previousContainer = new LayoutAnchorablePane
{
DockMinHeight = AutoHideMinHeight,
DockMinWidth = AutoHideMinWidth
};
var panel = new LayoutPanel { Orientation = Orientation.Horizontal };
var root = parentGroup.Root as LayoutRoot;
var oldRootPanel = parentGroup.Root.RootPanel;
Expand All @@ -460,12 +468,20 @@ public void ToggleAutoHide()
case AnchorSide.Left:
if (parentGroup.Root.RootPanel.Orientation == Orientation.Horizontal)
{
previousContainer = new LayoutAnchorablePane { DockMinWidth = AutoHideMinWidth };
previousContainer = new LayoutAnchorablePane
{
DockMinWidth = AutoHideMinWidth,
DockMinHeight = AutoHideMinHeight
};
parentGroup.Root.RootPanel.Children.Insert(0, previousContainer);
}
else
{
previousContainer = new LayoutAnchorablePane();
previousContainer = new LayoutAnchorablePane
{
DockMinHeight = AutoHideMinHeight,
DockMinWidth = AutoHideMinWidth
};
var panel = new LayoutPanel { Orientation = Orientation.Horizontal };
var root = parentGroup.Root as LayoutRoot;
var oldRootPanel = parentGroup.Root.RootPanel;
Expand All @@ -478,12 +494,20 @@ public void ToggleAutoHide()
case AnchorSide.Top:
if (parentGroup.Root.RootPanel.Orientation == Orientation.Vertical)
{
previousContainer = new LayoutAnchorablePane { DockMinHeight = AutoHideMinHeight };
previousContainer = new LayoutAnchorablePane
{
DockMinHeight = AutoHideMinHeight,
DockMinWidth = AutoHideMinWidth
};
parentGroup.Root.RootPanel.Children.Insert(0, previousContainer);
}
else
{
previousContainer = new LayoutAnchorablePane();
previousContainer = new LayoutAnchorablePane
{
DockMinWidth = AutoHideMinWidth,
DockMinHeight = AutoHideMinHeight
};
var panel = new LayoutPanel { Orientation = Orientation.Vertical };
var root = parentGroup.Root as LayoutRoot;
var oldRootPanel = parentGroup.Root.RootPanel;
Expand All @@ -498,13 +522,18 @@ public void ToggleAutoHide()
{
previousContainer = new LayoutAnchorablePane
{
DockMinHeight = AutoHideMinHeight
DockMinHeight = AutoHideMinHeight,
DockMinWidth = AutoHideMinWidth
};
parentGroup.Root.RootPanel.Children.Add(previousContainer);
}
else
{
previousContainer = new LayoutAnchorablePane();
previousContainer = new LayoutAnchorablePane
{
DockMinWidth = AutoHideMinWidth,
DockMinHeight = AutoHideMinHeight
};
var panel = new LayoutPanel { Orientation = Orientation.Vertical };
var root = parentGroup.Root as LayoutRoot;
var oldRootPanel = parentGroup.Root.RootPanel;
Expand All @@ -524,9 +553,17 @@ public void ToggleAutoHide()
cnt.PreviousContainer = previousContainer;
}

var selectedIndex = -1;
var selectedItem = parentGroup.Children.FirstOrDefault(x => x.IsActive);
if (selectedItem != null)
selectedIndex = parentGroup.Children.IndexOf(selectedItem);

foreach (var anchorableToToggle in parentGroup.Children.ToArray())
previousContainer.Children.Add(anchorableToToggle);

if (selectedIndex != -1)
previousContainer.SelectedContentIndex = selectedIndex;

parentSide.Children.Remove(parentGroup);

var parent = previousContainer.Parent as LayoutGroupBase;
Expand Down

0 comments on commit 01ebaca

Please sign in to comment.