|
@@ -257,6 +257,14 @@ public static class IPanelHostExtensions
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/// <summary>
|
|
|
+/// Implement this interface to cause a class to act as a host of <see cref="ISubPanel"/>. Then, you can use the extension functions
|
|
|
+/// <see cref="ISubPanelHostExtensions.ShutdownSubPanels(ISubPanelHost, CancelEventArgs?)"/> and
|
|
|
+/// <see cref="ISubPanelHostExtensions.AddSubPanel(ISubPanelHost, ISubPanel)"/> to interact with it.
|
|
|
+/// </summary>
|
|
|
+/// <remarks>
|
|
|
+/// If you mark an <see cref="IPanel{T}"/> as an <see cref="ISubPanelHost"/>, then the shutdown method is called automatically by <see cref="IPanelHost"/>.
|
|
|
+/// </remarks>
|
|
|
public interface ISubPanelHost
|
|
|
{
|
|
|
List<ISubPanel> SubPanels { get; }
|
|
@@ -278,14 +286,24 @@ public static class ISubPanelHostExtensions
|
|
|
{
|
|
|
panels = host.SubPanels.ToArray();
|
|
|
host.SubPanels.Clear();
|
|
|
- }
|
|
|
|
|
|
- foreach(var panel in panels)
|
|
|
- {
|
|
|
- panel.Shutdown(cancel);
|
|
|
- if (cancel?.Cancel == true)
|
|
|
+ var isCancelled = false;
|
|
|
+
|
|
|
+ foreach(var panel in panels)
|
|
|
{
|
|
|
- return;
|
|
|
+ if (isCancelled)
|
|
|
+ {
|
|
|
+ host.SubPanels.Add(panel);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ panel.Shutdown(cancel);
|
|
|
+ if (cancel?.Cancel == true)
|
|
|
+ {
|
|
|
+ isCancelled = true;
|
|
|
+ host.SubPanels.Add(panel);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|