refactor(ui): own retained controller lifetimes
This commit is contained in:
parent
921c388e2c
commit
5d9e98c118
21 changed files with 373 additions and 35 deletions
|
|
@ -34,7 +34,7 @@ public sealed class RetailWindowHandle
|
|||
public string Name { get; }
|
||||
public UiElement OuterFrame { get; }
|
||||
public UiElement ContentRoot { get; }
|
||||
public IRetainedPanelController? Controller { get; }
|
||||
public IRetainedPanelController? Controller { get; private set; }
|
||||
public IRetainedWindowStateController? StateController { get; }
|
||||
public bool IsRegistered => !_disposed;
|
||||
public bool IsVisible => OuterFrame.Visible;
|
||||
|
|
@ -70,6 +70,19 @@ public sealed class RetailWindowHandle
|
|||
Controller?.OnShown();
|
||||
}
|
||||
|
||||
internal void AttachController(IRetainedPanelController controller)
|
||||
{
|
||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||
ArgumentNullException.ThrowIfNull(controller);
|
||||
if (ReferenceEquals(Controller, controller)) return;
|
||||
if (Controller is not null)
|
||||
throw new InvalidOperationException($"Retained window '{Name}' already owns a controller.");
|
||||
|
||||
Controller = controller;
|
||||
if (_notifiedVisible)
|
||||
Controller.OnShown();
|
||||
}
|
||||
|
||||
internal void NotifyVisibility(bool visible)
|
||||
{
|
||||
if (_notifiedVisible == visible) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue