Browse Source

Update AvalonDock to 1.2.2154.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4269 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
8396a39d9c
  1. 1
      src/Libraries/AvalonDock/AvalonDock.csproj
  2. 25
      src/Libraries/AvalonDock/DeserializationCallbackEventArgs.cs
  3. 8
      src/Libraries/AvalonDock/DockableContent.cs
  4. 6
      src/Libraries/AvalonDock/DockablePane.cs
  5. 140
      src/Libraries/AvalonDock/DockingManager.cs
  6. 24
      src/Libraries/AvalonDock/FloatingWindow.cs
  7. 2
      src/Libraries/AvalonDock/Properties/AssemblyInfo.cs
  8. 4
      src/Libraries/AvalonDock/ResizingPanel.cs

1
src/Libraries/AvalonDock/AvalonDock.csproj

@ -76,6 +76,7 @@
<Compile Include="AlignedImage.cs" /> <Compile Include="AlignedImage.cs" />
<Compile Include="AvalonDockBrushes.cs" /> <Compile Include="AvalonDockBrushes.cs" />
<Compile Include="ContextMenuElement.cs" /> <Compile Include="ContextMenuElement.cs" />
<Compile Include="DeserializationCallbackEventArgs.cs" />
<Compile Include="DockableContent.cs" /> <Compile Include="DockableContent.cs" />
<Compile Include="DockableFloatingWindow.cs" /> <Compile Include="DockableFloatingWindow.cs" />
<Compile Include="DockablePane.cs" /> <Compile Include="DockablePane.cs" />

25
src/Libraries/AvalonDock/DeserializationCallbackEventArgs.cs

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AvalonDock
{
public class DeserializationCallbackEventArgs : EventArgs
{
public DeserializationCallbackEventArgs(string contentName)
{
Name = contentName;
}
/// <summary>
/// Gets the name of the content to deserialize
/// </summary>
public string Name { get; protected set; }
/// <summary>
/// Gets/Sets the content manually deserialized
/// </summary>
public DockableContent Content { get; set; }
}
}

8
src/Libraries/AvalonDock/DockableContent.cs

@ -156,6 +156,8 @@ namespace AvalonDock
public readonly double Width; public readonly double Width;
public readonly double Height; public readonly double Height;
public readonly AnchorStyle Anchor = AnchorStyle.None;
public DockableContentStateAndPosition( public DockableContentStateAndPosition(
DockableContent cntToSave) DockableContent cntToSave)
{ {
@ -163,6 +165,12 @@ namespace AvalonDock
ChildIndex = ContainerPane.Items.IndexOf(cntToSave); ChildIndex = ContainerPane.Items.IndexOf(cntToSave);
Width = ContainerPane.ActualWidth; Width = ContainerPane.ActualWidth;
Height = ContainerPane.ActualHeight; Height = ContainerPane.ActualHeight;
DockablePane dockablePane = ContainerPane as DockablePane;
if (dockablePane != null)
{
Anchor = dockablePane.Anchor;
}
} }
} }

6
src/Libraries/AvalonDock/DockablePane.cs

