Artemis.Managers.EffectManager.DisableGame C# (CSharp) Method

DisableGame() public method

Disables the given game
public DisableGame ( EffectModel activeEffect ) : void
activeEffect Artemis.Models.EffectModel
return void
        public void DisableGame(EffectModel activeEffect)
        {
            _logger.Debug("Disabling game: {0}", activeEffect?.Name);
            if (GetLastEffect() == null)
                ClearEffect();
            else
                ChangeEffect(GetLastEffect());
        }

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        ///     Manages active games by keeping an eye on their processes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ScanProcesses(object sender, ElapsedEventArgs e)
        {
            if (!ProgramEnabled)
            {
                return;
            }

            var runningProcesses = Process.GetProcesses();

            // If the currently active effect is a disabled game, get rid of it.
            if (EffectManager.ActiveEffect != null)
            {
                EffectManager.DisableInactiveGame();
            }

            if (EffectManager.ActiveEffect is ProfilePreviewModel)
            {
                return;
            }

            // If the currently active effect is a no longer running game, get rid of it.
            var activeGame = EffectManager.ActiveEffect as GameModel;

            if (activeGame != null)
            {
                if (!runningProcesses.Any(p => p.ProcessName == activeGame.ProcessName && p.HasExited == false))
                {
                    Logger.Info("Disabling game: {0}", activeGame.Name);
                    EffectManager.DisableGame(activeGame);
                }
            }

            // Look for running games, stopping on the first one that's found.
            var newGame = EffectManager.EnabledGames
                          .FirstOrDefault(g => runningProcesses
                                          .Any(p => p.ProcessName == g.ProcessName && p.HasExited == false));

            if (newGame == null || EffectManager.ActiveEffect == newGame)
            {
                return;
            }
            // If it's not already enabled, do so.
            Logger.Info("Detected and enabling game: {0}", newGame.Name);
            EffectManager.ChangeEffect(newGame, LoopManager);
        }