Browse Source

Added carefully filtered forked code changes from Cortex repo to AvalonDock project.

pull/1645/head
Johannes Brittain 8 years ago
parent
commit
fb6e8812e8
  1. 4
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/AutoHideWindowManager.cs
  2. 20
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DragService.cs
  3. 3
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/FocusElementManager.cs
  4. 43
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorControl.cs
  5. 9
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs
  6. 3
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableItem.cs
  7. 52
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAutoHideWindowControl.cs
  8. 944
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs
  9. 1
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs
  10. 33
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutItem.cs
  11. 3
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/NavigatorWindow.cs
  12. 1071
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/OverlayWindow.cs
  13. 6363
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/DockingManager.cs
  14. 1518
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/LayoutContent.cs
  15. 544
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/LayoutPositionableGroup.cs
  16. 29
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/Serialization/LayoutSerializer.cs
  17. 16
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/Serialization/XmlLayoutSerializer.cs
  18. 5
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Win32Helper.cs
  19. 3
      ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Xceed.Wpf.AvalonDock.csproj

4
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/AutoHideWindowManager.cs

@ -38,10 +38,13 @@ namespace Xceed.Wpf.AvalonDock.Controls
public void ShowAutoHideWindow(LayoutAnchorControl anchor) public void ShowAutoHideWindow(LayoutAnchorControl anchor)
{ {
if(_currentAutohiddenAnchor.GetValueOrDefault<LayoutAnchorControl>() != anchor)
{
StopCloseTimer(); StopCloseTimer();
_currentAutohiddenAnchor = new WeakReference(anchor); _currentAutohiddenAnchor = new WeakReference(anchor);
_manager.AutoHideWindow.Show(anchor); _manager.AutoHideWindow.Show(anchor);
StartCloseTimer(); StartCloseTimer();
}
} }
public void HideAutoWindow(LayoutAnchorControl anchor = null) public void HideAutoWindow(LayoutAnchorControl anchor = null)
@ -81,6 +84,7 @@ namespace Xceed.Wpf.AvalonDock.Controls
{ {
_closeTimer.Stop(); _closeTimer.Stop();
_manager.AutoHideWindow.Hide(); _manager.AutoHideWindow.Hide();
_currentAutohiddenAnchor = null;
} }
} }
} }

20
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/DragService.cs

