Esempio n. 1
0
        private void t_Tick(object sender, EventArgs e)
        {
            ((Timer)sender).Stop();
            if (DoubleClickHappened)
            {
                return;
            }

            if (ConfigurationSettings.EnableQuickSwitch)
            {
                if (FavouriteDeviceManager.FavouriteDeviceCount > 0)
                {
                    string devid = FavouriteDeviceManager.GetNextFavouritePlaybackDevice();

                    AudioDeviceManager.GetAudioDevice(devid).SetAsDefaultDevice();

                    RefreshPlaybackDevices();
                }
            }
            else
            {
                RefreshNotifyIconItems();
                MethodInfo mi = typeof(NotifyIcon).GetMethod("ShowContextMenu",
                                                             BindingFlags.Instance | BindingFlags.NonPublic);
                mi.Invoke(notifyIcon1, null);
            }
        }
Esempio n. 2
0
        public static string GetNextFavouritePlaybackDevice()
        {
            //Start at the next device
            int index = (FavouriteDeviceIDs.IndexOf(AudioDeviceManager.DefaultPlaybackDevice.ID) + 1) %
                        FavouriteDeviceIDs.Count;

            int i = index;

            while (true)
            {
                AudioDevice ad = AudioDeviceManager.GetAudioDevice(FavouriteDeviceIDs[i % FavouriteDeviceIDs.Count]);
                if (ad.DataFlow == EDataFlow.eRender)
                {
                    return(FavouriteDeviceIDs[i % FavouriteDeviceIDs.Count]);
                }

                i++;

                if (i == index)
                {
                    break;
                }
            }

            return("");
        }
Esempio n. 3
0
        public AudioSwitcher()
        {
            InitializeComponent();

            try
            {
                //try make it look pretty
                SetWindowTheme(listBoxPlayback.Handle, "Explorer", null);
                SetWindowTheme(listBoxRecording.Handle, "Explorer", null);
            }
            catch
            {
            }

            //Set up the config
            ConfigurationWriter.ConfigWriter.SetPath(
                Path.Combine(Directory.GetParent(Assembly.GetEntryAssembly().Location).FullName,
                             Resources.ConfigurationFile));

            lblVersion.Text   = "Version: " + AssemblyVersion;
            lblCopyright.Text = AssemblyCopyright;
            lblCompany.Text   = AssemblyCompany;

            LoadSettings();

            RefreshRecordingDevices();
            RefreshPlaybackDevices();

            HotKeyManager.HotKeyPressed   += HotKeyManager_HotKeyPressed;
            hotKeyBindingSource.DataSource = HotKeyManager.HotKeys;

            if (ConfigurationSettings.CheckForUpdatesOnStartup || ConfigurationSettings.PollForUpdates >= 1)
            {
                var t = new Thread(CheckForUpdates);
                t.Start();
            }

            try
            {
                AudioDevice dev = AudioDeviceManager.GetAudioDevice(ConfigurationSettings.StartupPlaybackDeviceID);

                if (dev != null)
                {
                    dev.SetAsDefaultDevice();
                }

                dev = AudioDeviceManager.GetAudioDevice(ConfigurationSettings.StartupRecordingDeviceID);

                if (dev != null)
                {
                    dev.SetAsDefaultDevice();
                }
            }
            catch
            {
            }

            MinimizeFootprint();
        }
Esempio n. 4
0
        public static bool LoadFavouriteDevices(string[] favouriteIDs)
        {
            FavouriteDeviceIDs = new List <string>();

            foreach (string s in favouriteIDs)
            {
                if (AudioDeviceManager.GetAudioDevice(s) != null)
                {
                    AddFavouriteDevice(s);
                }
                else
                {
                    RemoveFavouriteDevice(s);
                }
            }
            return(true);
        }