Browse Source

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

pull/1645/head
Johannes Brittain 7 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. 45
      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. 15
      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)
{
if(_currentAutohiddenAnchor.GetValueOrDefault<LayoutAnchorControl>() != anchor)
{
StopCloseTimer();
_currentAutohiddenAnchor = new WeakReference(anchor);
_manager.AutoHideWindow.Show(anchor);
StartCloseTimer();
}
}
public void HideAutoWindow(LayoutAnchorControl anchor = null)
@ -81,6 +84,7 @@ namespace Xceed.Wpf.AvalonDock.Controls
{
_closeTimer.Stop();
_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)
{
if (!_floatingWindow.Model.Root.ActiveContent.CanDock) return;
var floatingWindowModel = _floatingWindow.Model as LayoutFloatingWindow;
var newHost = _overlayWindowHosts.FirstOrDefault(oh => oh.HitTest(dragPosition));
@ -89,8 +91,19 @@ namespace Xceed.Wpf.AvalonDock.Controls
}
}
if (_currentHost == null)
return;
if (_currentHost == null)
{
Debug.WriteLine("Zero Dock Areas");
if(_manager.Parent is DockingManager)
{
_manager = _manager.Parent as DockingManager;
GetOverlayWindowHosts();
UpdateMouseLocation(dragPosition);
}
return;
}
if (_currentDropTarget != null &&
!_currentDropTarget.HitTest(dragPosition))
@ -175,7 +188,8 @@ namespace Xceed.Wpf.AvalonDock.Controls
{
var floatingWindowModel = _floatingWindow.Model as LayoutFloatingWindow;
_currentWindowAreas.ForEach(a => _currentWindow.DragLeave(a));
if(_currentWindow != null)
_currentWindowAreas.ForEach(a => _currentWindow.DragLeave(a));
if (_currentDropTarget != null)
_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;
if (focusedElement != null &&
!(focusedElement is LayoutAnchorableTabItem || focusedElement is LayoutDocumentTabItem) &&
!(focusedElement is ICommandSource))//Avoid tracking focus for elements like this
!(focusedElement is LayoutAnchorableTabItem || focusedElement is LayoutDocumentTabItem))
{
var parentAnchorable = focusedElement.FindVisualAncestor<LayoutAnchorableControl>();
if (parentAnchorable != null)

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

@ -105,14 +105,31 @@ namespace Xceed.Wpf.AvalonDock.Controls
if (!e.Handled)
{
_model.Root.Manager.ShowAutoHideWindow(this);
_model.IsActive = true;
if (_model.Root.Manager.AutoHideWindow.Visibility != Visibility.Visible)
{
_model.Root.Manager.ShowAutoHideWindow(this);
_model.IsActive = true;
_manuallyOpened = true;
}
else
{
if (!_inGracePeriod)
{
_model.Root.Manager.HideAutoHideWindow(this);
}
}
}
}
DispatcherTimer _openUpTimer = null;
DispatcherTimer _clickGracePeriodTimer = null;
bool _inGracePeriod = false;
bool _manuallyOpened = false;
protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
{
base.OnMouseEnter(e);
@ -132,6 +149,30 @@ namespace Xceed.Wpf.AvalonDock.Controls
_openUpTimer.Stop();
_openUpTimer = null;
_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)

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

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

