diff --git a/src/Libraries/AvalonDock/DockableContent.cs b/src/Libraries/AvalonDock/DockableContent.cs
index c65d60ac58..5fa7d13239 100644
--- a/src/Libraries/AvalonDock/DockableContent.cs
+++ b/src/Libraries/AvalonDock/DockableContent.cs
@@ -137,7 +137,7 @@ namespace AvalonDock
///
/// Dockable to a border of a and into a
///
- Dockable = DockableToBorders | Document,
+ Dockable = DockableToBorders | Document | Floating,
///
/// Dockable to a border of a and into a but not in autohidden mode (WinForms controls)
@@ -159,6 +159,20 @@ namespace AvalonDock
public readonly AnchorStyle Anchor = AnchorStyle.None;
public DockableContentStateAndPosition(
+ Pane containerPane,
+ int childIndex,
+ double width,
+ double height,
+ AnchorStyle anchor)
+ {
+ ContainerPane = containerPane;
+ ChildIndex = childIndex;
+ Width = width;
+ Height = height;
+ Anchor = anchor;
+ }
+
+ public DockableContentStateAndPosition(
DockableContent cntToSave)
{
ContainerPane = cntToSave.ContainerPane;
@@ -485,6 +499,19 @@ namespace AvalonDock
storeWriter.WriteAttributeString(
"FloatingWindowSize", new SizeConverter().ConvertToInvariantString(FloatingWindowSize));
}
+
+ if (SavedStateAndPosition != null)
+ {
+ storeWriter.WriteAttributeString(
+ "ChildIndex", SavedStateAndPosition.ChildIndex.ToString());
+ storeWriter.WriteAttributeString(
+ "Width", SavedStateAndPosition.Width.ToString());
+ storeWriter.WriteAttributeString(
+ "Height", SavedStateAndPosition.Height.ToString());
+ storeWriter.WriteAttributeString(
+ "Anchor", SavedStateAndPosition.Anchor.ToString());
+ }
+
}
///
@@ -496,6 +523,28 @@ namespace AvalonDock
{
if (contentElement.HasAttribute("FloatingWindowSize"))
FloatingWindowSize = (Size)(new SizeConverter()).ConvertFromInvariantString(contentElement.GetAttribute("FloatingWindowSize"));
+
+
+ Size effectiveSize = new Size(0d, 0d);
+ if (contentElement.HasAttribute("EffectiveSize"))
+ {
+ // Store
+ effectiveSize = (Size)(new SizeConverter()).ConvertFromInvariantString(contentElement.GetAttribute("EffectiveSize"));
+ }
+
+ ResizingPanel.SetEffectiveSize(this, effectiveSize);
+
+ if (contentElement.HasAttribute("ChildIndex"))
+ {
+ _savedStateAndPosition = new DockableContentStateAndPosition(
+ ContainerPane,
+ int.Parse(contentElement.GetAttribute("ChildIndex")),
+ double.Parse(contentElement.GetAttribute("Width")),
+ double.Parse(contentElement.GetAttribute("Height")),
+ (AnchorStyle) Enum.Parse(typeof(AnchorStyle), contentElement.GetAttribute("Anchor"))
+ );
+
+ }
}
#endregion
}
diff --git a/src/Libraries/AvalonDock/DockingManager.cs b/src/Libraries/AvalonDock/DockingManager.cs
index dc7a0e2587..4320c6d93f 100644
--- a/src/Libraries/AvalonDock/DockingManager.cs
+++ b/src/Libraries/AvalonDock/DockingManager.cs
@@ -543,6 +543,11 @@ namespace AvalonDock
}
}
}
+ else
+ {
+ _mainDocumentPane = value;
+ }
+
}
}
@@ -1746,7 +1751,11 @@ namespace AvalonDock
if (content.ContainerPane.GetManager() == null)
{
//disconnect the parent pane from previous panel
- ((Panel)content.ContainerPane.Parent).Children.Remove(content.ContainerPane);
+ //((Panel)content.ContainerPane.Parent).Children.Remove(content.ContainerPane);
+ if (content.ContainerPane.Parent != null)
+ {
+ ((Panel)content.ContainerPane.Parent).Children.Remove(content.ContainerPane);
+ }
Anchor(content.ContainerPane, desideredAnchor);
}
@@ -2482,7 +2491,10 @@ namespace AvalonDock
void SaveLayout(XmlWriter xmlWriter, DockableContent content)
{
- Debug.Assert(!string.IsNullOrEmpty(content.Name));
+ Debug.Assert(!string.IsNullOrEmpty(content.Name),
+ "DockableContent must have a Name to save its content.\n" +
+ "Click Ignore to skip this element and continue with save."
+ );
if (!string.IsNullOrEmpty(content.Name))
{
@@ -2960,6 +2972,7 @@ namespace AvalonDock
&& hiddenContent.State != DockableContentState.Hidden)
{
Hide(hiddenContent);
+ hiddenContent.RestoreLayout(hiddenContentElement);
}
}
}
diff --git a/src/Libraries/AvalonDock/DocumentContent.cs b/src/Libraries/AvalonDock/DocumentContent.cs
index 75613ae0dc..07cc2682cb 100644
--- a/src/Libraries/AvalonDock/DocumentContent.cs
+++ b/src/Libraries/AvalonDock/DocumentContent.cs
@@ -158,6 +158,16 @@ namespace AvalonDock
base.OnDragMouseLeave(sender, e);
}
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ if (DragEnabledArea != null)
+ {
+ DragEnabledArea.InputBindings.Add(new InputBinding(ApplicationCommands.Close, new MouseGesture(MouseAction.MiddleClick)));
+ }
+ }
+
///
/// Event fired when the document is about to be closed
///
@@ -205,6 +215,7 @@ namespace AvalonDock
}
+
if (manager != null)
{
if (manager.ActiveDocument == this)
diff --git a/src/Libraries/AvalonDock/DocumentFloatingWindow.cs b/src/Libraries/AvalonDock/DocumentFloatingWindow.cs
index 67e3c3da88..6072d9e4fd 100644
--- a/src/Libraries/AvalonDock/DocumentFloatingWindow.cs
+++ b/src/Libraries/AvalonDock/DocumentFloatingWindow.cs
@@ -348,6 +348,8 @@ namespace AvalonDock
DocumentContent docContent = this.HostedPane.Items[0] as DocumentContent;
if (!docContent.Close())
e.Cancel = true;
+ else
+ this.HostedPane.Items.Remove(docContent);
}
base.OnClosing(e);
diff --git a/src/Libraries/AvalonDock/DocumentPane.cs b/src/Libraries/AvalonDock/DocumentPane.cs
index 6e35bacb4e..05644e0e2a 100644
--- a/src/Libraries/AvalonDock/DocumentPane.cs
+++ b/src/Libraries/AvalonDock/DocumentPane.cs
@@ -331,6 +331,8 @@ namespace AvalonDock
{
_optionsContextMenuPlacementTarget = GetTemplateChild("PART_ShowContextMenuButton") as UIElement;
+
+
base.OnApplyTemplate();
}
@@ -390,14 +392,32 @@ namespace AvalonDock
internal void CheckContentsEmpty()
{
- if (IsMainDocumentPane.HasValue &&
- !IsMainDocumentPane.Value &&
- Items.Count == 0)
+ if (Items.Count == 0)
{
- ResizingPanel containerPanel = Parent as ResizingPanel;
- if (containerPanel != null)
- containerPanel.RemoveChild(this);
- }
+ bool isMainDocPaneToBeClose = IsMainDocumentPane.HasValue &&
+ IsMainDocumentPane.Value;
+
+ if (isMainDocPaneToBeClose)
+ {
+ DockingManager manager = GetManager();
+ DocumentPane candidateNewMainDocPane = manager.FindAnotherLogicalChildContained(this);
+ if (candidateNewMainDocPane != null)
+ {
+ ResizingPanel containerPanel = Parent as ResizingPanel;
+ if (containerPanel != null)
+ containerPanel.RemoveChild(this);
+
+ manager.MainDocumentPane = candidateNewMainDocPane;
+ }
+ }
+ else
+ {
+ ResizingPanel containerPanel = Parent as ResizingPanel;
+ if (containerPanel != null)
+ containerPanel.RemoveChild(this);
+ }
+ }
+
}
diff --git a/src/Libraries/AvalonDock/HelperFunc.cs b/src/Libraries/AvalonDock/HelperFunc.cs
index 35a0be6dd5..2a6e1851fa 100644
--- a/src/Libraries/AvalonDock/HelperFunc.cs
+++ b/src/Libraries/AvalonDock/HelperFunc.cs
@@ -105,7 +105,6 @@ namespace AvalonDock
if (child is DependencyObject)
{
-
T childFound = (child as DependencyObject).GetLogicalChildContained();
if (childFound != null)
return childFound;
@@ -115,6 +114,24 @@ namespace AvalonDock
return null;
}
+ public static T FindAnotherLogicalChildContained(this DependencyObject obj, UIElement childToExclude) where T : DependencyObject
+ {
+ foreach (object child in LogicalTreeHelper.GetChildren(obj))
+ {
+ if (child is T && child != childToExclude)
+ return child as T;
+
+ if (child is DependencyObject)
+ {
+ T childFound = (child as DependencyObject).FindAnotherLogicalChildContained(childToExclude);
+ if (childFound != null)
+ return childFound;
+ }
+ }
+
+ return null;
+ }
+
public static DockablePane FindChildDockablePane(this DockingManager manager, AnchorStyle desideredAnchor)
{
foreach (UIElement childObject in LogicalTreeHelper.GetChildren(manager))
diff --git a/src/Libraries/AvalonDock/OverlayWindow.cs b/src/Libraries/AvalonDock/OverlayWindow.cs
index 907030e257..ae20f3fb55 100644
--- a/src/Libraries/AvalonDock/OverlayWindow.cs
+++ b/src/Libraries/AvalonDock/OverlayWindow.cs
@@ -201,10 +201,12 @@ namespace AvalonDock
else
owdPaneInto.Enabled = !(_manager.DragPaneServices.FloatingWindow is DocumentFloatingWindow);
- owdPaneBottom.Enabled = owdPaneInto.Enabled;
- owdPaneTop.Enabled = owdPaneInto.Enabled;
- owdPaneLeft.Enabled = owdPaneInto.Enabled;
- owdPaneRight.Enabled = owdPaneInto.Enabled;
+ int destPaneChildCount = pane.Items.Count;
+
+ owdPaneBottom.Enabled = owdPaneInto.Enabled && destPaneChildCount > 0;
+ owdPaneTop.Enabled = owdPaneInto.Enabled && destPaneChildCount > 0;
+ owdPaneLeft.Enabled = owdPaneInto.Enabled && destPaneChildCount > 0;
+ owdPaneRight.Enabled = owdPaneInto.Enabled && destPaneChildCount > 0;
CurrentDropPane = pane;
}
diff --git a/src/Libraries/AvalonDock/Properties/AssemblyInfo.cs b/src/Libraries/AvalonDock/Properties/AssemblyInfo.cs
index 8c10c468db..fa40c104ed 100644
--- a/src/Libraries/AvalonDock/Properties/AssemblyInfo.cs
+++ b/src/Libraries/AvalonDock/Properties/AssemblyInfo.cs
@@ -59,4 +59,4 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.2.2515")]
+[assembly: AssemblyVersion("1.2.2632")]
diff --git a/src/Libraries/AvalonDock/ResizingPanel.cs b/src/Libraries/AvalonDock/ResizingPanel.cs
index d51d081ade..9a0fb64a16 100644
--- a/src/Libraries/AvalonDock/ResizingPanel.cs
+++ b/src/Libraries/AvalonDock/ResizingPanel.cs
@@ -264,6 +264,19 @@ namespace AvalonDock
}
availableSize = newAvailSize;
}
+ //Thx to TMx
+ else if (availableSize.Height == double.PositiveInfinity &&
+ Orientation == Orientation.Vertical)
+ {
+ Size newAvailSize = new Size();
+ foreach (FrameworkElement child in visibleChildren)
+ {
+ child.Measure(newAvailSize);
+ newAvailSize.Width = Math.Max(child.DesiredSize.Width, newAvailSize.Width);
+ newAvailSize.Height += child.DesiredSize.Height;
+ }
+ availableSize = newAvailSize;
+ }
var splitters = from FrameworkElement child in visibleChildren
where child is ResizingPanelSplitter