private void IDC_COMBO_CHAT_TRANSPORT_SelectedIndexChanged(object sender, EventArgs e) { var currentSel = IDC_COMBO_CHAT_TRANSPORT.SelectedIndex; // The user modified the chat transport. Delete the existing chat transport and create a new one. g_CurrentChat.Shutdown(); g_CurrentChat = null; if (currentSel == g_WasapiComboBoxIndex) { // Instantiate the WASAPI transport. g_CurrentChat = new CWasapiChat(Handle); } else if (currentSel == g_WaveComboBoxIndex) { // Instantiate the wave transport. g_CurrentChat = new CWaveChat(Handle); } // Sync the UI to the transport choice SyncUIState(Handle, ChatState.ChatStateNotPlaying); // Initialize the chat object var useInputDevice = IDC_RADIO_CAPTURE.Checked; if (g_CurrentChat.Initialize(useInputDevice)) { // Sync the UI to the state again - we're not playing but after initializing the state might change. SyncUIState(Handle, ChatState.ChatStateNotPlaying); } else { MessageBox.Show(this, "Unable to initialize chat", "Error", MessageBoxButtons.OK); } }
private void IDOK_Click(object sender, EventArgs e) { g_CurrentChat?.StopChat(); g_CurrentChat?.Shutdown(); g_CurrentChat = null; Close(); }