Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust GetSide to allow for multiple anchorable panes on the left or top #486

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
24 changes: 21 additions & 3 deletions source/Components/AvalonDock/Layout/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/************************************************************************
/************************************************************************
AvalonDock

Copyright (C) 2007-2013 Xceed Software Inc.
Expand Down Expand Up @@ -70,8 +70,8 @@ public static AnchorSide GetSide(this ILayoutElement element)
if (layoutPanel != null && layoutPanel.Children.Count > 0)
{
if (layoutPanel.Orientation == System.Windows.Controls.Orientation.Horizontal)
return layoutPanel.Children[0].Equals(element) || layoutPanel.Children[0].Descendents().Contains(element) ? AnchorSide.Left : AnchorSide.Right;
return layoutPanel.Children[0].Equals(element) || layoutPanel.Children[0].Descendents().Contains(element) ? AnchorSide.Top : AnchorSide.Bottom;
return element.InAnchorablePaneAtStartOfPanel(layoutPanel) ? AnchorSide.Left : AnchorSide.Right;
return element.InAnchorablePaneAtStartOfPanel(layoutPanel) ? AnchorSide.Top : AnchorSide.Bottom;
}
}
Debug.Fail("Unable to find the side for an element, possible layout problem!");
Expand Down Expand Up @@ -116,6 +116,24 @@ internal static void KeepInsideNearestMonitor_Issue20(this ILayoutElementForFloa
paneInsideFloatingWindow.FloatingTop = monitorInfo.Work.Bottom - (paneInsideFloatingWindow.FloatingHeight + 10);
}

private static bool InAnchorablePaneAtStartOfPanel(this ILayoutElement element, LayoutPanel layoutPanel)
{
foreach (var child in layoutPanel.Children)
{
if (!(child is LayoutAnchorablePane || child is LayoutAnchorablePaneGroup))
{
return false;
}

if (child.Equals(element) || child.Descendents().Contains(element))
{
return true;
}
}

return false;
}

#endregion Internal Methods
}
}