private void btnAdd_Click(object sender, EventArgs e) { int command = (int)((HotkeyTypeEnum)cbAddType.SelectedValue); Hotkey newHotkey = HotkeyTypeFactory.GetHotkeyType(command); newHotkey.Command = command; Form hotkeyEdit = HotkeyEditFormFactory.GetHotkeyEditForm(newHotkey.Command, newHotkey); IHotkeyForm hotkeyEditConv = null; if (hotkeyEdit is IHotkeyForm) { hotkeyEditConv = (IHotkeyForm)hotkeyEdit; } else { throw new Exception("Somehow the form doesn't cast to IHotkeyForm. Developer bad! Bad developer!"); } DialogResult result = hotkeyEdit.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { Hotkeys.Add(hotkeyEditConv.Hotkey); AddedHotkeys.Add(hotkeyEditConv.Hotkey); } }
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); tempHotkey.ExtraData1 = tbExtraData1.Text; EditHotkeyData1 = chkDataOneEdit.Checked; EditHotkeyData2 = chkDataTwoEdit.Checked; EditHotkeyData3 = chkDataThreeEdit.Checked; EditHotkeyData4 = chkDataFourEdit.Checked; if (cbDevices.SelectedItem != null) { tempHotkey.ExtraData2 = cbDevices.SelectedItem.ToString(); } tempHotkey.ExtraData3 = tbExtraData3.Text; 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 void GetHotkeysForGroup(HotkeyGroup group) { ds.OpenConnection(); // doing this in the mean-time. this is no way to program. too lazy to fix factory being in the logic tier making the data reading rely on it SQLiteDataReader dataReader = ds.GetHotkeys(group); Hotkeys = new BindingList <Hotkey>(); if (dataReader != null) { while (dataReader.Read()) { int hotkeyCommand = int.Parse(dataReader["command"].ToString()); Hotkey newHotkey = HotkeyTypeFactory.GetHotkeyType(hotkeyCommand); newHotkey.Modifier = int.Parse(dataReader["modifier"].ToString()); newHotkey.Key = int.Parse(dataReader["key"].ToString()); newHotkey.Command = hotkeyCommand; newHotkey.ExtraData1 = dataReader["extraData1"].ToString(); newHotkey.ExtraData2 = dataReader["extraData2"].ToString(); newHotkey.ExtraData3 = dataReader["extraData3"].ToString(); Hotkeys.Add(newHotkey); } } ds.CloseConnection(); ds.OpenConnection(); SQLiteDataReader addtDataReader = ds.GetHotkeysAdditionalData(group); if (addtDataReader != null) { while (addtDataReader.Read()) { int currentModifier = int.Parse(addtDataReader["modifier"].ToString()); int currentKey = int.Parse(addtDataReader["key"].ToString()); int currentCommand = int.Parse(addtDataReader["command"].ToString()); Hotkey addedHotkey = Hotkeys.FirstOrDefault(hk => hk.Modifier == currentModifier && hk.Key == currentKey && hk.Command == currentCommand); if (addedHotkey != null) { string currentDataKey = addtDataReader["keyName"].ToString(); string currentDataValue = addtDataReader["dataValue"].ToString(); addedHotkey.AdditionalExtraData.Add(int.Parse(currentDataKey), currentDataValue); } } } ds.CloseConnection(); foreach (Hotkey currentHotkey in Hotkeys) { LoadHotKey(currentHotkey); } }
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(); } }
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); tempHotkey.ExtraData1 = tbExtraData1.Text; tempHotkey.ExtraData2 = tbExtraData2.Text; tempHotkey.ExtraData3 = tbExtraData3.Text; ValidationResult result = Validate(tempHotkey); if (result.HasErrors()) { MessageBox.Show("Errors: " + result.CommaDelimErrors()); } else { Hotkey = tempHotkey; this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } }