Ejemplo n.º 1
0
        /// <summary>Creates the necessary switching objects from the config settings, and returns the engine object</summary>
        public static Engine PrepareSwitchingFromConfig()
        {
            int numberSwitches = Globals.Root.CurrentConfig.ReadInteger(Config.Number_Switches, 1); // only needed indirectly;  the engine often is enough info, but a 2 switch engine can use 1 with long presses

            PhysicalSwitch.Initialise();                                                            // will be ignored if already done
            var engine = Create((Methods)Globals.Root.CurrentConfig.ReadInteger(Config.Switch_Engine, (int)DefaultMethodForSwitches(numberSwitches)));

            PhysicalSwitch.ClearSwitches();
            if (engine.NumberSwitchInputs >= 1)
            {
                PhysicalSwitch.AssignSwitchFromConfig(0);
            }
            if (engine.NumberSwitchInputs >= 2)
            {
                PhysicalSwitch.AssignSwitchFromConfig(1);
            }

            if (numberSwitches > 0)             // for 0, mouse switch will do what is needed on initialise
            {
                if (numberSwitches == 2)
                {
                    Logical.CreateSwitches(Logical.Number.Two, engine);
                }
                else if (engine.NumberSwitchInputs == 2)
                {
                    Logical.CreateSwitches(Logical.Number.ShortLong, engine);
                }
                else
                {
                    Logical.CreateSwitches(Logical.Number.One, engine);
                }
            }

            engine.Initialise();
            return(engine);
        }
Ejemplo n.º 2
0
 public void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     PhysicalSwitch.ClearSwitches();
     m_Engine.Dispose();
 }