public Add ( |
||
c | The control to add | |
Résultat | void |
private void ControlAddedToVisualTree(ConsoleControl c) { c.Application = this; c.OnDisposed(() => { if (c.Application == this && c.Parent != null && c.Parent.Application == this) { if (c.Parent is ConsolePanel) { (c.Parent as ConsolePanel).Controls.Remove(c); } else { throw new NotSupportedException($"You cannot manually dispose child controls of parent type {c.Parent.GetType().Name}"); } } }); if (c is ConsolePanel) { var childPanel = c as ConsolePanel; childPanel.Controls.SynchronizeForLifetime((cp) => { ControlAddedToVisualTree(cp); }, (cp) => { ControlRemovedFromVisualTree(cp); }, () => { }, c); } else if (c is ProtectedConsolePanel) { var childPanel = c as ProtectedConsolePanel; ControlAddedToVisualTree(childPanel.ProtectedPanelInternal); childPanel.OnDisposed(() => ControlRemovedFromVisualTree(childPanel.ProtectedPanelInternal)); } FocusManager.Add(c); c.AddedToVisualTreeInternal(); ControlAdded.Fire(c); }
private void ControlAddedToVisualTree(ConsoleControl c) { c.Application = this; if (c is ConsolePanel) { var childPanel = c as ConsolePanel; childPanel.Controls.SynchronizeForLifetime((cp) => { ControlAddedToVisualTree(cp); }, (cp) => { ControlRemovedFromVisualTree(cp); }, () => { }, c.LifetimeManager); } FocusManager.Add(c); c.AddedToVisualTreeInternal(); ControlAdded.Fire(c); }