Skip to content

Commit

Permalink
Fix for issue #9
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirkster99 committed Nov 12, 2018
1 parent 75305de commit ece04af
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions source/Components/Xceed.Wpf.AvalonDock/Layout/Extentions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,34 +85,41 @@ public static bool IsOfType<T, S>( this ILayoutContainer container )
return container is T || container is S;
}

public static AnchorSide GetSide( this ILayoutElement element )
{
var parentContainer = element.Parent as ILayoutOrientableGroup;
if( parentContainer != null )
{
var layoutPanel = parentContainer as LayoutPanel;
if( layoutPanel == null )
public static AnchorSide GetSide(this ILayoutElement element)
{
layoutPanel = parentContainer.FindParent<LayoutPanel>();
var parentContainer = element.Parent as ILayoutOrientableGroup;
if (parentContainer != null)
{
if (!parentContainer.ContainsChildOfType<LayoutDocumentPaneGroup, LayoutDocumentPane>())
return GetSide(parentContainer);

foreach (var childElement in parentContainer.Children)
{
if (childElement == element ||
childElement.Descendents().Contains(element))
return parentContainer.Orientation == System.Windows.Controls.Orientation.Horizontal ?
AnchorSide.Left : AnchorSide.Top;

var childElementAsContainer = childElement as ILayoutContainer;
if (childElementAsContainer != null &&
(childElementAsContainer.IsOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>() ||
childElementAsContainer.ContainsChildOfType<LayoutDocumentPane, LayoutDocumentPaneGroup>()))
{
return parentContainer.Orientation == System.Windows.Controls.Orientation.Horizontal ?
AnchorSide.Right : AnchorSide.Bottom;
}
}
}

Debug.Fail("Unable to find the side for an element, possible layout problem!");
return AnchorSide.Right;
}

if( (layoutPanel != null) && ( layoutPanel.Children.Count > 0 ) )
{
if( layoutPanel.Orientation == System.Windows.Controls.Orientation.Horizontal )
return layoutPanel.Children[ 0 ].Descendents().Contains( element ) ? AnchorSide.Left : AnchorSide.Right;
return layoutPanel.Children[ 0 ].Descendents().Contains( element ) ? AnchorSide.Top : AnchorSide.Bottom;
}
}

Debug.Fail( "Unable to find the side for an element, possible layout problem!" );
return AnchorSide.Right;
}

#endregion
#endregion

#region Internal Methods
#region Internal Methods

internal static void KeepInsideNearestMonitor( this ILayoutElementForFloatingWindow paneInsideFloatingWindow )
internal static void KeepInsideNearestMonitor( this ILayoutElementForFloatingWindow paneInsideFloatingWindow )
{
Win32Helper.RECT r = new Win32Helper.RECT();
r.Left = ( int )paneInsideFloatingWindow.FloatingLeft;
Expand Down

0 comments on commit ece04af

Please sign in to comment.