private void voiceDisableButton_CheckedChanged(object sender, EventArgs e)
 {
     if (((RadioButton)sender).Checked)
     {
         runListenForChannelOpenThread = false;
         runListenForButtonPressesThread = controllerConfiguration.listenForButtons(false);
         voiceOption = VoiceOptionEnum.DISABLED;
         UserSettings.GetUserSettings().setProperty("VOICE_OPTION", getVoiceOptionString());
         UserSettings.GetUserSettings().saveUserSettings();
     }
 }
        public MainWindow()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false;
            Console.SetOut(new ControlWriter(textBox1));
            crewChief = new CrewChief();
            controllerConfiguration = new ControllerConfiguration();
            float messagesVolume = UserSettings.GetUserSettings().getFloat("messages_volume");
            float backgroundVolume = UserSettings.GetUserSettings().getFloat("background_volume");
            setMessagesVolume(messagesVolume);
            messagesVolumeSlider.Value = (int)(messagesVolume * 10f);
            backgroundVolumeSlider.Value = (int) (backgroundVolume * 10f);

            getControllers();
            controllerConfiguration.loadSettings(this);
            String customDeviceGuid = UserSettings.GetUserSettings().getString("custom_device_guid");
            if (customDeviceGuid != null && customDeviceGuid.Length > 0)
            {
                try
                {
                    Guid guid;
                    if (Guid.TryParse(customDeviceGuid, out guid)) {
                        controllerConfiguration.addCustomController(guid);
                    }
                    else
                    {
                        Console.WriteLine("Failed to add custom device, unable to process GUID");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to add custom device, message: " + e.Message);
                }
            }
            voiceOption = getVoiceOptionEnum(UserSettings.GetUserSettings().getString("VOICE_OPTION"));
            if (voiceOption == VoiceOptionEnum.DISABLED)
            {
                this.voiceDisableButton.Checked = true;
            }
            else if (voiceOption == VoiceOptionEnum.ALWAYS_ON)
            {
                this.alwaysOnButton.Checked = true;
            } else if (voiceOption == VoiceOptionEnum.HOLD)
            {
                this.holdButton.Checked = true;
            }
            else if (voiceOption == VoiceOptionEnum.TOGGLE)
            {
                this.toggleButton.Checked = true;
            }
            speechRecogniser = new SpeechRecogniser(crewChief);
            if (voiceOption != VoiceOptionEnum.DISABLED)
            {
                initialiseSpeechEngine();
            }
            runListenForButtonPressesThread = controllerConfiguration.listenForButtons(voiceOption == VoiceOptionEnum.TOGGLE);
            updateActions();
            this.assignButtonToAction.Enabled = false;
            this.deleteAssigmentButton.Enabled = false;

            if (UserSettings.GetUserSettings().getBoolean("run_immediately"))
            {
                doStartAppStuff();
            }
        }
 private void toggleButton_CheckedChanged(object sender, EventArgs e)
 {
     if (((RadioButton)sender).Checked)
     {
         runListenForButtonPressesThread = true;
         runListenForChannelOpenThread = false;
         try
         {
             if (speechRecogniser == null)
             {
                 speechRecogniser = new SpeechRecogniser(crewChief);
             }
             speechRecogniser.initialiseSpeechEngine();
             speechRecogniser.voiceOptionEnum = VoiceOptionEnum.TOGGLE;
             voiceOption = VoiceOptionEnum.TOGGLE;
             UserSettings.GetUserSettings().setProperty("VOICE_OPTION", getVoiceOptionString());
             UserSettings.GetUserSettings().saveUserSettings();
         }
         catch (Exception ex)
         {
             Console.WriteLine("Unable to initialise speech engine, message = " + ex.Message);
         }
     }
 }
 private void holdButton_CheckedChanged(object sender, EventArgs e)
 {
     if (((RadioButton)sender).Checked)
     {
         runListenForButtonPressesThread = controllerConfiguration.listenForButtons(false);
         try
         {
             initialiseSpeechEngine();
             crewChief.speechRecogniser.voiceOptionEnum = VoiceOptionEnum.HOLD;
             voiceOption = VoiceOptionEnum.HOLD;
             runListenForChannelOpenThread = true;
             UserSettings.GetUserSettings().setProperty("VOICE_OPTION", getVoiceOptionString());
             UserSettings.GetUserSettings().saveUserSettings();
         }
         catch (Exception ex)
         {
             Console.WriteLine("Unable to initialise speech engine, message = " + ex.Message);
         }
     }
 }