Browse Source

Update to AvalonDock 1.2.2691.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5211 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
6898c3b700
  1. 20
      src/Libraries/AvalonDock/DockableContent.cs
  2. 5
      src/Libraries/AvalonDock/DockableTabPanel.cs
  3. 108
      src/Libraries/AvalonDock/DockingManager.cs
  4. 85
      src/Libraries/AvalonDock/DocumentTabPanel.cs
  5. 11
      src/Libraries/AvalonDock/HelperFunc.cs
  6. 36
      src/Libraries/AvalonDock/ManagedContent.cs
  7. 4
      src/Libraries/AvalonDock/OverlayWindow.cs
  8. 2
      src/Libraries/AvalonDock/Properties/AssemblyInfo.cs

20
src/Libraries/AvalonDock/DockableContent.cs

@ -155,7 +155,7 @@ namespace AvalonDock @@ -155,7 +155,7 @@ namespace AvalonDock
public readonly int ChildIndex = -1;
public readonly double Width;
public readonly double Height;
public readonly DockableContentState State;
public readonly AnchorStyle Anchor = AnchorStyle.None;
public DockableContentStateAndPosition(
@ -163,13 +163,15 @@ namespace AvalonDock @@ -163,13 +163,15 @@ namespace AvalonDock
int childIndex,
double width,
double height,
AnchorStyle anchor)
AnchorStyle anchor,
DockableContentState state)
{
ContainerPane = containerPane;
ChildIndex = childIndex;
Width = Math.Max(width, 100.0);
Height = Math.Max(height, 100.0);
Anchor = anchor;
State = state;
}
public DockableContentStateAndPosition(
@ -179,6 +181,7 @@ namespace AvalonDock @@ -179,6 +181,7 @@ namespace AvalonDock
ChildIndex = ContainerPane.Items.IndexOf(cntToSave);
Width = Math.Max(ContainerPane.ActualWidth, 100.0);
Height = Math.Max(ContainerPane.ActualHeight, 100.0);
State = cntToSave.State;
DockablePane dockablePane = ContainerPane as DockablePane;
if (dockablePane != null)
@ -195,7 +198,7 @@ namespace AvalonDock @@ -195,7 +198,7 @@ namespace AvalonDock
{
static DockableContent()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(DockableContent), new FrameworkPropertyMetadata(typeof(DockableContent)));
//DefaultStyleKeyProperty.OverrideMetadata(typeof(DockableContent), new FrameworkPropertyMetadata(typeof(DockableContent)));
}
public DockableContent()
@ -317,6 +320,10 @@ namespace AvalonDock @@ -317,6 +320,10 @@ namespace AvalonDock
#endregion
protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
@ -530,6 +537,8 @@ namespace AvalonDock @@ -530,6 +537,8 @@ namespace AvalonDock
"Height", SavedStateAndPosition.Height.ToString());
storeWriter.WriteAttributeString(
"Anchor", SavedStateAndPosition.Anchor.ToString());
storeWriter.WriteAttributeString(
"State", SavedStateAndPosition.State.ToString());
}
}
@ -561,9 +570,10 @@ namespace AvalonDock @@ -561,9 +570,10 @@ namespace AvalonDock
int.Parse(contentElement.GetAttribute("ChildIndex")),
double.Parse(contentElement.GetAttribute("Width")),
double.Parse(contentElement.GetAttribute("Height")),
(AnchorStyle) Enum.Parse(typeof(AnchorStyle), contentElement.GetAttribute("Anchor"))
(AnchorStyle) Enum.Parse(typeof(AnchorStyle), contentElement.GetAttribute("Anchor")),
(DockableContentState) Enum.Parse(typeof(DockableContentState), contentElement.GetAttribute("State"))
);
//contentElement.HasAttribute("State") ? (DockableContentState)Enum.Parse(typeof(DockableContentState), contentElement.GetAttribute("State") );
}
}
#endregion

5
src/Libraries/AvalonDock/DockableTabPanel.cs