@ -53,6 +53,8 @@ namespace Xceed.Wpf.AvalonDock.Controls
public void UpdateMouseLocation(Point dragPosition) public void UpdateMouseLocation(Point dragPosition)
{ {
if (!_floatingWindow.Model.Root.ActiveContent.CanDock) return;
var floatingWindowModel = _floatingWindow.Model as LayoutFloatingWindow; var floatingWindowModel = _floatingWindow.Model as LayoutFloatingWindow;
var newHost = _overlayWindowHosts.FirstOrDefault(oh => oh.HitTest(dragPosition)); var newHost = _overlayWindowHosts.FirstOrDefault(oh => oh.HitTest(dragPosition));
@ -89,8 +91,19 @@ namespace Xceed.Wpf.AvalonDock.Controls
} }
} }
if (_currentHost == null) if (_currentHost == null)
return; {
Debug.WriteLine("Zero Dock Areas");
if(_manager.Parent is DockingManager)
{
_manager = _manager.Parent as DockingManager;
GetOverlayWindowHosts();
UpdateMouseLocation(dragPosition);
}
return;
}
if (_currentDropTarget != null && if (_currentDropTarget != null &&
!_currentDropTarget.HitTest(dragPosition)) !_currentDropTarget.HitTest(dragPosition))
@ -175,7 +188,8 @@ namespace Xceed.Wpf.AvalonDock.Controls
{ {
var floatingWindowModel = _floatingWindow.Model as LayoutFloatingWindow; var floatingWindowModel = _floatingWindow.Model as LayoutFloatingWindow;
_currentWindowAreas.ForEach(a => _currentWindow.DragLeave(a)); if(_currentWindow != null)
_currentWindowAreas.ForEach(a => _currentWindow.DragLeave(a));
if (_currentDropTarget != null) if (_currentDropTarget != null)
_currentWindow.DragLeave(_currentDropTarget); _currentWindow.DragLeave(_currentDropTarget);

3
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/FocusElementManager.cs

@ -87,8 +87,7 @@ namespace Xceed.Wpf.AvalonDock.Controls
{ {
var focusedElement = e.NewFocus as Visual; var focusedElement = e.NewFocus as Visual;
if (focusedElement != null && if (focusedElement != null &&
!(focusedElement is LayoutAnchorableTabItem || focusedElement is LayoutDocumentTabItem) && !(focusedElement is LayoutAnchorableTabItem || focusedElement is LayoutDocumentTabItem))
!(focusedElement is ICommandSource))//Avoid tracking focus for elements like this
{ {
var parentAnchorable = focusedElement.FindVisualAncestor<LayoutAnchorableControl>(); var parentAnchorable = focusedElement.FindVisualAncestor<LayoutAnchorableControl>();
if (parentAnchorable != null) if (parentAnchorable != null)

43
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorControl.cs

@ -105,14 +105,31 @@ namespace Xceed.Wpf.AvalonDock.Controls
if (!e.Handled) if (!e.Handled)
{ {
if (_model.Root.Manager.AutoHideWindow.Visibility != Visibility.Visible)
{
_model.Root.Manager.ShowAutoHideWindow(this); _model.Root.Manager.ShowAutoHideWindow(this);
_model.IsActive = true; _model.IsActive = true;
_manuallyOpened = true;
}
else
{
if (!_inGracePeriod)
{
_model.Root.Manager.HideAutoHideWindow(this);
}
}
} }
} }
DispatcherTimer _openUpTimer = null; DispatcherTimer _openUpTimer = null;
DispatcherTimer _clickGracePeriodTimer = null;
bool _inGracePeriod = false;
bool _manuallyOpened = false;
protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e) protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
{ {
base.OnMouseEnter(e); base.OnMouseEnter(e);
@ -132,6 +149,30 @@ namespace Xceed.Wpf.AvalonDock.Controls
_openUpTimer.Stop(); _openUpTimer.Stop();
_openUpTimer = null; _openUpTimer = null;
_model.Root.Manager.ShowAutoHideWindow(this); _model.Root.Manager.ShowAutoHideWindow(this);
if (!_manuallyOpened)
{
_clickGracePeriodTimer = new DispatcherTimer(DispatcherPriority.ApplicationIdle);
_clickGracePeriodTimer.Interval = TimeSpan.FromMilliseconds(1000);
_inGracePeriod = true;
_clickGracePeriodTimer.Tick += new EventHandler(_clickGracePeriodTimer_Tick);
_clickGracePeriodTimer.Start();
}
_manuallyOpened = false;
}
void _clickGracePeriodTimer_Tick(object sender, EventArgs e)
{
StopGraceTimer();
}
void StopGraceTimer()
{
_clickGracePeriodTimer.Tick -= new EventHandler(_clickGracePeriodTimer_Tick);
_clickGracePeriodTimer.Stop();
_clickGracePeriodTimer = null;
_inGracePeriod = false;
} }
protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e) protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e)

9
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableFloatingWindowControl.cs

@ -51,6 +51,9 @@ namespace Xceed.Wpf.AvalonDock.Controls
internal override void UpdateThemeResources( Xceed.Wpf.AvalonDock.Themes.Theme oldTheme = null ) internal override void UpdateThemeResources( Xceed.Wpf.AvalonDock.Themes.Theme oldTheme = null )
{ {
if (Application.Current != null)
return;
base.UpdateThemeResources(oldTheme); base.UpdateThemeResources(oldTheme);
if (_overlayWindow != null) if (_overlayWindow != null)
@ -141,6 +144,7 @@ namespace Xceed.Wpf.AvalonDock.Controls
bool IOverlayWindowHost.HitTest(Point dragPoint) bool IOverlayWindowHost.HitTest(Point dragPoint)
{ {
if (!this.IsVisible) return false;
Rect detectionRect = new Rect(this.PointToScreenDPIWithoutFlowDirection(new Point()), this.TransformActualSizeToAncestor()); Rect detectionRect = new Rect(this.PointToScreenDPIWithoutFlowDirection(new Point()), this.TransformActualSizeToAncestor());
return detectionRect.Contains(dragPoint); return detectionRect.Contains(dragPoint);
} }
@ -175,8 +179,11 @@ namespace Xceed.Wpf.AvalonDock.Controls
void IOverlayWindowHost.HideOverlayWindow() void IOverlayWindowHost.HideOverlayWindow()
{ {
_dropAreas = null; _dropAreas = null;
if (_overlayWindow != null)
{
_overlayWindow.Owner = null; _overlayWindow.Owner = null;
_overlayWindow.HideDropTargets(); _overlayWindow.HideDropTargets();
}
} }
List<IDropArea> _dropAreas = null; List<IDropArea> _dropAreas = null;
@ -345,7 +352,7 @@ namespace Xceed.Wpf.AvalonDock.Controls
foreach (var anchorable in this.Model.Descendents().OfType<LayoutAnchorable>().ToArray()) foreach (var anchorable in this.Model.Descendents().OfType<LayoutAnchorable>().ToArray())
{ {
var anchorableLayoutItem = manager.GetLayoutItemFromModel(anchorable) as LayoutAnchorableItem; var anchorableLayoutItem = manager.GetLayoutItemFromModel(anchorable) as LayoutAnchorableItem;
anchorableLayoutItem.HideCommand.Execute(parameter); anchorableLayoutItem.CloseCommand.Execute(parameter);
} }
} }
#endregion #endregion

3
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableItem.cs

@ -267,7 +267,8 @@ namespace Xceed.Wpf.AvalonDock.Controls
{ {
if (LayoutElement == null) if (LayoutElement == null)
return false; return false;
return LayoutElement.FindParent<LayoutAnchorableFloatingWindow>() != null;
return LayoutElement.CanDock && LayoutElement.FindParent<LayoutAnchorableFloatingWindow>() != null;
} }
private void ExecuteDockCommand(object parameter) private void ExecuteDockCommand(object parameter)

52
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAutoHideWindowControl.cs

@ -28,6 +28,7 @@ using System.Windows.Media;
using Xceed.Wpf.AvalonDock.Layout; using Xceed.Wpf.AvalonDock.Layout;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Threading; using System.Windows.Threading;
using System.ComponentModel;
namespace Xceed.Wpf.AvalonDock.Controls namespace Xceed.Wpf.AvalonDock.Controls
{ {
@ -119,12 +120,23 @@ namespace Xceed.Wpf.AvalonDock.Controls
protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{ {
// Make sure that autohide windows always display on top of other Controls
// (even Win32 control which WPF cannot normally overlay!)
if (msg == Win32Helper.WM_WINDOWPOSCHANGING) if (msg == Win32Helper.WM_WINDOWPOSCHANGING)
{ {
if (_internalHost_ContentRendered) // APD Fix - Stop a recursive call to WndProc when the window has been destroyed
Win32Helper.SetWindowPos(_internalHwndSource.Handle, Win32Helper.HWND_TOP, 0, 0, 0, 0, Win32Helper.SetWindowPosFlags.IgnoreMove | Win32Helper.SetWindowPosFlags.IgnoreResize); // It was making a call to SetWindowPos which could cause a stack overflow.
if (_internalHost_ContentRendered)
{
Win32Helper.WINDOWPOS mwp = (Win32Helper.WINDOWPOS)Marshal.PtrToStructure(lParam, typeof(Win32Helper.WINDOWPOS));
mwp.hwndInsertAfter = Win32Helper.HWND_TOP;
mwp.flags = mwp.flags & ~(int)Win32Helper.SetWindowPosFlags.IgnoreZOrder;
Marshal.StructureToPtr(mwp, lParam, true);
}
} }
return base.WndProc(hwnd, msg, wParam, lParam, ref handled); return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
} }
protected override void DestroyWindowCore(System.Runtime.InteropServices.HandleRef hwnd) protected override void DestroyWindowCore(System.Runtime.InteropServices.HandleRef hwnd)
@ -478,23 +490,23 @@ namespace Xceed.Wpf.AvalonDock.Controls
return base.ArrangeOverride(finalSize);// new Size(_internalHostPresenter.ActualWidth, _internalHostPresenter.ActualHeight); return base.ArrangeOverride(finalSize);// new Size(_internalHostPresenter.ActualWidth, _internalHostPresenter.ActualHeight);
} }
WeakReference _lastFocusedElement = null; WeakReference _lastFocusedElement = null;
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
{ {
base.OnGotKeyboardFocus(e); base.OnGotKeyboardFocus(e);
if (!e.Handled && _internalHostPresenter != null) if (!e.Handled && _internalHostPresenter != null)
{ {
if (e.NewFocus == _internalHostPresenter) if (e.NewFocus == _internalHostPresenter)
{ {
var elementToFocus = _lastFocusedElement.GetValueOrDefault<IInputElement>(); var elementToFocus = _lastFocusedElement.GetValueOrDefault<IInputElement>();
if (elementToFocus != null) if (elementToFocus != null)
Keyboard.Focus(elementToFocus); Keyboard.Focus(elementToFocus);
e.Handled = true; e.Handled = true;
} }
else else
_lastFocusedElement = new WeakReference(e.NewFocus); _lastFocusedElement = new WeakReference(e.NewFocus);
} }
} }
#region Background #region Background

944
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutFloatingWindowControl.cs

@ -32,469 +32,487 @@ using Xceed.Wpf.AvalonDock.Themes;
namespace Xceed.Wpf.AvalonDock.Controls namespace Xceed.Wpf.AvalonDock.Controls
{ {
public abstract class LayoutFloatingWindowControl : Window, ILayoutControl public abstract class LayoutFloatingWindowControl : Window, ILayoutControl
{ {
static LayoutFloatingWindowControl() static LayoutFloatingWindowControl()
{ {
LayoutFloatingWindowControl.ContentProperty.OverrideMetadata(typeof(LayoutFloatingWindowControl), new FrameworkPropertyMetadata(null, null, new CoerceValueCallback(CoerceContentValue))); LayoutFloatingWindowControl.ContentProperty.OverrideMetadata(typeof(LayoutFloatingWindowControl), new FrameworkPropertyMetadata(null, null, new CoerceValueCallback(CoerceContentValue)));
AllowsTransparencyProperty.OverrideMetadata(typeof(LayoutFloatingWindowControl), new FrameworkPropertyMetadata(false)); AllowsTransparencyProperty.OverrideMetadata(typeof(LayoutFloatingWindowControl), new FrameworkPropertyMetadata(false));
ShowInTaskbarProperty.OverrideMetadata(typeof(LayoutFloatingWindowControl), new FrameworkPropertyMetadata(false)); ShowInTaskbarProperty.OverrideMetadata(typeof(LayoutFloatingWindowControl), new FrameworkPropertyMetadata(false));
} }
static object CoerceContentValue(DependencyObject sender, object content) static object CoerceContentValue(DependencyObject sender, object content)
{ {
return new FloatingWindowContentHost(sender as LayoutFloatingWindowControl) { Content = content as UIElement }; return new FloatingWindowContentHost(sender as LayoutFloatingWindowControl) { Content = content as UIElement };
} }
protected class FloatingWindowContentHost : HwndHost protected class FloatingWindowContentHost : HwndHost
{ {
LayoutFloatingWindowControl _owner; LayoutFloatingWindowControl _owner;
public FloatingWindowContentHost(LayoutFloatingWindowControl owner) public FloatingWindowContentHost(LayoutFloatingWindowControl owner)
{ {
_owner = owner; _owner = owner;
var manager = _owner.Model.Root.Manager; var manager = _owner.Model.Root.Manager;
} }
HwndSource _wpfContentHost = null; HwndSource _wpfContentHost = null;
Border _rootPresenter = null; Border _rootPresenter = null;
DockingManager _manager = null; DockingManager _manager = null;
protected override System.Runtime.InteropServices.HandleRef BuildWindowCore(System.Runtime.InteropServices.HandleRef hwndParent) protected override System.Runtime.InteropServices.HandleRef BuildWindowCore(System.Runtime.InteropServices.HandleRef hwndParent)
{ {
_wpfContentHost = new HwndSource(new HwndSourceParameters() _wpfContentHost = new HwndSource(new HwndSourceParameters()
{ {
ParentWindow = hwndParent.Handle, ParentWindow = hwndParent.Handle,
WindowStyle = Win32Helper.WS_CHILD | Win32Helper.WS_VISIBLE | Win32Helper.WS_CLIPSIBLINGS | Win32Helper.WS_CLIPCHILDREN, WindowStyle = Win32Helper.WS_CHILD | Win32Helper.WS_VISIBLE | Win32Helper.WS_CLIPSIBLINGS | Win32Helper.WS_CLIPCHILDREN,
Width = 1, Width = 1,
Height = 1 Height = 1
}); });
_rootPresenter = new Border() { Child = new AdornerDecorator() { Child = Content }, Focusable = true }; _rootPresenter = new Border() { Child = new AdornerDecorator() { Child = Content }, Focusable = true };
_rootPresenter.SetBinding(Border.BackgroundProperty, new Binding("Background") { Source = _owner }); _rootPresenter.SetBinding(Border.BackgroundProperty, new Binding("Background") { Source = _owner });
_wpfContentHost.RootVisual = _rootPresenter; _wpfContentHost.RootVisual = _rootPresenter;
_wpfContentHost.SizeToContent = SizeToContent.Manual; _wpfContentHost.SizeToContent = SizeToContent.Manual;
_manager = _owner.Model.Root.Manager; _manager = _owner.Model.Root.Manager;
_manager.InternalAddLogicalChild(_rootPresenter); _manager.InternalAddLogicalChild(_rootPresenter);
return new HandleRef(this, _wpfContentHost.Handle); return new HandleRef(this, _wpfContentHost.Handle);
} }
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
{ {
Trace.WriteLine("FloatingWindowContentHost.GotKeyboardFocus"); Trace.WriteLine("FloatingWindowContentHost.GotKeyboardFocus");
base.OnGotKeyboardFocus(e); base.OnGotKeyboardFocus(e);
} }
protected override void DestroyWindowCore(HandleRef hwnd) protected override void DestroyWindowCore(HandleRef hwnd)
{ {
_manager.InternalRemoveLogicalChild(_rootPresenter); _manager.InternalRemoveLogicalChild(_rootPresenter);
if (_wpfContentHost != null) if (_wpfContentHost != null)
{ {
_wpfContentHost.Dispose(); _wpfContentHost.Dispose();
_wpfContentHost = null; _wpfContentHost = null;
} }
} }
protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{ {
switch (msg) switch (msg)
{ {
case Win32Helper.WM_SETFOCUS: case Win32Helper.WM_SETFOCUS:
Trace.WriteLine("FloatingWindowContentHost.WM_SETFOCUS"); Trace.WriteLine("FloatingWindowContentHost.WM_SETFOCUS");
break; break;
case Win32Helper.WM_KILLFOCUS: case Win32Helper.WM_KILLFOCUS:
Trace.WriteLine("FloatingWindowContentHost.WM_KILLFOCUS"); Trace.WriteLine("FloatingWindowContentHost.WM_KILLFOCUS");
break; break;
} }
return base.WndProc(hwnd, msg, wParam, lParam, ref handled); return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
} }
public Visual RootVisual public Visual RootVisual
{ {
get { return _rootPresenter; } get { return _rootPresenter; }
} }
protected override Size MeasureOverride(Size constraint) protected override Size MeasureOverride(Size constraint)
{ {
if (Content == null) if (Content == null)
return base.MeasureOverride(constraint); return base.MeasureOverride(constraint);
Content.Measure(constraint); Content.Measure(constraint);
return Content.DesiredSize; return Content.DesiredSize;
} }
#region Content #region Content
/// <summary> /// <summary>
/// Content Dependency Property /// Content Dependency Property
/// </summary> /// </summary>
public static readonly DependencyProperty ContentProperty = public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register("Content", typeof(UIElement), typeof(FloatingWindowContentHost), DependencyProperty.Register("Content", typeof(UIElement), typeof(FloatingWindowContentHost),
new FrameworkPropertyMetadata((UIElement)null, new FrameworkPropertyMetadata((UIElement)null,
new PropertyChangedCallback(OnContentChanged))); new PropertyChangedCallback(OnContentChanged)));
/// <summary> /// <summary>
/// Gets or sets the Content property. This dependency property /// Gets or sets the Content property. This dependency property
/// indicates .... /// indicates ....
/// </summary> /// </summary>
public UIElement Content public UIElement Content
{ {
get { return (UIElement)GetValue(ContentProperty); } get { return (UIElement)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); } set { SetValue(ContentProperty, value); }
} }
/// <summary> /// <summary>
/// Handles changes to the Content property. /// Handles changes to the Content property.
/// </summary> /// </summary>
private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
((FloatingWindowContentHost)d).OnContentChanged(e); ((FloatingWindowContentHost)d).OnContentChanged(e);
} }
/// <summary> /// <summary>
/// Provides derived classes an opportunity to handle changes to the Content property. /// Provides derived classes an opportunity to handle changes to the Content property.
/// </summary> /// </summary>
protected virtual void OnContentChanged(DependencyPropertyChangedEventArgs e) protected virtual void OnContentChanged(DependencyPropertyChangedEventArgs e)
{ {
if (_rootPresenter != null) if (_rootPresenter != null)
_rootPresenter.Child = Content; _rootPresenter.Child = Content;
} }
#endregion #endregion
} }
ILayoutElement _model; ILayoutElement _model;
protected LayoutFloatingWindowControl(ILayoutElement model) protected LayoutFloatingWindowControl(ILayoutElement model)
{ {
this.Loaded += new RoutedEventHandler(OnLoaded); this.Loaded += new RoutedEventHandler(OnLoaded);
this.Unloaded += new RoutedEventHandler(OnUnloaded); this.Unloaded += new RoutedEventHandler(OnUnloaded);
_model = model; _model = model;
UpdateThemeResources(); UpdateThemeResources();
} }
internal virtual void UpdateThemeResources(Theme oldTheme = null) internal virtual void UpdateThemeResources(Theme oldTheme = null)
{ {
if (oldTheme != null) if (Application.Current != null)
{ return;
var resourceDictionaryToRemove =
Resources.MergedDictionaries.FirstOrDefault(r => r.Source == oldTheme.GetResourceUri()); if (oldTheme != null)
if (resourceDictionaryToRemove != null) {
Resources.MergedDictionaries.Remove( var resourceDictionaryToRemove =
resourceDictionaryToRemove); Resources.MergedDictionaries.FirstOrDefault(r => r.Source == oldTheme.GetResourceUri());
} if (resourceDictionaryToRemove != null)
Resources.MergedDictionaries.Remove(
var manager = _model.Root.Manager; resourceDictionaryToRemove);
if (manager.Theme != null) }
{
Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = manager.Theme.GetResourceUri() }); var manager = _model.Root.Manager;
} if (manager.Theme != null)
} {
Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = manager.Theme.GetResourceUri() });
protected override void OnClosed(EventArgs e) }
{ }
if (Content != null)
{ protected override void OnClosed(EventArgs e)
var host = Content as FloatingWindowContentHost; {
host.Dispose(); if (Content != null)
{
if (_hwndSrc != null) var host = Content as FloatingWindowContentHost;
{ host.Dispose();
_hwndSrc.RemoveHook(_hwndSrcHook);
_hwndSrc.Dispose(); if (_hwndSrc != null)
_hwndSrc = null; {
} _hwndSrc.RemoveHook(_hwndSrcHook);
} _hwndSrc.Dispose();
_hwndSrc = null;
base.OnClosed(e); }
} }
bool _attachDrag = false; base.OnClosed(e);
internal void AttachDrag(bool onActivated = true) }
{
if (onActivated) bool _attachDrag = false;
{ internal void AttachDrag(bool onActivated = true)
_attachDrag = true; {
this.Activated += new EventHandler(OnActivated); if (onActivated)
} {
else _attachDrag = true;
{ this.Activated += new EventHandler(OnActivated);
IntPtr windowHandle = new WindowInteropHelper(this).Handle; }
IntPtr lParam = new IntPtr(((int)Left & (int)0xFFFF) | (((int)Top) << 16)); else
Win32Helper.SendMessage(windowHandle, Win32Helper.WM_NCLBUTTONDOWN, new IntPtr(Win32Helper.HT_CAPTION), lParam); {
} IntPtr windowHandle = new WindowInteropHelper(this).Handle;
} IntPtr lParam = new IntPtr(((int)Left & (int)0xFFFF) | (((int)Top) << 16));
Win32Helper.SendMessage(windowHandle, Win32Helper.WM_NCLBUTTONDOWN, new IntPtr(Win32Helper.HT_CAPTION), lParam);
HwndSource _hwndSrc; }
HwndSourceHook _hwndSrcHook; }
void OnLoaded(object sender, RoutedEventArgs e) HwndSource _hwndSrc;
{ HwndSourceHook _hwndSrcHook;
this.Loaded -= new RoutedEventHandler(OnLoaded);
void OnLoaded(object sender, RoutedEventArgs e)
this.SetParentToMainWindowOf(Model.Root.Manager); {
this.Loaded -= new RoutedEventHandler(OnLoaded);
_hwndSrc = HwndSource.FromDependencyObject(this) as HwndSource; this.SetParentToMainWindowOf(Model.Root.Manager);
_hwndSrcHook = new HwndSourceHook(FilterMessage);
_hwndSrc.AddHook(_hwndSrcHook);
} _hwndSrc = HwndSource.FromDependencyObject(this) as HwndSource;
_hwndSrcHook = new HwndSourceHook(FilterMessage);
void OnUnloaded(object sender, RoutedEventArgs e) _hwndSrc.AddHook(_hwndSrcHook);
{ }
this.Unloaded -= new RoutedEventHandler(OnUnloaded);
void OnUnloaded(object sender, RoutedEventArgs e)
if (_hwndSrc != null) {
{ this.Unloaded -= new RoutedEventHandler(OnUnloaded);
_hwndSrc.RemoveHook(_hwndSrcHook);
_hwndSrc.Dispose(); if (_hwndSrc != null)
_hwndSrc = null; {
} _hwndSrc.RemoveHook(_hwndSrcHook);
} _hwndSrc.Dispose();
_hwndSrc = null;
void OnActivated(object sender, EventArgs e) }
{ }
this.Activated -= new EventHandler(OnActivated);
void OnActivated(object sender, EventArgs e)
if (_attachDrag && Mouse.LeftButton == MouseButtonState.Pressed) {
{ this.Activated -= new EventHandler(OnActivated);
IntPtr windowHandle = new WindowInteropHelper(this).Handle;
var mousePosition = this.PointToScreenDPI(Mouse.GetPosition(this)); if (_attachDrag && Mouse.LeftButton == MouseButtonState.Pressed)
var clientArea = Win32Helper.GetClientRect(windowHandle); {
var windowArea = Win32Helper.GetWindowRect(windowHandle); IntPtr windowHandle = new WindowInteropHelper(this).Handle;
var mousePosition = this.PointToScreenDPI(Mouse.GetPosition(this));
Left = mousePosition.X - windowArea.Width / 2.0; var clientArea = Win32Helper.GetClientRect(windowHandle);
Top = mousePosition.Y - (windowArea.Height - clientArea.Height) / 2.0; var windowArea = Win32Helper.GetWindowRect(windowHandle);
_attachDrag = false;
Left = mousePosition.X - windowArea.Width / 2.0;
IntPtr lParam = new IntPtr(((int)mousePosition.X & (int)0xFFFF) | (((int)mousePosition.Y) << 16)); Top = mousePosition.Y - (windowArea.Height - clientArea.Height) / 2.0;
Win32Helper.SendMessage(windowHandle, Win32Helper.WM_NCLBUTTONDOWN, new IntPtr(Win32Helper.HT_CAPTION), lParam); _attachDrag = false;
}
} IntPtr lParam = new IntPtr(((int)mousePosition.X & (int)0xFFFF) | (((int)mousePosition.Y) << 16));
Win32Helper.SendMessage(windowHandle, Win32Helper.WM_NCLBUTTONDOWN, new IntPtr(Win32Helper.HT_CAPTION), lParam);
}
protected override void OnInitialized(EventArgs e) }
{
CommandBindings.Add(new CommandBinding(Microsoft.Windows.Shell.SystemCommands.CloseWindowCommand,
new ExecutedRoutedEventHandler((s, args) => Microsoft.Windows.Shell.SystemCommands.CloseWindow((Window)args.Parameter)))); protected override void OnInitialized(EventArgs e)
CommandBindings.Add(new CommandBinding(Microsoft.Windows.Shell.SystemCommands.MaximizeWindowCommand, {
new ExecutedRoutedEventHandler((s, args) => Microsoft.Windows.Shell.SystemCommands.MaximizeWindow((Window)args.Parameter)))); CommandBindings.Add(new CommandBinding(Microsoft.Windows.Shell.SystemCommands.CloseWindowCommand,
CommandBindings.Add(new CommandBinding(Microsoft.Windows.Shell.SystemCommands.MinimizeWindowCommand, new ExecutedRoutedEventHandler((s, args) => Microsoft.Windows.Shell.SystemCommands.CloseWindow((Window)args.Parameter))));
new ExecutedRoutedEventHandler((s, args) => Microsoft.Windows.Shell.SystemCommands.MinimizeWindow((Window)args.Parameter)))); CommandBindings.Add(new CommandBinding(Microsoft.Windows.Shell.SystemCommands.MaximizeWindowCommand,
CommandBindings.Add(new CommandBinding(Microsoft.Windows.Shell.SystemCommands.RestoreWindowCommand, new ExecutedRoutedEventHandler((s, args) => Microsoft.Windows.Shell.SystemCommands.MaximizeWindow((Window)args.Parameter))));
new ExecutedRoutedEventHandler((s, args) => Microsoft.Windows.Shell.SystemCommands.RestoreWindow((Window)args.Parameter)))); CommandBindings.Add(new CommandBinding(Microsoft.Windows.Shell.SystemCommands.MinimizeWindowCommand,
//Debug.Assert(this.Owner != null); new ExecutedRoutedEventHandler((s, args) => Microsoft.Windows.Shell.SystemCommands.MinimizeWindow((Window)args.Parameter))));
base.OnInitialized(e); CommandBindings.Add(new CommandBinding(Microsoft.Windows.Shell.SystemCommands.RestoreWindowCommand,
} new ExecutedRoutedEventHandler((s, args) => Microsoft.Windows.Shell.SystemCommands.RestoreWindow((Window)args.Parameter))));
//Debug.Assert(this.Owner != null);
public abstract ILayoutElement Model { get; } base.OnInitialized(e);
}
#region IsDragging public abstract ILayoutElement Model { get; }
/// <summary>
/// IsDragging Read-Only Dependency Property #region IsDragging
/// </summary>
private static readonly DependencyPropertyKey IsDraggingPropertyKey /// <summary>
= DependencyProperty.RegisterReadOnly("IsDragging", typeof(bool), typeof(LayoutFloatingWindowControl), /// IsDragging Read-Only Dependency Property
new FrameworkPropertyMetadata((bool)false, /// </summary>
new PropertyChangedCallback(OnIsDraggingChanged))); private static readonly DependencyPropertyKey IsDraggingPropertyKey
= DependencyProperty.RegisterReadOnly("IsDragging", typeof(bool), typeof(LayoutFloatingWindowControl),
public static readonly DependencyProperty IsDraggingProperty new FrameworkPropertyMetadata((bool)false,
= IsDraggingPropertyKey.DependencyProperty; new PropertyChangedCallback(OnIsDraggingChanged)));
/// <summary> public static readonly DependencyProperty IsDraggingProperty
/// Gets the IsDragging property. This dependency property = IsDraggingPropertyKey.DependencyProperty;
/// indicates that this floating window is being dragged.
/// </summary> /// <summary>
public bool IsDragging /// Gets the IsDragging property. This dependency property
{ /// indicates that this floating window is being dragged.
get { return (bool)GetValue(IsDraggingProperty); } /// </summary>
} public bool IsDragging
{
/// <summary> get { return (bool)GetValue(IsDraggingProperty); }
/// Provides a secure method for setting the IsDragging property. }
/// This dependency property indicates that this floating window is being dragged.
/// </summary> /// <summary>
/// <param name="value">The new value for the property.</param> /// Provides a secure method for setting the IsDragging property.
protected void SetIsDragging(bool value) /// This dependency property indicates that this floating window is being dragged.
{ /// </summary>
SetValue(IsDraggingPropertyKey, value); /// <param name="value">The new value for the property.</param>
} protected void SetIsDragging(bool value)
{
/// <summary> SetValue(IsDraggingPropertyKey, value);
/// Handles changes to the IsDragging property. }
/// </summary>
private static void OnIsDraggingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) /// <summary>
{ /// Handles changes to the IsDragging property.
((LayoutFloatingWindowControl)d).OnIsDraggingChanged(e); /// </summary>
} private static void OnIsDraggingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
/// <summary> ((LayoutFloatingWindowControl)d).OnIsDraggingChanged(e);
/// Provides derived classes an opportunity to handle changes to the IsDragging property. }
/// </summary>
protected virtual void OnIsDraggingChanged(DependencyPropertyChangedEventArgs e) /// <summary>
{ /// Provides derived classes an opportunity to handle changes to the IsDragging property.
//Trace.WriteLine("IsDragging={0}", e.NewValue); /// </summary>
} protected virtual void OnIsDraggingChanged(DependencyPropertyChangedEventArgs e)
{
#endregion //Trace.WriteLine("IsDragging={0}", e.NewValue);
}
#endregion
DragService _dragService = null;
void UpdatePositionAndSizeOfPanes()
{ DragService _dragService = null;
foreach (var posElement in Model.Descendents().OfType<ILayoutElementForFloatingWindow>())
{ void UpdatePositionAndSizeOfPanes()
posElement.FloatingLeft = Left; {
posElement.FloatingTop = Top; foreach (var posElement in Model.Descendents().OfType<ILayoutElementForFloatingWindow>())
posElement.FloatingWidth = Width; {
posElement.FloatingHeight = Height; posElement.FloatingLeft = Left;
posElement.IsMaximized = this.WindowState == System.Windows.WindowState.Maximized; posElement.FloatingTop = Top;
} posElement.FloatingWidth = Width;
} posElement.FloatingHeight = Height;
}
protected virtual IntPtr FilterMessage( }
IntPtr hwnd,
int msg, void UpdateMaximizedState(bool isMaximized)
IntPtr wParam, {
IntPtr lParam, foreach (var posElement in Model.Descendents().OfType<ILayoutElementForFloatingWindow>())
ref bool handled {
) posElement.IsMaximized = isMaximized;
{ }
handled = false; }
switch (msg) protected virtual IntPtr FilterMessage(
{ IntPtr hwnd,
case Win32Helper.WM_ACTIVATE: int msg,
if (((int)wParam & 0xFFFF) == Win32Helper.WA_INACTIVE) IntPtr wParam,
{ IntPtr lParam,
if (lParam == this.GetParentWindowHandle()) ref bool handled
{ )
Win32Helper.SetActiveWindow(_hwndSrc.Handle); {
handled = true; handled = false;
}
} switch (msg)
break; {
case Win32Helper.WM_EXITSIZEMOVE: case Win32Helper.WM_ACTIVATE:
UpdatePositionAndSizeOfPanes(); if (((int)wParam & 0xFFFF) == Win32Helper.WA_INACTIVE)
{
if (_dragService != null) if (lParam == this.GetParentWindowHandle())
{ {
bool dropFlag; Win32Helper.SetActiveWindow(_hwndSrc.Handle);
var mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition()); handled = true;
_dragService.Drop(mousePosition, out dropFlag); }
_dragService = null; }
SetIsDragging(false); break;
case Win32Helper.WM_EXITSIZEMOVE:
if (dropFlag) UpdatePositionAndSizeOfPanes();
InternalClose();
} if (_dragService != null)
{
break; bool dropFlag;
case Win32Helper.WM_MOVING: var mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());
{ _dragService.Drop(mousePosition, out dropFlag);
UpdateDragPosition(); _dragService = null;
} SetIsDragging(false);
break;
case Win32Helper.WM_LBUTTONUP: //set as handled right button click on title area (after showing context menu) if (dropFlag)
if (_dragService != null && Mouse.LeftButton == MouseButtonState.Released) InternalClose();
{ }
_dragService.Abort();
_dragService = null; break;
SetIsDragging(false); case Win32Helper.WM_MOVING:
} {
break; UpdateDragPosition();
} }
break;
case Win32Helper.WM_LBUTTONUP: //set as handled right button click on title area (after showing context menu)
if (_dragService != null && Mouse.LeftButton == MouseButtonState.Released)
return IntPtr.Zero; {
} _dragService.Abort();
_dragService = null;
private void UpdateDragPosition() SetIsDragging(false);
{ }
if (_dragService == null) break;
{ case Win32Helper.WM_SYSCOMMAND:
_dragService = new DragService(this); IntPtr wMaximize = new IntPtr(Win32Helper.SC_MAXIMIZE);
SetIsDragging(true); IntPtr wRestore = new IntPtr(Win32Helper.SC_RESTORE);
} if (wParam == wMaximize || wParam == wRestore)
{
var mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition()); UpdateMaximizedState(wParam == wMaximize);
_dragService.UpdateMouseLocation(mousePosition); }
} break;
}
bool _internalCloseFlag = false;
internal void InternalClose()
{ return IntPtr.Zero;
_internalCloseFlag = true; }
Close();
} private void UpdateDragPosition()
{
if (_dragService == null)
protected bool CloseInitiatedByUser {
{ _dragService = new DragService(this);
get { return !_internalCloseFlag; } SetIsDragging(true);
} }
internal bool KeepContentVisibleOnClose var mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());
{ _dragService.UpdateMouseLocation(mousePosition);
get; }
set;
} bool _internalCloseFlag = false;
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) internal void InternalClose()
{ {
base.OnMouseLeftButtonUp(e); _internalCloseFlag = true;
} Close();
}
#region IsMaximized
/// <summary> protected bool CloseInitiatedByUser
/// IsMaximized Read-Only Dependency Property {
/// </summary> get { return !_internalCloseFlag; }
private static readonly DependencyPropertyKey IsMaximizedPropertyKey }
= DependencyProperty.RegisterReadOnly("IsMaximized", typeof(bool), typeof(LayoutFloatingWindowControl),
new FrameworkPropertyMetadata((bool)false)); internal bool KeepContentVisibleOnClose
{
public static readonly DependencyProperty IsMaximizedProperty get;
= IsMaximizedPropertyKey.DependencyProperty; set;
}
/// <summary>
/// Gets the IsMaximized property. This dependency property protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
/// indicates if the window is maximized. {
/// </summary> base.OnMouseLeftButtonUp(e);
public bool IsMaximized }
{
get { return (bool)GetValue(IsMaximizedProperty); } #region IsMaximized
}
/// <summary>
/// <summary> /// IsMaximized Read-Only Dependency Property
/// Provides a secure method for setting the IsMaximized property. /// </summary>
/// This dependency property indicates if the window is maximized. private static readonly DependencyPropertyKey IsMaximizedPropertyKey
/// </summary> = DependencyProperty.RegisterReadOnly("IsMaximized", typeof(bool), typeof(LayoutFloatingWindowControl),
/// <param name="value">The new value for the property.</param> new FrameworkPropertyMetadata((bool)false));
protected void SetIsMaximized(bool value)
{ public static readonly DependencyProperty IsMaximizedProperty
SetValue(IsMaximizedPropertyKey, value); = IsMaximizedPropertyKey.DependencyProperty;
}
/// <summary>
protected override void OnStateChanged(EventArgs e) /// Gets the IsMaximized property. This dependency property
{ /// indicates if the window is maximized.
SetIsMaximized(WindowState == System.Windows.WindowState.Maximized); /// </summary>
base.OnStateChanged(e); public bool IsMaximized
} {
get { return (bool)GetValue(IsMaximizedProperty); }
#endregion }
/// <summary>
/// Provides a secure method for setting the IsMaximized property.
/// This dependency property indicates if the window is maximized.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetIsMaximized(bool value)
{
SetValue(IsMaximizedPropertyKey, value);
}
protected override void OnStateChanged(EventArgs e)
{
SetIsMaximized(WindowState == System.Windows.WindowState.Maximized);
base.OnStateChanged(e);
}
#endregion
}
}
} }