@ -267,7 +267,8 @@ namespace Xceed.Wpf.AvalonDock.Controls
{
if (LayoutElement == null)
return false;
return LayoutElement.FindParent<LayoutAnchorableFloatingWindow>() != null;
return LayoutElement.CanDock && LayoutElement.FindParent<LayoutAnchorableFloatingWindow>() != null;
}
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 System.Diagnostics;
using System.Windows.Threading;
using System.ComponentModel;
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)
{
// 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 (_internalHost_ContentRendered)
Win32Helper.SetWindowPos(_internalHwndSource.Handle, Win32Helper.HWND_TOP, 0, 0, 0, 0, Win32Helper.SetWindowPosFlags.IgnoreMove | Win32Helper.SetWindowPosFlags.IgnoreResize);
// APD Fix - Stop a recursive call to WndProc when the window has been destroyed
// 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)
@ -478,23 +490,23 @@ namespace Xceed.Wpf.AvalonDock.Controls
return base.ArrangeOverride(finalSize);// new Size(_internalHostPresenter.ActualWidth, _internalHostPresenter.ActualHeight);
}
WeakReference _lastFocusedElement = null;
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
base.OnGotKeyboardFocus(e);
if (!e.Handled && _internalHostPresenter != null)
{
if (e.NewFocus == _internalHostPresenter)
{
var elementToFocus = _lastFocusedElement.GetValueOrDefault<IInputElement>();
if (elementToFocus != null)
Keyboard.Focus(elementToFocus);
e.Handled = true;
}
else
_lastFocusedElement = new WeakReference(e.NewFocus);
}
}
WeakReference _lastFocusedElement = null;
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
base.OnGotKeyboardFocus(e);
if (!e.Handled && _internalHostPresenter != null)
{
if (e.NewFocus == _internalHostPresenter)
{
var elementToFocus = _lastFocusedElement.GetValueOrDefault<IInputElement>();
if (elementToFocus != null)
Keyboard.Focus(elementToFocus);
e.Handled = true;
}
else
_lastFocusedElement = new WeakReference(e.NewFocus);
}
}
#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
{
public abstract class LayoutFloatingWindowControl : Window, ILayoutControl
{
static LayoutFloatingWindowControl()
{
LayoutFloatingWindowControl.ContentProperty.OverrideMetadata(typeof(LayoutFloatingWindowControl), new FrameworkPropertyMetadata(null, null, new CoerceValueCallback(CoerceContentValue)));
AllowsTransparencyProperty.OverrideMetadata(typeof(LayoutFloatingWindowControl), new FrameworkPropertyMetadata(false));
ShowInTaskbarProperty.OverrideMetadata(typeof(LayoutFloatingWindowControl), new FrameworkPropertyMetadata(false));
}
static object CoerceContentValue(DependencyObject sender, object content)
{
return new FloatingWindowContentHost(sender as LayoutFloatingWindowControl) { Content = content as UIElement };
}
protected class FloatingWindowContentHost : HwndHost
{
LayoutFloatingWindowControl _owner;
public FloatingWindowContentHost(LayoutFloatingWindowControl owner)
{
_owner = owner;
var manager = _owner.Model.Root.Manager;
}
HwndSource _wpfContentHost = null;
Border _rootPresenter = null;
DockingManager _manager = null;
protected override System.Runtime.InteropServices.HandleRef BuildWindowCore(System.Runtime.InteropServices.HandleRef hwndParent)
{
_wpfContentHost = new HwndSource(new HwndSourceParameters()
{
ParentWindow = hwndParent.Handle,
WindowStyle = Win32Helper.WS_CHILD | Win32Helper.WS_VISIBLE | Win32Helper.WS_CLIPSIBLINGS | Win32Helper.WS_CLIPCHILDREN,
Width = 1,
Height = 1
});
_rootPresenter = new Border() { Child = new AdornerDecorator() { Child = Content }, Focusable = true };
_rootPresenter.SetBinding(Border.BackgroundProperty, new Binding("Background") { Source = _owner });
_wpfContentHost.RootVisual = _rootPresenter;
_wpfContentHost.SizeToContent = SizeToContent.Manual;
_manager = _owner.Model.Root.Manager;
_manager.InternalAddLogicalChild(_rootPresenter);
return new HandleRef(this, _wpfContentHost.Handle);
}
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
Trace.WriteLine("FloatingWindowContentHost.GotKeyboardFocus");
base.OnGotKeyboardFocus(e);
}
protected override void DestroyWindowCore(HandleRef hwnd)
{
_manager.InternalRemoveLogicalChild(_rootPresenter);
if (_wpfContentHost != null)
{
_wpfContentHost.Dispose();
_wpfContentHost = null;
}
}
protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
switch (msg)
{
case Win32Helper.WM_SETFOCUS:
Trace.WriteLine("FloatingWindowContentHost.WM_SETFOCUS");
break;
case Win32Helper.WM_KILLFOCUS:
Trace.WriteLine("FloatingWindowContentHost.WM_KILLFOCUS");
break;
}
return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
}
public Visual RootVisual
{
get { return _rootPresenter; }
}
protected override Size MeasureOverride(Size constraint)
{
if (Content == null)
return base.MeasureOverride(constraint);
Content.Measure(constraint);
return Content.DesiredSize;
}
#region Content
/// <summary>
/// Content Dependency Property
/// </summary>
public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register("Content", typeof(UIElement), typeof(FloatingWindowContentHost),
new FrameworkPropertyMetadata((UIElement)null,
new PropertyChangedCallback(OnContentChanged)));
/// <summary>
/// Gets or sets the Content property. This dependency property
/// indicates ....
/// </summary>
public UIElement Content
{
get { return (UIElement)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); }
}
/// <summary>
/// Handles changes to the Content property.
/// </summary>
private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((FloatingWindowContentHost)d).OnContentChanged(e);
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the Content property.
/// </summary>
protected virtual void OnContentChanged(DependencyPropertyChangedEventArgs e)
{
if (_rootPresenter != null)
_rootPresenter.Child = Content;
}
#endregion
}
ILayoutElement _model;
protected LayoutFloatingWindowControl(ILayoutElement model)
{
this.Loaded += new RoutedEventHandler(OnLoaded);
this.Unloaded += new RoutedEventHandler(OnUnloaded);
_model = model;
UpdateThemeResources();
}
internal virtual void UpdateThemeResources(Theme oldTheme = null)
{
if (oldTheme != null)
{
var resourceDictionaryToRemove =
Resources.MergedDictionaries.FirstOrDefault(r => r.Source == oldTheme.GetResourceUri());
if (resourceDictionaryToRemove != null)
Resources.MergedDictionaries.Remove(
resourceDictionaryToRemove);
}
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)
{
var host = Content as FloatingWindowContentHost;
host.Dispose();
if (_hwndSrc != null)
{
_hwndSrc.RemoveHook(_hwndSrcHook);
_hwndSrc.Dispose();
_hwndSrc = null;
}
}
base.OnClosed(e);
}
bool _attachDrag = false;
internal void AttachDrag(bool onActivated = true)
{
if (onActivated)
{
_attachDrag = true;
this.Activated += new EventHandler(OnActivated);
}
else
{
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)
{
this.Loaded -= new RoutedEventHandler(OnLoaded);
this.SetParentToMainWindowOf(Model.Root.Manager);
_hwndSrc = HwndSource.FromDependencyObject(this) as HwndSource;
_hwndSrcHook = new HwndSourceHook(FilterMessage);
_hwndSrc.AddHook(_hwndSrcHook);
}
void OnUnloaded(object sender, RoutedEventArgs e)
{
this.Unloaded -= new RoutedEventHandler(OnUnloaded);
if (_hwndSrc != null)
{
_hwndSrc.RemoveHook(_hwndSrcHook);
_hwndSrc.Dispose();
_hwndSrc = null;
}
}
void OnActivated(object sender, EventArgs e)
{
this.Activated -= new EventHandler(OnActivated);
if (_attachDrag && Mouse.LeftButton == MouseButtonState.Pressed)
{
IntPtr windowHandle = new WindowInteropHelper(this).Handle;
var mousePosition = this.PointToScreenDPI(Mouse.GetPosition(this));
var clientArea = Win32Helper.GetClientRect(windowHandle);
var windowArea = Win32Helper.GetWindowRect(windowHandle);
Left = mousePosition.X - windowArea.Width / 2.0;
Top = mousePosition.Y - (windowArea.Height - clientArea.Height) / 2.0;
_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))));
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.MinimizeWindowCommand,
new ExecutedRoutedEventHandler((s, args) => Microsoft.Windows.Shell.SystemCommands.MinimizeWindow((Window)args.Parameter))));
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);
base.OnInitialized(e);
}
public abstract ILayoutElement Model { get; }
#region IsDragging
/// <summary>
/// IsDragging Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey IsDraggingPropertyKey
= DependencyProperty.RegisterReadOnly("IsDragging", typeof(bool), typeof(LayoutFloatingWindowControl),
new FrameworkPropertyMetadata((bool)false,
new PropertyChangedCallback(OnIsDraggingChanged)));
public static readonly DependencyProperty IsDraggingProperty
= IsDraggingPropertyKey.DependencyProperty;
/// <summary>
/// Gets the IsDragging property. This dependency property
/// indicates that this floating window is being dragged.
/// </summary>
public bool IsDragging
{
get { return (bool)GetValue(IsDraggingProperty); }
}
/// <summary>
/// Provides a secure method for setting the IsDragging property.
/// This dependency property indicates that this floating window is being dragged.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetIsDragging(bool value)
{
SetValue(IsDraggingPropertyKey, value);
}
/// <summary>
/// Handles changes to the IsDragging property.
/// </summary>
private static void OnIsDraggingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((LayoutFloatingWindowControl)d).OnIsDraggingChanged(e);
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the IsDragging property.
/// </summary>
protected virtual void OnIsDraggingChanged(DependencyPropertyChangedEventArgs e)
{
//Trace.WriteLine("IsDragging={0}", e.NewValue);
}
#endregion
DragService _dragService = null;
void UpdatePositionAndSizeOfPanes()
{
foreach (var posElement in Model.Descendents().OfType<ILayoutElementForFloatingWindow>())
{
posElement.FloatingLeft = Left;
posElement.FloatingTop = Top;
posElement.FloatingWidth = Width;
posElement.FloatingHeight = Height;
posElement.IsMaximized = this.WindowState == System.Windows.WindowState.Maximized;
}
}
protected virtual IntPtr FilterMessage(
IntPtr hwnd,
int msg,
IntPtr wParam,
IntPtr lParam,
ref bool handled
)
{
handled = false;
switch (msg)
{
case Win32Helper.WM_ACTIVATE:
if (((int)wParam & 0xFFFF) == Win32Helper.WA_INACTIVE)
{
if (lParam == this.GetParentWindowHandle())
{
Win32Helper.SetActiveWindow(_hwndSrc.Handle);
handled = true;
}
}
break;
case Win32Helper.WM_EXITSIZEMOVE:
UpdatePositionAndSizeOfPanes();
if (_dragService != null)
{
bool dropFlag;
var mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());
_dragService.Drop(mousePosition, out dropFlag);
_dragService = null;
SetIsDragging(false);
if (dropFlag)
InternalClose();
}
break;
case Win32Helper.WM_MOVING:
{
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)
{
_dragService.Abort();
_dragService = null;
SetIsDragging(false);
}
break;
}
return IntPtr.Zero;
}
private void UpdateDragPosition()
{
if (_dragService == null)
{
_dragService = new DragService(this);
SetIsDragging(true);
}
var mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());
_dragService.UpdateMouseLocation(mousePosition);
}
bool _internalCloseFlag = false;
internal void InternalClose()
{
_internalCloseFlag = true;
Close();
}
protected bool CloseInitiatedByUser
{
get { return !_internalCloseFlag; }
}
internal bool KeepContentVisibleOnClose
{
get;
set;
}
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonUp(e);
}
#region IsMaximized
/// <summary>
/// IsMaximized Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey IsMaximizedPropertyKey
= DependencyProperty.RegisterReadOnly("IsMaximized", typeof(bool), typeof(LayoutFloatingWindowControl),
new FrameworkPropertyMetadata((bool)false));
public static readonly DependencyProperty IsMaximizedProperty
= IsMaximizedPropertyKey.DependencyProperty;
/// <summary>
/// Gets the IsMaximized property. This dependency property
/// indicates if the window is maximized.
/// </summary>
public bool IsMaximized
{
get { return (bool)GetValue(IsMaximizedProperty); }
}
/// <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
public abstract class LayoutFloatingWindowControl : Window, ILayoutControl
{
static LayoutFloatingWindowControl()
{
LayoutFloatingWindowControl.ContentProperty.OverrideMetadata(typeof(LayoutFloatingWindowControl), new FrameworkPropertyMetadata(null, null, new CoerceValueCallback(CoerceContentValue)));
AllowsTransparencyProperty.OverrideMetadata(typeof(LayoutFloatingWindowControl), new FrameworkPropertyMetadata(false));
ShowInTaskbarProperty.OverrideMetadata(typeof(LayoutFloatingWindowControl), new FrameworkPropertyMetadata(false));
}
static object CoerceContentValue(DependencyObject sender, object content)
{
return new FloatingWindowContentHost(sender as LayoutFloatingWindowControl) { Content = content as UIElement };
}
protected class FloatingWindowContentHost : HwndHost
{
LayoutFloatingWindowControl _owner;
public FloatingWindowContentHost(LayoutFloatingWindowControl owner)
{
_owner = owner;
var manager = _owner.Model.Root.Manager;
}
HwndSource _wpfContentHost = null;
Border _rootPresenter = null;
DockingManager _manager = null;
protected override System.Runtime.InteropServices.HandleRef BuildWindowCore(System.Runtime.InteropServices.HandleRef hwndParent)
{
_wpfContentHost = new HwndSource(new HwndSourceParameters()
{
ParentWindow = hwndParent.Handle,
WindowStyle = Win32Helper.WS_CHILD | Win32Helper.WS_VISIBLE | Win32Helper.WS_CLIPSIBLINGS | Win32Helper.WS_CLIPCHILDREN,
Width = 1,
Height = 1
});
_rootPresenter = new Border() { Child = new AdornerDecorator() { Child = Content }, Focusable = true };
_rootPresenter.SetBinding(Border.BackgroundProperty, new Binding("Background") { Source = _owner });
_wpfContentHost.RootVisual = _rootPresenter;
_wpfContentHost.SizeToContent = SizeToContent.Manual;
_manager = _owner.Model.Root.Manager;
_manager.InternalAddLogicalChild(_rootPresenter);
return new HandleRef(this, _wpfContentHost.Handle);
}
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
Trace.WriteLine("FloatingWindowContentHost.GotKeyboardFocus");
base.OnGotKeyboardFocus(e);
}
protected override void DestroyWindowCore(HandleRef hwnd)
{
_manager.InternalRemoveLogicalChild(_rootPresenter);
if (_wpfContentHost != null)
{
_wpfContentHost.Dispose();
_wpfContentHost = null;
}
}
protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
switch (msg)
{
case Win32Helper.WM_SETFOCUS:
Trace.WriteLine("FloatingWindowContentHost.WM_SETFOCUS");
break;
case Win32Helper.WM_KILLFOCUS:
Trace.WriteLine("FloatingWindowContentHost.WM_KILLFOCUS");
break;
}
return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
}
public Visual RootVisual
{
get { return _rootPresenter; }
}
protected override Size MeasureOverride(Size constraint)
{
if (Content == null)
return base.MeasureOverride(constraint);
Content.Measure(constraint);
return Content.DesiredSize;
}
#region Content
/// <summary>
/// Content Dependency Property
/// </summary>
public static readonly DependencyProperty ContentProperty =
DependencyProperty.Register("Content", typeof(UIElement), typeof(FloatingWindowContentHost),
new FrameworkPropertyMetadata((UIElement)null,
new PropertyChangedCallback(OnContentChanged)));
/// <summary>
/// Gets or sets the Content property. This dependency property
/// indicates ....
/// </summary>
public UIElement Content
{
get { return (UIElement)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); }
}
/// <summary>
/// Handles changes to the Content property.
/// </summary>
private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((FloatingWindowContentHost)d).OnContentChanged(e);
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the Content property.
/// </summary>
protected virtual void OnContentChanged(DependencyPropertyChangedEventArgs e)
{
if (_rootPresenter != null)
_rootPresenter.Child = Content;
}
#endregion
}
ILayoutElement _model;
protected LayoutFloatingWindowControl(ILayoutElement model)
{
this.Loaded += new RoutedEventHandler(OnLoaded);
this.Unloaded += new RoutedEventHandler(OnUnloaded);
_model = model;
UpdateThemeResources();
}
internal virtual void UpdateThemeResources(Theme oldTheme = null)
{
if (Application.Current != null)
return;
if (oldTheme != null)
{
var resourceDictionaryToRemove =
Resources.MergedDictionaries.FirstOrDefault(r => r.Source == oldTheme.GetResourceUri());
if (resourceDictionaryToRemove != null)
Resources.MergedDictionaries.Remove(
resourceDictionaryToRemove);
}
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)
{
var host = Content as FloatingWindowContentHost;
host.Dispose();
if (_hwndSrc != null)
{
_hwndSrc.RemoveHook(_hwndSrcHook);
_hwndSrc.Dispose();
_hwndSrc = null;
}
}
base.OnClosed(e);
}
bool _attachDrag = false;
internal void AttachDrag(bool onActivated = true)
{
if (onActivated)
{
_attachDrag = true;
this.Activated += new EventHandler(OnActivated);
}
else
{
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)
{
this.Loaded -= new RoutedEventHandler(OnLoaded);
this.SetParentToMainWindowOf(Model.Root.Manager);
_hwndSrc = HwndSource.FromDependencyObject(this) as HwndSource;
_hwndSrcHook = new HwndSourceHook(FilterMessage);
_hwndSrc.AddHook(_hwndSrcHook);
}
void OnUnloaded(object sender, RoutedEventArgs e)
{
this.Unloaded -= new RoutedEventHandler(OnUnloaded);
if (_hwndSrc != null)
{
_hwndSrc.RemoveHook(_hwndSrcHook);
_hwndSrc.Dispose();
_hwndSrc = null;
}
}
void OnActivated(object sender, EventArgs e)
{
this.Activated -= new EventHandler(OnActivated);
if (_attachDrag && Mouse.LeftButton == MouseButtonState.Pressed)
{
IntPtr windowHandle = new WindowInteropHelper(this).Handle;
var mousePosition = this.PointToScreenDPI(Mouse.GetPosition(this));
var clientArea = Win32Helper.GetClientRect(windowHandle);
var windowArea = Win32Helper.GetWindowRect(windowHandle);
Left = mousePosition.X - windowArea.Width / 2.0;
Top = mousePosition.Y - (windowArea.Height - clientArea.Height) / 2.0;
_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))));
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.MinimizeWindowCommand,
new ExecutedRoutedEventHandler((s, args) => Microsoft.Windows.Shell.SystemCommands.MinimizeWindow((Window)args.Parameter))));
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);
base.OnInitialized(e);
}
public abstract ILayoutElement Model { get; }
#region IsDragging
/// <summary>
/// IsDragging Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey IsDraggingPropertyKey
= DependencyProperty.RegisterReadOnly("IsDragging", typeof(bool), typeof(LayoutFloatingWindowControl),
new FrameworkPropertyMetadata((bool)false,
new PropertyChangedCallback(OnIsDraggingChanged)));
public static readonly DependencyProperty IsDraggingProperty
= IsDraggingPropertyKey.DependencyProperty;
/// <summary>
/// Gets the IsDragging property. This dependency property
/// indicates that this floating window is being dragged.
/// </summary>
public bool IsDragging
{
get { return (bool)GetValue(IsDraggingProperty); }
}
/// <summary>
/// Provides a secure method for setting the IsDragging property.
/// This dependency property indicates that this floating window is being dragged.
/// </summary>
/// <param name="value">The new value for the property.</param>
protected void SetIsDragging(bool value)
{
SetValue(IsDraggingPropertyKey, value);
}
/// <summary>
/// Handles changes to the IsDragging property.
/// </summary>
private static void OnIsDraggingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((LayoutFloatingWindowControl)d).OnIsDraggingChanged(e);
}
/// <summary>
/// Provides derived classes an opportunity to handle changes to the IsDragging property.
/// </summary>
protected virtual void OnIsDraggingChanged(DependencyPropertyChangedEventArgs e)
{
//Trace.WriteLine("IsDragging={0}", e.NewValue);
}
#endregion
DragService _dragService = null;
void UpdatePositionAndSizeOfPanes()
{
foreach (var posElement in Model.Descendents().OfType<ILayoutElementForFloatingWindow>())
{
posElement.FloatingLeft = Left;
posElement.FloatingTop = Top;
posElement.FloatingWidth = Width;
posElement.FloatingHeight = Height;
}
}
void UpdateMaximizedState(bool isMaximized)
{
foreach (var posElement in Model.Descendents().OfType<ILayoutElementForFloatingWindow>())
{
posElement.IsMaximized = isMaximized;
}
}
protected virtual IntPtr FilterMessage(
IntPtr hwnd,
int msg,
IntPtr wParam,
IntPtr lParam,
ref bool handled
)
{
handled = false;
switch (msg)
{
case Win32Helper.WM_ACTIVATE:
if (((int)wParam & 0xFFFF) == Win32Helper.WA_INACTIVE)
{
if (lParam == this.GetParentWindowHandle())
{
Win32Helper.SetActiveWindow(_hwndSrc.Handle);
handled = true;
}
}
break;
case Win32Helper.WM_EXITSIZEMOVE:
UpdatePositionAndSizeOfPanes();
if (_dragService != null)
{
bool dropFlag;
var mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());
_dragService.Drop(mousePosition, out dropFlag);
_dragService = null;
SetIsDragging(false);
if (dropFlag)
InternalClose();
}
break;
case Win32Helper.WM_MOVING:
{
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)
{
_dragService.Abort();
_dragService = null;
SetIsDragging(false);
}
break;
case Win32Helper.WM_SYSCOMMAND:
IntPtr wMaximize = new IntPtr(Win32Helper.SC_MAXIMIZE);
IntPtr wRestore = new IntPtr(Win32Helper.SC_RESTORE);
if (wParam == wMaximize || wParam == wRestore)
{
UpdateMaximizedState(wParam == wMaximize);
}
break;
}
return IntPtr.Zero;
}
private void UpdateDragPosition()
{
if (_dragService == null)
{
_dragService = new DragService(this);
SetIsDragging(true);
}
var mousePosition = this.TransformToDeviceDPI(Win32Helper.GetMousePosition());
_dragService.UpdateMouseLocation(mousePosition);
}
bool _internalCloseFlag = false;
internal void InternalClose()
{
_internalCloseFlag = true;
Close();
}
protected bool CloseInitiatedByUser
{
get { return !_internalCloseFlag; }
}
internal bool KeepContentVisibleOnClose
{
get;
set;
}
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonUp(e);
}
#region IsMaximized
/// <summary>
/// IsMaximized Read-Only Dependency Property
/// </summary>
private static readonly DependencyPropertyKey IsMaximizedPropertyKey
= DependencyProperty.RegisterReadOnly("IsMaximized", typeof(bool), typeof(LayoutFloatingWindowControl),
new FrameworkPropertyMetadata((bool)false));
public static readonly DependencyProperty IsMaximizedProperty
= IsMaximizedPropertyKey.DependencyProperty;
/// <summary>
/// Gets the IsMaximized property. This dependency property
/// indicates if the window is maximized.
/// </summary>
public bool IsMaximized
{
get { return (bool)GetValue(IsMaximizedProperty); }
}
/// <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()
{
SizeToContent = System.Windows.SizeToContent.Manual,
ResizeMode = ResizeMode.NoResize,
WindowStyle = System.Windows.WindowStyle.None,
ShowInTaskbar = false,

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

@ -523,6 +523,31 @@ namespace Xceed.Wpf.AvalonDock.Controls
#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
/// <summary>
@ -570,10 +595,10 @@ namespace Xceed.Wpf.AvalonDock.Controls
private bool CanExecuteCloseCommand(object parameter)
{
#if DEBUG
if( LayoutElement != null )
System.Diagnostics.Trace.WriteLine( string.Format( "CanExecuteCloseCommand({0}) = {1}", LayoutElement.Title, LayoutElement.CanClose ) );
if( LayoutElement != null )
System.Diagnostics.Trace.WriteLine( string.Format( "CanExecuteCloseCommand({0}) = {1}", LayoutElement.Title, LayoutElement.CanClose ) );
#endif
return LayoutElement != null && LayoutElement.CanClose;
return LayoutElement != null && LayoutElement.CanClose;
}
private void ExecuteCloseCommand(object parameter)
@ -694,7 +719,7 @@ namespace Xceed.Wpf.AvalonDock.Controls
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)

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