@ -51,8 +51,11 @@ namespace AvalonDock @@ -51,8 +51,11 @@ namespace AvalonDock
List<UIElement> childsOrderedByWidth = new List<UIElement>();
foreach (UIElement child in Children)
foreach (DockableContent child in Children)
{
child.Width = double.NaN;
child.Height = double.NaN;
child.Measure(new Size(double.PositiveInfinity, availableSize.Height));
totWidth += child.DesiredSize.Width;
childsOrderedByWidth.Add(child);

108
src/Libraries/AvalonDock/DockingManager.cs

@ -43,6 +43,7 @@ using System.Xml; @@ -43,6 +43,7 @@ using System.Xml;
using System.Linq;
using System.Collections;
using System.Collections.Specialized;
using System.Collections.ObjectModel;
namespace AvalonDock
{
@ -400,13 +401,30 @@ namespace AvalonDock @@ -400,13 +401,30 @@ namespace AvalonDock
void DocumentsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Reset)
{
DocumentContent[] docs = this.Documents;
foreach (DocumentContent doc in docs)
doc.Close();
}
if (e.Action == NotifyCollectionChangedAction.Reset)
{
DocumentContent[] docs = this.Documents;
ObservableCollection<DocumentContent> documentsToClose = new ObservableCollection<DocumentContent>();
foreach (DocumentContent doc in docs)
{
if (doc.Parent is DocumentPane)
{
if ((doc.Parent as DocumentPane).IsMainDocumentPane == false)
{
documentsToClose.Add(doc);
}
}
}
foreach (DocumentContent doc in documentsToClose)
{
doc.InternalClose();
}
foreach (DocumentContent doc in docs)
doc.InternalClose();
}
if (MainDocumentPane == null)
return;
@ -458,6 +476,16 @@ namespace AvalonDock @@ -458,6 +476,16 @@ namespace AvalonDock
{
if (child is DocumentPane)
return child as DocumentPane;
//if (child is DockablePane)
//{
// DocumentPane doc = new DocumentPane();
// DockablePane dockablePane = child as DockablePane;
// while (dockablePane.Items.Count > 0)
// {
// doc.Items.Add((dockablePane.Items[0] as DockableContent).DetachFromContainerPane());
// }
// return doc;
//}
if (child is ResizingPanel)
{
DocumentPane foundDocPane = GetMainDocumentPane(child as ResizingPanel);
@ -1707,7 +1735,10 @@ namespace AvalonDock @@ -1707,7 +1735,10 @@ namespace AvalonDock
/// <param name="content">Content to show</param>
public void Show(DockableContent content)
{
Show(content, DockableContentState.Docked);
if (content.SavedStateAndPosition != null)
Show(content, content.SavedStateAndPosition.State);
else
Show(content, DockableContentState.Docked);
}
/// <summary>
@ -1954,20 +1985,44 @@ namespace AvalonDock @@ -1954,20 +1985,44 @@ namespace AvalonDock
else if (desideredState == DockableContentState.DockableWindow ||
desideredState == DockableContentState.FloatingWindow)
{
DockablePane newHostpane = new DockablePane();
newHostpane.Items.Add(content);
content.SetStateToDock();
//ResizingPanel.SetResizeWidth(newHostpane, 200);
//ResizingPanel.SetResizeWidth(newHostpane, 500);
DockableFloatingWindow floatingWindow = new DockableFloatingWindow(this, newHostpane);
floatingWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
floatingWindow.Width = 200;
floatingWindow.Height = 500;
floatingWindow.Owner = Window.GetWindow(this);
RegisterFloatingWindow(floatingWindow);
floatingWindow.Show();
DockablePane newHostpane = null;
FloatingDockablePane prevHostpane = null;
if (content.SavedStateAndPosition != null && content.SavedStateAndPosition.ContainerPane != null && content.SavedStateAndPosition.ContainerPane is FloatingDockablePane)
{
prevHostpane = content.SavedStateAndPosition.ContainerPane as FloatingDockablePane;
if (!prevHostpane.Items.Contains(content))
prevHostpane.Items.Add(content);
}
else
{
newHostpane = new DockablePane();
newHostpane.Items.Add(content);
}
content.SetStateToDock();
if (prevHostpane != null)
{
DockableFloatingWindow floatingWindow = new DockableFloatingWindow(this, content);
floatingWindow.WindowStartupLocation = WindowStartupLocation.Manual;
floatingWindow.Top = prevHostpane.FloatingWindow.Top;
floatingWindow.Left = prevHostpane.FloatingWindow.Left;
floatingWindow.Width = prevHostpane.FloatingWindow.Width;
floatingWindow.Height = prevHostpane.FloatingWindow.Height;
floatingWindow.Owner = Window.GetWindow(this);
RegisterFloatingWindow(floatingWindow);
floatingWindow.Show();
}
else if (newHostpane != null)
{
DockableFloatingWindow floatingWindow = new DockableFloatingWindow(this, newHostpane);
floatingWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
floatingWindow.Width = 200;
floatingWindow.Height = 500;
floatingWindow.Owner = Window.GetWindow(this);
RegisterFloatingWindow(floatingWindow);
floatingWindow.Show();
}
}
else if (desideredState == DockableContentState.Document)
@ -2743,7 +2798,14 @@ namespace AvalonDock @@ -2743,7 +2798,14 @@ namespace AvalonDock
void RestoreDocumentPaneLayout(XmlElement childElement, out DocumentPane mainExistingDocumentPane, out DocumentPaneResizingPanel existingDocumentPanel, DockableContent[] dockableContents)
{
mainExistingDocumentPane = (Content is DocumentPane) ? Content as DocumentPane : GetMainDocumentPane(Content as ResizingPanel);
existingDocumentPanel = mainExistingDocumentPane.GetParentDocumentPaneResizingPanel();
if (mainExistingDocumentPane != null)
{
existingDocumentPanel = mainExistingDocumentPane.GetParentDocumentPaneResizingPanel();
}
else
{
existingDocumentPanel = null;
}
if (existingDocumentPanel != null)
{

85
src/Libraries/AvalonDock/DocumentTabPanel.cs

@ -100,91 +100,6 @@ namespace AvalonDock @@ -100,91 +100,6 @@ namespace AvalonDock
return finalSize;
////Check if selected content is visible
//bool selectedDocumentIsVisible = false;
//foreach (ManagedContent doc in Children)
//{
// if (doc.IsSelected)
// {
// selectedDocumentIsVisible = true;
// break;
// }
// offset += doc.DesiredSize.Width;
// if (offset + doc.DesiredSize.Width >= finalSize.Width)
// break;
//}
//bool flag = false;
//ManagedContent selectedDocument = null;
//offset = 0;
//if (!selectedDocumentIsVisible)
//{
// //try to put it visible
// foreach (ManagedContent doc in Children)
// {
// if (doc.IsSelected)
// {
// selectedDocument = doc;
// selectedDocument.Arrange(new Rect(offset, 0, Math.Min(doc.DesiredSize.Width, finalSize.Width - offset), finalSize.Height));
// //doc.Arrange(new Rect(offset, 0, finalSize.Width - offset, finalSize.Height));
// offset += doc.ActualWidth;// selectedDocument.DesiredSize.Width;
// break;
// }
// }
//}
//foreach (FrameworkElement child in Children)
//{
// if (!selectedDocumentIsVisible && child == selectedDocument)
// continue;
// if (flag || offset + child.DesiredSize.Width > finalSize.Width)
// {
// if (!flag && selectedDocumentIsVisible)
// child.Arrange(new Rect(offset, 0, Math.Min(child.DesiredSize.Width, finalSize.Width - offset), finalSize.Height));
// else
// child.Arrange(new Rect());
// flag = true;
// }
// else
// {
// child.Arrange(new Rect(offset, 0, Math.Min(child.DesiredSize.Width, finalSize.Width - offset), finalSize.Height));
// //child.Arrange(new Rect(offset, 0, finalSize.Width - offset, finalSize.Height));
// offset += child.ActualWidth;
// }
//}
////return new Size(offset, finalSize.Height);
////return base.ArrangeOverride(finalSize);
//return finalSize;
}
//protected override Visual GetVisualChild(int index)
//{
// return base.GetVisualChild(VisualChildrenCount - index - 1);
// //return base.GetVisualChild(index);
//}
//protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
//{
// base.OnVisualChildrenChanged(visualAdded, visualRemoved);
// if (visualAdded != null)
// {
// SetZIndex(visualAdded as UIElement, -Children.Count);
// //Debug.Assert(visualAdded is DocumentContent);
// }
//}
}
}

11
src/Libraries/AvalonDock/HelperFunc.cs

@ -191,5 +191,16 @@ namespace AvalonDock @@ -191,5 +191,16 @@ namespace AvalonDock
{
return PresentationSource.FromVisual(visual) != null;
}
public static void CallMethod(this object o, string methodName, object[] args)
{
o.GetType().GetMethod(methodName).Invoke(o, null);
}
public static T GetPropertyValue<T>(this object o, string propertyName)
{
return (T)o.GetType().GetProperty(propertyName).GetValue(o, null);
}
}
}