@ -47,6 +47,10 @@ namespace AvalonDock
/// </summary> /// </summary>
public enum AnchorStyle public enum AnchorStyle
{ {
/// <summary>
/// No anchor style, while content is hosted in a <see cref="DocumentPane"/> or a <see cref="FloatingWindow"/>
/// </summary>
None,
/// <summary> /// <summary>
/// Top border anchor /// Top border anchor
/// </summary> /// </summary>
@ -135,7 +139,7 @@ namespace AvalonDock
// Using a DependencyProperty as the backing store for Anchor. This enables animation, styling, binding, etc... // Using a DependencyProperty as the backing store for Anchor. This enables animation, styling, binding, etc...
public static readonly DependencyPropertyKey AnchorPropertyKey = public static readonly DependencyPropertyKey AnchorPropertyKey =
DependencyProperty.RegisterAttachedReadOnly("Anchor", typeof(AnchorStyle), typeof(DockablePane), new UIPropertyMetadata(AnchorStyle.Left)); DependencyProperty.RegisterAttachedReadOnly("Anchor", typeof(AnchorStyle), typeof(DockablePane), new UIPropertyMetadata(AnchorStyle.None));
public override void OnApplyTemplate() public override void OnApplyTemplate()

140
src/Libraries/AvalonDock/DockingManager.cs

@ -213,8 +213,8 @@ namespace AvalonDock
} }
set set
{ {
if (_activeDocument != value && if (_activeDocument != value/* &&
value.ContainerPane is DocumentPane) value.ContainerPane is DocumentPane*/)
{ {
List<ManagedContent> listOfAllDocuments = FindContents<ManagedContent>(); List<ManagedContent> listOfAllDocuments = FindContents<ManagedContent>();
listOfAllDocuments.ForEach((ManagedContent cnt) => listOfAllDocuments.ForEach((ManagedContent cnt) =>
@ -685,6 +685,9 @@ namespace AvalonDock
//remove the pane from its original children collection //remove the pane from its original children collection
FrameworkElement parentElement = paneToAnchor.Parent as FrameworkElement; FrameworkElement parentElement = paneToAnchor.Parent as FrameworkElement;
if (anchor == AnchorStyle.None)
anchor = AnchorStyle.Right;
//Change anchor border according to FlowDirection //Change anchor border according to FlowDirection
if (FlowDirection == FlowDirection.RightToLeft) if (FlowDirection == FlowDirection.RightToLeft)
{ {
@ -801,6 +804,9 @@ namespace AvalonDock
/// <param name="anchor"></param> /// <param name="anchor"></param>
public void Anchor(Pane paneToAnchor, Pane relativePane, AnchorStyle anchor) public void Anchor(Pane paneToAnchor, Pane relativePane, AnchorStyle anchor)
{ {
if (anchor == AnchorStyle.None)
anchor = AnchorStyle.Right;
//Change anchor border according to FlowDirection //Change anchor border according to FlowDirection
if (FlowDirection == FlowDirection.RightToLeft) if (FlowDirection == FlowDirection.RightToLeft)
{ {
@ -832,6 +838,9 @@ namespace AvalonDock
/// <param name="anchor"></param> /// <param name="anchor"></param>
public void Anchor(DockablePane paneToAnchor, DocumentPane relativePane, AnchorStyle anchor) public void Anchor(DockablePane paneToAnchor, DocumentPane relativePane, AnchorStyle anchor)
{ {
if (anchor == AnchorStyle.None)
anchor = AnchorStyle.Right;
//get a reference to the resizingpanel container of relativePane //get a reference to the resizingpanel container of relativePane
ResizingPanel relativePaneContainer = LogicalTreeHelper.GetParent(relativePane) as ResizingPanel; ResizingPanel relativePaneContainer = LogicalTreeHelper.GetParent(relativePane) as ResizingPanel;
DocumentPaneResizingPanel relativeDocumentPaneContainer = relativePane.GetParentDocumentPaneResizingPanel(); DocumentPaneResizingPanel relativeDocumentPaneContainer = relativePane.GetParentDocumentPaneResizingPanel();
@ -981,6 +990,9 @@ namespace AvalonDock
/// <param name="anchor"></param> /// <param name="anchor"></param>
public void Anchor(DocumentPane paneToAnchor, DocumentPane relativePane, AnchorStyle anchor) public void Anchor(DocumentPane paneToAnchor, DocumentPane relativePane, AnchorStyle anchor)
{ {
if (anchor == AnchorStyle.None)
anchor = AnchorStyle.Right;
//get a reference to the resizingpanel container of relativePane //get a reference to the resizingpanel container of relativePane
ResizingPanel relativePaneContainer = LogicalTreeHelper.GetParent(relativePane) as ResizingPanel; ResizingPanel relativePaneContainer = LogicalTreeHelper.GetParent(relativePane) as ResizingPanel;
DocumentPaneResizingPanel relativeDocumentPaneContainer = relativePane.GetParentDocumentPaneResizingPanel(); DocumentPaneResizingPanel relativeDocumentPaneContainer = relativePane.GetParentDocumentPaneResizingPanel();
@ -1083,6 +1095,9 @@ namespace AvalonDock
/// <param name="anchor"></param> /// <param name="anchor"></param>
public void Anchor(DockablePane paneToAnchor, DockablePane relativePane, AnchorStyle anchor) public void Anchor(DockablePane paneToAnchor, DockablePane relativePane, AnchorStyle anchor)
{ {
if (anchor == AnchorStyle.None)
anchor = AnchorStyle.Right;
//get a refernce to the resizingpanel container of relativePane //get a refernce to the resizingpanel container of relativePane
ResizingPanel relativePaneContainer = LogicalTreeHelper.GetParent(relativePane) as ResizingPanel; ResizingPanel relativePaneContainer = LogicalTreeHelper.GetParent(relativePane) as ResizingPanel;
Orientation requestedOrientation = Orientation requestedOrientation =
@ -1536,7 +1551,7 @@ namespace AvalonDock
/// <param name="desideredState">State desidered</param> /// <param name="desideredState">State desidered</param>
public void Show(DockableContent content, DockableContentState desideredState) public void Show(DockableContent content, DockableContentState desideredState)
{ {
Show(content, desideredState, AnchorStyle.Right); Show(content, desideredState, AnchorStyle.None);
} }
/// <summary> /// <summary>
@ -1696,6 +1711,14 @@ namespace AvalonDock
DockablePane newHostpane = new DockablePane(); DockablePane newHostpane = new DockablePane();
newHostpane.Items.Add(content); newHostpane.Items.Add(content);
if (desideredAnchor == AnchorStyle.None &&
content.SavedStateAndPosition != null &&
content.SavedStateAndPosition.Anchor != AnchorStyle.None)
desideredAnchor = content.SavedStateAndPosition.Anchor;
if (desideredAnchor == AnchorStyle.None)
desideredAnchor = AnchorStyle.Right;
if (desideredAnchor == AnchorStyle.Left || if (desideredAnchor == AnchorStyle.Left ||
desideredAnchor == AnchorStyle.Right) desideredAnchor == AnchorStyle.Right)
{ {
@ -1705,7 +1728,8 @@ namespace AvalonDock
!double.IsNaN(content.SavedStateAndPosition.Width)) !double.IsNaN(content.SavedStateAndPosition.Width))
w = content.SavedStateAndPosition.Width; w = content.SavedStateAndPosition.Width;
//ResizingPanel.SetResizeWidth(newHostpane, w); ResizingPanel.SetResizeWidth(newHostpane, new GridLength(w));
ResizingPanel.SetEffectiveSize(newHostpane, new Size(w, 0.0));
} }
else else
{ {
@ -1715,7 +1739,8 @@ namespace AvalonDock
!double.IsNaN(content.SavedStateAndPosition.Height)) !double.IsNaN(content.SavedStateAndPosition.Height))
h = content.SavedStateAndPosition.Height; h = content.SavedStateAndPosition.Height;
//ResizingPanel.SetResizeHeight(newHostpane, h); ResizingPanel.SetResizeHeight(newHostpane, new GridLength(h));
ResizingPanel.SetEffectiveSize(newHostpane, new Size(0.0, h));
} }
Anchor(newHostpane, desideredAnchor); Anchor(newHostpane, desideredAnchor);
@ -2474,13 +2499,18 @@ namespace AvalonDock
{ {
if (content.State == DockableContentState.AutoHide) if (content.State == DockableContentState.AutoHide)
{ {
if ((content.Parent as DockablePane).Items.Count == 1) DockablePane parentContainer = content.Parent as DockablePane;
if (parentContainer != null &&
parentContainer.Items.Count == 1)
ToggleAutoHide(content.Parent as DockablePane); ToggleAutoHide(content.Parent as DockablePane);
} }
if (content.State == DockableContentState.DockableWindow || if (content.State == DockableContentState.DockableWindow ||
content.State == DockableContentState.FloatingWindow) content.State == DockableContentState.FloatingWindow)
{ {
if ((content.Parent as DockablePane).Items.Count == 1) DockablePane parentContainer = content.Parent as DockablePane;
if (parentContainer != null &&
parentContainer.Items.Count == 1)
{ {
FloatingWindow floatingWindow = Window.GetWindow(content) as FloatingWindow; FloatingWindow floatingWindow = Window.GetWindow(content) as FloatingWindow;
floatingWindow.Close(); floatingWindow.Close();
@ -2493,6 +2523,11 @@ namespace AvalonDock
content.DetachFromContainerPane(); content.DetachFromContainerPane();
} }
public delegate void DeserializationCallbackHandler(object sender, DeserializationCallbackEventArgs e);
public DeserializationCallbackHandler DeserializationCallback { get; set; }
void ShowAllHiddenContents() void ShowAllHiddenContents()
{ {
while (_hiddenContents.Count > 0) while (_hiddenContents.Count > 0)
@ -2502,7 +2537,7 @@ namespace AvalonDock
} }
} }
void RestoreDocumentPaneLayout(XmlElement childElement, out DocumentPane mainExistingDocumentPane, out DocumentPaneResizingPanel existingDocumentPanel) void RestoreDocumentPaneLayout(XmlElement childElement, out DocumentPane mainExistingDocumentPane, out DocumentPaneResizingPanel existingDocumentPanel, DockableContent[] dockableContents)
{ {
mainExistingDocumentPane = (Content is DocumentPane) ? Content as DocumentPane : GetMainDocumentPane(Content as ResizingPanel); mainExistingDocumentPane = (Content is DocumentPane) ? Content as DocumentPane : GetMainDocumentPane(Content as ResizingPanel);
existingDocumentPanel = mainExistingDocumentPane.GetParentDocumentPaneResizingPanel(); existingDocumentPanel = mainExistingDocumentPane.GetParentDocumentPaneResizingPanel();
@ -2534,17 +2569,36 @@ namespace AvalonDock
{ {
if (contentElement.HasAttribute("Name")) if (contentElement.HasAttribute("Name"))
{ {
foreach (DockableContent content in DockableContents) DockableContent foundContent = null;
string contentName = contentElement.GetAttribute("Name");
foreach (DockableContent content in dockableContents)
{ {
if (content.Name == contentElement.GetAttribute("Name")) if (content.Name == contentName)
{ {
DetachContentFromDockingManager(content); foundContent = content;
mainExistingDocumentPane.Items.Add(content);
content.SetStateToDocument();
content.RestoreLayout(contentElement);
break; break;
} }
} }
if (foundContent == null &&
DeserializationCallback != null)
{
DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName);
DeserializationCallback(this, e);
foundContent = e.Content;
}
if (foundContent != null)
{
DetachContentFromDockingManager(foundContent);
mainExistingDocumentPane.Items.Add(foundContent);
foundContent.SetStateToDocument();
//call custom layout persistence method
foundContent.RestoreLayout(contentElement);
}
} }
} }
} }
@ -2593,24 +2647,40 @@ namespace AvalonDock
{ {
if (contentElement.HasAttribute("Name")) if (contentElement.HasAttribute("Name"))
{ {
DockableContent foundContent = null;
string contentName = contentElement.GetAttribute("Name");
foreach (DockableContent content in dockableContents) foreach (DockableContent content in dockableContents)
{ {
if (content.Name == contentElement.GetAttribute("Name")) if (content.Name == contentName)
{ {
DetachContentFromDockingManager(content); foundContent = content;
pane.Items.Add(content);
content.SetStateToDock();
if (contentElement.HasAttribute("AutoHide") &&
XmlConvert.ToBoolean(contentElement.GetAttribute("AutoHide")) &&
pane.Items.Count == 1)
toggleAutoHide = true;
//call custom layout persistence method
content.RestoreLayout(contentElement);
break; break;
} }
} }
if (foundContent == null &&
DeserializationCallback != null)
{
DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName);
DeserializationCallback(this, e);
foundContent = e.Content;
}
if (foundContent != null)
{
DetachContentFromDockingManager(foundContent);
pane.Items.Add(foundContent);
foundContent.SetStateToDock();
if (contentElement.HasAttribute("AutoHide") &&
XmlConvert.ToBoolean(contentElement.GetAttribute("AutoHide")) &&
pane.Items.Count == 1)
toggleAutoHide = true;
//call custom layout persistence method
foundContent.RestoreLayout(contentElement);
}
} }
} }
if (pane.Items.Count > 0) if (pane.Items.Count > 0)
@ -2629,7 +2699,7 @@ namespace AvalonDock
DocumentPaneResizingPanel existingDocumentPanel = null; DocumentPaneResizingPanel existingDocumentPanel = null;
DocumentPane mainExistingDocumentPane = null; DocumentPane mainExistingDocumentPane = null;
RestoreDocumentPaneLayout(childElement, out mainExistingDocumentPane, out existingDocumentPanel); RestoreDocumentPaneLayout(childElement, out mainExistingDocumentPane, out existingDocumentPanel, dockableContents);
if (existingDocumentPanel != null) if (existingDocumentPanel != null)
{ {
@ -2723,7 +2793,7 @@ namespace AvalonDock
DocumentPaneResizingPanel existingDocumentPanel = null; DocumentPaneResizingPanel existingDocumentPanel = null;
DocumentPane mainExistingDocumentPane = null; DocumentPane mainExistingDocumentPane = null;
RestoreDocumentPaneLayout(rootElement, out mainExistingDocumentPane, out existingDocumentPanel); RestoreDocumentPaneLayout(rootElement, out mainExistingDocumentPane, out existingDocumentPanel, actualContents);
if (existingDocumentPanel != null) if (existingDocumentPanel != null)
{ {
@ -2776,14 +2846,24 @@ namespace AvalonDock
foreach (XmlElement contentElement in paneElement.ChildNodes) foreach (XmlElement contentElement in paneElement.ChildNodes)
{ {
#region Find the content to transfer #region Find the content to transfer
string contentToFindName = contentElement.GetAttribute("Name");
foreach (DockableContent content in actualContents) foreach (DockableContent content in actualContents)
{ {
if (contentElement.GetAttribute("Name") == content.Name) if (contentToFindName == content.Name)
{ {
contentToTransfer = content; contentToTransfer = content;
break; break;
} }
} }
if (contentToTransfer == null &&
DeserializationCallback != null)
{
DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentToFindName);
DeserializationCallback(this, e);
contentToTransfer = e.Content;
}
#endregion #endregion

24
src/Libraries/AvalonDock/FloatingWindow.cs

@ -117,6 +117,29 @@ namespace AvalonDock
} }
#region Active Content Management
ManagedContent lastActiveContent = null;
protected override void OnActivated(EventArgs e)
{
if (Manager != null)
{
lastActiveContent = Manager.ActiveContent;
Manager.ActiveContent = HostedPane.SelectedItem as ManagedContent;
}
base.OnActivated(e);
}
protected override void OnDeactivated(EventArgs e)
{
if (Manager != null && lastActiveContent != null)
{
Manager.ActiveContent = lastActiveContent;
}
base.OnDeactivated(e);
}
#endregion
public abstract Pane ClonePane(); public abstract Pane ClonePane();
@ -368,7 +391,6 @@ namespace AvalonDock
} }
#endregion #endregion
#region INotifyPropertyChanged Members #region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;

2
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 // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("1.2.2104")] [assembly: AssemblyVersion("1.2.2154")]

4
src/Libraries/AvalonDock/ResizingPanel.cs

@ -789,7 +789,7 @@ namespace AvalonDock
#if DEBUG #if DEBUG
Debug.Assert(_splitterList.Count == Children.Count / 2); Debug.Assert(_splitterList.Count == Children.Count / 2);
i = 0; i = 0;
while (true) while (Children.Count > 0)
{ {
Debug.Assert(Children[i] != null); Debug.Assert(Children[i] != null);
Debug.Assert(!(Children[i] is ResizingPanelSplitter)); Debug.Assert(!(Children[i] is ResizingPanelSplitter));
@ -799,7 +799,7 @@ namespace AvalonDock
Debug.Assert((Children[i] is ResizingPanelSplitter)); Debug.Assert((Children[i] is ResizingPanelSplitter));
i++; i++;
} }
#endif #endif
splitterListIsDirty = false; splitterListIsDirty = false;

Loading…
Cancel
Save