Browse Source

Update to AvalonDock 1.2.2641

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4931 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
91c7b3aec8
  1. 128
      src/Libraries/AvalonDock/ColorFactory.cs
  2. 43
      src/Libraries/AvalonDock/DockableContent.cs
  3. 1
      src/Libraries/AvalonDock/DockableFloatingWindow.cs
  4. 10
      src/Libraries/AvalonDock/DockablePane.cs
  5. 40
      src/Libraries/AvalonDock/DockingManager.cs
  6. 13
      src/Libraries/AvalonDock/DocumentContent.cs
  7. 21
      src/Libraries/AvalonDock/DocumentPane.cs
  8. 10
      src/Libraries/AvalonDock/ManagedContent.cs
  9. 4
      src/Libraries/AvalonDock/Properties/AssemblyInfo.cs
  10. 4
      src/Libraries/AvalonDock/ResizingPanel.cs
  11. 2
      src/Libraries/AvalonDock/Resources/DocumentPaneStyles.xaml

128
src/Libraries/AvalonDock/ColorFactory.cs

@ -39,6 +39,20 @@ namespace AvalonDock
/// </summary> /// </summary>
public sealed class ColorFactory public sealed class ColorFactory
{ {
/// Change the theme to one from AvalonDock.
/// </summary>
/// <param name="theme">for example: "aero.normalcolor" (default style)</param>
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);
}
/// <summary> /// <summary>
/// Change the colors based on the aero-theme from AvalonDock. /// Change the colors based on the aero-theme from AvalonDock.
/// <para> /// <para>
@ -72,16 +86,17 @@ namespace AvalonDock
//ResourceDictionary parent = Application.Current.Resources; //ResourceDictionary parent = Application.Current.Resources;
// first search and remove old one // first search and remove old one
foreach (ResourceDictionary res in Application.Current.Resources.MergedDictionaries) //foreach (ResourceDictionary res in Application.Current.Resources.MergedDictionaries)
{ //{
string source = res.Source.ToString(); // string source = res.Source.ToString();
if (source.Contains("/AvalonDock;component/themes/")) // if (source.Contains("/AvalonDock;component/themes/"))
{ // {
Application.Current.Resources.MergedDictionaries.Remove(res); // Application.Current.Resources.MergedDictionaries.Remove(res);
break; // break;
} // }
} //}
ResetColors();
Application.Current.Resources.MergedDictionaries.Add(rd); Application.Current.Resources.MergedDictionaries.Add(rd);
} }
@ -90,18 +105,83 @@ namespace AvalonDock
/// </summary> /// </summary>
public static void ResetColors() 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);
}
/// <summary>
/// Change a specified brush inside the actual theme.
/// Look at AvalonDockBrushes.cs for possible values.
/// </summary>
/// <param name="brushName">an AvalonDockBrushes value</param>
/// <param name="brush">The new brush. It can be every brush type that is derived from Brush-class.</param>
public static void ChangeBrush(AvalonDockBrushes brushName, Brush brush)
{
ChangeBrush(brushName.ToString(), brush);
}
/// <summary>
/// Change a specified brush inside the actual theme.
/// </summary>
/// <param name="brushName">a brush name</param>
/// <param name="brush">The new brush. It can be every brush type that is derived from Brush-class.</param>
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(); foreach (ResourceDictionary rd2 in rd.MergedDictionaries)
if (source.Contains("/AvalonDock;component/themes/")) {
{ //- Application.Current.Resources.MergedDictionaries.Remove(res);
Application.Current.Resources.MergedDictionaries.Remove(res); //- break;
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;
// }
// }
//}
/// <summary> /// <summary>
/// Searches for keys in the ResourceDictionary for brushes and changes the color-values /// Searches for keys in the ResourceDictionary for brushes and changes the color-values
/// </summary> /// </summary>
@ -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) static Color GetColor(Color c, Color newCol)
{ {

43
src/Libraries/AvalonDock/DockableContent.cs

@ -167,8 +167,8 @@ namespace AvalonDock
{ {
ContainerPane = containerPane; ContainerPane = containerPane;
ChildIndex = childIndex; ChildIndex = childIndex;
Width = width; Width = Math.Max(width, 100.0);
Height = height; Height = Math.Max(height, 100.0);
Anchor = anchor; Anchor = anchor;
} }
@ -177,8 +177,8 @@ namespace AvalonDock
{ {
ContainerPane = cntToSave.ContainerPane; ContainerPane = cntToSave.ContainerPane;
ChildIndex = ContainerPane.Items.IndexOf(cntToSave); ChildIndex = ContainerPane.Items.IndexOf(cntToSave);
Width = ContainerPane.ActualWidth; Width = Math.Max(ContainerPane.ActualWidth, 100.0);
Height = ContainerPane.ActualHeight; Height = Math.Max(ContainerPane.ActualHeight, 100.0);
DockablePane dockablePane = ContainerPane as DockablePane; DockablePane dockablePane = ContainerPane as DockablePane;
if (dockablePane != null) if (dockablePane != null)
@ -222,11 +222,20 @@ namespace AvalonDock
#endregion #endregion
#region State Properties & Events #region State Properties & Events
public delegate void DockableContentStateHandler(object sender, DockableContentState state);
public event DockableContentStateHandler StateChanged;
public DockableContentState State public DockableContentState State
{ {
get { return (DockableContentState)GetValue(StatePropertyKey.DependencyProperty); } 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... // Using a DependencyProperty as the backing store for State. This enables animation, styling, binding, etc...
@ -297,6 +306,16 @@ namespace AvalonDock
} }
#endregion #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) protected override void OnInitialized(EventArgs e)
{ {
@ -461,15 +480,15 @@ namespace AvalonDock
internal void SaveCurrentStateAndPosition() internal void SaveCurrentStateAndPosition()
{ {
if (State == DockableContentState.Docked) //if (State == DockableContentState.Docked)
{ //{
_savedStateAndPosition = new DockableContentStateAndPosition( _savedStateAndPosition = new DockableContentStateAndPosition(
this); this);
} //}
else //else
{ //{
_savedStateAndPosition = null; // _savedStateAndPosition = null;
} //}
} }
/// <summary> /// <summary>

1
src/Libraries/AvalonDock/DockableFloatingWindow.cs

@ -123,6 +123,7 @@ namespace AvalonDock
{ {
Width = selectedContent.FloatingWindowSize.Width; Width = selectedContent.FloatingWindowSize.Width;
Height = selectedContent.FloatingWindowSize.Height; Height = selectedContent.FloatingWindowSize.Height;
this.ResizeMode = selectedContent.FloatingResizeMode;
} }
else else
{ {

10
src/Libraries/AvalonDock/DockablePane.cs

@ -486,7 +486,15 @@ namespace AvalonDock
/// </summary> /// </summary>
internal virtual void Close() 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 #endregion

40
src/Libraries/AvalonDock/DockingManager.cs

@ -1669,6 +1669,17 @@ namespace AvalonDock
if (!found && MainDocumentPane != null) 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); MainDocumentPane.Items.Insert(0, document);
} }
@ -1804,6 +1815,23 @@ namespace AvalonDock
{ {
content.ContainerPane.SelectedItem = content; content.ContainerPane.SelectedItem = content;
content.SetAsActive(); 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; //ActiveContent = content;
////content.FocusContent(); ////content.FocusContent();
//if (content.Content is IInputElement) //if (content.Content is IInputElement)
@ -1815,8 +1843,18 @@ namespace AvalonDock
content.State == DockableContentState.FloatingWindow) content.State == DockableContentState.FloatingWindow)
{ {
FloatingDockablePane containerPane = content.ContainerPane as FloatingDockablePane; FloatingDockablePane containerPane = content.ContainerPane as FloatingDockablePane;
if (containerPane != null) 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(); containerPane.FloatingWindow.Activate();
}
} }
else if (content.State == DockableContentState.Document) else if (content.State == DockableContentState.Document)
@ -2475,7 +2513,7 @@ namespace AvalonDock
void SaveLayout(XmlWriter xmlWriter, DockableFloatingWindow flWindow) void SaveLayout(XmlWriter xmlWriter, DockableFloatingWindow flWindow)
{ {
xmlWriter.WriteStartElement("FloatingWinfow"); xmlWriter.WriteStartElement("FloatingWindow");
xmlWriter.WriteAttributeString("IsDockableWindow", XmlConvert.ToString(flWindow.IsDockableWindow)); xmlWriter.WriteAttributeString("IsDockableWindow", XmlConvert.ToString(flWindow.IsDockableWindow));
xmlWriter.WriteAttributeString("Top", XmlConvert.ToString(flWindow.Top)); xmlWriter.WriteAttributeString("Top", XmlConvert.ToString(flWindow.Top));

13
src/Libraries/AvalonDock/DocumentContent.cs

@ -213,6 +213,15 @@ namespace AvalonDock
parentPane.CheckContentsEmpty(); 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) if (oldManager != null)
oldManager.FireDocumentClosedEvent(); oldManager.FireDocumentClosedEvent();
if (Parent != null)
throw new InvalidOperationException("Parent MUST bu null after Doc is closed");
return true; return true;
} }

21
src/Libraries/AvalonDock/DocumentPane.cs

@ -88,6 +88,8 @@ namespace AvalonDock
new CommandBinding(ShowDocumentsListMenuCommand, ExecutedShowDocumentsListMenuCommand, CanExecuteShowDocumentsListMenuCommand)); new CommandBinding(ShowDocumentsListMenuCommand, ExecutedShowDocumentsListMenuCommand, CanExecuteShowDocumentsListMenuCommand));
this.CommandBindings.Add( this.CommandBindings.Add(
new CommandBinding(ApplicationCommands.Close, ExecutedCloseCommand, CanExecuteCloseCommand)); new CommandBinding(ApplicationCommands.Close, ExecutedCloseCommand, CanExecuteCloseCommand));
this.CommandBindings.Add(
new CommandBinding(CloseCommand, ExecutedCloseCommand, CanExecuteCloseCommand));
this.CommandBindings.Add( this.CommandBindings.Add(
new CommandBinding(CloseAllButThisCommand, this.OnExecuteCommand, this.OnCanExecuteCommand)); new CommandBinding(CloseAllButThisCommand, this.OnExecuteCommand, this.OnCanExecuteCommand));
@ -136,7 +138,7 @@ namespace AvalonDock
ManagedContent contentToClose = SelectedItem as ManagedContent; ManagedContent contentToClose = SelectedItem as ManagedContent;
if (e.Parameter != null) if (e.Parameter is ManagedContent)
contentToClose = e.Parameter as ManagedContent; contentToClose = e.Parameter as ManagedContent;
DockableContent dockableContent = contentToClose as DockableContent; 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; private static RoutedUICommand newHTabGroupCommand = null;
public static RoutedUICommand NewHorizontalTabGroupCommand public static RoutedUICommand NewHorizontalTabGroupCommand
{ {
@ -408,6 +426,7 @@ namespace AvalonDock
containerPanel.RemoveChild(this); containerPanel.RemoveChild(this);
manager.MainDocumentPane = candidateNewMainDocPane; manager.MainDocumentPane = candidateNewMainDocPane;
candidateNewMainDocPane.NotifyPropertyChanged("IsMainDocumentPane");
} }
} }
else else

