private void ActualPatternOnPatternFinished(object sender, EventArgs e)
 {
     World.Robot.RobotConsole[Leds.Led1].LedEnabled = false;
       fww.worldView1.AddRobotParkSpot(World.Robot.Position);
       _actualPattern = null;
 }
        private void OnSwitchStateChanged(object sender, SwitchEventArgs switchEventArgs)
        {
            if (commonRunParameters1.InvokeRequired) {
            commonRunParameters1.Invoke(new Action(() => OnSwitchStateChanged(sender, switchEventArgs)));
              }

              if (switchEventArgs.SwitchEnabled)
              {
            if (_actualPattern == null)
            {
              World.Robot.RobotConsole[Leds.Led1].LedEnabled = switchEventArgs.SwitchEnabled;
              _actualPattern = new FindSpaceAndParkPattern((float)commonRunParameters1.UPSpeed.Value / 1000f, (float)commonRunParameters1.UPAcceleration.Value / 1000f);
              _actualPattern.PatternFinished += ActualPatternOnPatternFinished;
              _actualPattern.Start();
            }
            else
            {
              _actualPattern.Restart();
            }
              }
              else
              {
            if (_actualPattern != null)
            {
              _actualPattern.Halt();
            }
              }
        }