diff --git a/src/Libraries/AvalonDock/ColorFactory.cs b/src/Libraries/AvalonDock/ColorFactory.cs
index 95ef75accb..bac0381de5 100644
--- a/src/Libraries/AvalonDock/ColorFactory.cs
+++ b/src/Libraries/AvalonDock/ColorFactory.cs
@@ -39,6 +39,20 @@ namespace AvalonDock
///
public sealed class ColorFactory
{
+ /// Change the theme to one from AvalonDock.
+ ///
+ /// for example: "aero.normalcolor" (default style)
+ public static void ChangeTheme(string theme)
+ {
+ ResourceDictionary rd = new ResourceDictionary();
+ rd.Source = new Uri("/AvalonDock;component/themes/" + theme + ".xaml", UriKind.RelativeOrAbsolute);
+
+ // first search and remove old one
+ ResetColors();
+
+ Application.Current.Resources.MergedDictionaries.Add(rd);
+ }
+
///
/// Change the colors based on the aero-theme from AvalonDock.
///
@@ -72,16 +86,17 @@ namespace AvalonDock
//ResourceDictionary parent = Application.Current.Resources;
// first search and remove old one
- foreach (ResourceDictionary res in Application.Current.Resources.MergedDictionaries)
- {
- string source = res.Source.ToString();
- if (source.Contains("/AvalonDock;component/themes/"))
- {
- Application.Current.Resources.MergedDictionaries.Remove(res);
- break;
- }
- }
-
+ //foreach (ResourceDictionary res in Application.Current.Resources.MergedDictionaries)
+ //{
+ // string source = res.Source.ToString();
+ // if (source.Contains("/AvalonDock;component/themes/"))
+ // {
+ // Application.Current.Resources.MergedDictionaries.Remove(res);
+ // break;
+ // }
+ //}
+ ResetColors();
+
Application.Current.Resources.MergedDictionaries.Add(rd);
}
@@ -90,18 +105,83 @@ namespace AvalonDock
///
public static void ResetColors()
{
- foreach (ResourceDictionary res in Application.Current.Resources.MergedDictionaries)
+//- foreach (ResourceDictionary res in Application.Current.Resources.MergedDictionaries)
+ ResourceDictionary res = GetActualResourceDictionary();
+ if (res != null)
+ Application.Current.Resources.MergedDictionaries.Remove(res);
+ }
+
+ ///
+ /// Change a specified brush inside the actual theme.
+ /// Look at AvalonDockBrushes.cs for possible values.
+ ///
+ /// an AvalonDockBrushes value
+ /// The new brush. It can be every brush type that is derived from Brush-class.
+ public static void ChangeBrush(AvalonDockBrushes brushName, Brush brush)
+ {
+ ChangeBrush(brushName.ToString(), brush);
+ }
+
+ ///
+ /// Change a specified brush inside the actual theme.
+ ///
+ /// a brush name
+ /// The new brush. It can be every brush type that is derived from Brush-class.
+ public static void ChangeBrush(string brushName, Brush brush)
+ {
+ // get the actual ResourceDictionary
+ ResourceDictionary rd = GetActualResourceDictionary();
+ if (rd == null)
+ {
+//- string source = res.Source.ToString();
+//- if (source.Contains("/AvalonDock;component/themes/"))
+ ChangeTheme("aero.normalcolor");
+ rd = GetActualResourceDictionary();
+ }
+
+ if (rd != null)
{
- string source = res.Source.ToString();
- if (source.Contains("/AvalonDock;component/themes/"))
- {
- Application.Current.Resources.MergedDictionaries.Remove(res);
- break;
+ foreach (ResourceDictionary rd2 in rd.MergedDictionaries)
+ {
+//- Application.Current.Resources.MergedDictionaries.Remove(res);
+//- break;
+ foreach (object key in rd2.Keys)
+ {
+ object item = rd2[key];
+ string keyTypeName = key.GetType().Name;
+
+ string str = "";
+ switch (keyTypeName)
+ {
+ case "ComponentResourceKey":
+ str = ((ComponentResourceKey)key).ResourceId.ToString();
+ break;
+ case "String":
+ str = (string)key;
+ break;
+ }
+ if (str == brushName)
+ {
+ rd[key] = brush;
+ return;
+ }
+ }
}
}
}
+ // {
+ // string source = res.Source.ToString();
+ // if (source.Contains("/AvalonDock;component/themes/"))
+ // {
+ // Application.Current.Resources.MergedDictionaries.Remove(res);
+ // break;
+ // }
+ // }
+ //}
+
+
///
/// Searches for keys in the ResourceDictionary for brushes and changes the color-values
///
@@ -137,6 +217,22 @@ namespace AvalonDock
}
}
+ static ResourceDictionary GetActualResourceDictionary()
+ {
+ // get the actual ResourceDictionary
+ foreach (ResourceDictionary res in Application.Current.Resources.MergedDictionaries)
+ {
+ if (res.Source != null)
+ {
+ string source = res.Source.ToString();
+ if (source.Contains("/AvalonDock;component/themes/"))
+ {
+ return res;
+ }
+ }
+ }
+ return null;
+ }
static Color GetColor(Color c, Color newCol)
{
diff --git a/src/Libraries/AvalonDock/DockableContent.cs b/src/Libraries/AvalonDock/DockableContent.cs
index 5fa7d13239..fe6ffabacd 100644
--- a/src/Libraries/AvalonDock/DockableContent.cs
+++ b/src/Libraries/AvalonDock/DockableContent.cs
@@ -167,8 +167,8 @@ namespace AvalonDock
{
ContainerPane = containerPane;
ChildIndex = childIndex;
- Width = width;
- Height = height;
+ Width = Math.Max(width, 100.0);
+ Height = Math.Max(height, 100.0);
Anchor = anchor;
}
@@ -177,8 +177,8 @@ namespace AvalonDock
{
ContainerPane = cntToSave.ContainerPane;
ChildIndex = ContainerPane.Items.IndexOf(cntToSave);
- Width = ContainerPane.ActualWidth;
- Height = ContainerPane.ActualHeight;
+ Width = Math.Max(ContainerPane.ActualWidth, 100.0);
+ Height = Math.Max(ContainerPane.ActualHeight, 100.0);
DockablePane dockablePane = ContainerPane as DockablePane;
if (dockablePane != null)
@@ -222,11 +222,20 @@ namespace AvalonDock
#endregion
#region State Properties & Events
+
+ public delegate void DockableContentStateHandler(object sender, DockableContentState state);
+ public event DockableContentStateHandler StateChanged;
public DockableContentState State
{
get { return (DockableContentState)GetValue(StatePropertyKey.DependencyProperty); }
- protected set { SetValue(StatePropertyKey, value); }
+ //protected set { SetValue(StatePropertyKey, value); }
+ protected set
+ {
+ SetValue(StatePropertyKey, value);
+ if (StateChanged != null)
+ StateChanged(this, value);
+ }
}
// Using a DependencyProperty as the backing store for State. This enables animation, styling, binding, etc...
@@ -297,6 +306,16 @@ namespace AvalonDock
}
#endregion
+ #region HideOnClose
+ public static DependencyProperty HideOnCloseKey = DependencyProperty.Register("HideOnClose", typeof(bool), typeof(DockableContent), new PropertyMetadata(true));
+
+ public bool HideOnClose
+ {
+ get { return (bool)GetValue(HideOnCloseKey); }
+ set { SetValue(HideOnCloseKey, value); }
+ }
+ #endregion
+
protected override void OnInitialized(EventArgs e)
{
@@ -461,15 +480,15 @@ namespace AvalonDock
internal void SaveCurrentStateAndPosition()
{
- if (State == DockableContentState.Docked)
- {
+ //if (State == DockableContentState.Docked)
+ //{
_savedStateAndPosition = new DockableContentStateAndPosition(
this);
- }
- else
- {
- _savedStateAndPosition = null;
- }
+ //}
+ //else
+ //{
+ // _savedStateAndPosition = null;
+ //}
}
///
diff --git a/src/Libraries/AvalonDock/DockableFloatingWindow.cs b/src/Libraries/AvalonDock/DockableFloatingWindow.cs
index 8ebccc45bd..6205113c4d 100644
--- a/src/Libraries/AvalonDock/DockableFloatingWindow.cs
+++ b/src/Libraries/AvalonDock/DockableFloatingWindow.cs
@@ -123,6 +123,7 @@ namespace AvalonDock
{
Width = selectedContent.FloatingWindowSize.Width;
Height = selectedContent.FloatingWindowSize.Height;
+ this.ResizeMode = selectedContent.FloatingResizeMode;
}
else
{
diff --git a/src/Libraries/AvalonDock/DockablePane.cs b/src/Libraries/AvalonDock/DockablePane.cs
index a139c61a0f..af5c087d88 100644
--- a/src/Libraries/AvalonDock/DockablePane.cs
+++ b/src/Libraries/AvalonDock/DockablePane.cs
@@ -486,7 +486,15 @@ namespace AvalonDock
///
internal virtual void Close()
{
- GetManager().Hide(SelectedItem as DockableContent);
+ //GetManager().Hide(SelectedItem as DockableContent);
+ if (SelectedItem is DockableContent)
+ {
+ DockableContent item = SelectedItem as DockableContent;
+ if (item.HideOnClose)
+ GetManager().Hide(SelectedItem as DockableContent);
+ else
+ this.Items.Remove(SelectedItem as DockableContent);
+ }
}
#endregion
diff --git a/src/Libraries/AvalonDock/DockingManager.cs b/src/Libraries/AvalonDock/DockingManager.cs
index 4320c6d93f..4d7ec32637 100644
--- a/src/Libraries/AvalonDock/DockingManager.cs
+++ b/src/Libraries/AvalonDock/DockingManager.cs
@@ -1669,6 +1669,17 @@ namespace AvalonDock
if (!found && MainDocumentPane != null)
{
+ if (document.Parent is DocumentPane)
+ {
+ ((DocumentPane)document.Parent).Items.Clear();
+ }
+ //if (document.Parent != null)
+ //{
+ // throw new InvalidProgramException(
+ // string.Format("Disconnnect first the document from its logical parent ({0})",
+ // document.Parent.GetType()));
+ //}
+
MainDocumentPane.Items.Insert(0, document);
}
@@ -1804,6 +1815,23 @@ namespace AvalonDock
{
content.ContainerPane.SelectedItem = content;
content.SetAsActive();
+
+ DockablePane dockParent = content.ContainerPane as DockablePane;
+ if (content.ActualWidth == 0.0 && (
+ dockParent.Anchor == AnchorStyle.Left || dockParent.Anchor == AnchorStyle.Right))
+ {
+ ResizingPanel.SetResizeWidth(dockParent, new GridLength(200));
+ ResizingPanel.SetEffectiveSize(dockParent, new Size(200, 0.0));
+ }
+ else if (content.ActualWidth == 0.0 && (
+ dockParent.Anchor == AnchorStyle.Left || dockParent.Anchor == AnchorStyle.Right))
+ {
+ ResizingPanel.SetResizeWidth(dockParent, new GridLength(200));
+ ResizingPanel.SetEffectiveSize(dockParent, new Size(200, 0.0));
+ }
+
+
+
//ActiveContent = content;
////content.FocusContent();
//if (content.Content is IInputElement)
@@ -1815,8 +1843,18 @@ namespace AvalonDock
content.State == DockableContentState.FloatingWindow)
{
FloatingDockablePane containerPane = content.ContainerPane as FloatingDockablePane;
+
if (containerPane != null)
+ {
+ //check if visible on the primary screen
+ if (containerPane.FloatingWindow.Left > System.Windows.SystemParameters.PrimaryScreenWidth)
+ containerPane.FloatingWindow.Left = System.Windows.SystemParameters.PrimaryScreenWidth - containerPane.FloatingWindow.Width;
+ if (containerPane.FloatingWindow.Top > System.Windows.SystemParameters.PrimaryScreenHeight)
+ containerPane.FloatingWindow.Top = System.Windows.SystemParameters.PrimaryScreenHeight - containerPane.FloatingWindow.Height;
+
+
containerPane.FloatingWindow.Activate();
+ }
}
else if (content.State == DockableContentState.Document)
@@ -2475,7 +2513,7 @@ namespace AvalonDock
void SaveLayout(XmlWriter xmlWriter, DockableFloatingWindow flWindow)
{
- xmlWriter.WriteStartElement("FloatingWinfow");
+ xmlWriter.WriteStartElement("FloatingWindow");
xmlWriter.WriteAttributeString("IsDockableWindow", XmlConvert.ToString(flWindow.IsDockableWindow));
xmlWriter.WriteAttributeString("Top", XmlConvert.ToString(flWindow.Top));
diff --git a/src/Libraries/AvalonDock/DocumentContent.cs b/src/Libraries/AvalonDock/DocumentContent.cs
index 07cc2682cb..5599335df6 100644
--- a/src/Libraries/AvalonDock/DocumentContent.cs
+++ b/src/Libraries/AvalonDock/DocumentContent.cs
@@ -213,6 +213,15 @@ namespace AvalonDock
parentPane.CheckContentsEmpty();
}
+ else
+ {
+ FloatingDockablePane floatingParentPane = ContainerPane as FloatingDockablePane;
+ if (floatingParentPane != null)
+ {
+ floatingParentPane.RemoveContent(0);
+ floatingParentPane.FloatingWindow.Close();
+ }
+ }
@@ -267,6 +276,10 @@ namespace AvalonDock
if (oldManager != null)
oldManager.FireDocumentClosedEvent();
+
+ if (Parent != null)
+ throw new InvalidOperationException("Parent MUST bu null after Doc is closed");
+
return true;
}
diff --git a/src/Libraries/AvalonDock/DocumentPane.cs b/src/Libraries/AvalonDock/DocumentPane.cs
index 05644e0e2a..c2d5e08fb1 100644
--- a/src/Libraries/AvalonDock/DocumentPane.cs
+++ b/src/Libraries/AvalonDock/DocumentPane.cs
@@ -88,6 +88,8 @@ namespace AvalonDock
new CommandBinding(ShowDocumentsListMenuCommand, ExecutedShowDocumentsListMenuCommand, CanExecuteShowDocumentsListMenuCommand));
this.CommandBindings.Add(
new CommandBinding(ApplicationCommands.Close, ExecutedCloseCommand, CanExecuteCloseCommand));
+ this.CommandBindings.Add(
+ new CommandBinding(CloseCommand, ExecutedCloseCommand, CanExecuteCloseCommand));
this.CommandBindings.Add(
new CommandBinding(CloseAllButThisCommand, this.OnExecuteCommand, this.OnCanExecuteCommand));
@@ -136,7 +138,7 @@ namespace AvalonDock
ManagedContent contentToClose = SelectedItem as ManagedContent;
- if (e.Parameter != null)
+ if (e.Parameter is ManagedContent)
contentToClose = e.Parameter as ManagedContent;
DockableContent dockableContent = contentToClose as DockableContent;
@@ -219,6 +221,22 @@ namespace AvalonDock
}
}
+ private static RoutedUICommand closeCommand = null;
+ public static RoutedUICommand CloseCommand
+ {
+ get
+ {
+ lock (syncRoot)
+ {
+ if (null == closeCommand)
+ {
+ closeCommand = new RoutedUICommand("C_lose", "Close", typeof(DocumentPane));
+ }
+ }
+ return closeCommand;
+ }
+ }
+
private static RoutedUICommand newHTabGroupCommand = null;
public static RoutedUICommand NewHorizontalTabGroupCommand
{
@@ -408,6 +426,7 @@ namespace AvalonDock
containerPanel.RemoveChild(this);
manager.MainDocumentPane = candidateNewMainDocPane;
+ candidateNewMainDocPane.NotifyPropertyChanged("IsMainDocumentPane");
}
}
else
diff --git a/src/Libraries/AvalonDock/ManagedContent.cs b/src/Libraries/AvalonDock/ManagedContent.cs
index f0930e1e08..53b0c99835 100644
--- a/src/Libraries/AvalonDock/ManagedContent.cs
+++ b/src/Libraries/AvalonDock/ManagedContent.cs
@@ -499,6 +499,16 @@ namespace AvalonDock
{ _floatingWindowSize = value; }
}
+
+ ResizeMode _floatingResizeMode = ResizeMode.CanResize;
+ public ResizeMode FloatingResizeMode
+ {
+ get
+ { return _floatingResizeMode; }
+ set
+ { _floatingResizeMode = value; }
+ }
+
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
diff --git a/src/Libraries/AvalonDock/Properties/AssemblyInfo.cs b/src/Libraries/AvalonDock/Properties/AssemblyInfo.cs
index fa40c104ed..a02fabaee4 100644
--- a/src/Libraries/AvalonDock/Properties/AssemblyInfo.cs
+++ b/src/Libraries/AvalonDock/Properties/AssemblyInfo.cs
@@ -17,7 +17,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AvalonDock")]
-[assembly: AssemblyCopyright("Copyright @ Adolfo Marinucci 2007-2008")]
+[assembly: AssemblyCopyright("Copyright @ Adolfo Marinucci 2007-2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
@@ -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.2632")]
+[assembly: AssemblyVersion("1.2.2641")]
diff --git a/src/Libraries/AvalonDock/ResizingPanel.cs b/src/Libraries/AvalonDock/ResizingPanel.cs
index 9a0fb64a16..06c8e9caa6 100644
--- a/src/Libraries/AvalonDock/ResizingPanel.cs
+++ b/src/Libraries/AvalonDock/ResizingPanel.cs
@@ -108,7 +108,9 @@ namespace AvalonDock
static void OnSplitSizeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
-
+ ResizingPanel parentPanel = LogicalTreeHelper.GetParent(sender) as ResizingPanel;
+ if (parentPanel != null)
+ parentPanel.InvalidateMeasure();
}
static object OnCoerceSplitSize(DependencyObject sender, object value)
diff --git a/src/Libraries/AvalonDock/Resources/DocumentPaneStyles.xaml b/src/Libraries/AvalonDock/Resources/DocumentPaneStyles.xaml
index 08c47422d9..edbdc3e2f0 100644
--- a/src/Libraries/AvalonDock/Resources/DocumentPaneStyles.xaml
+++ b/src/Libraries/AvalonDock/Resources/DocumentPaneStyles.xaml
@@ -13,7 +13,7 @@
x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:ContextMenuElement.DocumentPane}}"
>
+ Command="ApplicationCommands.Close" />