10
src/Libraries/AvalonDock/ManagedContent.cs

@ -499,6 +499,16 @@ namespace AvalonDock
{ _floatingWindowSize = value; } { _floatingWindowSize = value; }
} }
ResizeMode _floatingResizeMode = ResizeMode.CanResize;
public ResizeMode FloatingResizeMode
{
get
{ return _floatingResizeMode; }
set
{ _floatingResizeMode = value; }
}
#region INotifyPropertyChanged Members #region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;

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

@ -17,7 +17,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AvalonDock")] [assembly: AssemblyProduct("AvalonDock")]
[assembly: AssemblyCopyright("Copyright @ Adolfo Marinucci 2007-2008")] [assembly: AssemblyCopyright("Copyright @ Adolfo Marinucci 2007-2009")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [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 // 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.2632")] [assembly: AssemblyVersion("1.2.2641")]

4
src/Libraries/AvalonDock/ResizingPanel.cs

@ -108,7 +108,9 @@ namespace AvalonDock
static void OnSplitSizeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) 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) static object OnCoerceSplitSize(DependencyObject sender, object value)

2
src/Libraries/AvalonDock/Resources/DocumentPaneStyles.xaml

@ -13,7 +13,7 @@
x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:ContextMenuElement.DocumentPane}}" x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:ContextMenuElement.DocumentPane}}"
> >
<MenuItem Header="Close" <MenuItem Header="Close"
Command="ApplicationCommands.Close" CommandParameter="{Binding}" /> Command="ApplicationCommands.Close" />
<MenuItem Command="ad:DocumentPane.CloseAllButThisCommand" /> <MenuItem Command="ad:DocumentPane.CloseAllButThisCommand" />
<Separator/> <Separator/>
<MenuItem Command="ad:DocumentPane.NewHorizontalTabGroupCommand"> <MenuItem Command="ad:DocumentPane.NewHorizontalTabGroupCommand">

Loading…
Cancel
Save