public MainWindow() { InitializeComponent(); Environment.CurrentDirectory = AssemblyHelper.GetDirectory(); tray = new TaskbarIcon(); tray.Visibility = Visibility.Hidden; tray.ToolTipText = "Open Voice Modder"; tray.TrayLeftMouseDown += (s, e) => { tray.Visibility = Visibility.Hidden; this.Show(); this.WindowState = WindowState.Normal; }; tray.TrayRightMouseDown += (s, e) => this.MuteOutput.IsChecked = !this.MuteOutput.IsChecked; this.MuteOutput.IsChecked = Properties.Settings.Default.Muted; try { AudioManager.instance.UpdateDevices( AudioDevices.ListDevices(DataFlow.Capture)[Properties.Settings.Default.InputIndex], AudioDevices.ListDevices(DataFlow.Render)[Properties.Settings.Default.OutputIndex]); } catch (Exception ex) { MessageBox.Show("Error, please update your settings."); } if (!String.IsNullOrEmpty(Properties.Settings.Default.Save)) { RestoreAudioData(JObject.Parse(Properties.Settings.Default.Save)); } KeyboardHook.Initialize(); KeyboardHook.KeyIntercept += (a, k) => { if (a == KeyAction.WM_KEYDOWN) { foreach (UIElement element in SongsHolder.Children) { if (element is SoundController) { if ((element as SoundController).KeyBind == k.ToString()) { (element as SoundController).Play(); } } } if (k.ToString() == Properties.Settings.Default.BeepKey) { AudioResampler.Instance.Censor = true; } } if (a == KeyAction.WM_KEYUP) { if (k.ToString() == Properties.Settings.Default.BeepKey) { AudioResampler.Instance.Censor = false; } } }; }
public SettingsWindow() { InitializeComponent(); AudioDevices.ListDevices(DataFlow.Capture).ToList() .ForEach(dv => InputDevices.Items.Add(new DeviceData() { device = dv })); AudioDevices.ListDevices(DataFlow.Render).ToList() .ForEach(dv => OutputDevices.Items.Add(new DeviceData() { device = dv })); int iIndex = Properties.Settings.Default.InputIndex; int oIndex = Properties.Settings.Default.OutputIndex; if (InputDevices.Items.Count == 0 || OutputDevices.Items.Count == 0) { MessageBox.Show("Error: No avaiable audio devices !"); Environment.Exit(-1); return; } iIndex = iIndex >= InputDevices.Items.Count ? 0 : iIndex; oIndex = oIndex >= OutputDevices.Items.Count ? 0 : oIndex; InputDevices.SelectedIndex = iIndex; OutputDevices.SelectedIndex = oIndex; beepBind.Text = Properties.Settings.Default.BeepKey; MinimizeToTray.IsChecked = Properties.Settings.Default.MinimizeToTray; }