GetLastEffect() public method

Loads the last active effect from settings and enables it.
public GetLastEffect ( ) : EffectModel
return Artemis.Models.EffectModel
Beispiel #1
0
        private void Start()
        {
            if (Running)
            {
                return;
            }

            _logger.Debug("Starting LoopManager");

            if (_deviceManager.ActiveKeyboard == null)
            {
                _deviceManager.EnableLastKeyboard();
            }
            // If still null, no last keyboard, so stop.
            if (_deviceManager.ActiveKeyboard == null)
            {
                _logger.Debug("Cancel LoopManager start, no keyboard");
                return;
            }

            if (_effectManager.ActiveEffect == null)
            {
                var lastEffect = _effectManager.GetLastEffect();
                if (lastEffect == null)
                {
                    _logger.Debug("Cancel LoopManager start, no effect");
                    return;
                }
                _effectManager.ChangeEffect(lastEffect);
            }

            Running = true;
        }
Beispiel #2
0
        /// <summary>
        ///     Keeps track of profiles being previewed and sets up the active efffect accordingly
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SetupProfilePreview(object sender, ElapsedEventArgs e)
        {
            if (string.IsNullOrEmpty(_generalSettings.LastKeyboard) || _deviceManager.ChangingKeyboard ||
                ProfilePreviewModel == null)
            {
                return;
            }

            var activePreview = GameViewModels.FirstOrDefault(vm => vm.IsActive);

            if (activePreview == null)
            {
                // Should not be active if no selected profile is set
                if (_effectManager.ActiveEffect != ProfilePreviewModel)
                {
                    return;
                }

                _logger.Debug("Loading last effect after profile preview");
                var lastEffect = _effectManager.GetLastEffect();
                if (lastEffect != null)
                {
                    _effectManager.ChangeEffect(lastEffect);
                }
                else
                {
                    _effectManager.ClearEffect();
                }
            }
            else
            {
                if (_effectManager.ActiveEffect != ProfilePreviewModel && !(_effectManager.ActiveEffect is GameModel))
                {
                    _logger.Debug("Activate profile preview");
                    _effectManager.ChangeEffect(ProfilePreviewModel);
                }

                // LoopManager might be running, this method won't do any harm in that case.
                _loopManager.StartAsync();

                ProfilePreviewModel.ProfileViewModel = activePreview.ProfileEditor.ProfileViewModel;
                if (!ReferenceEquals(ProfilePreviewModel.Profile, activePreview.ProfileEditor.SelectedProfile))
                {
                    ProfilePreviewModel.Profile = activePreview.ProfileEditor.SelectedProfile;
                }
            }
        }