//private void btnSave_Click(object sender, EventArgs e) //{ // if (xmlLoc == "" || !File.Exists(xmlLoc)) // xmlLoc = Helper.userGetXMLLoc(); // if (xmlLoc != "") // { // XMLSettings.WriteXML(new XMLSettings.Settings() { SoundHotkeys = soundHotkeys.ToArray() }, xmlLoc); // MessageBox.Show("Saved"); // } //} public void AutoSave() { XMLSettings.WriteXML(new XMLSettings.Settings() { SoundHotkeys = soundHotkeys.ToArray() }, Path.GetDirectoryName(Application.ExecutablePath) + "\\AHS-autosave.xml"); }
private void cbPlaybackDevices2_SelectedIndexChanged(object sender, EventArgs e) { stopPlayback(); initAudioPlaybackEngine(); XMLSettings.soundboardSettings.LastPlaybackDevice2 = (string)cbPlaybackDevices2.SelectedItem; XMLSettings.SaveSoundboardSettingsXML(); }
private void cbLoopbackDevices_SelectedIndexChanged(object sender, EventArgs e) { stopLoopback(); if (cbLoopbackDevices.SelectedIndex > 0) { startLoopback(); } XMLSettings.soundboardSettings.LastLoopbackDevice = (string)cbLoopbackDevices.SelectedItem; XMLSettings.SaveSoundboardSettingsXML(); }
private void CbAudioOverdrive_CheckedChanged(object sender, EventArgs e) { if (cbAudioOverdrive.Checked) { labelVolume.Text = (trackbarVolume.Value * 3).ToString() + " dB"; } else { labelVolume.Text = trackbarVolume.Value.ToString() + " dB"; } XMLSettings.soundboardSettings.GoEvenFurtherBeyond = cbAudioOverdrive.Checked; XMLSettings.SaveSoundboardSettingsXML(); }
private void TrackBar1_Scroll(object sender, EventArgs e) { if (cbAudioOverdrive.Checked) { labelVolume.Text = (trackbarVolume.Value * 3).ToString() + " dB"; } else { labelVolume.Text = trackbarVolume.Value.ToString() + " dB"; } XMLSettings.soundboardSettings.GainValue = trackbarVolume.Value; XMLSettings.SaveSoundboardSettingsXML(); }
private void btnSaveAs_Click(object sender, EventArgs e) { string last = xmlLoc; xmlLoc = Helper.userGetXMLLoc(); if (xmlLoc == "") { xmlLoc = last; } else if (last != xmlLoc) { XMLSettings.WriteXML(new XMLSettings.Settings() { SoundHotkeys = soundHotkeys.ToArray() }, xmlLoc); } }
public MainForm() { Instance = this; InitializeComponent(); loadSoundDevices(); XMLSettings.LoadSoundboardSettingsXML(); if (cbPlaybackDevices.Items.Contains(XMLSettings.soundboardSettings.LastPlaybackDevice)) { cbPlaybackDevices.SelectedItem = XMLSettings.soundboardSettings.LastPlaybackDevice; } if (cbPlaybackDevices2.Items.Contains(XMLSettings.soundboardSettings.LastPlaybackDevice2)) { cbPlaybackDevices2.SelectedItem = XMLSettings.soundboardSettings.LastPlaybackDevice2; } if (cbLoopbackDevices.Items.Contains(XMLSettings.soundboardSettings.LastLoopbackDevice)) { cbLoopbackDevices.SelectedItem = XMLSettings.soundboardSettings.LastLoopbackDevice; } //add events after settings have been loaded cbPlaybackDevices.SelectedIndexChanged += cbPlaybackDevices_SelectedIndexChanged; cbPlaybackDevices2.SelectedIndexChanged += cbPlaybackDevices2_SelectedIndexChanged; cbLoopbackDevices.SelectedIndexChanged += cbLoopbackDevices_SelectedIndexChanged; mainTimer.Enabled = true; initAudioPlaybackEngine(); string filePath = Path.GetDirectoryName(Application.ExecutablePath) + "\\AHS-autosave.xml"; if (File.Exists(filePath)) { loadXMLFile(filePath); } }
private void btnOK_Click(object sender, EventArgs e) { Keys[] keysArr = null; Keys[] keysArr2 = null; string error = ""; if ((string.IsNullOrWhiteSpace(tbStopSoundKeys.Text) || Helper.keysArrayFromString(tbStopSoundKeys.Text, out keysArr, out error)) && (string.IsNullOrWhiteSpace(tbPlaySelectionKeys.Text) || Helper.keysArrayFromString(tbPlaySelectionKeys.Text, out keysArr2, out error))) { if (loadXMLFilesList.Count == 0 || loadXMLFilesList.All(x => x.Keys.Length > 0 && !string.IsNullOrWhiteSpace(x.XMLLocation) && File.Exists(x.XMLLocation))) { XMLSettings.soundboardSettings.StopSoundKeys = (keysArr == null ? new Keys[] { } : keysArr); XMLSettings.soundboardSettings.PlaySelectionKeys = (keysArr2 == null ? new Keys[] { } : keysArr2); XMLSettings.soundboardSettings.LoadXMLFiles = loadXMLFilesList.ToArray(); XMLSettings.soundboardSettings.MinimizeToTray = cbMinimizeToTray.Checked; XMLSettings.soundboardSettings.PlaySoundsOverEachOther = cbPlaySoundsOverEachOther.Checked; XMLSettings.soundboardSettings.RememberGainControl = cbRememberGainControl.Checked; XMLSettings.soundboardSettings.GainValue = MainForm.Instance.trackbarVolume.Value; XMLSettings.soundboardSettings.GoEvenFurtherBeyond = MainForm.Instance.cbAudioOverdrive.Checked; XMLSettings.SaveSoundboardSettingsXML(); this.Close(); } else { MessageBox.Show("One or more entries either have no keys added, the location is empty, or the file the location points to does not exist"); } } else if (error != "") { MessageBox.Show(error); } }
private void loadXMLFile(string path) { XMLSettings.Settings s = (XMLSettings.Settings)XMLSettings.ReadXML(typeof(XMLSettings.Settings), path); if (s != null && s.SoundHotkeys != null && s.SoundHotkeys.Length > 0) { var items = new List <object[]>(); string errors = ""; for (int i = 0; i < s.SoundHotkeys.Length; i++) { int kLength = s.SoundHotkeys[i].Keys.Length; bool keysNull = (kLength > 0 && !s.SoundHotkeys[i].Keys.Any(x => x != 0)); int sLength = s.SoundHotkeys[i].SoundLocations.Length; bool soundsNotEmpty = s.SoundHotkeys[i].SoundLocations.All(x => !string.IsNullOrWhiteSpace(x)); Environment.CurrentDirectory = Path.GetDirectoryName(Application.ExecutablePath); bool filesExist = s.SoundHotkeys[i].SoundLocations.All(x => File.Exists(x)); if (keysNull || sLength < 1 || !soundsNotEmpty || !filesExist) //error in XML file { string tempErr = ""; if (kLength == 0 && (sLength == 0 || !soundsNotEmpty)) { tempErr = "entry is empty"; } else if (!keysNull) { tempErr = "one or more sounds do not exist"; // "one or more keys are null"; } else if (sLength == 0) { tempErr = "no sounds provided"; } else if (!filesExist) { tempErr = "one or more sounds do not exist"; } errors += "Entry #" + (i + 1).ToString() + " has an error: " + tempErr + "\r\n"; } object[] temp = new object[2]; temp[0] = s.SoundHotkeys[i].SoundClips; temp[1] = Helper.keysToString(s.SoundHotkeys[i].Keys); items.Add(temp); // add even if there was an error, so that the user can fix within the app } if (items.Count > 0) { if (errors != "") { MessageBox.Show((errors == "" ? "" : errors)); } soundHotkeys.Clear(); soundHotkeys.AddRange(s.SoundHotkeys); dgvKeySounds.Rows.Clear(); foreach (object[] row in items) { dgvKeySounds.Rows.Add(row); } xmlLoc = path; } else { SystemSounds.Beep.Play(); MessageBox.Show("No entries found, or all entries had errors in them (sound location behind empty or non-existant)"); } } else { SystemSounds.Beep.Play(); MessageBox.Show("No entries found, or there was an error reading the settings file"); } AutoSave(); }