private void ChangeAndInvokeEvent(EmulationStateName stateName, bool invokeEvent)
 {
     Name = stateName;
     if (invokeEvent)
     {
         Changed?.Invoke(stateName);
     }
 }
        public void Change(EmulationStateName stateName, bool invokeEvent = true)
        {
            switch (stateName)
            {
            case EmulationStateName.NotInitialized:
                Initialized = InAction = Paused = Pending = false;
                ChangeAndInvokeEvent(stateName, invokeEvent);
                break;

            case EmulationStateName.Initialized:
                Initialized = true;
                ChangeAndInvokeEvent(stateName, invokeEvent);
                break;

            case EmulationStateName.InAction when !Pending:
                InAction = true;
                Paused   = false;
                ChangeAndInvokeEvent(stateName, invokeEvent);
                break;

            case EmulationStateName.PendedToPause:
                Pending = true;
                ChangeAndInvokeEvent(stateName, invokeEvent);
                break;

            case EmulationStateName.Paused:
                InAction = false;
                Paused   = true;
                Pending  = false;
                ChangeAndInvokeEvent(stateName, invokeEvent);
                break;

            case EmulationStateName.Finished:
                InAction = false;
                ChangeAndInvokeEvent(stateName, invokeEvent);
                break;

            case EmulationStateName.PendedToRestart:
                Pending = true;
                ChangeAndInvokeEvent(stateName, invokeEvent);
                break;
            }
        }
        private void OnEmulationStateChanged(EmulationStateName state)
        {
            switch (state)
            {
            case EmulationStateName.Initialized when initialized:
            case EmulationStateName.Initialized:
                initialized = true;
                InitMap();
                AdjustToContent();
                RenderWorldMap();
                StartEmulationAction.IsEnabled = true;
                break;

            case EmulationStateName.InAction:
                PauseEmulationAction.IsEnabled = true;
                break;
            }
            Title = $"Main window - {state}";
        }