1
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs

@ -525,6 +525,7 @@ namespace Xceed.Wpf.AvalonDock.Controls
_resizerWindowHost = new Window() _resizerWindowHost = new Window()
{ {
SizeToContent = System.Windows.SizeToContent.Manual,
ResizeMode = ResizeMode.NoResize, ResizeMode = ResizeMode.NoResize,
WindowStyle = System.Windows.WindowStyle.None, WindowStyle = System.Windows.WindowStyle.None,
ShowInTaskbar = false, ShowInTaskbar = false,

33
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutItem.cs

@ -523,6 +523,31 @@ namespace Xceed.Wpf.AvalonDock.Controls
#endregion #endregion
#region CanDock
public static readonly DependencyProperty CanDockProperty =
DependencyProperty.Register("CanDock", typeof(bool), typeof(LayoutItem),
new FrameworkPropertyMetadata(true,
new PropertyChangedCallback(OnCanDockChanged)));
public bool CanDock
{
get { return (bool)GetValue(CanDockProperty); }
set { SetValue(CanDockProperty, value); }
}
private static void OnCanDockChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((LayoutItem)d).OnCanDockChanged(e);
}
protected virtual void OnCanDockChanged(DependencyPropertyChangedEventArgs e)
{
LayoutElement.CanDock = (bool)e.NewValue;
}
#endregion
#region CloseCommand #region CloseCommand
/// <summary> /// <summary>
@ -570,10 +595,10 @@ namespace Xceed.Wpf.AvalonDock.Controls
private bool CanExecuteCloseCommand(object parameter) private bool CanExecuteCloseCommand(object parameter)
{ {
#if DEBUG #if DEBUG
if( LayoutElement != null ) if( LayoutElement != null )
System.Diagnostics.Trace.WriteLine( string.Format( "CanExecuteCloseCommand({0}) = {1}", LayoutElement.Title, LayoutElement.CanClose ) ); System.Diagnostics.Trace.WriteLine( string.Format( "CanExecuteCloseCommand({0}) = {1}", LayoutElement.Title, LayoutElement.CanClose ) );
#endif #endif
return LayoutElement != null && LayoutElement.CanClose; return LayoutElement != null && LayoutElement.CanClose;
} }
private void ExecuteCloseCommand(object parameter) private void ExecuteCloseCommand(object parameter)
@ -694,7 +719,7 @@ namespace Xceed.Wpf.AvalonDock.Controls
private bool CanExecuteDockAsDocumentCommand(object parameter) private bool CanExecuteDockAsDocumentCommand(object parameter)
{ {
return LayoutElement != null && LayoutElement.FindParent<LayoutDocumentPane>() == null; return LayoutElement != null && LayoutElement.CanDock && LayoutElement.FindParent<LayoutDocumentPane>() == null;
} }
private void ExecuteDockAsDocumentCommand(object parameter) private void ExecuteDockAsDocumentCommand(object parameter)

3
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/NavigatorWindow.cs

@ -59,6 +59,9 @@ namespace Xceed.Wpf.AvalonDock.Controls
internal void UpdateThemeResources(Theme oldTheme = null) internal void UpdateThemeResources(Theme oldTheme = null)
{ {
if (Application.Current != null)
return;
if (oldTheme != null) if (oldTheme != null)
{ {
var resourceDictionaryToRemove = var resourceDictionaryToRemove =

1071
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/OverlayWindow.cs

File diff suppressed because it is too large

6363
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/DockingManager.cs

File diff suppressed because it is too large

1518
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/LayoutContent.cs

File diff suppressed because it is too large

544
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/LayoutPositionableGroup.cs

@ -23,274 +23,278 @@ using System.Globalization;
namespace Xceed.Wpf.AvalonDock.Layout namespace Xceed.Wpf.AvalonDock.Layout
{ {
[Serializable] [Serializable]
public abstract class LayoutPositionableGroup<T> : LayoutGroup<T>, ILayoutPositionableElement, ILayoutPositionableElementWithActualSize where T : class, ILayoutElement public abstract class LayoutPositionableGroup<T> : LayoutGroup<T>, ILayoutPositionableElement, ILayoutPositionableElementWithActualSize where T : class, ILayoutElement
{ {
public LayoutPositionableGroup() public LayoutPositionableGroup()
{ } { }
GridLength _dockWidth = new GridLength(1.0, GridUnitType.Star); GridLength _dockWidth = new GridLength(1.0, GridUnitType.Star);
public GridLength DockWidth public GridLength DockWidth
{ {
get get
{ {
return _dockWidth; return _dockWidth;
} }
set set
{ {
if (DockWidth != value) if (DockWidth != value)
{ {
RaisePropertyChanging("DockWidth"); RaisePropertyChanging("DockWidth");
_dockWidth = value; _dockWidth = value;
RaisePropertyChanged("DockWidth"); RaisePropertyChanged("DockWidth");
OnDockWidthChanged(); OnDockWidthChanged();
} }
} }
} }
protected virtual void OnDockWidthChanged() protected virtual void OnDockWidthChanged()
{ {
} }
GridLength _dockHeight = new GridLength(1.0, GridUnitType.Star); GridLength _dockHeight = new GridLength(1.0, GridUnitType.Star);
public GridLength DockHeight public GridLength DockHeight
{ {
get get
{ {
return _dockHeight; return _dockHeight;
} }
set set
{ {
if (DockHeight != value) if (DockHeight != value)
{ {
RaisePropertyChanging("DockHeight"); RaisePropertyChanging("DockHeight");
_dockHeight = value; _dockHeight = value;
RaisePropertyChanged("DockHeight"); RaisePropertyChanged("DockHeight");
OnDockHeightChanged(); OnDockHeightChanged();
} }
} }
} }
protected virtual void OnDockHeightChanged() protected virtual void OnDockHeightChanged()
{ {
} }
#region DockMinWidth #region DockMinWidth
private double _dockMinWidth = 25.0; private double _dockMinWidth = 25.0;
public double DockMinWidth public double DockMinWidth
{ {
get { return _dockMinWidth; } get { return _dockMinWidth; }
set set
{ {
if (_dockMinWidth != value) if (_dockMinWidth != value)
{ {
MathHelper.AssertIsPositiveOrZero(value); MathHelper.AssertIsPositiveOrZero(value);
RaisePropertyChanging("DockMinWidth"); RaisePropertyChanging("DockMinWidth");
_dockMinWidth = value; _dockMinWidth = value;
RaisePropertyChanged("DockMinWidth"); RaisePropertyChanged("DockMinWidth");
} }
} }
} }
#endregion #endregion
#region DockMinHeight #region DockMinHeight
private double _dockMinHeight = 25.0; private double _dockMinHeight = 25.0;
public double DockMinHeight public double DockMinHeight
{ {
get { return _dockMinHeight; } get { return _dockMinHeight; }
set set
{ {
if (_dockMinHeight != value) if (_dockMinHeight != value)
{ {
MathHelper.AssertIsPositiveOrZero(value); MathHelper.AssertIsPositiveOrZero(value);
RaisePropertyChanging("DockMinHeight"); RaisePropertyChanging("DockMinHeight");
_dockMinHeight = value; _dockMinHeight = value;
RaisePropertyChanged("DockMinHeight"); RaisePropertyChanged("DockMinHeight");
} }
} }
} }
#endregion #endregion
#region FloatingWidth #region FloatingWidth
private double _floatingWidth = 0.0; private double _floatingWidth = 0.0;
public double FloatingWidth public double FloatingWidth
{ {
get { return _floatingWidth; } get { return _floatingWidth; }
set set
{ {
if (_floatingWidth != value) if (_floatingWidth != value)
{ {
RaisePropertyChanging("FloatingWidth"); RaisePropertyChanging("FloatingWidth");
_floatingWidth = value; _floatingWidth = value;
RaisePropertyChanged("FloatingWidth"); RaisePropertyChanged("FloatingWidth");
} }
} }
} }
#endregion #endregion
#region FloatingHeight #region FloatingHeight
private double _floatingHeight = 0.0; private double _floatingHeight = 0.0;
public double FloatingHeight public double FloatingHeight
{ {
get { return _floatingHeight; } get { return _floatingHeight; }
set set
{ {
if (_floatingHeight != value) if (_floatingHeight != value)
{ {
RaisePropertyChanging("FloatingHeight"); RaisePropertyChanging("FloatingHeight");
_floatingHeight = value; _floatingHeight = value;
RaisePropertyChanged("FloatingHeight"); RaisePropertyChanged("FloatingHeight");
} }
} }
} }
#endregion #endregion
#region FloatingLeft #region FloatingLeft
private double _floatingLeft = 0.0; private double _floatingLeft = 0.0;
public double FloatingLeft public double FloatingLeft
{ {
get { return _floatingLeft; } get { return _floatingLeft; }
set set
{ {
if (_floatingLeft != value) if (_floatingLeft != value)
{ {
RaisePropertyChanging("FloatingLeft"); RaisePropertyChanging("FloatingLeft");
_floatingLeft = value; _floatingLeft = value;
RaisePropertyChanged("FloatingLeft"); RaisePropertyChanged("FloatingLeft");
} }
} }
} }
#endregion #endregion
#region FloatingTop #region FloatingTop
private double _floatingTop = 0.0; private double _floatingTop = 0.0;
public double FloatingTop public double FloatingTop
{ {
get { return _floatingTop; } get { return _floatingTop; }
set set
{ {
if (_floatingTop != value) if (_floatingTop != value)
{ {
RaisePropertyChanging("FloatingTop"); RaisePropertyChanging("FloatingTop");
_floatingTop = value; _floatingTop = value;
RaisePropertyChanged("FloatingTop"); RaisePropertyChanged("FloatingTop");
} }
} }
} }
#endregion #endregion
#region IsMaximized #region IsMaximized
private bool _isMaximized = false; private bool _isMaximized = false;
public bool IsMaximized public bool IsMaximized
{ {
get { return _isMaximized; } get { return _isMaximized; }
set set
{ {
if (_isMaximized != value) if (_isMaximized != value)
{ {
_isMaximized = value; _isMaximized = value;
RaisePropertyChanged("IsMaximized"); RaisePropertyChanged("IsMaximized");
} }
} }
} }
#endregion #endregion
[NonSerialized] [NonSerialized]
double _actualWidth; double _actualWidth;
double ILayoutPositionableElementWithActualSize.ActualWidth double ILayoutPositionableElementWithActualSize.ActualWidth
{ {
get get
{ {
return _actualWidth; return _actualWidth;
} }
set set
{ {
_actualWidth = value; _actualWidth = value;
} }
} }
[NonSerialized] [NonSerialized]
double _actualHeight; double _actualHeight;
double ILayoutPositionableElementWithActualSize.ActualHeight double ILayoutPositionableElementWithActualSize.ActualHeight
{ {
get get
{ {
return _actualHeight; return _actualHeight;
} }
set set
{ {
_actualHeight = value; _actualHeight = value;
} }
} }
public override void WriteXml(System.Xml.XmlWriter writer) public override void WriteXml(System.Xml.XmlWriter writer)
{ {
if (DockWidth.Value != 1.0 || !DockWidth.IsStar) if (DockWidth.Value != 1.0 || !DockWidth.IsStar)
writer.WriteAttributeString("DockWidth", _gridLengthConverter.ConvertToInvariantString(DockWidth)); writer.WriteAttributeString("DockWidth", _gridLengthConverter.ConvertToInvariantString(DockWidth));
if (DockHeight.Value != 1.0 || !DockHeight.IsStar) if (DockHeight.Value != 1.0 || !DockHeight.IsStar)
writer.WriteAttributeString("DockHeight", _gridLengthConverter.ConvertToInvariantString(DockHeight)); writer.WriteAttributeString("DockHeight", _gridLengthConverter.ConvertToInvariantString(DockHeight));
if (DockMinWidth != 25.0) if (DockMinWidth != 25.0)
writer.WriteAttributeString("DocMinWidth", DockMinWidth.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("DocMinWidth", DockMinWidth.ToString(CultureInfo.InvariantCulture));
if (DockMinHeight != 25.0) if (DockMinHeight != 25.0)
writer.WriteAttributeString("DockMinHeight", DockMinHeight.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("DockMinHeight", DockMinHeight.ToString(CultureInfo.InvariantCulture));
if (FloatingWidth != 0.0) if (FloatingWidth != 0.0)
writer.WriteAttributeString("FloatingWidth", FloatingWidth.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("FloatingWidth", FloatingWidth.ToString(CultureInfo.InvariantCulture));
if (FloatingHeight != 0.0) if (FloatingHeight != 0.0)
writer.WriteAttributeString("FloatingHeight", FloatingHeight.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("FloatingHeight", FloatingHeight.ToString(CultureInfo.InvariantCulture));
if (FloatingLeft != 0.0) if (FloatingLeft != 0.0)
writer.WriteAttributeString("FloatingLeft", FloatingLeft.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("FloatingLeft", FloatingLeft.ToString(CultureInfo.InvariantCulture));
if (FloatingTop != 0.0) if (FloatingTop != 0.0)
writer.WriteAttributeString("FloatingTop", FloatingTop.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("FloatingTop", FloatingTop.ToString(CultureInfo.InvariantCulture));
if (IsMaximized)
base.WriteXml(writer); writer.WriteAttributeString("IsMaximized", IsMaximized.ToString());
}
base.WriteXml(writer);
static GridLengthConverter _gridLengthConverter = new GridLengthConverter(); }
public override void ReadXml(System.Xml.XmlReader reader)
{ static GridLengthConverter _gridLengthConverter = new GridLengthConverter();
if (reader.MoveToAttribute("DockWidth")) public override void ReadXml(System.Xml.XmlReader reader)
_dockWidth = (GridLength)_gridLengthConverter.ConvertFromInvariantString(reader.Value); {
if (reader.MoveToAttribute("DockHeight")) if (reader.MoveToAttribute("DockWidth"))
_dockHeight = (GridLength)_gridLengthConverter.ConvertFromInvariantString(reader.Value); _dockWidth = (GridLength)_gridLengthConverter.ConvertFromInvariantString(reader.Value);
if (reader.MoveToAttribute("DockHeight"))
if (reader.MoveToAttribute("DocMinWidth")) _dockHeight = (GridLength)_gridLengthConverter.ConvertFromInvariantString(reader.Value);
_dockMinWidth = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("DocMinHeight")) if (reader.MoveToAttribute("DocMinWidth"))
_dockMinHeight = double.Parse(reader.Value, CultureInfo.InvariantCulture); _dockMinWidth = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("DocMinHeight"))
if (reader.MoveToAttribute("FloatingWidth")) _dockMinHeight = double.Parse(reader.Value, CultureInfo.InvariantCulture);
_floatingWidth = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("FloatingHeight")) if (reader.MoveToAttribute("FloatingWidth"))
_floatingHeight = double.Parse(reader.Value, CultureInfo.InvariantCulture); _floatingWidth = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("FloatingLeft")) if (reader.MoveToAttribute("FloatingHeight"))
_floatingLeft = double.Parse(reader.Value, CultureInfo.InvariantCulture); _floatingHeight = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("FloatingTop")) if (reader.MoveToAttribute("FloatingLeft"))
_floatingTop = double.Parse(reader.Value, CultureInfo.InvariantCulture); _floatingLeft = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("FloatingTop"))
base.ReadXml(reader); _floatingTop = double.Parse(reader.Value, CultureInfo.InvariantCulture);
} if (reader.MoveToAttribute("IsMaximized"))
} _isMaximized = bool.Parse(reader.Value);
base.ReadXml(reader);
}
}
} }

29
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/Serialization/LayoutSerializer.cs

@ -134,5 +134,34 @@ namespace Xceed.Wpf.AvalonDock.Layout.Serialization
Manager.SuspendDocumentsSourceBinding = false; Manager.SuspendDocumentsSourceBinding = false;
Manager.SuspendAnchorablesSourceBinding = false; Manager.SuspendAnchorablesSourceBinding = false;
} }
#region Virtual Serialize and Deserialize methods
public virtual void Serialize(System.Xml.XmlWriter writer)
{
} }
public virtual void Serialize(System.IO.TextWriter writer)
{
}
public virtual void Serialize(System.IO.Stream stream)
{
}
public virtual void Serialize(string filepath)
{
}
public virtual void Deserialize(System.IO.Stream stream)
{
}
public virtual void Deserialize(System.IO.TextReader reader)
{
}
public virtual void Deserialize(System.Xml.XmlReader reader)
{
}
public virtual void Deserialize(string filepath)
{
}
#endregion
}
} }

