From 6bbba8d32a00c4b62bdabcfcbd18f6b42dbb23b8 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 6 Jul 2010 15:40:11 +0000 Subject: [PATCH] Upgrade to AvalonDock 1.3.3571 git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6053 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../AvalonDock.Themes35.csproj | 125 +++++ .../Properties/Resources.Designer.cs | 42 +- .../Properties/Settings.Designer.cs | 20 +- .../Themes/ExpressionDark.xaml | 76 ++- .../AvalonDock.Themes/Themes/dev2010.xaml | 25 +- .../AvalonDock/AvalonDock/AlignedImage.cs | 187 -------- .../AvalonDock/AvalonDock/AvalonDock.csproj | 13 +- .../AvalonDock/AvalonDock/AvalonDock35.csproj | 268 +++++++++++ .../AvalonDock/AvalonDock/Converters.cs | 14 +- .../AvalonDock/AvalonDock/DockableContent.cs | 73 ++- .../AvalonDock/DockableFloatingWindow.cs | 4 - .../AvalonDock/AvalonDock/DockablePane.cs | 195 ++++---- .../AvalonDock/AvalonDock/DockingManager.cs | 443 ++++++++---------- .../AvalonDock/AvalonDock/DocumentContent.cs | 20 +- .../AvalonDock/DocumentFloatingWindow.cs | 3 +- .../AvalonDock/AvalonDock/DocumentPane.cs | 62 ++- .../AvalonDock/AvalonDock/DocumentTabPanel.cs | 30 +- .../AvalonDock/FloatingDockablePane.cs | 18 +- .../AvalonDock/FloatingDocumentPane.cs | 57 ++- .../AvalonDock/AvalonDock/FloatingWindow.cs | 4 +- .../AvalonDock/FlyoutDockablePane.cs | 8 +- .../AvalonDock/AvalonDock/FlyoutPaneWindow.cs | 227 ++------- .../AvalonDock/AvalonDock/HelperFunc.cs | 31 +- .../AvalonDock/AvalonDock/ImageEx.cs | 19 + .../AvalonDock/AvalonDock/ManagedContent.cs | 148 ++++-- .../AvalonDock/AvalonDock/NavigatorWindow.cs | 222 ++++++++- src/Libraries/AvalonDock/AvalonDock/Pane.cs | 155 ++++-- .../AvalonDock/AvalonDock/PaneTabPanel.cs | 10 +- .../AvalonDock/Properties/AssemblyInfo.cs | 4 +- .../Properties/Settings.Designer.cs | 20 +- .../AvalonDock/AvalonDock/ResizingPanel.cs | 37 +- .../AvalonDock/Resources/Common.xaml | 7 +- .../Resources/DockablePaneStyles.xaml | 8 +- .../Resources/DockingManagerStyles.xaml | 2 +- .../Resources/DocumentPaneStyles.xaml | 43 +- .../Resources/FloatingWindowStyle.xaml | 12 +- .../Resources/NavigatorWindowStyle.xaml | 26 +- .../Resources/OverlayWindowStyle.xaml | 30 +- .../Resources/SpecFrameworkStyles.xaml | 6 + .../AvalonDock/Resources/SpecNET40Styles.xaml | 6 + .../AvalonDock/Themes/aero.normalcolor.xaml | 123 +++-- .../AvalonDock/AvalonDock/Themes/classic.xaml | 29 +- 42 files changed, 1695 insertions(+), 1157 deletions(-) create mode 100644 src/Libraries/AvalonDock/AvalonDock.Themes/AvalonDock.Themes35.csproj delete mode 100644 src/Libraries/AvalonDock/AvalonDock/AlignedImage.cs create mode 100644 src/Libraries/AvalonDock/AvalonDock/AvalonDock35.csproj create mode 100644 src/Libraries/AvalonDock/AvalonDock/ImageEx.cs create mode 100644 src/Libraries/AvalonDock/AvalonDock/Resources/SpecFrameworkStyles.xaml create mode 100644 src/Libraries/AvalonDock/AvalonDock/Resources/SpecNET40Styles.xaml diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/AvalonDock.Themes35.csproj b/src/Libraries/AvalonDock/AvalonDock.Themes/AvalonDock.Themes35.csproj new file mode 100644 index 0000000000..44d249e3b1 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/AvalonDock.Themes35.csproj @@ -0,0 +1,125 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {3836F4A8-4B35-4F5E-BB0F-DAD374297525} + library + Properties + AvalonDock.Themes + AvalonDock.Themes + v3.5 + Client + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + true + full + false + bin\Debug\v35\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\v35\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {87E61430-4243-45F2-B74E-0A4C096CEBF3} + AvalonDock35 + + + + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Resources.Designer.cs b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Resources.Designer.cs index b1b282a8cf..550edbb843 100644 --- a/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Resources.Designer.cs +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Resources.Designer.cs @@ -8,10 +8,10 @@ // //------------------------------------------------------------------------------ -namespace AvalonDock.Themes.Properties -{ - - +namespace AvalonDock.Themes.Properties { + using System; + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -22,48 +22,40 @@ namespace AvalonDock.Themes.Properties [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AvalonDock.Themes.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Settings.Designer.cs b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Settings.Designer.cs index 57f26aa8b7..7a4ed5c849 100644 --- a/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Settings.Designer.cs +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Settings.Designer.cs @@ -8,21 +8,17 @@ // //------------------------------------------------------------------------------ -namespace AvalonDock.Themes.Properties -{ - - +namespace AvalonDock.Themes.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/ExpressionDark.xaml b/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/ExpressionDark.xaml index 0bef6aafde..95eaabfb06 100644 --- a/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/ExpressionDark.xaml +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/ExpressionDark.xaml @@ -283,7 +283,7 @@ x:Name="PART_DragArea" Background="{StaticResource ManagedContentTabItemNormalBackground}" CornerRadius="3,0,0,0" - ContextMenu="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:ContextMenuElement.DockablePane}}}" + > @@ -305,7 +305,7 @@ Style="{StaticResource PaneHeaderCommandStyle}" Command="ad:ManagedContentCommands.Close" Width="13" Height="13" Opacity="0.6"> - + @@ -385,14 +385,14 @@ - + BorderThickness="1,1,1,0" + Padding="5,0,5,4" + Margin="-1,0,2,-4" + CornerRadius="3,3,0,0" + Background="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderBackground}}}"> + @@ -454,7 +455,7 @@ Text="{TemplateBinding Title}" Foreground="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderForeground}}}"/> - + + diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/dev2010.xaml b/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/dev2010.xaml index 1e1751be84..6236aac7f3 100644 --- a/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/dev2010.xaml +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/dev2010.xaml @@ -322,14 +322,13 @@ Background="{StaticResource ManagedContentTabItemNormalBackground}" CornerRadius="0,0,2,2" Padding="1" - ContextMenu="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:ContextMenuElement.DockablePane}}}" > - + @@ -517,12 +516,12 @@ TextWrapping="NoWrap" Text="{TemplateBinding Title}" Foreground="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderForeground}}}"/> - + @@ -604,7 +603,7 @@ - + @@ -724,7 +723,7 @@ - + + CornerRadius="2"> @@ -1188,9 +1186,7 @@ + Background="{TemplateBinding Background}"> @@ -1202,7 +1198,6 @@ - diff --git a/src/Libraries/AvalonDock/AvalonDock/AlignedImage.cs b/src/Libraries/AvalonDock/AvalonDock/AlignedImage.cs deleted file mode 100644 index ecafc7182f..0000000000 --- a/src/Libraries/AvalonDock/AvalonDock/AlignedImage.cs +++ /dev/null @@ -1,187 +0,0 @@ -//Copyright (c) 2007-2010, Adolfo Marinucci -//All rights reserved. - -//Redistribution and use in source and binary forms, with or without modification, -//are permitted provided that the following conditions are met: -// -//* Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -//* Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -//* Neither the name of Adolfo Marinucci nor the names of its contributors may -// be used to endorse or promote products derived from this software without -// specific prior written permission. -// -//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Controls; -using System.Windows; -using System.Windows.Media; - -namespace AvalonDock -{ - public class AlignedImage : Decorator - { - public AlignedImage() - { - this.LayoutUpdated += new EventHandler(OnLayoutUpdated); - } - - protected override System.Windows.Size MeasureOverride(Size constraint) - { - Size desideredSize = new Size(); - - if (Child != null) - { - Child.Measure(constraint); - - PresentationSource ps = PresentationSource.FromVisual(this); - if (ps != null) - { - Matrix fromDevice = ps.CompositionTarget.TransformFromDevice; - - Vector pixelSize = new Vector(Child.DesiredSize.Width, Child.DesiredSize.Height); - Vector measureSizeV = fromDevice.Transform(pixelSize); - desideredSize = new Size(measureSizeV.X, measureSizeV.Y); - } - } - - return desideredSize; - } - - protected override Size ArrangeOverride(Size arrangeBounds) - { - Size finalSize = new Size(); - - if (Child != null) - { - _pixelOffset = GetPixelOffset(); - Child.Arrange(new Rect(_pixelOffset, Child.DesiredSize)); - finalSize = arrangeBounds; - } - - return finalSize; - } - - private Point _pixelOffset; - - private void OnLayoutUpdated(object sender, EventArgs e) - { - // This event just means that layout happened somewhere. However, this is - // what we need since layout anywhere could affect our pixel positioning. - Point pixelOffset = GetPixelOffset(); - if (!AreClose(pixelOffset, _pixelOffset)) - { - InvalidateArrange(); - } - } - - // Gets the matrix that will convert a point from "above" the - // coordinate space of a visual into the the coordinate space - // "below" the visual. - private Matrix GetVisualTransform(Visual v) - { - if (v != null) - { - Matrix m = Matrix.Identity; - - Transform transform = VisualTreeHelper.GetTransform(v); - if (transform != null) - { - Matrix cm = transform.Value; - m = Matrix.Multiply(m, cm); - } - - Vector offset = VisualTreeHelper.GetOffset(v); - m.Translate(offset.X, offset.Y); - - return m; - } - - return Matrix.Identity; - } - - private Point TryApplyVisualTransform(Point point, Visual v, bool inverse, bool throwOnError, out bool success) - { - success = true; - if (v != null) - { - Matrix visualTransform = GetVisualTransform(v); - if (inverse) - { - if (!throwOnError && !visualTransform.HasInverse) - { - success = false; - return new Point(0, 0); - } - visualTransform.Invert(); - } - point = visualTransform.Transform(point); - } - return point; - } - - private Point ApplyVisualTransform(Point point, Visual v, bool inverse) - { - bool success = true; - return TryApplyVisualTransform(point, v, inverse, true, out success); - } - - private Point GetPixelOffset() - { - Point pixelOffset = new Point(); - - PresentationSource ps = PresentationSource.FromVisual(this); - if (ps != null) - { - Visual rootVisual = ps.RootVisual; - - // Transform (0,0) from this element up to pixels. - pixelOffset = this.TransformToAncestor(rootVisual).Transform(pixelOffset); - pixelOffset = ApplyVisualTransform(pixelOffset, rootVisual, false); - pixelOffset = ps.CompositionTarget.TransformToDevice.Transform(pixelOffset); - - // Round the origin to the nearest whole pixel. - pixelOffset.X = Math.Round(pixelOffset.X); - pixelOffset.Y = Math.Round(pixelOffset.Y); - - // Transform the whole-pixel back to this element. - pixelOffset = ps.CompositionTarget.TransformFromDevice.Transform(pixelOffset); - pixelOffset = ApplyVisualTransform(pixelOffset, rootVisual, true); - pixelOffset = rootVisual.TransformToDescendant(this).Transform(pixelOffset); - } - - return pixelOffset; - } - - private bool AreClose(Point point1, Point point2) - { - return AreClose(point1.X, point2.X) && AreClose(point1.Y, point2.Y); - } - - private bool AreClose(double value1, double value2) - { - if (value1 == value2) - { - return true; - } - double delta = value1 - value2; - return ((delta < 1.53E-06) && (delta > -1.53E-06)); - } - - } -} diff --git a/src/Libraries/AvalonDock/AvalonDock/AvalonDock.csproj b/src/Libraries/AvalonDock/AvalonDock/AvalonDock.csproj index 463c98c348..06887dc446 100644 --- a/src/Libraries/AvalonDock/AvalonDock/AvalonDock.csproj +++ b/src/Libraries/AvalonDock/AvalonDock/AvalonDock.csproj @@ -26,22 +26,23 @@ true Full false - DEBUG;TRACE + TRACE;DEBUG;NET4 prompt 4 pdbonly true - TRACE + TRACE;NET4 prompt 4 + bin\Release\AvalonDock.XML true - AvalonDock.snk + ..\..\..\Main\ICSharpCode.SharpDevelop.snk False @@ -72,6 +73,7 @@ + @@ -148,7 +150,6 @@ MSBuild:Compile Designer - @@ -251,6 +252,10 @@ + + + + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock/Converters.cs b/src/Libraries/AvalonDock/AvalonDock/Converters.cs index feae586935..3856ec73b3 100644 --- a/src/Libraries/AvalonDock/AvalonDock/Converters.cs +++ b/src/Libraries/AvalonDock/AvalonDock/Converters.cs @@ -101,11 +101,13 @@ namespace AvalonDock var img = new BitmapImage(iconUri); if (img != null) { - return new Image() + return new Image() { - UseLayoutRounding = true, - Width = width, - Source = img +#if NET4 + UseLayoutRounding = true, +#endif + Width = width, + Source = img }; } } @@ -115,13 +117,15 @@ namespace AvalonDock var img = value as BitmapImage; return new Image() { +#if NET4 UseLayoutRounding = true, +#endif Width = width, Source = new BitmapImage(img.UriSource) }; - } + return value; } diff --git a/src/Libraries/AvalonDock/AvalonDock/DockableContent.cs b/src/Libraries/AvalonDock/AvalonDock/DockableContent.cs index ecbec60d80..322917f0ea 100644 --- a/src/Libraries/AvalonDock/AvalonDock/DockableContent.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DockableContent.cs @@ -702,14 +702,12 @@ namespace AvalonDock if (e.Cancel) return false; - - DockingManager oldManager = Manager; - - if (e.Cancel) - return false; - - ((DockablePane)ContainerPane).RemoveContent( - ContainerPane.Items.IndexOf(this)); + + if (ContainerPane != null) + { + ContainerPane.RemoveContent( + ContainerPane.Items.IndexOf(this)); + } OnClosed(); return true; @@ -870,6 +868,12 @@ namespace AvalonDock "FloatingWindowSize", new SizeConverter().ConvertToInvariantString(FloatingWindowSize)); } + if (!FlyoutWindowSize.IsEmpty) + { + storeWriter.WriteAttributeString( + "FlyoutWindowSize", new SizeConverter().ConvertToInvariantString(FlyoutWindowSize)); + } + if (SavedStateAndPosition != null) { storeWriter.WriteAttributeString( @@ -902,6 +906,8 @@ namespace AvalonDock { if (contentElement.HasAttribute("FloatingWindowSize")) FloatingWindowSize = (Size)(new SizeConverter()).ConvertFromInvariantString(contentElement.GetAttribute("FloatingWindowSize")); + if (contentElement.HasAttribute("FlyoutWindowSize")) + FlyoutWindowSize = (Size)(new SizeConverter()).ConvertFromInvariantString(contentElement.GetAttribute("FlyoutWindowSize")); Size effectiveSize = new Size(0d, 0d); if (contentElement.HasAttribute("EffectiveSize")) @@ -918,7 +924,7 @@ namespace AvalonDock Guid containerPaneGuid = Guid.Empty; if (contentElement.HasAttribute("ContainerPaneID")) { - containerPaneGuid = Guid.Parse(contentElement.GetAttribute("ContainerPaneID")); + containerPaneGuid = new Guid(contentElement.GetAttribute("ContainerPaneID")); if (Manager != null) { @@ -950,5 +956,54 @@ namespace AvalonDock } } #endregion + + #region FlyoutWindowSize + + /// + /// FlyoutWindowSize Dependency Property + /// + public static readonly DependencyProperty FlyoutWindowSizeProperty = + DependencyProperty.Register("FlyoutWindowSize", typeof(Size), typeof(DockableContent), + new FrameworkPropertyMetadata((Size)Size.Empty, + new PropertyChangedCallback(OnFlyoutWindowSizeChanged), + new CoerceValueCallback(CoerceFlyoutWindowSizeValue))); + + /// + /// Gets or sets the FlyoutWindowSize property. This dependency property + /// indicates size of the window hosting this content when is in auto-hidden state. + /// This property is persisted when layout of the container is saved. + /// + public Size FlyoutWindowSize + { + get { return (Size)GetValue(FlyoutWindowSizeProperty); } + set { SetValue(FlyoutWindowSizeProperty, value); } + } + + /// + /// Handles changes to the FlyoutWindowSize property. + /// + private static void OnFlyoutWindowSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + } + + + /// + /// Coerces the FlyoutWindowSize value. + /// + private static object CoerceFlyoutWindowSizeValue(DependencyObject d, object value) + { + //coerces size to 100.0-100.0 + Size newSize = (Size)value; + + newSize.Width = Math.Max(100.0, newSize.Width); + newSize.Height = Math.Max(100.0, newSize.Height); + + return newSize; + } + + #endregion + + + } } diff --git a/src/Libraries/AvalonDock/AvalonDock/DockableFloatingWindow.cs b/src/Libraries/AvalonDock/AvalonDock/DockableFloatingWindow.cs index be1fc8fdd1..669ad795ce 100644 --- a/src/Libraries/AvalonDock/AvalonDock/DockableFloatingWindow.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DockableFloatingWindow.cs @@ -59,10 +59,6 @@ namespace AvalonDock new CoerceValueCallback(OnCoerceValueContentProperty))); } - //Pane _previousPane = null; - - //int _arrayIndexPreviousPane = -1; - internal DockableFloatingWindow(DockingManager manager) : base(manager) diff --git a/src/Libraries/AvalonDock/AvalonDock/DockablePane.cs b/src/Libraries/AvalonDock/AvalonDock/DockablePane.cs index 9f148670fb..a837c8897b 100644 --- a/src/Libraries/AvalonDock/AvalonDock/DockablePane.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DockablePane.cs @@ -39,6 +39,8 @@ using System.Diagnostics; using System.ComponentModel; using System.Collections; using System.Linq; +using System.Windows.Threading; +using System.Threading; namespace AvalonDock { @@ -108,14 +110,11 @@ namespace AvalonDock protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { - if (e.NewItems != null) + Items.Cast().ForEach(c => { - e.NewItems.Cast().ForEach(c => - { - if (c.State == DockableContentState.None) - c.SetStateToDock(); - }); - } + if (c.State == DockableContentState.None) + c.SetStateToDock(); + }); UpdateCanAutohideProperty(); base.OnItemsChanged(e); @@ -176,7 +175,20 @@ namespace AvalonDock _partHeader.MouseRightButtonDown += (s, e) => { - OpenOptionsMenu(null); e.Handled = true; + if (_partHeader.ContextMenu == null) + { + FocusContent(); + if (_partHeader.ContextMenu == null) + { + Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(delegate + { + OpenOptionsMenu(null); + })); + + e.Handled = true; + } + + } }; } @@ -233,7 +245,7 @@ namespace AvalonDock flag = flag && ((c.DockableStyle & DockableStyle.AutoHide) > 0); #if DEBUG - Debug.WriteLine("{0} CanAutohide()= {1}", c.Title, flag); + Debug.WriteLine(string.Format("{0} CanAutohide()= {1}", c.Title, flag)); #endif return flag; }) @@ -266,93 +278,108 @@ namespace AvalonDock #region OptionsContextMenu - ContextMenu cxOptions = null; - /// - /// Open the option context menu - /// - public bool OpenOptionsMenu(UIElement menuTarget) + public override bool OpenOptionsMenu(UIElement menuTarget) { if (cxOptions == null) { - Debug.Assert(cxOptions == null); cxOptions = TryFindResource(new ComponentResourceKey(typeof(DockingManager), ContextMenuElement.DockablePane)) as ContextMenu; - if (cxOptions != null) - { - cxOptions.Opened += (s, e) => IsOptionsMenuOpen = true; - cxOptions.Closed += (s, e) => IsOptionsMenuOpen = false; - } - } - - if (cxOptions != null) - { - cxOptions.DataContext = this.SelectedItem as DockableContent; - - foreach (MenuItem menuItem in cxOptions.Items.OfType()) - menuItem.CommandTarget = this.SelectedItem as DockableContent; - - if (menuTarget != null) - { - cxOptions.Placement = PlacementMode.Bottom; - cxOptions.PlacementTarget = menuTarget; - } - else - { - cxOptions.Placement = PlacementMode.MousePoint; - cxOptions.PlacementTarget = this; - } - - FocusContent(); - cxOptions.IsOpen = true; - } - - return (cxOptions != null && cxOptions.IsOpen); - } - - /// - /// Close the options context menu - /// - public void CloseOptionsMenu() - { - if (cxOptions != null) - { - cxOptions.IsOpen = false; - cxOptions = null; } - } - /// - /// Gets a value indicating if the options context menu is open - /// - public bool IsOptionsMenuOpen - { - get { return (bool)GetValue(IsOptionsMenuOpenProperty); } - protected set { SetValue(IsOptionsMenuOpenPropertyKey, value); } - } - - // Using a DependencyProperty as the backing store for IsOptionsMenuOpen. This enables animation, styling, binding, etc... - static readonly DependencyPropertyKey IsOptionsMenuOpenPropertyKey = - DependencyProperty.RegisterReadOnly("IsOptionsMenuOpen", typeof(bool), typeof(DockablePane), new UIPropertyMetadata(false)); - - public static readonly DependencyProperty IsOptionsMenuOpenProperty = IsOptionsMenuOpenPropertyKey.DependencyProperty; - - + return base.OpenOptionsMenu(menuTarget); + } + + //ContextMenu cxOptions = null; + + ///// + ///// Open the option context menu + ///// + ///// Target element under which context menu will be shown. Pass null if context menu + ///// should be shown at mouse position. + ///// True if context menu resource was found and open, false otherwise. + //public bool OpenOptionsMenu(UIElement menuTarget) + //{ + // if (cxOptions == null) + // { + // cxOptions = TryFindResource(new ComponentResourceKey(typeof(DockingManager), ContextMenuElement.DockablePane)) as ContextMenu; + // if (cxOptions != null) + // { + // cxOptions.Opened += (s, e) => UpdateIsOptionsMenuOpen(); + // cxOptions.Closed += (s, e) => UpdateIsOptionsMenuOpen(); + // } + // } + + // if (cxOptions != null) + // { + // cxOptions.DataContext = this.SelectedItem as DockableContent; + + // foreach (MenuItem menuItem in cxOptions.Items.OfType()) + // menuItem.CommandTarget = this.SelectedItem as DockableContent; + + // if (menuTarget != null) + // { + // cxOptions.Placement = PlacementMode.Bottom; + // cxOptions.PlacementTarget = menuTarget; + // } + // else + // { + // cxOptions.Placement = PlacementMode.MousePoint; + // cxOptions.PlacementTarget = this; + // } + + // FocusContent(); + // cxOptions.IsOpen = true; + // } + + // return (cxOptions != null && cxOptions.IsOpen); + //} + + ///// + ///// Close the options context menu + ///// + //public void CloseOptionsMenu() + //{ + // if (cxOptions != null) + // { + // cxOptions.IsOpen = false; + // cxOptions = null; + // } + //} + + ///// + ///// Gets a value indicating if the options context menu is open + ///// + //public bool IsOptionsMenuOpen + //{ + // get { return (bool)GetValue(IsOptionsMenuOpenProperty); } + // protected set { SetValue(IsOptionsMenuOpenPropertyKey, value); } + //} + + //// Using a DependencyProperty as the backing store for IsOptionsMenuOpen. This enables animation, styling, binding, etc... + //static readonly DependencyPropertyKey IsOptionsMenuOpenPropertyKey = + // DependencyProperty.RegisterReadOnly("IsOptionsMenuOpen", typeof(bool), typeof(DockablePane), new UIPropertyMetadata(false)); + + //public static readonly DependencyProperty IsOptionsMenuOpenProperty = IsOptionsMenuOpenPropertyKey.DependencyProperty; + + //void UpdateIsOptionsMenuOpen() + //{ + // if (cxOptions != null) + // { + // var selectedContent = cxOptions.DataContext as DockableContent; + + // if (selectedContent != null) + // { + // (selectedContent.ContainerPane as DockablePane).IsOptionsMenuOpen = + // cxOptions.IsOpen; + // } + // } + //} #endregion #region Mouse management - void FocusContent() - { - ManagedContent selectedContent = SelectedItem as ManagedContent; - if (selectedContent != null)// && selectedContent.Content is UIElement) - { - UIElement internalContent = selectedContent.Content as UIElement; - bool res = Focus(); - //Keyboard.Focus(internalContent); - selectedContent.Activate(); - } - } + Point ptStartDrag; bool isMouseDown = false; diff --git a/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs b/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs index 85ce9b84ab..c130ba6ac8 100644 --- a/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs @@ -427,21 +427,6 @@ namespace AvalonDock } } - /// - /// Gets an array of all dockable contents currenty managed - /// - //public DockableContent[] DockableContents - //{ - // get - // { - // List contents = FindContents(); - - // foreach (DockableContent content in HiddenContents) - // contents.Add(content); - - // return contents.ToArray(); - // } - //} #region DockableContents /// @@ -480,7 +465,7 @@ namespace AvalonDock /// /// Gets the DockableContents property. This dependency property - /// retrives the collection of that are bound to + /// retrives the collection of that are bound to /// public ManagedContentCollection Documents { @@ -490,18 +475,6 @@ namespace AvalonDock #endregion - - ///// - ///// Gets an array of all document contents - ///// - //public DocumentContent[] Documents - //{ - // get - // { - // return FindContents().ToArray(); - // } - //} - #region Documents Source /// @@ -535,32 +508,17 @@ namespace AvalonDock } } - void DocumentsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { + void DocumentsSourceCollectionChanged( + object sender, + NotifyCollectionChangedEventArgs e) + { if (e.Action == NotifyCollectionChangedAction.Reset) { //close first documents that do not belong to the MainDocumentPane DocumentContent[] docs = this.Documents.ToArray(); - List documentsToCloseFirst = new List(); - foreach (DocumentContent doc in docs) - { - if (doc.Parent is DocumentPane) - { - if ((doc.Parent as DocumentPane).IsMainDocumentPane == false) - { - documentsToCloseFirst.Add(doc); - } - } - } - - foreach (DocumentContent doc in documentsToCloseFirst) - { - doc.InternalClose(); - } - - foreach (DocumentContent doc in docs) - doc.InternalClose(); + docs.Where(d => ((DocumentPane)d.Parent).IsMainDocumentPane.GetValueOrDefault()).ForEach(d => d.InternalClose()); + docs.Where(d => d.Parent != null && !((DocumentPane)d.Parent).IsMainDocumentPane.GetValueOrDefault()).ForEach(d => d.InternalClose()); } if (e.OldItems != null && @@ -590,7 +548,6 @@ namespace AvalonDock if (MainDocumentPane == null) throw new InvalidOperationException("DockingManager must have at least a DocumentPane to host documents"); - int iInsertIndex = e.NewStartingIndex; foreach (object newDoc in e.NewItems) { if (newDoc is DocumentContent) @@ -601,7 +558,7 @@ namespace AvalonDock ((DocumentPane)documentToAdd.Parent).Items.Clear(); } - MainDocumentPane.Items.Insert(iInsertIndex, documentToAdd); + MainDocumentPane.Items.Add(documentToAdd); } else if (newDoc is UIElement) //limit objects to be at least framework elements { @@ -610,14 +567,14 @@ namespace AvalonDock Content = newDoc }; - MainDocumentPane.Items.Insert(iInsertIndex, documentToAdd); + MainDocumentPane.Items.Add(documentToAdd); } else throw new InvalidOperationException(string.Format("Unable to add type {0} as DocumentContent", newDoc)); - - iInsertIndex++; } } + + RefreshContents(); } internal void HandleDocumentClose(DocumentContent contentClosed) @@ -754,8 +711,13 @@ namespace AvalonDock RefreshContents(); } + bool _allowRefreshContents = true; + internal void RefreshContents() { + if (!_allowRefreshContents) + return; + var contentsFoundUnderMe = new LogicalTreeAdapter(this).Descendants().Where(d => d.Item is ManagedContent).Select(d => d.Item).Cast(); var contentsFoundInFloatingMode = _floatingWindows.SelectMany(d => d.HostedPane.Items.Cast()); DockableContent contentFoundInFlyoutMode = null; @@ -1077,7 +1039,7 @@ namespace AvalonDock navigatorWindow.Height = this.ActualHeight; navigatorWindow.ShowActivated = false; navigatorWindow.Show(); - navigatorWindow.Focus(); + //navigatorWindow.Focus(); } void HideNavigatorWindow() @@ -1102,12 +1064,13 @@ namespace AvalonDock { ShowNavigatorWindow(); } - - navigatorWindow.MoveNextSelectedContent(); + e.Handled = true; } - else + else if (NavigatorWindow.IsKeyHandled(e.Key)) + { HideNavigatorWindow(); + } base.OnKeyDown(e); @@ -1119,93 +1082,38 @@ namespace AvalonDock bool _navigatorWindowIsVisible = navigatorWindow != null ? navigatorWindow.IsVisible : false; Debug.WriteLine(string.Format("OnKeyUp {0} CtrlDn={1}", e.Key, isCtrlDown)); - if (e.Key != Key.Tab || !isCtrlDown) - HideNavigatorWindow(); - - base.OnKeyUp(e); - } - - //void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e) - //{ - // if (e.Command == ShowNavigatorWindowCommand && ((Keyboard.Modifiers & ModifierKeys.Control)>0) ) - // { - // ShowNavigatorWindow(); - // e.Handled = true; - // } - // else if (e.Command == ShowDocumentNavigatorWindowCommand && ((Keyboard.Modifiers & ModifierKeys.Shift) > 0)) - // { - // ShowDocumentNavigatorWindow(); - // e.Handled = true; - // } - - //} - - //void OnCanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) - //{ - // e.CanExecute = true; - //} - - - //private static RoutedUICommand showDocumentNavigatorCommand = null; - - ///// - ///// Get the command to show document navigator window - ///// - //public static RoutedUICommand ShowDocumentNavigatorWindowCommand - //{ - // get - // { - // lock (syncRoot) - // { - // if (null == showDocumentNavigatorCommand) - // { - // showDocumentNavigatorCommand = new RoutedUICommand("S_how document navigator window", "DocumentNavigator", typeof(DockingManager)); - // showDocumentNavigatorCommand.InputGestures.Add(new KeyGesture(Key.Tab, ModifierKeys.Shift)); - // } - - // } - // return showDocumentNavigatorCommand; - // } - //} - - //DocumentNavigatorWindow documentNavigatorWindow = null; - - //void ShowDocumentNavigatorWindow() - //{ - // HideDocumentNavigatorWindow(); - - // //if (documentNavigatorWindow == null) - // { - // documentNavigatorWindow = new DocumentNavigatorWindow(this); - // documentNavigatorWindow.Owner = Window.GetWindow(this); - // } - - // if (MainDocumentPane == null) - // return; + if (NavigatorWindow.IsKeyHandled(e.Key) && isCtrlDown) + { + if (!_navigatorWindowIsVisible && e.Key == Key.Tab) + { + ShowNavigatorWindow(); + } - // Point locMainDocumentPane = MainDocumentPane.PointToScreenDPI(new Point()); - // documentNavigatorWindow.Left = locMainDocumentPane.X; - // documentNavigatorWindow.Top = locMainDocumentPane.Y; - // documentNavigatorWindow.Width = MainDocumentPane.ActualWidth; - // documentNavigatorWindow.Height = MainDocumentPane.ActualHeight; - // documentNavigatorWindow.Show(); - // documentNavigatorWindow.Focus(); - //} + if (_navigatorWindowIsVisible) + navigatorWindow.HandleKey(e.Key); + } + else + { + if (_navigatorWindowIsVisible) + { + if (navigatorWindow.Documents.CurrentItem != null) + { + var docSelected = (navigatorWindow.Documents.CurrentItem as NavigatorWindowDocumentItem).ItemContent as DocumentContent; + docSelected.Activate(); + } + else if (navigatorWindow.DockableContents.CurrentItem != null) + { + var cntSelected = (navigatorWindow.DockableContents.CurrentItem as NavigatorWindowItem).ItemContent as DockableContent; + cntSelected.Activate(); + } - //void HideDocumentNavigatorWindow() - //{ - // //if (documentNavigatorWindow != null) - // //{ - // // documentNavigatorWindow.Hide(); - - // // //don't close this window to be more responsive - // // documentNavigatorWindow.Close(); - // // documentNavigatorWindow = null; - // //} - //} + HideNavigatorWindow(); + } + } - //#endregion + base.OnKeyUp(e); + } #region DockablePane operations /// @@ -1268,7 +1176,9 @@ namespace AvalonDock toplevelPanel.Orientation = requestedOrientation; FrameworkElement contentElement = Content as FrameworkElement; - Content = toplevelPanel; + + _allowRefreshContents = false; + Content = null; if (anchor == AnchorStyle.Left || anchor == AnchorStyle.Top) @@ -1281,6 +1191,9 @@ namespace AvalonDock toplevelPanel.Children.Add(paneToAnchor); toplevelPanel.InsertChildRelativeTo(contentElement, paneToAnchor, false); } + + _allowRefreshContents = true; + Content = toplevelPanel; } else { @@ -1329,16 +1242,13 @@ namespace AvalonDock } //refresh contents state - foreach (ManagedContent content in paneToAnchor.Items) - { - if (content is DockableContent) + paneToAnchor.Items.OfType().ForEach(dc => { - ((DockableContent)content).SetStateToDock(); - } - } + dc.SetStateToDock(); + }); - paneToAnchor.Focus(); + //paneToAnchor.Focus(); toplevelPanel.InvalidateMeasure(); } @@ -1533,7 +1443,7 @@ namespace AvalonDock //than set the new anchor style for the pane paneToAnchor.Anchor = anchor; - paneToAnchor.Focus(); + //paneToAnchor.Focus(); } /// @@ -1632,20 +1542,20 @@ namespace AvalonDock relativePane, true); } - if (relativePaneContainer.Orientation == Orientation.Horizontal) - { - Size desideredSize = ResizingPanel.GetEffectiveSize(paneToAnchor); - double approxStarForNewPane = desideredSize.Width / relativePaneContainer.ActualWidth; - approxStarForNewPane = Math.Min(approxStarForNewPane, 1.0); - paneToAnchor.SetValue(ResizingPanel.ResizeWidthProperty, new GridLength(approxStarForNewPane, GridUnitType.Star)); - } + //if (relativePaneContainer.Orientation == Orientation.Horizontal) + //{ + // Size desideredSize = ResizingPanel.GetEffectiveSize(paneToAnchor); + // double approxStarForNewPane = desideredSize.Width / relativePaneContainer.ActualWidth; + // approxStarForNewPane = Math.Min(approxStarForNewPane, 1.0); + // paneToAnchor.SetValue(ResizingPanel.ResizeWidthProperty, new GridLength(approxStarForNewPane, GridUnitType.Star)); + //} } relativePaneContainer.InvalidateMeasure(); } #endregion - paneToAnchor.Focus(); + //paneToAnchor.Focus(); //(paneToAnchor.SelectedItem as ManagedContent).Activate(); //if (paneToAnchor.SelectedItem is DocumentContent) @@ -1766,7 +1676,7 @@ namespace AvalonDock if (relativePaneContainer != null) relativePaneContainer.AdjustPanelSizes(); - paneToAnchor.Focus(); + //paneToAnchor.Focus(); } #region DropInto methods @@ -1788,19 +1698,20 @@ namespace AvalonDock { //transfer tha contents of dragged pane (conatined in a FloatingWindow) //to the pane which user select - ManagedContent contentToFocus = null; + //ManagedContent contentToFocus = null; while (paneDragged.Items.Count > 0) { - ManagedContent contentToTransfer = paneDragged.RemoveContent(0); + var contentToTransfer = paneDragged.RemoveContent(0); paneToDropInto.Items.Insert(0, contentToTransfer); - contentToFocus = contentToTransfer; + //contentToFocus = contentToTransfer; + contentToTransfer.Activate(); } - - paneToDropInto.SelectedIndex = 0; - paneToDropInto.Focus(); - if (contentToFocus != null) - contentToFocus.Activate(); + + //paneToDropInto.SelectedIndex = 0; + //paneToDropInto.Focus(); + //if (contentToFocus != null) + // contentToFocus.Activate(); } internal void DropInto(DockablePane paneDragged, DocumentPane paneToDropInto) { @@ -1812,18 +1723,20 @@ namespace AvalonDock //to Dock (using Dock() method of class DockablePane). while (paneDragged.Items.Count > 0) { - ManagedContent contentToTransfer = paneDragged.RemoveContent(0); + var contentToTransfer = paneDragged.RemoveContent(0); paneToDropInto.Items.Add(contentToTransfer); - DockableContent dockContentToTransfer = contentToTransfer as DockableContent; + var dockContentToTransfer = contentToTransfer as DockableContent; if (dockContentToTransfer != null) dockContentToTransfer.SetStateToDocument(); + + contentToTransfer.Activate(); } - paneToDropInto.SelectedIndex = paneToDropInto.Items.Count - 1; - paneToDropInto.Focus(); + //paneToDropInto.SelectedIndex = paneToDropInto.Items.Count - 1; + //paneToDropInto.Focus(); } internal void DropInto(DockablePane paneDragged, DockablePane paneToDropInto) { @@ -1844,7 +1757,7 @@ namespace AvalonDock paneToDropInto.SelectedIndex = paneToDropInto.Items.Count - 1; - paneToDropInto.Focus(); + //paneToDropInto.Focus(); } #endregion @@ -2175,6 +2088,7 @@ namespace AvalonDock if (floating) { DocumentFloatingWindow floatingWindow = new DocumentFloatingWindow(this); + floatingWindow.Owner = Window.GetWindow(this); floatingWindow.Content = document; floatingWindow.Show(); } @@ -2286,6 +2200,11 @@ namespace AvalonDock else { //if no suitable pane was found create e new one on the fly + if (content.ContainerPane != null) + { + content.ContainerPane.RemoveContent(content); + } + DockablePane pane = new DockablePane(); pane.Items.Add(content); Anchor(pane, desideredAnchor); @@ -2370,9 +2289,9 @@ namespace AvalonDock ResizingPanel.SetEffectiveSize(dockParent, new Size(200, 0.0)); } else if (content.ActualWidth == 0.0 && ( - dockParent.Anchor == AnchorStyle.Left || dockParent.Anchor == AnchorStyle.Right)) + dockParent.Anchor == AnchorStyle.Top || dockParent.Anchor == AnchorStyle.Bottom)) { - ResizingPanel.SetResizeWidth(dockParent, new GridLength(200)); + ResizingPanel.SetResizeHeight(dockParent, new GridLength(200)); ResizingPanel.SetEffectiveSize(dockParent, new Size(200, 0.0)); } @@ -2628,10 +2547,13 @@ namespace AvalonDock #region Anchor Style Update routines protected override Size ArrangeOverride(Size arrangeBounds) { - //at the moment this is the easy way to get anchor properties always updated + //at the moment this is the easiest way to get anchor properties always updated if (this.Content as ResizingPanel != null) UpdateAnchorStyle(); + //hide the flyout window because transform could be changed + HideFlyoutWindow(); + return base.ArrangeOverride(arrangeBounds); } @@ -2741,10 +2663,10 @@ namespace AvalonDock { if (_flyoutWindow != null && !_flyoutWindow.IsClosing) { - _flyoutWindow.Height = 0.0; - _flyoutWindow.Width = 0.0; - _flyoutWindow.Close(); + var flWindow = _flyoutWindow; _flyoutWindow = null; + flWindow.Closing -= new System.ComponentModel.CancelEventHandler(OnFlyoutWindowClosing); + flWindow.Close(); } } @@ -2770,13 +2692,13 @@ namespace AvalonDock //_flyoutWindow.KeepWindowOpen(); return; } - //hide previous create window + + //hide previous window HideFlyoutWindow(); //select this content in the referenced pane content.ContainerPane.SelectedItem = content; - if (_wndInteropWrapper == null) { _wndInteropWrapper = new WindowInteropWrapper(parentWindow); @@ -2819,8 +2741,11 @@ namespace AvalonDock /// void OnFlyoutWindowClosing(object sender, System.ComponentModel.CancelEventArgs e) { - _flyoutWindow.Closing -= new System.ComponentModel.CancelEventHandler(OnFlyoutWindowClosing); - _flyoutWindow.Owner = null; + if (_flyoutWindow != null) + { + _flyoutWindow.Closing -= new System.ComponentModel.CancelEventHandler(OnFlyoutWindowClosing); + _flyoutWindow.Owner = null; + } } /// @@ -2839,70 +2764,86 @@ namespace AvalonDock { if (_flyoutWindow == null) return; - - double leftTabsWidth = FlowDirection == FlowDirection.LeftToRight ? _leftAnchorTabPanel.ActualWidth : _rightAnchorTabPanel.ActualWidth; - double rightTabsWidth = FlowDirection == FlowDirection.LeftToRight ? _rightAnchorTabPanel.ActualWidth : _leftAnchorTabPanel.ActualWidth; - double topTabsHeight = _topAnchorTabPanel.ActualHeight; - double bottomTabsHeight = _bottomAnchorTabPanel.ActualHeight; + if (_flyoutWindow.ReferencedPane == null) + return; + if (_flyoutWindow.ReferencedPane.SelectedItem == null) + return; + + var actualSize = this.TransformedActualSize(); + + double leftTabsWidth = FlowDirection == FlowDirection.LeftToRight ? _leftAnchorTabPanel.TransformedActualSize().Width : _rightAnchorTabPanel.TransformedActualSize().Width; + double rightTabsWidth = FlowDirection == FlowDirection.LeftToRight ? _rightAnchorTabPanel.TransformedActualSize().Width : _leftAnchorTabPanel.TransformedActualSize().Width; + double topTabsHeight = _topAnchorTabPanel.TransformedActualSize().Height; + double bottomTabsHeight = _bottomAnchorTabPanel.TransformedActualSize().Height; + bool hOrientation = _flyoutWindow.ReferencedPane.Anchor == AnchorStyle.Right || _flyoutWindow.ReferencedPane.Anchor == AnchorStyle.Left; Point locDockingManager = HelperFunc.PointToScreenWithoutFlowDirection(this, new Point()); Point locContent = HelperFunc.PointToScreenWithoutFlowDirection(Content as FrameworkElement, new Point()); - double resWidth = initialSetup ? ResizingPanel.GetResizeWidth(_flyoutWindow.ReferencedPane).Value : _flyoutWindow.Width; - double resHeight = initialSetup ? ResizingPanel.GetResizeHeight(_flyoutWindow.ReferencedPane).Value : _flyoutWindow.Height; + Size initialSetupFlyoutWindowSize = Size.Empty; + initialSetupFlyoutWindowSize = (_flyoutWindow.ReferencedPane.SelectedItem as DockableContent).FlyoutWindowSize; + + if (hOrientation && initialSetupFlyoutWindowSize.Width <= 0.0) + initialSetupFlyoutWindowSize = ResizingPanel.GetEffectiveSize(_flyoutWindow.ReferencedPane.ReferencedPane); + + if (!hOrientation && initialSetupFlyoutWindowSize.Height <= 0.0) + initialSetupFlyoutWindowSize = ResizingPanel.GetEffectiveSize(_flyoutWindow.ReferencedPane.ReferencedPane); + + initialSetupFlyoutWindowSize = this.TransformSize(initialSetupFlyoutWindowSize); + + double resWidth = initialSetup ? initialSetupFlyoutWindowSize.Width : _flyoutWindow.Width; + double resHeight = initialSetup ? initialSetupFlyoutWindowSize.Height : _flyoutWindow.Height; - if (_flyoutWindow.ReferencedPane.Anchor == AnchorStyle.Right) { + _flyoutWindow.MaxWidth = actualSize.Width - rightTabsWidth; + _flyoutWindow.MaxHeight = actualSize.Height - topTabsHeight - bottomTabsHeight; + _flyoutWindow.Top = locDockingManager.Y + topTabsHeight; - _flyoutWindow.Height = this.ActualHeight - topTabsHeight - bottomTabsHeight; + _flyoutWindow.Height = _flyoutWindow.MaxHeight; - _flyoutWindow.MaxWidth = ActualWidth - rightTabsWidth; - _flyoutWindow.MaxHeight = ActualHeight; if (initialSetup) { - _flyoutWindow.Left = FlowDirection == FlowDirection.LeftToRight ? locDockingManager.X + this.ActualWidth - rightTabsWidth : locDockingManager.X + leftTabsWidth; + _flyoutWindow.Left = (FlowDirection == FlowDirection.LeftToRight ? locDockingManager.X + actualSize.Width - rightTabsWidth : locDockingManager.X + leftTabsWidth); _flyoutWindow.Width = 0.0; _flyoutWindow.TargetWidth = resWidth; } else { if (!_flyoutWindow.IsOpening && !_flyoutWindow.IsClosing) - _flyoutWindow.Left = FlowDirection == FlowDirection.LeftToRight ? locDockingManager.X + this.ActualWidth - rightTabsWidth - _flyoutWindow.Width : locDockingManager.X + leftTabsWidth; + _flyoutWindow.Left = (FlowDirection == FlowDirection.LeftToRight ? locDockingManager.X + actualSize.Width - rightTabsWidth - _flyoutWindow.Width : locDockingManager.X + leftTabsWidth); } } if (_flyoutWindow.ReferencedPane.Anchor == AnchorStyle.Left) { + _flyoutWindow.MaxWidth = actualSize.Width - leftTabsWidth; + _flyoutWindow.MaxHeight = actualSize.Height - topTabsHeight - bottomTabsHeight; + _flyoutWindow.Top = locDockingManager.Y + topTabsHeight; - //_flyoutWindow.Top = locContent.Y; - _flyoutWindow.Height = this.ActualHeight - topTabsHeight - bottomTabsHeight; - //_flyoutWindow.Height = ((FrameworkElement)this.Content).ActualHeight; + _flyoutWindow.Height = _flyoutWindow.MaxHeight; - _flyoutWindow.MaxWidth = ActualWidth - leftTabsWidth; - _flyoutWindow.MaxHeight = ActualHeight; - if (initialSetup) { - _flyoutWindow.Left = FlowDirection == FlowDirection.RightToLeft ? locDockingManager.X + this.ActualWidth - rightTabsWidth : locDockingManager.X + leftTabsWidth; + _flyoutWindow.Left = FlowDirection == FlowDirection.RightToLeft ? locDockingManager.X + actualSize.Width - rightTabsWidth : locDockingManager.X + leftTabsWidth; _flyoutWindow.Width = 0.0; _flyoutWindow.TargetWidth = resWidth; } else { if (!_flyoutWindow.IsOpening && !_flyoutWindow.IsClosing) - _flyoutWindow.Left = FlowDirection == FlowDirection.RightToLeft ? locDockingManager.X + this.ActualWidth - rightTabsWidth - _flyoutWindow.Width : locDockingManager.X + leftTabsWidth; + _flyoutWindow.Left = FlowDirection == FlowDirection.RightToLeft ? locDockingManager.X + actualSize.Width - rightTabsWidth - _flyoutWindow.Width : locDockingManager.X + leftTabsWidth; } } if (_flyoutWindow.ReferencedPane.Anchor == AnchorStyle.Top) { - _flyoutWindow.Left = locDockingManager.X + leftTabsWidth; - _flyoutWindow.Width = this.ActualWidth - rightTabsWidth -leftTabsWidth; - - _flyoutWindow.MaxWidth = ActualWidth; - _flyoutWindow.MaxHeight = ActualHeight - topTabsHeight; + _flyoutWindow.MaxWidth = actualSize.Width - rightTabsWidth - leftTabsWidth; + _flyoutWindow.MaxHeight = actualSize.Height - topTabsHeight; + _flyoutWindow.Left = locDockingManager.X + leftTabsWidth; + _flyoutWindow.Width = _flyoutWindow.MaxWidth; + if (initialSetup) { _flyoutWindow.Height = 0.0; @@ -2916,31 +2857,35 @@ namespace AvalonDock } if (_flyoutWindow.ReferencedPane.Anchor == AnchorStyle.Bottom) { - _flyoutWindow.Left = locDockingManager.X + leftTabsWidth; - _flyoutWindow.Width = this.ActualWidth - rightTabsWidth - leftTabsWidth; + _flyoutWindow.MaxWidth = actualSize.Width - rightTabsWidth - leftTabsWidth; + _flyoutWindow.MaxHeight = actualSize.Height - bottomTabsHeight; - _flyoutWindow.MaxWidth = ActualWidth; - _flyoutWindow.MaxHeight = ActualHeight - bottomTabsHeight; + _flyoutWindow.Left = locDockingManager.X + leftTabsWidth; + _flyoutWindow.Width = _flyoutWindow.MaxWidth; if (initialSetup) { - _flyoutWindow.Top = locDockingManager.Y + this.ActualHeight - bottomTabsHeight; + _flyoutWindow.Top = locDockingManager.Y + actualSize.Height - bottomTabsHeight; _flyoutWindow.Height = 0.0; _flyoutWindow.TargetHeight = resHeight; } else { if (!_flyoutWindow.IsOpening && !_flyoutWindow.IsClosing) - _flyoutWindow.Top = locDockingManager.Y + this.ActualHeight - bottomTabsHeight - _flyoutWindow.Height; - if (_flyoutWindow.IsClosing) - _flyoutWindow.Top = locDockingManager.Y + this.ActualHeight - bottomTabsHeight - _flyoutWindow.Height; + _flyoutWindow.Top = locDockingManager.Y + actualSize.Height - bottomTabsHeight - _flyoutWindow.Height; + //if (_flyoutWindow.IsClosing) + // _flyoutWindow.Top = locDockingManager.Y + actualSize.Height - bottomTabsHeight - _flyoutWindow.Height; } } if (_flyoutWindow != null && !_flyoutWindow.IsClosing) _flyoutWindow.UpdatePositionAndSize(); - } + if (initialSetup) + _flyoutWindow.ReferencedPane.LayoutTransform = (MatrixTransform)this.TansformToAncestor(); + + Debug.WriteLine(string.Format("UpdateFlyoutWindowPosition() Rect->{0} InitialSetup={1}", new Rect(_flyoutWindow.Left, _flyoutWindow.Top, _flyoutWindow.Width, _flyoutWindow.Height), initialSetup)); + } #endregion @@ -2999,7 +2944,7 @@ namespace AvalonDock { if (CaptureMouse()) { - DockableFloatingWindow floatingWindow = new DockableFloatingWindow(this); + var floatingWindow = new DockableFloatingWindow(this); floatingWindow.Content = dockablePane; floatingWindow.Owner = Window.GetWindow(this); Drag(floatingWindow, point, offset); @@ -3079,9 +3024,13 @@ namespace AvalonDock Rect IDropSurface.SurfaceRectangle { get - { + { if (PresentationSource.FromVisual(this) != null) - return new Rect(HelperFunc.PointToScreenWithoutFlowDirection(this, new Point(0, 0)), new Size(ActualWidth, ActualHeight)); + { + var actualSize = this.TransformedActualSize(); + return new Rect(HelperFunc.PointToScreenWithoutFlowDirection(this, new Point(0, 0)), new Size(actualSize.Width, actualSize.Height)); + } + return Rect.Empty; } } @@ -3117,15 +3066,15 @@ namespace AvalonDock if (OverlayWindow.IsVisible) return; + var actualSize = this.TransformedActualSize(); OverlayWindow.Owner = DragPaneServices.FloatingWindow; - //OverlayWindow.Left = PointToScreen(new Point(0, 0)).X; - //OverlayWindow.Top = PointToScreen(new Point(0, 0)).Y; Point origPoint = HelperFunc.PointToScreenWithoutFlowDirection(this, new Point()); OverlayWindow.Left = origPoint.X; OverlayWindow.Top = origPoint.Y; - OverlayWindow.Width = ActualWidth; - OverlayWindow.Height = ActualHeight; + OverlayWindow.Width = actualSize.Width; + OverlayWindow.Height = actualSize.Height; + //don't pass transform matrix to Overlay window otherwise anchor thumbs will be resized OverlayWindow.Show(); } @@ -3146,9 +3095,6 @@ namespace AvalonDock { OverlayWindow.Owner = null; OverlayWindow.Hide(); - //Window mainWindow = Window.GetWindow(this); - //if (mainWindow != null) - // mainWindow.Activate(); } /// @@ -3193,6 +3139,9 @@ namespace AvalonDock xmlWriter.WriteAttributeString("EffectiveSize", new SizeConverter().ConvertToInvariantString(ResizingPanel.GetEffectiveSize(pane))); xmlWriter.WriteAttributeString("ID", pane.ID.ToString()); xmlWriter.WriteAttributeString("Anchor", pane.Anchor.ToString()); + + if (pane.Items.Count > 1) + xmlWriter.WriteAttributeString("SelectedIndex", XmlConvert.ToString(pane.SelectedIndex)); xmlWriter.WriteAttributeString("IsAutoHidden", XmlConvert.ToString(pane.IsAutoHidden)); @@ -3234,7 +3183,6 @@ namespace AvalonDock xmlWriter.WriteStartElement("DockableContent"); xmlWriter.WriteAttributeString("Name", content.Name); - //xmlWriter.WriteAttributeString("AutoHide", XmlConvert.ToString(content.State == DockableContentState.AutoHide)); content.SaveLayout(xmlWriter); @@ -3266,6 +3214,13 @@ namespace AvalonDock if (pane.IsMainDocumentPane.GetValueOrDefault()) xmlWriter.WriteAttributeString("IsMain", "true"); + if (pane.Items.Count > 1) + xmlWriter.WriteAttributeString("SelectedIndex", XmlConvert.ToString(pane.SelectedIndex)); + + xmlWriter.WriteAttributeString("ResizeWidth", ResizingPanel.GetResizeWidth(pane).ToString()); + xmlWriter.WriteAttributeString("ResizeHeight", ResizingPanel.GetResizeHeight(pane).ToString()); + xmlWriter.WriteAttributeString("EffectiveSize", new SizeConverter().ConvertToInvariantString(ResizingPanel.GetEffectiveSize(pane))); + foreach (ManagedContent content in pane.Items) { if (content is DockableContent) @@ -3402,8 +3357,6 @@ namespace AvalonDock SaveLayout(sw, Content as ResizingPanel); else if (Content is DocumentPane) SaveLayout(sw, Content as DocumentPane); - //else if (Content is DocumentPaneResizingPanel) - // SaveLayout(sw, Content as DocumentPaneResizingPanel); sw.WriteStartElement("Hidden"); @@ -3610,6 +3563,13 @@ namespace AvalonDock { var documentPane = new DocumentPane(); + if (mainElement.HasAttribute("ResizeWidth")) + ResizingPanel.SetResizeWidth(documentPane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeWidth"))); + if (mainElement.HasAttribute("ResizeHeight")) + ResizingPanel.SetResizeHeight(documentPane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeHeight"))); + if (mainElement.HasAttribute("EffectiveSize")) + ResizingPanel.SetEffectiveSize(documentPane, (Size)(new SizeConverter()).ConvertFromInvariantString(mainElement.GetAttribute("EffectiveSize"))); + foreach (XmlElement contentElement in mainElement.ChildNodes) { if (contentElement.Name == "DockableContent" && @@ -3666,6 +3626,9 @@ namespace AvalonDock } } + if (mainElement.HasAttribute("SelectedIndex")) + documentPane.SelectedIndex = XmlConvert.ToInt32(mainElement.GetAttribute("SelectedIndex")); + return documentPane; } @@ -3684,7 +3647,7 @@ namespace AvalonDock if (mainElement.HasAttribute("EffectiveSize")) ResizingPanel.SetEffectiveSize(pane, (Size)(new SizeConverter()).ConvertFromInvariantString(mainElement.GetAttribute("EffectiveSize"))); if (mainElement.HasAttribute("ID")) - pane.ID = Guid.Parse(mainElement.GetAttribute("ID")); + pane.ID = new Guid(mainElement.GetAttribute("ID")); bool toggleAutoHide = false; if (mainElement.HasAttribute("IsAutoHidden")) @@ -3724,6 +3687,9 @@ namespace AvalonDock if (toggleAutoHide && pane.Items.Count > 0) ToggleAutoHide(pane); + if (mainElement.HasAttribute("SelectedIndex")) + pane.SelectedIndex = XmlConvert.ToInt32(mainElement.GetAttribute("SelectedIndex")); + return pane; } @@ -3989,16 +3955,17 @@ namespace AvalonDock ClearEmptyPanes(); RefreshContents(); - if (Documents.Count() > 0) - { - ActiveContent = Documents[0]; - } - else + if (ActiveDocument != null && + (ActiveDocument.ContainerPane == null || + ActiveDocument.ContainerPane.GetManager() != this)) { - ActiveContent = null; - ActiveDocument = null; + if (Documents.Count > 0) + ActiveDocument = Documents[0]; + else + ActiveDocument = null; } + ActiveContent = ActiveDocument; } #endregion diff --git a/src/Libraries/AvalonDock/AvalonDock/DocumentContent.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentContent.cs index 1271e6232a..743e8e653d 100644 --- a/src/Libraries/AvalonDock/AvalonDock/DocumentContent.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentContent.cs @@ -226,13 +226,13 @@ namespace AvalonDock if (!e.Handled && e.Command == DocumentContentCommands.FloatingDocument) { this.Show(true); - + Activate(); e.Handled = true; } else if (!e.Handled && e.Command == DocumentContentCommands.TabbedDocument) { this.Show(false); - + Activate(); e.Handled = true; } } @@ -307,6 +307,13 @@ namespace AvalonDock parentPane.SelectedIndex = 0; } } + + //Active this content as the active document + if (Manager != null) + Manager.ActiveDocument = this; + + //ensure this content is rendered first + Panel.SetZIndex(this, 2); } /// @@ -391,8 +398,8 @@ namespace AvalonDock DockingManager oldManager = Manager; - if (Manager != null) - Manager.FireDocumentClosingEvent(e); + if (oldManager != null) + oldManager.FireDocumentClosingEvent(e); if (e.Cancel) return false; @@ -403,9 +410,10 @@ namespace AvalonDock //if documents are attached to an external source via DockingManager.DocumentsSource //let application host handle the document closing by itself - if (Manager != null && Manager.DocumentsSource != null) + if (oldManager != null && + oldManager.DocumentsSource != null) { - Manager.HandleDocumentClose(this); + oldManager.HandleDocumentClose(this); } if (oldManager != null) diff --git a/src/Libraries/AvalonDock/AvalonDock/DocumentFloatingWindow.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentFloatingWindow.cs index 8ec877bf3b..832307be46 100644 --- a/src/Libraries/AvalonDock/AvalonDock/DocumentFloatingWindow.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentFloatingWindow.cs @@ -140,7 +140,8 @@ namespace AvalonDock // Close(); //} - ((FloatingDocumentPane)HostedPane).PreviousPane.CheckContentsEmpty(); + if (((FloatingDocumentPane)HostedPane).PreviousPane != null) + ((FloatingDocumentPane)HostedPane).PreviousPane.CheckContentsEmpty(); if (HostedPane.Items.Count == 0) Close(); diff --git a/src/Libraries/AvalonDock/AvalonDock/DocumentPane.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentPane.cs index 5d8ab68111..bd89c35b05 100644 --- a/src/Libraries/AvalonDock/AvalonDock/DocumentPane.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentPane.cs @@ -101,7 +101,7 @@ namespace AvalonDock Items.Cast().FirstOrDefault(d => d.IsActiveDocument) != null); if (Items.Count > 0) - Debug.WriteLine("{0} ContainsActiveDocument ={1}", (Items[0] as ManagedContent).Title, ContainsActiveDocument); + Debug.WriteLine(string.Format("{0} ContainsActiveDocument ={1}", (Items[0] as ManagedContent).Title, ContainsActiveDocument)); } @@ -297,28 +297,41 @@ namespace AvalonDock public DocumentPane CreateNewHorizontalTabGroup() { - ManagedContent activeContent = SelectedItem as ManagedContent; - DocumentPane newContainerPane = new DocumentPane(); + var activeContent = SelectedItem as ManagedContent; + var oldContainerPane = activeContent.ContainerPane as DocumentPane; + var newContainerPane = new DocumentPane(); - int indexOfDocumentInItsContainer = activeContent.ContainerPane.Items.IndexOf(activeContent); - activeContent.ContainerPane.RemoveContent(indexOfDocumentInItsContainer); + oldContainerPane.RemoveContent(activeContent); newContainerPane.Items.Add(activeContent); GetManager().Anchor(newContainerPane, this, AnchorStyle.Bottom); + activeContent.Activate(); + newContainerPane.RefreshContainsActiveContentProperty(); + newContainerPane.RefreshContainsActiveDocumentProperty(); + oldContainerPane.RefreshContainsActiveContentProperty(); + oldContainerPane.RefreshContainsActiveDocumentProperty(); + return newContainerPane; } public DocumentPane CreateNewVerticalTabGroup() { - ManagedContent activeContent = SelectedItem as ManagedContent; - DocumentPane newContainerPane = new DocumentPane(); + var activeContent = SelectedItem as ManagedContent; + var oldContainerPane = activeContent.ContainerPane as DocumentPane; + var newContainerPane = new DocumentPane(); - int indexOfDocumentInItsContainer = activeContent.ContainerPane.Items.IndexOf(activeContent); - activeContent.ContainerPane.RemoveContent(indexOfDocumentInItsContainer); + oldContainerPane.RemoveContent(activeContent); newContainerPane.Items.Add(activeContent); GetManager().Anchor(newContainerPane, this, AnchorStyle.Right); + + activeContent.Activate(); + newContainerPane.RefreshContainsActiveContentProperty(); + newContainerPane.RefreshContainsActiveDocumentProperty(); + oldContainerPane.RefreshContainsActiveContentProperty(); + oldContainerPane.RefreshContainsActiveDocumentProperty(); + return newContainerPane; } @@ -349,7 +362,26 @@ namespace AvalonDock ContextMenu cxMenuDocuments = (ContextMenu)TryFindResource("DocumentsListMenu"); if (cxMenuDocuments != null) { - cxMenuDocuments.ItemsSource = Items.OfType().OrderBy(c => c.Title); + //cxMenuDocuments.ItemsSource = Items.OfType().OrderBy(c => c.Title); + cxMenuDocuments.Items.Clear(); + Items.OfType().OrderBy(c => c.Title).ForEach( + c => + { + cxMenuDocuments.Items.Add(new MenuItem() + { + Header = c.Title, + Command = ManagedContentCommands.Activate, + CommandTarget = c, + Icon = new Image() + { + Source = c.Icon, + Width = 16, +#if NET4 + UseLayoutRounding = true +#endif + } + }); + }); //cxMenuDocuments.CommandBindings.Add(new CommandBinding(ActivateDocumentCommand, new ExecutedRoutedEventHandler(this.ExecutedActivateDocumentCommand), new CanExecuteRoutedEventHandler(CanExecuteActivateDocumentCommand))); if (_optionsContextMenuPlacementTarget != null) @@ -521,5 +553,15 @@ namespace AvalonDock base.OnSelectionChanged(e); } + + public override bool OpenOptionsMenu(UIElement menuTarget) + { + if (cxOptions == null) + { + cxOptions = TryFindResource(new ComponentResourceKey(typeof(DockingManager), ContextMenuElement.DocumentPane)) as ContextMenu; + } + + return base.OpenOptionsMenu(menuTarget); + } } } diff --git a/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs index 65226ee9fc..b4ed1cf282 100644 --- a/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs @@ -58,7 +58,6 @@ namespace AvalonDock public static readonly DependencyProperty IsHeaderVisibleProperty = DependencyProperty.RegisterAttached("IsHeaderVisible", typeof(bool), typeof(DocumentTabPanel), new UIPropertyMetadata(false)); - protected override Size MeasureOverride(Size availableSize) { Size desideredSize = new Size(); @@ -66,18 +65,14 @@ namespace AvalonDock foreach (ManagedContent child in Children) { - Panel.SetZIndex(child, Selector.GetIsSelected(child)?1:-i); + Panel.SetZIndex(child, Selector.GetIsSelected(child) ? 1 : -i); i++; - //child.Width = double.NaN; - //child.Height = double.NaN; child.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); desideredSize.Width += child.DesiredSize.Width; desideredSize.Height = Math.Max(desideredSize.Height, child.DesiredSize.Height); } return new Size(Math.Min(desideredSize.Width, availableSize.Width), desideredSize.Height); - //return base.MeasureOverride(availableSize); - //return desideredSize; } protected override Size ArrangeOverride(Size finalSize) @@ -104,28 +99,5 @@ namespace AvalonDock } - //#region Padding - - ///// - ///// Padding Dependency Property - ///// - //public static readonly DependencyProperty PaddingProperty = - // DependencyProperty.Register("Padding", typeof(Thickness), typeof(DocumentTabPanel), - // new FrameworkPropertyMetadata((Thickness)new Thickness(), - // FrameworkPropertyMetadataOptions.AffectsMeasure)); - - ///// - ///// Gets or sets the Padding property. This dependency property - ///// indicates internal padding of the panel. - ///// - //public Thickness Padding - //{ - // get { return (Thickness)GetValue(PaddingProperty); } - // set { SetValue(PaddingProperty, value); } - //} - - //#endregion - - } } diff --git a/src/Libraries/AvalonDock/AvalonDock/FloatingDockablePane.cs b/src/Libraries/AvalonDock/AvalonDock/FloatingDockablePane.cs index 1751b0c877..ee25799d77 100644 --- a/src/Libraries/AvalonDock/AvalonDock/FloatingDockablePane.cs +++ b/src/Libraries/AvalonDock/AvalonDock/FloatingDockablePane.cs @@ -29,6 +29,7 @@ using System.Text; using System.Windows; using System.Linq; using System.Windows.Data; +using System.Windows.Media; namespace AvalonDock { @@ -40,7 +41,6 @@ namespace AvalonDock //by design avoid style change Pane.ShowHeaderProperty.OverrideMetadata(typeof(FloatingDockablePane), new FrameworkPropertyMetadata(false)); - } @@ -106,6 +106,8 @@ namespace AvalonDock AttachStyleFromPane(_paneToTransfer); ApplyTemplate(); + + LayoutTransform = (MatrixTransform)_paneToTransfer.TansformToAncestor(); } else if (_contentToTransfer != null) { @@ -131,10 +133,7 @@ namespace AvalonDock SelectedIndex = 0; - //if (_previousPane is DockablePane) - //{ - // Style = _previousPane.Style; - //} + AttachStyleFromPane(_previousPane as DockablePane); DocumentPane originalDocumentPane = _previousPane as DocumentPane; @@ -143,6 +142,7 @@ namespace AvalonDock _contentToTransfer.SetStateToDockableWindow(); + LayoutTransform = (MatrixTransform)_contentToTransfer.TansformToAncestor(); } base.OnInitialized(e); @@ -153,11 +153,11 @@ namespace AvalonDock if (copyFromPane == null) return; - Binding bnd = new Binding("Style"); - bnd.Source = copyFromPane; - bnd.Mode = BindingMode.OneWay; + //Binding bnd = new Binding("Style"); + //bnd.Source = copyFromPane; + //bnd.Mode = BindingMode.OneWay; - SetBinding(StyleProperty, bnd); + //SetBinding(StyleProperty, bnd); } DockablePane _paneToTransfer = null; diff --git a/src/Libraries/AvalonDock/AvalonDock/FloatingDocumentPane.cs b/src/Libraries/AvalonDock/AvalonDock/FloatingDocumentPane.cs index 993a480292..ad8439df91 100644 --- a/src/Libraries/AvalonDock/AvalonDock/FloatingDocumentPane.cs +++ b/src/Libraries/AvalonDock/AvalonDock/FloatingDocumentPane.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Windows; using System.Windows.Data; +using System.Windows.Media; namespace AvalonDock { @@ -38,27 +39,49 @@ namespace AvalonDock protected override void OnInitialized(EventArgs e) { - //setup window size - _floatingWindow.Width = _documentToTransfer.ContainerPane.ActualWidth; - _floatingWindow.Height = _documentToTransfer.ContainerPane.ActualHeight; - - //save current content position in container pane _previousPane = _documentToTransfer.ContainerPane as DocumentPane; - _arrayIndexPreviousPane = _previousPane.Items.IndexOf(_documentToTransfer); - SetValue(ResizingPanel.ResizeWidthProperty, _previousPane.GetValue(ResizingPanel.ResizeWidthProperty)); - SetValue(ResizingPanel.ResizeHeightProperty, _previousPane.GetValue(ResizingPanel.ResizeHeightProperty)); - //Style = _previousPane.Style; - AttachStyleFromPane(_previousPane); + if (_documentToTransfer != null && _documentToTransfer.FloatingWindowSize.IsEmpty) + { + if (_previousPane != null) + _documentToTransfer.FloatingWindowSize = new Size(_previousPane.ActualWidth, _previousPane.ActualHeight); + else + _documentToTransfer.FloatingWindowSize = new Size(400.0, 400.0); + } + + if (_documentToTransfer != null && !_documentToTransfer.FloatingWindowSize.IsEmpty) + { + _floatingWindow.Width = _documentToTransfer.FloatingWindowSize.Width; + _floatingWindow.Height = _documentToTransfer.FloatingWindowSize.Height; + } + + + if (_previousPane != null) + { + //setup window size + _floatingWindow.Width = _documentToTransfer.ContainerPane.ActualWidth; + _floatingWindow.Height = _documentToTransfer.ContainerPane.ActualHeight; + + //save current content position in container pane + _arrayIndexPreviousPane = _previousPane.Items.IndexOf(_documentToTransfer); + SetValue(ResizingPanel.ResizeWidthProperty, _previousPane.GetValue(ResizingPanel.ResizeWidthProperty)); + SetValue(ResizingPanel.ResizeHeightProperty, _previousPane.GetValue(ResizingPanel.ResizeHeightProperty)); - //remove content from container pane - _previousPane.RemoveContent(_arrayIndexPreviousPane); + //Style = _previousPane.Style; + AttachStyleFromPane(_previousPane); + + //remove content from container pane + _previousPane.RemoveContent(_arrayIndexPreviousPane); + } + //add content to my temporary pane Items.Add(_documentToTransfer); _documentToTransfer.SetIsFloating(true); - + + LayoutTransform = (MatrixTransform)_documentToTransfer.TansformToAncestor(); + base.OnInitialized(e); } @@ -67,11 +90,11 @@ namespace AvalonDock if (copyFromPane == null) return; - Binding bnd = new Binding("Style"); - bnd.Source = copyFromPane; - bnd.Mode = BindingMode.OneWay; + //Binding bnd = new Binding("Style"); + //bnd.Source = copyFromPane; + //bnd.Mode = BindingMode.OneWay; - SetBinding(StyleProperty, bnd); + //SetBinding(StyleProperty, bnd); } protected override void OnUnloaded(object sender, RoutedEventArgs e) diff --git a/src/Libraries/AvalonDock/AvalonDock/FloatingWindow.cs b/src/Libraries/AvalonDock/AvalonDock/FloatingWindow.cs index 993de8ee3a..34193c272e 100644 --- a/src/Libraries/AvalonDock/AvalonDock/FloatingWindow.cs +++ b/src/Libraries/AvalonDock/AvalonDock/FloatingWindow.cs @@ -608,8 +608,8 @@ namespace AvalonDock { if (cnt.Manager == null || cnt.Manager != Manager || - (!cnt.Manager.DockableContents.Contains(cnt) && - !cnt.Manager.Documents.Contains(cnt))) + (!cnt.Manager.DockableContents.Contains(cnt as DockableContent) && + !cnt.Manager.Documents.Contains(cnt as DocumentContent))) cnt.ContainerPane.RemoveContent(cnt); }); } diff --git a/src/Libraries/AvalonDock/AvalonDock/FlyoutDockablePane.cs b/src/Libraries/AvalonDock/AvalonDock/FlyoutDockablePane.cs index 188f46a5c5..39733ab55a 100644 --- a/src/Libraries/AvalonDock/AvalonDock/FlyoutDockablePane.cs +++ b/src/Libraries/AvalonDock/AvalonDock/FlyoutDockablePane.cs @@ -53,8 +53,8 @@ namespace AvalonDock _arrayIndexPreviousPane = _referencedPane.Items.IndexOf(content); Anchor = _referencedPane.Anchor; - SetValue(ResizingPanel.ResizeWidthProperty, new GridLength(ResizingPanel.GetEffectiveSize(_referencedPane).Width)); - SetValue(ResizingPanel.ResizeHeightProperty, new GridLength(ResizingPanel.GetEffectiveSize(_referencedPane).Height)); + //SetValue(ResizingPanel.ResizeWidthProperty, new GridLength(ResizingPanel.GetEffectiveSize(_referencedPane).Width)); + //SetValue(ResizingPanel.ResizeHeightProperty, new GridLength(ResizingPanel.GetEffectiveSize(_referencedPane).Height)); this.Style = _referencedPane.Style; @@ -78,8 +78,8 @@ namespace AvalonDock if (this.Items.Count == 1) { _referencedPane.Items.Insert(_arrayIndexPreviousPane, RemoveContent(0)); - ResizingPanel.SetResizeWidth(_referencedPane, ResizingPanel.GetResizeWidth(this)); - ResizingPanel.SetResizeHeight(_referencedPane, ResizingPanel.GetResizeHeight(this)); + //ResizingPanel.SetResizeWidth(_referencedPane, ResizingPanel.GetResizeWidth(this)); + //ResizingPanel.SetResizeHeight(_referencedPane, ResizingPanel.GetResizeHeight(this)); } } diff --git a/src/Libraries/AvalonDock/AvalonDock/FlyoutPaneWindow.cs b/src/Libraries/AvalonDock/AvalonDock/FlyoutPaneWindow.cs index 28a51d7a68..41c0a8e14c 100644 --- a/src/Libraries/AvalonDock/AvalonDock/FlyoutPaneWindow.cs +++ b/src/Libraries/AvalonDock/AvalonDock/FlyoutPaneWindow.cs @@ -147,6 +147,7 @@ namespace AvalonDock IsResizing = true; ShowResizerOverlayWindow(s as Resizer); + Debug.WriteLine(string.Format("resizer.DragStarted() Rect->{0}", new Rect(Left, Top, Width, Height))); }; if (resizer != null) resizer.DragDelta += (s, e) => @@ -175,6 +176,9 @@ namespace AvalonDock break; } + + Debug.WriteLine(string.Format("resizer.DragDelta() Rect->{0}", new Rect(Left, Top, Width, Height))); + }; if (resizer != null) resizer.DragCompleted += (s, e) => @@ -216,14 +220,33 @@ namespace AvalonDock } IsResizing = false; + SaveFlyoutSizeToContent(); HideResizerOverlayWindow(); - }; + Debug.WriteLine(string.Format("resizer.DragCompleted() Rect->{0}", new Rect(Left, Top, Width, Height))); - + }; base.OnApplyTemplate(); } + void SaveFlyoutSizeToContent() + { + if (ReferencedPane.ActualWidth > 0.0 && + ReferencedPane.ActualHeight > 0.0) + { + var flyoutContent = ReferencedPane.SelectedItem as DockableContent; + + if (Anchor == AnchorStyle.Left || + Anchor == AnchorStyle.Right) + flyoutContent.FlyoutWindowSize = + new Size(ReferencedPane.ActualWidth, flyoutContent.FlyoutWindowSize.Height <= 0 ? ReferencedPane.ActualHeight : flyoutContent.FlyoutWindowSize.Height); + else + flyoutContent.FlyoutWindowSize = + new Size(flyoutContent.FlyoutWindowSize.Width <= 0 ? ReferencedPane.ActualWidth : flyoutContent.FlyoutWindowSize.Width, ReferencedPane.ActualHeight); + + Debug.WriteLine(string.Format("Save flyout size for content '{0}' -> {1}", flyoutContent.Name, flyoutContent.FlyoutWindowSize)); + } + } /// /// Handles the closed event @@ -240,6 +263,7 @@ namespace AvalonDock IsClosed = true; } + /// /// Gets a value indicating i fthis window is closed /// @@ -402,136 +426,6 @@ namespace AvalonDock } } - - //void ShowResizerPopup() - //{ - // _resizerPopup = new Window() - // { - // AllowsTransparency = true, - // Background = Brushes.Transparent, - // ShowActivated = false, - // ShowInTaskbar = false, - // ResizeMode = System.Windows.ResizeMode.NoResize, - // WindowStyle = System.Windows.WindowStyle.None, - // Owner = this - // }; - - // Debug.WriteLine(string.Format("{0}-{1} {2}-{3}", - // Left, - // Top, - // Width, - // Height)); - - // Canvas resizerCanvas = new Canvas() { Width = MaxWidth, Height = MaxHeight, Background = null}; - // Border resizer = new Border() { Background = new SolidColorBrush(Colors.DarkGray), Opacity = 0.1 }; - - // switch (CorrectedAnchor) - // { - // case AnchorStyle.Left: - // { - // _resizerPopup.Left = Left; - // _resizerPopup.Top = Top; - // _resizerPopup.Width = MaxWidth; - // _resizerPopup.Height = MaxHeight; - - // resizer.Width = 4; - // resizer.Height = MaxHeight; - // resizer.Cursor = Cursors.SizeWE; - - // Canvas.SetLeft(resizer, Width - resizer.Width); - // Canvas.SetTop(resizer, 0.0); - // } - // break; - // case AnchorStyle.Right: - // { - // _resizerPopup.Left = Left - MaxWidth + Width; - // _resizerPopup.Top = Top; - // _resizerPopup.Width = MaxWidth; - // _resizerPopup.Height = MaxHeight; - - // resizer.Width = 4; - // resizer.Height = MaxHeight; - // resizer.Cursor = Cursors.SizeWE; - - // Canvas.SetLeft(resizer, MaxWidth - Width); - // Canvas.SetTop(resizer, 0.0); - // } - // break; - // case AnchorStyle.Top: - // { - // _resizerPopup.Left = Left; - // _resizerPopup.Top = Top; - // _resizerPopup.Width = MaxWidth; - // _resizerPopup.Height = MaxHeight; - - // resizer.Width = MaxWidth; - // resizer.Height = 4; - // resizer.Cursor = Cursors.SizeNS; - - // Canvas.SetLeft(resizer, 4); - // Canvas.SetTop(resizer, Height - resizer.Height); - // } - // break; - // case AnchorStyle.Bottom: - // { - // _resizerPopup.Left = Left; - // _resizerPopup.Top = Top - MaxHeight + Height; - // _resizerPopup.Width = MaxWidth; - // _resizerPopup.Height = MaxHeight; - - // resizer.Width = MaxWidth; - // resizer.Height = 4; - // resizer.Cursor = Cursors.SizeNS; - - // Canvas.SetLeft(resizer, 4); - // Canvas.SetTop(resizer, MaxHeight - Height); - // } - // break; - // } - - // resizerCanvas.Children.Add(resizer); - - - // _resizerPopup.Content = resizerCanvas; - // _resizerPopup.Show(); - //} - - //void HideResizerPopup() - //{ - // if (_resizerPopup == null) - // return; - - // //_resizerPopup.IsOpen = false; - // _resizerPopup.Close(); - // _resizerPopup = null; - //} - - //void UpdateResizerPopup() - //{ - // if (_resizerPopup == null) - // return; - - // switch (CorrectedAnchor) - // { - // case AnchorStyle.Left: - // { - // //_resizerPopup.PlacementRectangle = new Rect(Left, Top, MaxWidth, MaxHeight); - // _resizerPopup.Left = Left; - // _resizerPopup.Top = Top; - // _resizerPopup.Width = MaxWidth; - // _resizerPopup.Height = MaxHeight; - - // } - // break; - // case AnchorStyle.Right: - // { - // //_resizerPopup.PlacementRectangle = new Rect(Left - MaxWidth + Width, Top, MaxWidth, MaxHeight); - // } - // break; - // } - - //} - /// /// Gets a value indicating if user is resizer the window /// @@ -544,15 +438,6 @@ namespace AvalonDock DispatcherTimer _closingTimer = null; - ///// - ///// Start the closing timer - ///// - //void StartClosingTimer() - //{ - // //if (_closingTimer != null) - // // _closingTimer.Start(); - //} - /// /// Creates the closing timer /// @@ -581,15 +466,6 @@ namespace AvalonDock } } - ///// - ///// Stop the closing timer - ///// - //void StopClosingTimer() - //{ - // //if (_closingTimer != null) - // // _closingTimer.Stop(); - //} - /// /// This handler is called when the closing time delay is elapsed (user is focusing to something else of the UI) /// @@ -639,55 +515,6 @@ namespace AvalonDock } - //protected override void OnMouseLeave(MouseEventArgs e) - //{ - // base.OnMouseLeave(e); - - // if (!IsFocused && !IsKeyboardFocusWithin && !ReferencedPane.IsOptionsMenuOpen) - // StartClosingTimer(); - //} - - //protected override void OnMouseMove(MouseEventArgs e) - //{ - // base.OnMouseMove(e); - - // StopClosingTimer(); - //} - - //protected override void OnLostFocus(RoutedEventArgs e) - //{ - // base.OnLostFocus(e); - - // if (!IsMouseOver && !ReferencedPane.IsOptionsMenuOpen) - // StartClosingTimer(); - //} - - //protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e) - //{ - // base.OnLostKeyboardFocus(e); - - // if (!IsMouseOver) - // StopClosingTimer(); - //} - - //protected override void OnGotFocus(RoutedEventArgs e) - //{ - // base.OnGotFocus(e); - - // StopClosingTimer(); - //} - - //protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) - //{ - // base.OnGotKeyboardFocus(e); - - // StopClosingTimer(); - //} - - //internal void KeepWindowOpen() - //{ - // StopClosingTimer(); - //} #endregion #region Open/Close Flyout window @@ -1003,7 +830,6 @@ namespace AvalonDock } } - /// /// Close the flyout window with or without animation depending on the ShowAnimated flag /// @@ -1019,6 +845,7 @@ namespace AvalonDock Close(); } } + #endregion diff --git a/src/Libraries/AvalonDock/AvalonDock/HelperFunc.cs b/src/Libraries/AvalonDock/AvalonDock/HelperFunc.cs index aab9b12344..a51436e50a 100644 --- a/src/Libraries/AvalonDock/AvalonDock/HelperFunc.cs +++ b/src/Libraries/AvalonDock/AvalonDock/HelperFunc.cs @@ -54,8 +54,9 @@ namespace AvalonDock { if (FrameworkElement.GetFlowDirection(element) == FlowDirection.RightToLeft) { + var actualSize = element.TransformedActualSize(); Point leftToRightPoint = new Point( - element.ActualWidth - point.X, + actualSize.Width - point.X, point.Y); return element.PointToScreenDPI(leftToRightPoint); } @@ -190,6 +191,34 @@ namespace AvalonDock return PresentationSource.FromVisual(visual) != null; } + public static Size TransformedActualSize(this FrameworkElement element) + { + if (PresentationSource.FromVisual(element) == null) + return new Size(element.ActualWidth, element.ActualHeight); + + var parentWindow = PresentationSource.FromVisual(element).RootVisual; + var transformToWindow = element.TransformToAncestor(parentWindow); + return transformToWindow.TransformBounds(new Rect(0, 0, element.ActualWidth, element.ActualHeight)).Size; + } + + public static Size TransformSize(this FrameworkElement element, Size sizeToTransform) + { + if (PresentationSource.FromVisual(element) == null) + return sizeToTransform; + + var parentWindow = PresentationSource.FromVisual(element).RootVisual; + var transformToWindow = element.TransformToAncestor(parentWindow); + return transformToWindow.TransformBounds(new Rect(0, 0, sizeToTransform.Width, sizeToTransform.Height)).Size; + } + + public static GeneralTransform TansformToAncestor(this FrameworkElement element) + { + if (PresentationSource.FromVisual(element) == null) + return new MatrixTransform(Matrix.Identity); + + var parentWindow = PresentationSource.FromVisual(element).RootVisual; + return element.TransformToAncestor(parentWindow); + } public static void CallMethod(this object o, string methodName, object[] args) { diff --git a/src/Libraries/AvalonDock/AvalonDock/ImageEx.cs b/src/Libraries/AvalonDock/AvalonDock/ImageEx.cs new file mode 100644 index 0000000000..3ed707dfb2 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/ImageEx.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Controls; +using System.Windows; + +namespace AvalonDock +{ + public class ImageEx : Image + { + static ImageEx() + { +#if NET4 + UseLayoutRoundingProperty.OverrideMetadata(typeof(ImageEx), new FrameworkPropertyMetadata(true)); +#endif + } + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/ManagedContent.cs b/src/Libraries/AvalonDock/AvalonDock/ManagedContent.cs index c00b925e23..d48394e499 100644 --- a/src/Libraries/AvalonDock/AvalonDock/ManagedContent.cs +++ b/src/Libraries/AvalonDock/AvalonDock/ManagedContent.cs @@ -101,8 +101,8 @@ namespace AvalonDock // return contentHost; //} - void ManagedContent_SizeChanged(object sender, SizeChangedEventArgs e) - { + //void ManagedContent_SizeChanged(object sender, SizeChangedEventArgs e) + //{ //WindowsFormsHost contentHost = GetWinFormsHost(); //if (contentHost != null) @@ -114,7 +114,7 @@ namespace AvalonDock // this.Dispatcher.Invoke(new Action((o) => o.CallMethod("Refresh", null)), DispatcherPriority.Render, childCtrl); // } //} - } + //} protected virtual void OnContentLoaded() { @@ -265,6 +265,24 @@ namespace AvalonDock if (_dragEnabledArea != null) _dragEnabledArea.InputBindings.Add(new InputBinding(ManagedContentCommands.Close, new MouseGesture(MouseAction.MiddleClick))); + if (_dragEnabledArea != null && _dragEnabledArea.ContextMenu == null) + { + _dragEnabledArea.MouseRightButtonDown += (s, e) => + { + if (!e.Handled) + { + Activate(); + if (_dragEnabledArea.ContextMenu == null) + { + Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(delegate + { + ContainerPane.OpenOptionsMenu(null); + })); + } + e.Handled = true; + } + }; + } } #region Mouse management @@ -294,6 +312,7 @@ namespace AvalonDock protected virtual void OnDragMouseDown(object sender, MouseButtonEventArgs e) { + Debug.WriteLine("OnDragMouseDown" + e.ClickCount); if (!e.Handled && Manager != null)// && State != DockableContentState.AutoHide) { isMouseDown = true; @@ -308,17 +327,18 @@ namespace AvalonDock protected virtual void OnDragMouseUp(object sender, MouseButtonEventArgs e) { isMouseDown = false; + + Debug.WriteLine("OnDragMouseUp" + e.ClickCount); } Point ptRelativePosition; protected virtual void OnDragMouseLeave(object sender, MouseEventArgs e) { - if (!e.Handled && e.LeftButton == MouseButtonState.Pressed && Manager != null) + if (!e.Handled && isMouseDown && e.LeftButton == MouseButtonState.Pressed && Manager != null) { if (!IsMouseCaptured) { - //Point ptMouseMove = e.GetPosition(this); Point ptMouseMove = e.GetPosition((IInputElement)System.Windows.Media.VisualTreeHelper.GetParent(this)); ManagedContent contentToSwap = null; if (ContainerPane != null) @@ -337,7 +357,8 @@ namespace AvalonDock } } - if (contentToSwap != null) + if (contentToSwap != null && + contentToSwap != this) { Pane containerPane = ContainerPane; int myIndex = containerPane.Items.IndexOf(this); @@ -352,8 +373,9 @@ namespace AvalonDock containerPane.Items.Insert(myIndex, contentToSwap); containerPane.SelectedItem = this; - + e.Handled = false; + //avoid ismouseDown = false call return; } else if (Math.Abs(ptMouseMove.X - StartDragPoint.X) > SystemParameters.MinimumHorizontalDragDistance || @@ -367,8 +389,8 @@ namespace AvalonDock } } } - - isMouseDown = false; + + ResetIsMouseDownFlag(); } @@ -579,52 +601,77 @@ namespace AvalonDock { if (IsActiveContent && !IsKeyboardFocused) { - Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(delegate + #region Focus on winforms content + if (this.Content is WindowsFormsHost) { - if (IsActiveContent && !IsKeyboardFocused) - { - if (this.Content is WindowsFormsHost) + //Use reflection in order to remove WinForms assembly reference + //WindowsFormsHost contentHost = this.Content as WindowsFormsHost; + + //object childCtrl = contentHost.GetType().GetProperty("Child").GetValue(contentHost, null); + + //if (childCtrl != null) + //{ + // if (!childCtrl.GetPropertyValue("Focused")) + // { + // childCtrl.CallMethod("Focus", null); + // } + //} + + //Dispatcher.BeginInvoke(DispatcherPriority.Background, new ThreadStart(delegate + // { + // if (IsActiveContent && !IsKeyboardFocused) + // { + // if (this.Content is WindowsFormsHost) + // { + // //Use reflection in order to remove WinForms assembly reference + // WindowsFormsHost contentHost = this.Content as WindowsFormsHost; + + // object childCtrl = contentHost.GetType().GetProperty("Child").GetValue(contentHost, null); + + // if (childCtrl != null) + // { + // if (!childCtrl.GetPropertyValue("Focused")) + // { + // childCtrl.CallMethod("Focus", null); + // } + // } + // } + // } + // })); + } + #endregion + + Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(delegate { - //Use reflection in order to remove WinForms assembly reference - WindowsFormsHost contentHost = this.Content as WindowsFormsHost; + if (IsActiveContent && !IsKeyboardFocused) + { + if (DefaultElement != null) + { + Debug.WriteLine("Try to set kb focus to " + DefaultElement); - object childCtrl = contentHost.GetType().GetProperty("Child").GetValue(contentHost, null); + IInputElement kbFocused = Keyboard.Focus(DefaultElement); - if (childCtrl != null) - { - if (!childCtrl.GetPropertyValue("Focused")) + if (kbFocused != null) + Debug.WriteLine("Focused element " + kbFocused); + else + Debug.WriteLine("No focused element"); + + } + else if (Content is UIElement && Content is DependencyObject) { - childCtrl.CallMethod("Focus", null); + Debug.WriteLine("Try to set kb focus to " + this.Content.ToString()); + (Content as UIElement).Focus(); + IInputElement kbFocused = Keyboard.Focus(this.Content as IInputElement); + if (kbFocused != null) + Debug.WriteLine("Focused element " + kbFocused); + else + Debug.WriteLine("No focused element"); } } - } - else if (DefaultElement != null) - { - Debug.WriteLine("Try to set kb focus to " + DefaultElement); - - IInputElement kbFocused = Keyboard.Focus(DefaultElement); - - if (kbFocused != null) - Debug.WriteLine("Focused element " + kbFocused); - else - Debug.WriteLine("No focused element"); + })); - } - else if (this.Content is IInputElement) - { - Debug.WriteLine("Try to set kb focus to " + this.Content.ToString()); - IInputElement kbFocused = Keyboard.Focus(this.Content as IInputElement); - if (kbFocused != null) - Debug.WriteLine("Focused element " + kbFocused); - else - Debug.WriteLine("No focused element"); - } - } - })); + } - - - } /// @@ -690,7 +737,7 @@ namespace AvalonDock parentDocumentPane.RefreshContainsActiveDocumentProperty(); } - Debug.WriteLine("{0}-{1}-{2}", IsFocused, IsKeyboardFocused, IsKeyboardFocusWithin); + //Debug.WriteLine("{0}-{1}-{2}", IsFocused, IsKeyboardFocused, IsKeyboardFocusWithin); //for backward compatibility RaisePropertyChanged("IsActiveDocumentChanged"); @@ -764,6 +811,7 @@ namespace AvalonDock #endregion + #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; @@ -930,7 +978,9 @@ namespace AvalonDock if (ContainerPane != null && Manager != null)// && Manager.ActiveContent != this) { ContainerPane.SelectedItem = this; - ContainerPane.Focus(); + + FocusContent(); + if (Manager != null) Manager.ActiveContent = this; } @@ -957,5 +1007,7 @@ namespace AvalonDock } #endregion + + } } diff --git a/src/Libraries/AvalonDock/AvalonDock/NavigatorWindow.cs b/src/Libraries/AvalonDock/AvalonDock/NavigatorWindow.cs index 1d9ee2d9c9..c37178ee19 100644 --- a/src/Libraries/AvalonDock/AvalonDock/NavigatorWindow.cs +++ b/src/Libraries/AvalonDock/AvalonDock/NavigatorWindow.cs @@ -134,7 +134,7 @@ namespace AvalonDock /// /// This window allow user to rapidly select a object or a object. /// When selected a content is also activate with the function - public class NavigatorWindow : AvalonDockWindow + public class NavigatorWindow : AvalonDockWindow, INotifyPropertyChanged { #region Constructors static NavigatorWindow() @@ -191,33 +191,66 @@ namespace AvalonDock #endregion #region Handlers for Tab+ctrl keys events - protected override void OnPreviewKeyDown(KeyEventArgs e) + + internal bool HandleKey(Key key) { - if (e.Key != Key.Tab) - Hide(); - else + if (key == Key.Tab) { - e.Handled = true; - MoveNextSelectedContent(); + MoveToNextContent(); + return true; } - - base.OnKeyDown(e); - } - - protected override void OnPreviewKeyUp(KeyEventArgs e) - { - if (e.Key != Key.Tab) + else if (key == Key.Down) { - var docSelected = (Documents.CurrentItem as NavigatorWindowDocumentItem).ItemContent as DocumentContent; - docSelected.Activate(); - Hide(); + MoveToNextContent(true); + return true; } - else + else if (key == Key.Up) + { + MoveToPreviousContent(true); + return true; + } + else if (key == Key.Left || key == Key.Right) { - e.Handled = true; + MoveToOtherList(); + return true; } - base.OnPreviewKeyUp(e); + return false; + } + + //protected override void OnPreviewKeyDown(KeyEventArgs e) + //{ + // if (e.Key == Key.Tab) + // { + // e.Handled = true; + // MoveToNextContent(); + // } + // else + // Hide(); + + // base.OnKeyDown(e); + //} + + //protected override void OnPreviewKeyUp(KeyEventArgs e) + //{ + // if (e.Key == Key.Tab) + // { + // e.Handled = true; + // } + // else + // { + // var docSelected = (Documents.CurrentItem as NavigatorWindowDocumentItem).ItemContent as DocumentContent; + // docSelected.Activate(); + // Hide(); + // } + + // base.OnPreviewKeyUp(e); + //} + + internal static bool IsKeyHandled(Key key) + { + return key == Key.Tab || key == Key.Down || + key == Key.Up || key == Key.Left || key == Key.Right; } #endregion @@ -232,9 +265,15 @@ namespace AvalonDock void DockableContents_CurrentChanged(object sender, EventArgs e) { + if (!_documentsSelected) + SelectedContent = DockableContents.CurrentItem as NavigatorWindowItem; + if (DockableContents.CurrentItem == null) return; + if (_intMoveFlag) + return; + Debug.WriteLine(string.Format("DockContent current changed to {0}", (DockableContents.CurrentItem as NavigatorWindowItem).ItemContent.Title)); var dockCntSelected = (DockableContents.CurrentItem as NavigatorWindowItem).ItemContent as DockableContent; Hide(); @@ -243,6 +282,9 @@ namespace AvalonDock void Documents_CurrentChanged(object sender, EventArgs e) { + if (_documentsSelected) + SelectedContent = Documents.CurrentItem as NavigatorWindowItem; + if (Documents.CurrentItem == null) return; if (_intMoveFlag) @@ -253,7 +295,36 @@ namespace AvalonDock var docSelected = (Documents.CurrentItem as NavigatorWindowDocumentItem).ItemContent as DocumentContent; docSelected.Activate(); Hide(); - } + } + + #region SelectedContent + + private NavigatorWindowItem _selectedContent = null; + public NavigatorWindowItem SelectedContent + { + get { return _selectedContent; } + set + { + if (_selectedContent != value) + { + NavigatorWindowItem oldValue = _selectedContent; + _selectedContent = value; + OnSelectedContentChanged(oldValue, value); + RaisePropertyChanged("SelectedContent"); + } + } + } + + /// + /// Provides derived classes an opportunity to handle changes to the SelectedContent property. + /// + protected virtual void OnSelectedContentChanged(NavigatorWindowItem oldValue, NavigatorWindowItem newValue) + { + } + + #endregion + + #endregion #region Documents @@ -324,15 +395,114 @@ namespace AvalonDock #region Move to Next document bool _intMoveFlag = false; - public void MoveNextSelectedContent() + bool _documentsSelected = true; + public void MoveToNextContent(bool moveToNextList = false) { _intMoveFlag = true; - if (!Documents.MoveCurrentToNext()) - Documents.MoveCurrentToFirst(); - if (Documents.IsCurrentAfterLast) - Documents.MoveCurrentToFirst(); + + if (_documentsSelected) + { + if (!Documents.MoveCurrentToNext()) + { + if (moveToNextList) + { + _documentsSelected = false; + DockableContents.MoveCurrentToFirst(); + } + else + Documents.MoveCurrentToFirst(); + } + } + else + { + if (!DockableContents.MoveCurrentToNext()) + { + if (moveToNextList) + { + _documentsSelected = true; + Documents.MoveCurrentToFirst(); + } + else + DockableContents.MoveCurrentToFirst(); + } + } + + _intMoveFlag = false; + } + public void MoveToPreviousContent(bool moveToNextList = false) + { + _intMoveFlag = true; + + if (_documentsSelected) + { + if (!Documents.MoveCurrentToPrevious()) + { + if (moveToNextList) + { + _documentsSelected = false; + DockableContents.MoveCurrentToLast(); + } + else + Documents.MoveCurrentToLast(); + } + } + else + { + if (!DockableContents.MoveCurrentToPrevious()) + { + if (moveToNextList) + { + _documentsSelected = true; + Documents.MoveCurrentToLast(); + } + else + DockableContents.MoveCurrentToLast(); + } + } + _intMoveFlag = false; } + public void MoveToOtherList() + { + _intMoveFlag = true; + if (_documentsSelected) + { + _documentsSelected = false; + int currentPos = Documents.CurrentPosition; + if (currentPos <= 0) + DockableContents.MoveCurrentToFirst(); + else if (currentPos >= DockableContents.Count) + DockableContents.MoveCurrentToLast(); + else + DockableContents.MoveCurrentToPosition(currentPos); + Documents.MoveCurrentTo(null); + } + else + { + _documentsSelected = true; + int currentPos = DockableContents.CurrentPosition; + if (currentPos <= 0) + Documents.MoveCurrentToFirst(); + else if (currentPos >= Documents.Count) + Documents.MoveCurrentToLast(); + else + Documents.MoveCurrentToPosition(currentPos); + DockableContents.MoveCurrentTo(null); + } + _intMoveFlag = false; + + } + #endregion + + + #region INotifyPropertyChanged Members + + public event PropertyChangedEventHandler PropertyChanged; + protected void RaisePropertyChanged(string propertyName) + { + if (PropertyChanged != null) + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } #endregion } } diff --git a/src/Libraries/AvalonDock/AvalonDock/Pane.cs b/src/Libraries/AvalonDock/AvalonDock/Pane.cs index 3171e884ee..20e0dcccd5 100644 --- a/src/Libraries/AvalonDock/AvalonDock/Pane.cs +++ b/src/Libraries/AvalonDock/AvalonDock/Pane.cs @@ -31,6 +31,9 @@ using System.Diagnostics; using System.ComponentModel; using System.Collections; using System.Linq; +using System.Windows.Controls.Primitives; +using System.Threading; +using System.Windows.Threading; namespace AvalonDock { @@ -93,6 +96,7 @@ namespace AvalonDock base.OnSelectionChanged(e); } + protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { DockingManager dockManager = GetManager(); @@ -116,6 +120,9 @@ namespace AvalonDock SelectedItem = _lastSelectedContent; } + //let base class handle SelectedIndex/Item value + base.OnItemsChanged(e); + if (Items.Count > 0) { int currentIndex = SelectedIndex; @@ -140,7 +147,7 @@ namespace AvalonDock } } - base.OnItemsChanged(e); + } protected override void OnVisualParentChanged(DependencyObject oldParent) @@ -161,32 +168,6 @@ namespace AvalonDock } } - //void RefreshContentsSelectedProperty() - //{ - // //foreach (ManagedContent mc in Items) - // //{ - // // //mc.IsSelected = (mc == SelectedItem); - // // //Selector.SetIsSelected(mc - - // // if (Selector.GetIsSelected(mc)) - // // mc.FocusContent(); - // //} - //} - - //protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) - //{ - // if (e.Property == SelectedItemProperty) - // RefreshContentsSelectedProperty(); - // // SetValue(ActiveContentProperty, SelectedItem); - - // //if (e.Property == ActiveContentProperty) - // //{ - // // //SetValue(SelectedItemProperty, ActiveContent); - - // //} - - // base.OnPropertyChanged(e); - //} #endregion #region IDockableControl Members @@ -264,7 +245,7 @@ namespace AvalonDock Items.Cast().FirstOrDefault(d => d.IsActiveContent) != null); if (Items.Count> 0) - Debug.WriteLine("{0} ContainsActiveContent ={1}", (Items[0] as ManagedContent).Title, ContainsActiveContent); + Debug.WriteLine(string.Format("{0} ContainsActiveContent ={1}", (Items[0] as ManagedContent).Title, ContainsActiveContent)); } #endregion @@ -318,7 +299,8 @@ namespace AvalonDock if (PresentationSource.FromVisual(this) == null) return new Rect(); - return new Rect(HelperFunc.PointToScreenWithoutFlowDirection(this, new Point()), new Size(ActualWidth, ActualHeight)); + var actualSize = this.TransformedActualSize(); + return new Rect(HelperFunc.PointToScreenWithoutFlowDirection(this, new Point()), new Size(actualSize.Width, actualSize.Height)); } } Rect IDropSurface.SurfaceRectangle @@ -399,7 +381,7 @@ namespace AvalonDock } } - Debug.WriteLine("Pane.OnCanExecuteCommand({0}) = {1} (ContinueRouting={2})", e.Command, e.CanExecute, e.ContinueRouting); + Debug.WriteLine(string.Format("Pane.OnCanExecuteCommand({0}) = {1} (ContinueRouting={2})", e.Command, e.CanExecute, e.ContinueRouting)); } /// @@ -455,7 +437,120 @@ namespace AvalonDock public static readonly DependencyProperty ShowHeaderProperty = DependencyProperty.Register("ShowHeader", typeof(bool), typeof(Pane), new UIPropertyMetadata(true)); + /// + /// Move focus to pane content and activate it + /// + protected void FocusContent() + { + ManagedContent selectedContent = SelectedItem as ManagedContent; + if (selectedContent != null)// && selectedContent.Content is UIElement) + { + //UIElement internalContent = selectedContent.Content as UIElement; + //bool res = Focus(); + //Keyboard.Focus(internalContent); + selectedContent.Activate(); + } + } + #region OptionsContextMenu + protected ContextMenu cxOptions = null; + ContextMenu _attachedCxOptions = null; + /// + /// Open the option context menu + /// + /// Target element under which context menu will be shown. Pass null if context menu + /// should be shown at mouse position. + /// True if context menu resource was found and open, false otherwise. + public virtual bool OpenOptionsMenu(UIElement menuTarget) + { + if (_attachedCxOptions != cxOptions) + { + if (_attachedCxOptions != null) + { + cxOptions.Opened -= (s, e) => UpdateIsOptionsMenuOpen(); + cxOptions.Closed -= (s, e) => UpdateIsOptionsMenuOpen(); + } + + _attachedCxOptions = cxOptions; + + if (_attachedCxOptions != null) + { + cxOptions.Opened += (s, e) => UpdateIsOptionsMenuOpen(); + cxOptions.Closed += (s, e) => UpdateIsOptionsMenuOpen(); + } + } + + if (cxOptions != null) + { + //FocusContent(); + } + + if (cxOptions != null) + { + cxOptions.DataContext = this.SelectedItem; + + foreach (MenuItem menuItem in cxOptions.Items.OfType()) + menuItem.CommandTarget = this.SelectedItem as IInputElement; + + if (menuTarget != null) + { + cxOptions.Placement = PlacementMode.Bottom; + cxOptions.PlacementTarget = menuTarget; + } + else + { + cxOptions.Placement = PlacementMode.MousePoint; + cxOptions.PlacementTarget = this; + } + + cxOptions.IsOpen = true; + } + + return (cxOptions != null && cxOptions.IsOpen); + } + + /// + /// Close the options context menu + /// + public virtual void CloseOptionsMenu() + { + if (cxOptions != null) + { + cxOptions.IsOpen = false; + cxOptions = null; + } + } + + /// + /// Gets a value indicating if the options context menu is open + /// + public bool IsOptionsMenuOpen + { + get { return (bool)GetValue(IsOptionsMenuOpenProperty); } + protected set { SetValue(IsOptionsMenuOpenPropertyKey, value); } + } + + // Using a DependencyProperty as the backing store for IsOptionsMenuOpen. This enables animation, styling, binding, etc... + static readonly DependencyPropertyKey IsOptionsMenuOpenPropertyKey = + DependencyProperty.RegisterReadOnly("IsOptionsMenuOpen", typeof(bool), typeof(DockablePane), new UIPropertyMetadata(false)); + + public static readonly DependencyProperty IsOptionsMenuOpenProperty = IsOptionsMenuOpenPropertyKey.DependencyProperty; + + void UpdateIsOptionsMenuOpen() + { + if (cxOptions != null) + { + var selectedContent = cxOptions.DataContext as DockableContent; + + if (selectedContent != null && selectedContent.ContainerPane != null) + { + (selectedContent.ContainerPane as Pane).IsOptionsMenuOpen = + cxOptions.IsOpen; + } + } + } + + #endregion #region INotifyPropertyChanged Members diff --git a/src/Libraries/AvalonDock/AvalonDock/PaneTabPanel.cs b/src/Libraries/AvalonDock/AvalonDock/PaneTabPanel.cs index 24857f6bc8..6e2ddef307 100644 --- a/src/Libraries/AvalonDock/AvalonDock/PaneTabPanel.cs +++ b/src/Libraries/AvalonDock/AvalonDock/PaneTabPanel.cs @@ -42,13 +42,6 @@ namespace AvalonDock { public abstract class PaneTabPanel : Panel { - //static PaneTabPanel() - //{ - // //This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class. - // //This style is defined in themes\generic.xaml - // DefaultStyleKeyProperty.OverrideMetadata(typeof(PaneTabPanel), new FrameworkPropertyMetadata(typeof(PaneTabPanel))); - //} - protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved) { base.OnVisualChildrenChanged(visualAdded, visualRemoved); @@ -62,8 +55,7 @@ namespace AvalonDock } - - + internal PaneTabPanel() { diff --git a/src/Libraries/AvalonDock/AvalonDock/Properties/AssemblyInfo.cs b/src/Libraries/AvalonDock/AvalonDock/Properties/AssemblyInfo.cs index 8db8b6927e..67f9e1cfff 100644 --- a/src/Libraries/AvalonDock/AvalonDock/Properties/AssemblyInfo.cs +++ b/src/Libraries/AvalonDock/AvalonDock/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ using System.Windows; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.3391")] -[assembly: AssemblyFileVersion("1.3.3391")] +[assembly: AssemblyVersion("1.3.3571")] +[assembly: AssemblyFileVersion("1.3.3571")] diff --git a/src/Libraries/AvalonDock/AvalonDock/Properties/Settings.Designer.cs b/src/Libraries/AvalonDock/AvalonDock/Properties/Settings.Designer.cs index 6ae5f90b65..3ef14c16cf 100644 --- a/src/Libraries/AvalonDock/AvalonDock/Properties/Settings.Designer.cs +++ b/src/Libraries/AvalonDock/AvalonDock/Properties/Settings.Designer.cs @@ -8,21 +8,17 @@ // //------------------------------------------------------------------------------ -namespace AvalonDock.Properties -{ - - +namespace AvalonDock.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/src/Libraries/AvalonDock/AvalonDock/ResizingPanel.cs b/src/Libraries/AvalonDock/AvalonDock/ResizingPanel.cs index 48108b286e..221258c9ce 100644 --- a/src/Libraries/AvalonDock/AvalonDock/ResizingPanel.cs +++ b/src/Libraries/AvalonDock/AvalonDock/ResizingPanel.cs @@ -879,13 +879,21 @@ namespace AvalonDock { Resizer splitter = sender as Resizer; + //Point draggedPoint = this.PointToScreenDPI( + // new Point(e.HorizontalChange, e.VerticalChange)); + Window wnd = Window.GetWindow(this); + var trToWnd = TransformToAncestor(wnd); + Vector transformedDelta = trToWnd.Transform(new Point(e.HorizontalChange, e.VerticalChange)) - + trToWnd.Transform(new Point()); + + if (Orientation == System.Windows.Controls.Orientation.Horizontal) { - Canvas.SetLeft(_resizerGhost, _initialStartPoint.X + e.HorizontalChange); + Canvas.SetLeft(_resizerGhost, _initialStartPoint.X + transformedDelta.X); } else { - Canvas.SetTop(_resizerGhost, _initialStartPoint.Y + e.VerticalChange); + Canvas.SetTop(_resizerGhost, _initialStartPoint.Y + transformedDelta.Y); } @@ -1163,7 +1171,11 @@ namespace AvalonDock visibleChildren.RemoveAt(visibleChildren.Count - 1); Size[] currentSizes = new Size[visibleChildren.Count]; - double delta = Orientation == Orientation.Horizontal ? e.HorizontalChange : e.VerticalChange; + Window wnd = Window.GetWindow(this); + var trToWnd = TransformToAncestor(wnd).Inverse; + Vector transformedDelta = trToWnd.Transform(new Point(e.HorizontalChange, e.VerticalChange)) - + trToWnd.Transform(new Point()); + double delta = Orientation == Orientation.Horizontal ? transformedDelta.X : transformedDelta.Y; if (_childrenFinalSizes == null) return; @@ -1352,7 +1364,7 @@ namespace AvalonDock void ShowResizerOverlayWindow(Resizer splitter) { - Point ptTopLeftScreen = this.PointToScreen(new Point()); + Point ptTopLeftScreen = this.PointToScreenDPI(new Point()); _resizerGhost = new Border() { @@ -1360,18 +1372,20 @@ namespace AvalonDock Opacity = 0.7 }; + Size actualSize = this.TransformedActualSize(); + if (Orientation == System.Windows.Controls.Orientation.Horizontal) { _resizerGhost.Width = 5.0; - _resizerGhost.Height = ActualHeight; + _resizerGhost.Height = actualSize.Height; } else { _resizerGhost.Height = 5.0; - _resizerGhost.Width = ActualWidth; + _resizerGhost.Width = actualSize.Width; } - _initialStartPoint = splitter.PointToScreen(new Point()) - this.PointToScreen(new Point()); + _initialStartPoint = splitter.PointToScreenDPI(new Point()) - this.PointToScreenDPI(new Point()); if (Orientation == System.Windows.Controls.Orientation.Horizontal) { @@ -1389,7 +1403,8 @@ namespace AvalonDock }; panelHostResizer.Children.Add(_resizerGhost); - + + _resizerWindowHost = new Window() { ResizeMode = ResizeMode.NoResize, @@ -1397,13 +1412,15 @@ namespace AvalonDock ShowInTaskbar = false, AllowsTransparency = true, Background = null, - Width = ActualWidth, - Height = ActualHeight, + Width = actualSize.Width, + Height = actualSize.Height, Left = ptTopLeftScreen.X, Top = ptTopLeftScreen.Y, ShowActivated = false, Owner = Window.GetWindow(this), Content = panelHostResizer + //, + //LayoutTransform = (MatrixTransform)this.TansformToAncestor() }; _resizerWindowHost.Show(); diff --git a/src/Libraries/AvalonDock/AvalonDock/Resources/Common.xaml b/src/Libraries/AvalonDock/AvalonDock/Resources/Common.xaml index fb12dda598..c3724c6181 100644 --- a/src/Libraries/AvalonDock/AvalonDock/Resources/Common.xaml +++ b/src/Libraries/AvalonDock/AvalonDock/Resources/Common.xaml @@ -83,6 +83,9 @@ Value="1"/> - - + + + + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock/Resources/DockablePaneStyles.xaml b/src/Libraries/AvalonDock/AvalonDock/Resources/DockablePaneStyles.xaml index e9db6e16b0..5af951d283 100644 --- a/src/Libraries/AvalonDock/AvalonDock/Resources/DockablePaneStyles.xaml +++ b/src/Libraries/AvalonDock/AvalonDock/Resources/DockablePaneStyles.xaml @@ -52,7 +52,7 @@ - + - + - + - - + + - + + Command="ad:DocumentPaneCommands.NewVerticalTabGroup" > - + + + + + + + + --> + - + --> + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock/Resources/SpecNET40Styles.xaml b/src/Libraries/AvalonDock/AvalonDock/Resources/SpecNET40Styles.xaml new file mode 100644 index 0000000000..d304e69ec2 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/Resources/SpecNET40Styles.xaml @@ -0,0 +1,6 @@ + + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.xaml b/src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.xaml index 5db743fc14..82a3b60b98 100644 --- a/src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.xaml +++ b/src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.xaml @@ -31,13 +31,12 @@ Background="{StaticResource ManagedContentTabItemNormalBackground}" Padding="1" > - - + - @@ -124,18 +122,18 @@ - + + @@ -217,8 +216,7 @@ x:Name="PART_DragArea" BorderBrush="{StaticResource ManagedContentTabControlNormalBorderBrush}" Margin="0,0,-10,0" - SnapsToDevicePixels="True" - ContextMenu="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:ContextMenuElement.DocumentPane}}}"> + SnapsToDevicePixels="True"> @@ -249,12 +247,12 @@ x:Name="tabItemTitle" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" - Text="{TemplateBinding Title}" + Text="{Binding Title, RelativeSource={RelativeSource TemplatedParent}, StringFormat='{}{0} '}" Foreground="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderForeground}}}"/> - + @@ -306,7 +304,7 @@ - + - + - + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - + + + - + - + - + - + - + - + - + - + - + - + diff --git a/src/Libraries/AvalonDock/AvalonDock/Themes/classic.xaml b/src/Libraries/AvalonDock/AvalonDock/Themes/classic.xaml index 74cd47ba02..5166402df8 100644 --- a/src/Libraries/AvalonDock/AvalonDock/Themes/classic.xaml +++ b/src/Libraries/AvalonDock/AvalonDock/Themes/classic.xaml @@ -30,7 +30,7 @@ - + - - - + + + @@ -248,9 +247,7 @@ TextWrapping="NoWrap" Text="{TemplateBinding Title}" Foreground="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.DocumentHeaderForeground}}}"/> - - - + @@ -303,7 +300,7 @@ - + --> - +