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 @@ -39,6 +39,20 @@ namespace AvalonDock
/// </summary>
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>
/// Change the colors based on the aero-theme from AvalonDock.
/// <para>
@ -72,16 +86,17 @@ namespace 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 @@ -90,18 +105,83 @@ namespace AvalonDock
/// </summary>
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();
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;
// }
// }
//}
/// <summary>
/// Searches for keys in the ResourceDictionary for brushes and changes the color-values
/// </summary>
@ -137,6 +217,22 @@ namespace AvalonDock @@ -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)
{

43
src/Libraries/AvalonDock/DockableContent.cs

@ -167,8 +167,8 @@ namespace AvalonDock @@ -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 @@ -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 @@ -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 @@ -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 @@ -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;
//}
}
/// <summary>

1
src/Libraries/AvalonDock/DockableFloatingWindow.cs

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

10
src/Libraries/AvalonDock/DockablePane.cs

@ -486,7 +486,15 @@ namespace AvalonDock @@ -486,7 +486,15 @@ namespace AvalonDock
/// </summary>
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

40
src/Libraries/AvalonDock/DockingManager.cs

@ -1669,6 +1669,17 @@ namespace AvalonDock @@ -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 @@ -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 @@ -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 @@ -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));

13
src/Libraries/AvalonDock/DocumentContent.cs

@ -213,6 +213,15 @@ namespace AvalonDock @@ -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 @@ -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;
}

21
src/Libraries/AvalonDock/DocumentPane.cs

@ -88,6 +88,8 @@ namespace AvalonDock @@ -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 @@ -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 @@ -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 @@ -408,6 +426,7 @@ namespace AvalonDock
containerPanel.RemoveChild(this);
manager.MainDocumentPane = candidateNewMainDocPane;
candidateNewMainDocPane.NotifyPropertyChanged("IsMainDocumentPane");
}
}
else

10
src/Libraries/AvalonDock/ManagedContent.cs

@ -499,6 +499,16 @@ namespace AvalonDock @@ -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;

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

@ -17,7 +17,7 @@ using System.Runtime.InteropServices; @@ -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; @@ -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")]

4
src/Libraries/AvalonDock/ResizingPanel.cs

@ -108,7 +108,9 @@ namespace AvalonDock @@ -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)

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

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

Loading…
Cancel
Save