public AlertsFramePresenter() { // This is a lot easier than a factory IoCManager.InjectDependencies(this); _alertsFrame = new AlertsUI(_chatManager); _userInterfaceManager.StateRoot.AddChild((AlertsUI)_alertsFrame); // This is required so that if we load after the system is initialized, we can bind to it immediately if (_systemManager.TryGetEntitySystem <ClientAlertsSystem>(out var alertsSystem)) { SystemBindingChanged(alertsSystem); } _systemManager.SystemLoaded += OnSystemLoaded; _systemManager.SystemUnloaded += OnSystemUnloaded; _alertsFrame.AlertPressed += OnAlertPressed; // initially populate the frame if system is available var alerts = alertsSystem?.ActiveAlerts; if (alerts != null) { SystemOnSyncAlerts(alertsSystem, alerts); } }
/// <inheritdoc /> public void Dispose() { _userInterfaceManager.StateRoot.RemoveChild((AlertsUI)_alertsFrame); _alertsFrame.Dispose(); _alertsFrame = null !; SystemBindingChanged(null); _systemManager.SystemLoaded -= OnSystemLoaded; _systemManager.SystemUnloaded -= OnSystemUnloaded; }