Skip to content

Commit

Permalink
Check the RootPanel (instead of LayoutAnchorablePane child of RootPan…
Browse files Browse the repository at this point in the history
…el) for last position (FloatingWidth etc..) and IsMaximized properties of LayoutAnchorableFloatingWindowControl
  • Loading branch information
Dirkster99 committed May 12, 2019
1 parent 1f5cf8b commit dcee22e
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions source/Components/Xceed.Wpf.AvalonDock/DockingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2069,31 +2069,18 @@ internal UIElement CreateUIElementForModel( ILayoutElement model )
};
newFW.SetParentToMainWindowOf( this );

var paneForExtensions = modelFW.RootPanel.Children.OfType<LayoutAnchorablePane>().FirstOrDefault();
if( paneForExtensions != null )
{
//ensure that floating window position is inside current (or nearest) monitor
paneForExtensions.KeepInsideNearestMonitor();

newFW.Left = paneForExtensions.FloatingLeft;
newFW.Top = paneForExtensions.FloatingTop;
newFW.Width = paneForExtensions.FloatingWidth;
newFW.Height = paneForExtensions.FloatingHeight;
}
else
// Floating Window can also contain only Pane Groups at its base (issue #27) so we check for
// RootPanel (which is a LayoutAnchorablePaneGroup) and make sure the window is positioned back
// in current (or nearest) monitor
var panegroup = modelFW.RootPanel;
if (panegroup != null)
{
// Floating Window can also contain only Pane Groups at its base (issue #27) so we check for that
// and make sure the window is position back to where it was before (or the nearest monitor)
var panegroup = modelFW.RootPanel.Children.OfType<LayoutAnchorablePaneGroup>().FirstOrDefault();
if (panegroup != null)
{
panegroup.KeepInsideNearestMonitor(); // Check position is valid in current setup
panegroup.KeepInsideNearestMonitor(); // Check position is valid in current setup

newFW.Left = panegroup.FloatingLeft; // Position the window to previous or nearest valid position
newFW.Top = panegroup.FloatingTop;
newFW.Width = panegroup.FloatingWidth;
newFW.Height = panegroup.FloatingHeight;
}
newFW.Left = panegroup.FloatingLeft; // Position the window to previous or nearest valid position
newFW.Top = panegroup.FloatingTop;
newFW.Width = panegroup.FloatingWidth;
newFW.Height = panegroup.FloatingHeight;
}

newFW.ShowInTaskbar = false;
Expand All @@ -2103,11 +2090,11 @@ internal UIElement CreateUIElementForModel( ILayoutElement model )
newFW.Show();
} ), DispatcherPriority.Send );

// Do not set the WindowState before showing or it will be lost
if( paneForExtensions != null && paneForExtensions.IsMaximized )
if( panegroup != null && panegroup.IsMaximized )
{
newFW.WindowState = WindowState.Maximized;
}

return newFW;
}

Expand Down

0 comments on commit dcee22e

Please sign in to comment.