36
src/Libraries/AvalonDock/ManagedContent.cs

@ -61,8 +61,35 @@ namespace AvalonDock @@ -61,8 +61,35 @@ namespace AvalonDock
{
this.Loaded += new RoutedEventHandler(ManagedContent_Loaded);
this.Unloaded += new RoutedEventHandler(ManagedContent_Unloaded);
}
this.LayoutUpdated += new EventHandler(ManagedContent_LayoutUpdated);
}
public void ManagedContent_LayoutUpdated(object sender, EventArgs e)
{
WindowsFormsHost contentHost = null;
if (this.Content is UserControl)
{
UserControl usTemp = this.Content as UserControl;
if (usTemp.Content is WindowsFormsHost)
contentHost = usTemp.Content as WindowsFormsHost;
}
else if (this.Content is WindowsFormsHost)
{
contentHost = this.Content as WindowsFormsHost;
}
if (contentHost != null)
{
object childCtrl = contentHost.GetType().GetProperty("Child").GetValue(contentHost, null);
if (childCtrl != null)
{
childCtrl.CallMethod("Refresh", null);
}
}
}
void ManagedContent_Loaded(object sender, RoutedEventArgs e)
{
@ -386,12 +413,9 @@ namespace AvalonDock @@ -386,12 +413,9 @@ namespace AvalonDock
if (childCtrl != null)
{
Type winFormType = childCtrl.GetType();
bool focused = (bool)winFormType.GetProperty("Focused").GetValue(childCtrl, null);
if (!focused)
if (!childCtrl.GetPropertyValue<bool>("Focused"))
{
winFormType.GetMethod("Focus").Invoke(childCtrl, null);
childCtrl.CallMethod("Focus", null);
}
}
}

4
src/Libraries/AvalonDock/OverlayWindow.cs

@ -157,8 +157,6 @@ namespace AvalonDock @@ -157,8 +157,6 @@ namespace AvalonDock
public void ShowOverlayPaneDockingOptions(Pane pane)
{
if (!IsVisible)
return;
HideOverlayPaneDockingOptions(pane);
@ -213,8 +211,6 @@ namespace AvalonDock @@ -213,8 +211,6 @@ namespace AvalonDock
public void HideOverlayPaneDockingOptions(Pane surfaceElement)
{
if (!IsVisible)
return;
owdPaneBottom.Enabled = false;
owdPaneTop.Enabled = false;

2
src/Libraries/AvalonDock/Properties/AssemblyInfo.cs

@ -59,4 +59,4 @@ using System.Runtime.InteropServices; @@ -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.2663")]
[assembly: AssemblyVersion("1.2.2691")]

Loading…
Cancel
Save