private void Initialize() { _window.Closed += HandleWindowClosedToDisconnected; _screenOps = new ScreenLifecycleOperations(_aggregator, _screen); _screenOps.Activate(); try { bool windowImplementsViewInterface = ViewFactory.TryInitializeView(_window, _screen); if (!windowImplementsViewInterface) { _window.Content = ViewFactory.CreateView(_screen); } } catch (Exception ex) { if (!ex.IsCritical()) { CloseScreen(checkState: false); } throw; } _screen.Children.Add(this); _aggregator.Publish( WindowService.InitializeWindowEvent, new InitializeWindowEventArgs(_screen, _window) ); AttachHandlers(); }
protected void SetLifecycleStateTo(LifecycleState state) { var operations = new ScreenLifecycleOperations(Aggregator, Screen); if (state == LifecycleState.Created) { return; } operations.Initialize(); if (state == LifecycleState.Initialized) { return; } operations.Activate(); if (state == LifecycleState.Activated) { return; } operations.Deactivate(); if (state == LifecycleState.Deactivated) { return; } operations.Close(); if (state == LifecycleState.Closed) { return; } if (state == LifecycleState.ExceptionOccured) { Aggregator.Publish( ScreenEvents.LifecycleExceptionOccured, new ScreenEventArgs(Screen) ); } else { throw new NotSupportedException(); } }