public string GetAdditionalData(HotkeyAdditionalDataType additionalDataType) { if (AdditionalExtraData != null && AdditionalExtraData.ContainsKey((int)additionalDataType)) { return(AdditionalExtraData[(int)additionalDataType]); } return(null); }
public void SetAdditionalData(HotkeyAdditionalDataType additionalDataType, string value) { if (AdditionalExtraData == null) { AdditionalExtraData = new Dictionary <int, string>(); } if (AdditionalExtraData.ContainsKey((int)additionalDataType)) { AdditionalExtraData[(int)additionalDataType] = value; } else { AdditionalExtraData.Add((int)additionalDataType, value); } }
private void btnSave_Click(object sender, EventArgs e) { int command = (int)((HotkeyTypeEnum)cbCommand.SelectedValue); Hotkey tempHotkey = HotkeyTypeFactory.GetHotkeyType(command); tempHotkey.Command = command; tempHotkey.Modifier = (int)((KeyModifier)cbModifier.SelectedValue); tempHotkey.Key = (int)((Keys)cbKey.SelectedValue); if (cbInputDeviceOne.SelectedItem != null) { tempHotkey.ExtraData1 = cbInputDeviceOne.SelectedItem.ToString(); } if (cbOutputDeviceOne.SelectedItem != null) { tempHotkey.ExtraData2 = cbOutputDeviceOne.SelectedItem.ToString(); } tempHotkey.SetAdditionalData(HotkeyAdditionalDataType.AutoTuneAttack, trBAttack.Value.ToString()); tempHotkey.SetAdditionalData(HotkeyAdditionalDataType.AutoTuneVibratoRate, tbVibratoRate.Text); foreach (NoteViewModel currentPitch in AutoTuneViewModel.Pitches) { HotkeyAdditionalDataType additionalType = GetAddtDataTypeFromPitch(currentPitch); tempHotkey.SetAdditionalData(additionalType, currentPitch.Selected.ToString()); } ValidationResult result = Validate(tempHotkey); if (result.HasErrors()) { MessageBox.Show("Errors: " + result.CommaDelimErrors()); } else { Hotkey = tempHotkey; this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } }
public HotkeyEditAudioAutoTunePassthroughForm(Hotkey hotkey) { InitializeComponent(); AutoTuneViewModel = new AutoTuneViewModel(); cbCommand.DataSource = Enum.GetValues(typeof(HotkeyTypeEnum)); cbModifier.DataSource = Enum.GetValues(typeof(KeyModifier)); cbKey.DataSource = Enum.GetValues(typeof(Keys)); foreach (HotkeyAudioDevice currentDevice in MainAudio.Instance.AudioInputDevices) { cbInputDeviceOne.Items.Add(currentDevice.AudioDeviceName); } foreach (HotkeyAudioDevice currentDevice in MainAudio.Instance.AudioOutputDevices) { cbOutputDeviceOne.Items.Add(currentDevice.AudioDeviceName); } foreach (string currentScale in AutoTuneViewModel.Scales) { cbScale.Items.Add(currentScale); } string trbAttackValue = hotkey.GetAdditionalData(HotkeyAdditionalDataType.AutoTuneAttack); if (trbAttackValue != null) { trBAttack.Value = int.Parse(trbAttackValue); lblAttackVal.Text = trbAttackValue + "ms"; } string vibratoRate = hotkey.GetAdditionalData(HotkeyAdditionalDataType.AutoTuneVibratoRate); if (vibratoRate != null) { tbVibratoRate.Text = vibratoRate; } foreach (NoteViewModel pitch in AutoTuneViewModel.Pitches) { HotkeyAdditionalDataType pitchAddtDataType = GetAddtDataTypeFromPitch(pitch); string pitchAddt = hotkey.GetAdditionalData(pitchAddtDataType); CheckBox pitchCb = GetCheckboxFromPitch(pitch); if (pitchAddt != null && pitchCb != null) { pitchCb.Checked = bool.Parse(pitchAddt); pitch.Selected = bool.Parse(pitchAddt); } } string selectedScale = AutoTuneViewModel.GetScaleFromSelectedPitches(); if (!String.IsNullOrWhiteSpace(selectedScale)) { cbScale.SelectedItem = selectedScale; } cbCommand.SelectedItem = (HotkeyTypeEnum)hotkey.Command; cbCommand.Enabled = false; cbModifier.SelectedItem = (KeyModifier)hotkey.Modifier; cbKey.SelectedItem = (Keys)hotkey.Key; cbInputDeviceOne.SelectedItem = hotkey.ExtraData1; cbOutputDeviceOne.SelectedItem = hotkey.ExtraData2; }