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); } }
private void t_Tick(object sender, EventArgs e) { ((Timer)sender).Stop(); if (_doubleClickHappened) { return; } if (Program.Settings.EnableQuickSwitch) { if (FavouriteDeviceManager.FavouriteDeviceCount > 0) { var changed = false; var currentDefaultDevice = AudioDeviceManager.Controller.DefaultPlaybackDevice; var candidate = FavouriteDeviceManager.GetNextFavouritePlaybackDevice(currentDefaultDevice); var attemptsCount = FavouriteDeviceManager.FavouritePlaybackDeviceCount; for (var i = 0; !changed && i < attemptsCount; i++) { changed = candidate.SetAsDefault(); if (changed && Program.Settings.DualSwitchMode) { candidate.SetAsDefaultCommunications(); } if (!changed) { candidate = FavouriteDeviceManager.GetNextFavouritePlaybackDevice(candidate); } } } } else { RefreshNotifyIconItems(); var mi = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic); mi.Invoke(notifyIcon1, null); } }