From fdf4af76bf0ece1d8c2d743ca354e8fbffdba835 Mon Sep 17 00:00:00 2001 From: Denis Smirnov Date: Tue, 11 Oct 2022 11:17:55 +0300 Subject: [PATCH] add open/close LayoutFlayoutingWindowsControl events --- .../Components/AvalonDock/DockingManager.cs | 25 ++++++++++++++++++- ...outFloatingWindowControlClosedEventArgs.cs | 16 ++++++++++++ ...utFloatingWindowControlCreatedEventArgs.cs | 16 ++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 source/Components/AvalonDock/LayoutFloatingWindowControlClosedEventArgs.cs create mode 100644 source/Components/AvalonDock/LayoutFloatingWindowControlCreatedEventArgs.cs diff --git a/source/Components/AvalonDock/DockingManager.cs b/source/Components/AvalonDock/DockingManager.cs index 762917bc..2a47f99e 100644 --- a/source/Components/AvalonDock/DockingManager.cs +++ b/source/Components/AvalonDock/DockingManager.cs @@ -119,6 +119,17 @@ public DockingManager() /// public event EventHandler ActiveContentChanged; + /// + /// Event is raised when LayoutFloatingWindowControl created + /// + public event EventHandler LayoutFloatingWindowControlCreated; + + /// + /// Event is raised when LayoutFloatingWindowControl closed + /// + public event EventHandler LayoutFloatingWindowControlClosed; + + #endregion Events #region Public Properties @@ -1736,8 +1747,12 @@ internal void StartDraggingFloatingWindowForContent(LayoutContent contentModel, var show = fwc == null; // Do not show already visible floating window if (fwc == null) + { fwc = CreateFloatingWindow(contentModel, false); + LayoutFloatingWindowControlCreated?.Invoke(this, new LayoutFloatingWindowControlCreatedEventArgs(fwc)); + } + if (fwc != null) { Dispatcher.BeginInvoke(new Action(() => @@ -1758,6 +1773,9 @@ internal void StartDraggingFloatingWindowForPane(LayoutAnchorablePane paneModel) { var fwc = CreateFloatingWindowForLayoutAnchorableWithoutParent(paneModel, false); if (fwc == null) return; + + LayoutFloatingWindowControlCreated?.Invoke(this, new LayoutFloatingWindowControlCreatedEventArgs(fwc)); + fwc.AttachDrag(); fwc.Show(); } @@ -1815,7 +1833,12 @@ internal void GetOverlayWindowHostsByZOrder(ref List overlay overlayWindowHosts.AddRange(bottomFloatingWindows); } - internal void RemoveFloatingWindow(LayoutFloatingWindowControl floatingWindow) => _fwList.Remove(floatingWindow); + internal void RemoveFloatingWindow(LayoutFloatingWindowControl floatingWindow) + { + _fwList.Remove(floatingWindow); + + LayoutFloatingWindowControlClosed?.Invoke(this, new LayoutFloatingWindowControlClosedEventArgs(floatingWindow)); + } internal void ExecuteCloseCommand(LayoutDocument document) { diff --git a/source/Components/AvalonDock/LayoutFloatingWindowControlClosedEventArgs.cs b/source/Components/AvalonDock/LayoutFloatingWindowControlClosedEventArgs.cs new file mode 100644 index 00000000..3769684a --- /dev/null +++ b/source/Components/AvalonDock/LayoutFloatingWindowControlClosedEventArgs.cs @@ -0,0 +1,16 @@ +using System; +using AvalonDock.Controls; + +namespace AvalonDock +{ + public sealed class LayoutFloatingWindowControlClosedEventArgs : EventArgs + { + public LayoutFloatingWindowControlClosedEventArgs(LayoutFloatingWindowControl layoutFloatingWindowControl) + { + LayoutFloatingWindowControl = layoutFloatingWindowControl; + } + + public LayoutFloatingWindowControl LayoutFloatingWindowControl { get; } + } + +} diff --git a/source/Components/AvalonDock/LayoutFloatingWindowControlCreatedEventArgs.cs b/source/Components/AvalonDock/LayoutFloatingWindowControlCreatedEventArgs.cs new file mode 100644 index 00000000..de7f9a19 --- /dev/null +++ b/source/Components/AvalonDock/LayoutFloatingWindowControlCreatedEventArgs.cs @@ -0,0 +1,16 @@ +using AvalonDock.Controls; +using System; + +namespace AvalonDock +{ + public sealed class LayoutFloatingWindowControlCreatedEventArgs : EventArgs + { + public LayoutFloatingWindowControlCreatedEventArgs(LayoutFloatingWindowControl layoutFloatingWindowControl) + { + LayoutFloatingWindowControl = layoutFloatingWindowControl; + } + + public LayoutFloatingWindowControl LayoutFloatingWindowControl { get; } + } + +}