16
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/Serialization/XmlLayoutSerializer.cs

@ -31,29 +31,29 @@ namespace Xceed.Wpf.AvalonDock.Layout.Serialization
} }
public void Serialize(System.Xml.XmlWriter writer) public override void Serialize(System.Xml.XmlWriter writer)
{ {
var serializer = new XmlSerializer(typeof(LayoutRoot)); var serializer = new XmlSerializer(typeof(LayoutRoot));
serializer.Serialize(writer, Manager.Layout); serializer.Serialize(writer, Manager.Layout);
} }
public void Serialize(System.IO.TextWriter writer) public override void Serialize(System.IO.TextWriter writer)
{ {
var serializer = new XmlSerializer(typeof(LayoutRoot)); var serializer = new XmlSerializer(typeof(LayoutRoot));
serializer.Serialize(writer, Manager.Layout); serializer.Serialize(writer, Manager.Layout);
} }
public void Serialize(System.IO.Stream stream) public override void Serialize(System.IO.Stream stream)
{ {
var serializer = new XmlSerializer(typeof(LayoutRoot)); var serializer = new XmlSerializer(typeof(LayoutRoot));
serializer.Serialize(stream, Manager.Layout); serializer.Serialize(stream, Manager.Layout);
} }
public void Serialize(string filepath) public override void Serialize(string filepath)
{ {
using (var stream = new StreamWriter(filepath)) using (var stream = new StreamWriter(filepath))
Serialize(stream); Serialize(stream);
} }
public void Deserialize(System.IO.Stream stream) public override void Deserialize(System.IO.Stream stream)
{ {
try try
{ {
@ -69,7 +69,7 @@ namespace Xceed.Wpf.AvalonDock.Layout.Serialization
} }
} }
public void Deserialize(System.IO.TextReader reader) public override void Deserialize(System.IO.TextReader reader)
{ {
try try
{ {
@ -85,7 +85,7 @@ namespace Xceed.Wpf.AvalonDock.Layout.Serialization
} }
} }
public void Deserialize(System.Xml.XmlReader reader) public override void Deserialize(System.Xml.XmlReader reader)
{ {
try try
{ {
@ -101,7 +101,7 @@ namespace Xceed.Wpf.AvalonDock.Layout.Serialization
} }
} }
public void Deserialize(string filepath) public override void Deserialize(string filepath)
{ {
using (var stream = new StreamReader(filepath)) using (var stream = new StreamReader(filepath))
Deserialize(stream); Deserialize(stream);

5
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Win32Helper.cs

@ -164,6 +164,11 @@ namespace Xceed.Wpf.AvalonDock
internal const int WA_INACTIVE = 0x0000; internal const int WA_INACTIVE = 0x0000;
internal const int WM_SYSCOMMAND = 0x0112;
// These are the wParam of WM_SYSCOMMAND
internal const int SC_MAXIMIZE = 0xF030;
internal const int SC_RESTORE = 0xF120;
internal const int internal const int
WM_CREATE = 0x0001; WM_CREATE = 0x0001;

3
ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Xceed.Wpf.AvalonDock.csproj

@ -21,7 +21,7 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
@ -349,7 +349,6 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

Loading…
Cancel
Save