private void load_devices(bool from_settings) { PortAudio.AudioDevice[] devices = broker.audio_devices; comboSpeakerInput.ItemsSource = comboHeadsetInput.ItemsSource = (from d in devices where d.inputs > 0 select d).ToArray(); comboRingDevice.ItemsSource = comboSpeakerOutput.ItemsSource = comboHeadsetOutput.ItemsSource = (from d in devices where d.outputs > 0 select d).ToArray(); string old_selected_item = comboHeadsetDevice.SelectedItem as string; comboHeadsetDevice.Items.Clear(); comboHeadsetDevice.Items.Add("None"); foreach (string headset in broker.AvailableHeadsets()) { comboHeadsetDevice.Items.Add(headset); } comboHeadsetDevice.SelectedItem = old_selected_item; if (from_settings) { comboHeadsetInput.SelectedItem = broker.HeadsetInDev; comboHeadsetOutput.SelectedItem = broker.HeadsetOutDev; comboSpeakerInput.SelectedItem = broker.SpeakerInDev; comboSpeakerOutput.SelectedItem = broker.SpeakerOutDev; comboRingDevice.SelectedItem = broker.RingDev; chkIncomingBalloons.IsChecked = broker.IncomingBalloons; string incoming_key = "None"; if (broker.IncomingTopMost) { incoming_key = broker.IncomingKeyboardFocus ? "FrontKeyboard" : "Front"; } comboOnIncomingCall.SelectedItem = (from g in IncomingCallOptions where g.key == incoming_key select g).FirstOrDefault(); if (comboOnIncomingCall.SelectedIndex == -1) { comboOnIncomingCall.SelectedIndex = 1; } chkClearDTMFS.IsChecked = broker.ClearDTMFS; chkUseNumbers.IsChecked = broker.UseNumberOnlyInput; chkUpdatesOnStart.IsChecked = broker.CheckForUpdates != "Never"; chkNAT.IsChecked = broker.UPNPNAT; txtRecordingPath.Text = broker.recordings_folder; chkDirectSip.IsChecked = broker.DirectSipDial; comboGUIStartup.SelectedItem = (from g in GuiOptions where g.key == broker.GUIStartup select g).FirstOrDefault(); if (comboGUIStartup.SelectedIndex == -1) { comboGUIStartup.SelectedIndex = 0; } comboTheme.SelectedItem = (from g in themes where g.key == broker.theme select g).FirstOrDefault(); if (comboTheme.SelectedIndex == -1) { comboTheme.SelectedIndex = 0; } comboHeadsetDevice.SelectedItem = broker.ActiveHeadset(); if (comboHeadsetDevice.SelectedIndex == -1) { comboHeadsetDevice.SelectedIndex = 0; } } }
private void load_devices(bool from_settings) { PortAudio.AudioDevice[] devices = broker.audio_devices; comboSpeakerInput.ItemsSource = comboHeadsetInput.ItemsSource = (from d in devices where d.inputs > 0 select d).ToArray(); comboRingDevice.ItemsSource = comboSpeakerOutput.ItemsSource = comboHeadsetOutput.ItemsSource = (from d in devices where d.outputs > 0 select d).ToArray(); string old_selected_item = comboHeadsetDevice.SelectedItem as string; comboHeadsetDevice.Items.Clear(); comboHeadsetDevice.Items.Add("None"); foreach (string headset in broker.AvailableHeadsets()) { comboHeadsetDevice.Items.Add(headset); } comboHeadsetDevice.SelectedItem = old_selected_item; if (from_settings) { comboHeadsetInput.SelectedItem = broker.HeadsetInDev; comboHeadsetOutput.SelectedItem = broker.HeadsetOutDev; comboSpeakerInput.SelectedItem = broker.SpeakerInDev; comboSpeakerOutput.SelectedItem = broker.SpeakerOutDev; comboRingDevice.SelectedItem = broker.RingDev; chkIncomingBalloons.IsChecked = broker.IncomingBalloons; string incoming_key = "None"; if (broker.IncomingTopMost) { incoming_key = broker.IncomingKeyboardFocus ? "FrontKeyboard" : "Front"; } comboOnIncomingCall.SelectedItem = (from g in IncomingCallOptions where g.key == incoming_key select g).FirstOrDefault(); if (comboOnIncomingCall.SelectedIndex == -1) { comboOnIncomingCall.SelectedIndex = 1; } chkClearDTMFS.IsChecked = broker.ClearDTMFS; chkUseNumbers.IsChecked = broker.UseNumberOnlyInput; chkUpdatesOnStart.IsChecked = broker.CheckForUpdates != "Never"; chkNAT.IsChecked = broker.UPNPNAT; txtRecordingPath.Text = broker.recordings_folder; chkDirectSip.IsChecked = broker.DirectSipDial; chkAlwaysOnTopDuringCall.IsChecked = broker.AlwaysOnTopDuringCall; chkGlobalAlt.IsChecked = broker.global_hotkey.modifiers.HasFlag(UnManaged.KeyModifier.Alt); chkGlobalShift.IsChecked = broker.global_hotkey.modifiers.HasFlag(UnManaged.KeyModifier.Shift); chkGlobalCntrl.IsChecked = broker.global_hotkey.modifiers.HasFlag(UnManaged.KeyModifier.Ctrl); chkGlobalWin.IsChecked = broker.global_hotkey.modifiers.HasFlag(UnManaged.KeyModifier.Win); var key_char = broker.global_hotkey.key.ToString(); if (broker.global_hotkey.key == System.Windows.Input.Key.None) { key_char = ""; } key_char = key_char.Replace("NumPad", "").Replace("Oem", ""); if (key_char.Length == 2) { key_char = key_char.Replace("D", ""); } if (key_char.Length > 1) { key_char = ""; } txtHotKey.Text = key_char; comboGUIStartup.SelectedItem = (from g in GuiOptions where g.key == broker.GUIStartup select g).FirstOrDefault(); if (comboGUIStartup.SelectedIndex == -1) { comboGUIStartup.SelectedIndex = 0; } comboTheme.SelectedItem = (from g in themes where g.key == broker.theme select g).FirstOrDefault(); if (comboTheme.SelectedIndex == -1) { comboTheme.SelectedIndex = 0; } comboHeadsetDevice.SelectedItem = broker.ActiveHeadset(); if (comboHeadsetDevice.SelectedIndex == -1) { comboHeadsetDevice.SelectedIndex = 0; } } }