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 IDC_RADIO_CAPTURE_CheckedChanged(object sender, EventArgs e) { var currentSel = IDC_COMBO_CHAT_TRANSPORT.SelectedIndex; // The radio button selection may change when the transport is changed to Wave because render is not an option for Wave. We // detect that here and only rebuild the transport for Wasapi if ((currentSel == g_WasapiComboBoxIndex) && (g_CurrentChat.TransportType == ChatTransportType.ChatTransportWasapi)) { // The user switched between render and capture. Delete the existing chat transport and create a new one. g_CurrentChat.Shutdown(); // Reinstantiate the WASAPI transport. // // Also update the state of the rendering options since the WASAPI transport supports them. g_CurrentChat = new CWasapiChat(Handle); g_CurrentChat.Initialize(IDC_CHECK_HIDE_FROM_VOLUME_MIXER.Checked); } SyncUIState(Handle, ChatState.ChatStateNotPlaying); }
private void IDD_DIALOG_CHAT_Load(object sender, EventArgs e) { // Start by using the wave transport for "chat". // Allocate the WAVE chat transport. If we failed to startup, we're done. g_CurrentChat = new CWaveChat(Handle); if (!g_CurrentChat.Initialize(true)) { Close(); } // Set up the combobox and initialize the chat options to reflect that we've set the Wave chat transport by default. g_WaveComboBoxIndex = IDC_COMBO_CHAT_TRANSPORT.Items.Add("WAVE API Transport"); g_WasapiComboBoxIndex = IDC_COMBO_CHAT_TRANSPORT.Items.Add("WASAPI API Transport"); IDC_COMBO_CHAT_TRANSPORT.SelectedIndex = g_WaveComboBoxIndex; // Simulate a "stop" event to get the UI in sync. SyncUIState(Handle, ChatState.ChatStateNotPlaying); }