using System;
using System.Drawing;
using System.Linq;
public static class DisplayFusionFunction {
public static void Run () {
//*** Typical usage scenario is to toggle between 2 devices - so make sure to enter the names of your devices here: (if you have problems getting them correctly, try uncommenting line 14-17)
string[] myPreferredDevices = { "Speakers/Headphones (Realtek(R) Audio)", "Lautsprecher (5- Sennheiser USB headset)" };
string[] devList = BFS.Audio.GetPlaybackDevices ();
string foo = string.Concat ("Devices", String.Join (",", devList.ToArray ()));
string currDevice = BFS.Audio.GetDefaultPlaybackSounds ();
string[] filteredList = devList.Intersect (myPreferredDevices, StringComparer.OrdinalIgnoreCase).ToArray ();
// Diagnosis to see name of devices etc.
//foo = string.Concat(foo, "\n");
//foo = string.Concat(foo, String.Join("," , filteredList.ToArray()));
// BFS.Dialog.ShowMessageError(foo);
string selectedAudioDevice = "";
bool doIt = false;
if (filteredList.Length == 0) {
BFS.Dialog.ShowMessageError ("No Audio Devices Found!");
} else if (filteredList.Length == 2) {
int i = Array.IndexOf (filteredList, currDevice);
int j = (i == 0) ? 1 : 0;
string msg = String.Concat ("Press Yes to switch to device ", filteredList[j]);
doIt = BFS.Dialog.GetUserConfirm (msg);
selectedAudioDevice = filteredList[j];
} else {
// Prompt to select an audio device
selectedAudioDevice = BFS.Dialog.GetUserInputList ("Please select an audio device:", devList);
doIt = true;
}
if (doIt) {
// Set the selected device as the default playback device
BFS.Audio.SetDefaultPlaybackSounds (selectedAudioDevice);
// Set the selected device as the default communication device
BFS.Audio.SetDefaultPlaybackCommunications (selectedAudioDevice);
}
}
}