@ -59,6 +59,9 @@ namespace Xceed.Wpf.AvalonDock.Controls
internal void UpdateThemeResources(Theme oldTheme = null)
{
if (Application.Current != null)
return;
if (oldTheme != null)
{
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
{
[Serializable]
public abstract class LayoutPositionableGroup<T> : LayoutGroup<T>, ILayoutPositionableElement, ILayoutPositionableElementWithActualSize where T : class, ILayoutElement
{
public LayoutPositionableGroup()
{ }
GridLength _dockWidth = new GridLength(1.0, GridUnitType.Star);
public GridLength DockWidth
{
get
{
return _dockWidth;
}
set
{
if (DockWidth != value)
{
RaisePropertyChanging("DockWidth");
_dockWidth = value;
RaisePropertyChanged("DockWidth");
OnDockWidthChanged();
}
}
}
protected virtual void OnDockWidthChanged()
{
}
GridLength _dockHeight = new GridLength(1.0, GridUnitType.Star);
public GridLength DockHeight
{
get
{
return _dockHeight;
}
set
{
if (DockHeight != value)
{
RaisePropertyChanging("DockHeight");
_dockHeight = value;
RaisePropertyChanged("DockHeight");
OnDockHeightChanged();
}
}
}
protected virtual void OnDockHeightChanged()
{
}
#region DockMinWidth
private double _dockMinWidth = 25.0;
public double DockMinWidth
{
get { return _dockMinWidth; }
set
{
if (_dockMinWidth != value)
{
MathHelper.AssertIsPositiveOrZero(value);
RaisePropertyChanging("DockMinWidth");
_dockMinWidth = value;
RaisePropertyChanged("DockMinWidth");
}
}
}
#endregion
#region DockMinHeight
private double _dockMinHeight = 25.0;
public double DockMinHeight
{
get { return _dockMinHeight; }
set
{
if (_dockMinHeight != value)
{
MathHelper.AssertIsPositiveOrZero(value);
RaisePropertyChanging("DockMinHeight");
_dockMinHeight = value;
RaisePropertyChanged("DockMinHeight");
}
}
}
#endregion
#region FloatingWidth
private double _floatingWidth = 0.0;
public double FloatingWidth
{
get { return _floatingWidth; }
set
{
if (_floatingWidth != value)
{
RaisePropertyChanging("FloatingWidth");
_floatingWidth = value;
RaisePropertyChanged("FloatingWidth");
}
}
}
#endregion
#region FloatingHeight
private double _floatingHeight = 0.0;
public double FloatingHeight
{
get { return _floatingHeight; }
set
{
if (_floatingHeight != value)
{
RaisePropertyChanging("FloatingHeight");
_floatingHeight = value;
RaisePropertyChanged("FloatingHeight");
}
}
}
#endregion
#region FloatingLeft
private double _floatingLeft = 0.0;
public double FloatingLeft
{
get { return _floatingLeft; }
set
{
if (_floatingLeft != value)
{
RaisePropertyChanging("FloatingLeft");
_floatingLeft = value;
RaisePropertyChanged("FloatingLeft");
}
}
}
#endregion
#region FloatingTop
private double _floatingTop = 0.0;
public double FloatingTop
{
get { return _floatingTop; }
set
{
if (_floatingTop != value)
{
RaisePropertyChanging("FloatingTop");
_floatingTop = value;
RaisePropertyChanged("FloatingTop");
}
}
}
#endregion
#region IsMaximized
private bool _isMaximized = false;
public bool IsMaximized
{
get { return _isMaximized; }
set
{
if (_isMaximized != value)
{
_isMaximized = value;
RaisePropertyChanged("IsMaximized");
}
}
}
#endregion
[NonSerialized]
double _actualWidth;
double ILayoutPositionableElementWithActualSize.ActualWidth
{
get
{
return _actualWidth;
}
set
{
_actualWidth = value;
}
}
[NonSerialized]
double _actualHeight;
double ILayoutPositionableElementWithActualSize.ActualHeight
{
get
{
return _actualHeight;
}
set
{
_actualHeight = value;
}
}
public override void WriteXml(System.Xml.XmlWriter writer)
{
if (DockWidth.Value != 1.0 || !DockWidth.IsStar)
writer.WriteAttributeString("DockWidth", _gridLengthConverter.ConvertToInvariantString(DockWidth));
if (DockHeight.Value != 1.0 || !DockHeight.IsStar)
writer.WriteAttributeString("DockHeight", _gridLengthConverter.ConvertToInvariantString(DockHeight));
if (DockMinWidth != 25.0)
writer.WriteAttributeString("DocMinWidth", DockMinWidth.ToString(CultureInfo.InvariantCulture));
if (DockMinHeight != 25.0)
writer.WriteAttributeString("DockMinHeight", DockMinHeight.ToString(CultureInfo.InvariantCulture));
if (FloatingWidth != 0.0)
writer.WriteAttributeString("FloatingWidth", FloatingWidth.ToString(CultureInfo.InvariantCulture));
if (FloatingHeight != 0.0)
writer.WriteAttributeString("FloatingHeight", FloatingHeight.ToString(CultureInfo.InvariantCulture));
if (FloatingLeft != 0.0)
writer.WriteAttributeString("FloatingLeft", FloatingLeft.ToString(CultureInfo.InvariantCulture));
if (FloatingTop != 0.0)
writer.WriteAttributeString("FloatingTop", FloatingTop.ToString(CultureInfo.InvariantCulture));
base.WriteXml(writer);
}
static GridLengthConverter _gridLengthConverter = new GridLengthConverter();
public override void ReadXml(System.Xml.XmlReader reader)
{
if (reader.MoveToAttribute("DockWidth"))
_dockWidth = (GridLength)_gridLengthConverter.ConvertFromInvariantString(reader.Value);
if (reader.MoveToAttribute("DockHeight"))
_dockHeight = (GridLength)_gridLengthConverter.ConvertFromInvariantString(reader.Value);
if (reader.MoveToAttribute("DocMinWidth"))
_dockMinWidth = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("DocMinHeight"))
_dockMinHeight = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("FloatingWidth"))
_floatingWidth = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("FloatingHeight"))
_floatingHeight = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("FloatingLeft"))
_floatingLeft = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("FloatingTop"))
_floatingTop = double.Parse(reader.Value, CultureInfo.InvariantCulture);
base.ReadXml(reader);
}
}
[Serializable]
public abstract class LayoutPositionableGroup<T> : LayoutGroup<T>, ILayoutPositionableElement, ILayoutPositionableElementWithActualSize where T : class, ILayoutElement
{
public LayoutPositionableGroup()
{ }
GridLength _dockWidth = new GridLength(1.0, GridUnitType.Star);
public GridLength DockWidth
{
get
{
return _dockWidth;
}
set
{
if (DockWidth != value)
{
RaisePropertyChanging("DockWidth");
_dockWidth = value;
RaisePropertyChanged("DockWidth");
OnDockWidthChanged();
}
}
}
protected virtual void OnDockWidthChanged()
{
}
GridLength _dockHeight = new GridLength(1.0, GridUnitType.Star);
public GridLength DockHeight
{
get
{
return _dockHeight;
}
set
{
if (DockHeight != value)
{
RaisePropertyChanging("DockHeight");
_dockHeight = value;
RaisePropertyChanged("DockHeight");
OnDockHeightChanged();
}
}
}
protected virtual void OnDockHeightChanged()
{
}
#region DockMinWidth
private double _dockMinWidth = 25.0;
public double DockMinWidth
{
get { return _dockMinWidth; }
set
{
if (_dockMinWidth != value)
{
MathHelper.AssertIsPositiveOrZero(value);
RaisePropertyChanging("DockMinWidth");
_dockMinWidth = value;
RaisePropertyChanged("DockMinWidth");
}
}
}
#endregion
#region DockMinHeight
private double _dockMinHeight = 25.0;
public double DockMinHeight
{
get { return _dockMinHeight; }
set
{
if (_dockMinHeight != value)
{
MathHelper.AssertIsPositiveOrZero(value);
RaisePropertyChanging("DockMinHeight");
_dockMinHeight = value;
RaisePropertyChanged("DockMinHeight");
}
}
}
#endregion
#region FloatingWidth
private double _floatingWidth = 0.0;
public double FloatingWidth
{
get { return _floatingWidth; }
set
{
if (_floatingWidth != value)
{
RaisePropertyChanging("FloatingWidth");
_floatingWidth = value;
RaisePropertyChanged("FloatingWidth");
}
}
}
#endregion
#region FloatingHeight
private double _floatingHeight = 0.0;
public double FloatingHeight
{
get { return _floatingHeight; }
set
{
if (_floatingHeight != value)
{
RaisePropertyChanging("FloatingHeight");
_floatingHeight = value;
RaisePropertyChanged("FloatingHeight");
}
}
}
#endregion
#region FloatingLeft
private double _floatingLeft = 0.0;
public double FloatingLeft
{
get { return _floatingLeft; }
set
{
if (_floatingLeft != value)
{
RaisePropertyChanging("FloatingLeft");
_floatingLeft = value;
RaisePropertyChanged("FloatingLeft");
}
}
}
#endregion
#region FloatingTop
private double _floatingTop = 0.0;
public double FloatingTop
{
get { return _floatingTop; }
set
{
if (_floatingTop != value)
{
RaisePropertyChanging("FloatingTop");
_floatingTop = value;
RaisePropertyChanged("FloatingTop");
}
}
}
#endregion
#region IsMaximized
private bool _isMaximized = false;
public bool IsMaximized
{
get { return _isMaximized; }
set
{
if (_isMaximized != value)
{
_isMaximized = value;
RaisePropertyChanged("IsMaximized");
}
}
}
#endregion
[NonSerialized]
double _actualWidth;
double ILayoutPositionableElementWithActualSize.ActualWidth
{
get
{
return _actualWidth;
}
set
{
_actualWidth = value;
}
}
[NonSerialized]
double _actualHeight;
double ILayoutPositionableElementWithActualSize.ActualHeight
{
get
{
return _actualHeight;
}
set
{
_actualHeight = value;
}
}
public override void WriteXml(System.Xml.XmlWriter writer)
{
if (DockWidth.Value != 1.0 || !DockWidth.IsStar)
writer.WriteAttributeString("DockWidth", _gridLengthConverter.ConvertToInvariantString(DockWidth));
if (DockHeight.Value != 1.0 || !DockHeight.IsStar)
writer.WriteAttributeString("DockHeight", _gridLengthConverter.ConvertToInvariantString(DockHeight));
if (DockMinWidth != 25.0)
writer.WriteAttributeString("DocMinWidth", DockMinWidth.ToString(CultureInfo.InvariantCulture));
if (DockMinHeight != 25.0)
writer.WriteAttributeString("DockMinHeight", DockMinHeight.ToString(CultureInfo.InvariantCulture));
if (FloatingWidth != 0.0)
writer.WriteAttributeString("FloatingWidth", FloatingWidth.ToString(CultureInfo.InvariantCulture));
if (FloatingHeight != 0.0)
writer.WriteAttributeString("FloatingHeight", FloatingHeight.ToString(CultureInfo.InvariantCulture));
if (FloatingLeft != 0.0)
writer.WriteAttributeString("FloatingLeft", FloatingLeft.ToString(CultureInfo.InvariantCulture));
if (FloatingTop != 0.0)
writer.WriteAttributeString("FloatingTop", FloatingTop.ToString(CultureInfo.InvariantCulture));
if (IsMaximized)
writer.WriteAttributeString("IsMaximized", IsMaximized.ToString());
base.WriteXml(writer);
}
static GridLengthConverter _gridLengthConverter = new GridLengthConverter();
public override void ReadXml(System.Xml.XmlReader reader)
{
if (reader.MoveToAttribute("DockWidth"))
_dockWidth = (GridLength)_gridLengthConverter.ConvertFromInvariantString(reader.Value);
if (reader.MoveToAttribute("DockHeight"))
_dockHeight = (GridLength)_gridLengthConverter.ConvertFromInvariantString(reader.Value);
if (reader.MoveToAttribute("DocMinWidth"))
_dockMinWidth = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("DocMinHeight"))
_dockMinHeight = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("FloatingWidth"))
_floatingWidth = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("FloatingHeight"))
_floatingHeight = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("FloatingLeft"))
_floatingLeft = double.Parse(reader.Value, CultureInfo.InvariantCulture);
if (reader.MoveToAttribute("FloatingTop"))
_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.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));
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));
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));
serializer.Serialize(stream, Manager.Layout);
}
public void Serialize(string filepath)
public override void Serialize(string filepath)
{
using (var stream = new StreamWriter(filepath))
Serialize(stream);
}
public void Deserialize(System.IO.Stream stream)
public override void Deserialize(System.IO.Stream stream)
{
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
{
@ -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
{
@ -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))
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 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
WM_CREATE = 0x0001;

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

@ -21,7 +21,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
@ -349,13 +349,12 @@
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
<!-- 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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Loading…
Cancel
Save