/// <summary> /// Switch to the specified strategy /// </summary> /// <param name="strategyName">The name of the strategy to switch to</param> public void SwitchTo( string strategyName ) { if( !Implementations.ContainsKey( strategyName ) ) { strategyName = ZoneScrollingStrategy.StrategyName; if( !Implementations.ContainsKey( strategyName ) ) throw new InvalidOperationException( "trying to switch ot an unknown strategy (" + strategyName + "). Fallbacking failed (there are no implementations available)" ); //A previous version of CiviKey has strategies that don't exist anymore. Loosening the process by implementing a fallback. //throw new InvalidOperationException( "Cannot switch to the unknown strategy : " + strategyName ); } _current.Stop(); _current = Implementations[strategyName]; _current.Start(); }
public void Start() { Configuration.ConfigChanged += ( o, e ) => { if( e.MultiPluginId.Any( u => u.UniqueId == KeyScrollerPlugin.PluginId.UniqueId ) ) { if( e.Key == "Strategy" ) { _scrollingStrategy.Stop(); _scrollingStrategy = GetStrategyByName( e.Value.ToString() ); _scrollingStrategy.Start(); } } }; ExternalInput.Service.Triggered += OnExternalInputTriggered; }