private void InitializeSelectedPedal(ComboBox box, Control knobSelectButton, string pedalSlot, ToolkitPedal[] pedals, bool allowNull) { knobSelectButton.Enabled = false; knobSelectButton.Click += (sender, e) => { dynamic pedal = (CurrentGameVersion == GameVersion.RS2012) ? tone.PedalList[pedalSlot] : tone.GearList[pedalSlot]; using (var form = new ToneKnobForm()) { form.Init(pedal, pedals.Single(p => p.Key == pedal.PedalKey).Knobs); form.ShowDialog(); } }; box.Items.Clear(); box.DisplayMember = "DisplayName"; if (allowNull) { box.Items.Add(string.Empty); } box.Items.AddRange(pedals); box.SelectedValueChanged += (sender, e) => { if (_refreshingCombos) { return; } var pedal = box.SelectedItem as ToolkitPedal; if (pedal == null) { switch (CurrentGameVersion) { case GameVersion.RS2012: tone.PedalList.Remove(pedalSlot); break; case GameVersion.RS2014: tone.GearList[pedalSlot] = null; break; } knobSelectButton.Enabled = false; } else { string pedalKey = ""; switch (CurrentGameVersion) { case GameVersion.RS2012: if (tone.PedalList.ContainsKey(pedalSlot)) { pedalKey = tone.PedalList[pedalSlot].PedalKey; } break; case GameVersion.RS2014: if (tone.GearList[pedalSlot] != null) { pedalKey = tone.GearList[pedalSlot].PedalKey; } break; } if (pedal.Key != pedalKey) { var pedalSetting = pedal.MakePedalSetting(CurrentGameVersion); switch (CurrentGameVersion) { case GameVersion.RS2012: tone.PedalList[pedalSlot] = pedalSetting; knobSelectButton.Enabled = ((Pedal)pedalSetting).KnobValues.Any(); break; case GameVersion.RS2014: tone.GearList[pedalSlot] = pedalSetting; knobSelectButton.Enabled = ((Pedal2014)pedalSetting).KnobValues.Any(); break; } } else { bool knobEnabled = false; switch (CurrentGameVersion) { case GameVersion.RS2012: knobEnabled = ((Pedal)tone.PedalList[pedalSlot]).KnobValues.Any(); break; case GameVersion.RS2014: knobEnabled = ((Pedal2014)tone.GearList[pedalSlot]).KnobValues.Any(); break; } knobSelectButton.Enabled = knobEnabled; } } }; }
private void InitializeSelectedPedal(ComboBox box, Control knobSelectButton, string pedalSlot, ToolkitPedal[] pedals, bool allowNull) { knobSelectButton.Enabled = false; knobSelectButton.Click += (sender, e) => { dynamic pedal = (CurrentGameVersion == GameVersion.RS2012) ? tone.PedalList[pedalSlot] : tone.GearList[pedalSlot]; using (var form = new ToneKnobForm()) { form.Init(pedal, pedals.Single(p => p.Key == pedal.PedalKey).Knobs); form.ShowDialog(); } }; box.Items.Clear(); box.DisplayMember = "DisplayName"; if (allowNull) box.Items.Add(string.Empty); box.Items.AddRange(pedals); box.SelectedValueChanged += (sender, e) => { if (_refreshingCombos) return; var pedal = box.SelectedItem as ToolkitPedal; if (pedal == null) { switch (CurrentGameVersion) { case GameVersion.RS2012: tone.PedalList.Remove(pedalSlot); break; case GameVersion.RS2014: tone.GearList[pedalSlot] = null; break; default: break; } knobSelectButton.Enabled = false; } else { string pedalKey = ""; switch (CurrentGameVersion) { case GameVersion.RS2012: if (tone.PedalList.ContainsKey(pedalSlot)) pedalKey = tone.PedalList[pedalSlot].PedalKey; break; case GameVersion.RS2014: if (tone.GearList[pedalSlot] != null) pedalKey = tone.GearList[pedalSlot].PedalKey; break; } if (pedal.Key != pedalKey) { var pedalSetting = pedal.MakePedalSetting(CurrentGameVersion); switch (CurrentGameVersion) { case GameVersion.RS2012: tone.PedalList[pedalSlot] = pedalSetting; knobSelectButton.Enabled = ((Pedal)pedalSetting).KnobValues.Any(); break; case GameVersion.RS2014: tone.GearList[pedalSlot] = pedalSetting; knobSelectButton.Enabled = ((Pedal2014)pedalSetting).KnobValues.Any(); break; } } else { bool knobEnabled = false; switch (CurrentGameVersion) { case GameVersion.RS2012: knobEnabled = ((Pedal)tone.PedalList[pedalSlot]).KnobValues.Any(); break; case GameVersion.RS2014: knobEnabled = ((Pedal2014)tone.GearList[pedalSlot]).KnobValues.Any(); break; } knobSelectButton.Enabled = knobEnabled; } } }; }
private void InitializePedalSelect(ComboBox box, Control knobSelectButton, string pedalSlot, Pedal[] pedals, bool allowNull) { knobSelectButton.Enabled = false; knobSelectButton.Click += (sender, e) => { var pedal = tone.PedalList[pedalSlot]; using (var form = new ToneKnobForm()) { form.Init(pedal, pedals.Single(p => p.Key == pedal.PedalKey).Knobs); form.ShowDialog(); } }; box.DisplayMember = "DisplayName"; if (allowNull) box.Items.Add(string.Empty); box.Items.AddRange(pedals); box.SelectedValueChanged += (sender, e) => { if (_RefreshingCombos) { return; } var pedal = box.SelectedItem as Pedal; if (pedal == null) { tone.PedalList.Remove(pedalSlot); knobSelectButton.Enabled = false; } else { if (pedal.Key != (tone.PedalList.ContainsKey(pedalSlot) ? tone.PedalList[pedalSlot].PedalKey : "")) { var pedalSetting = pedal.MakePedalSetting(); tone.PedalList[pedalSlot] = pedalSetting; knobSelectButton.Enabled = pedalSetting.KnobValues.Any(); } else { knobSelectButton.Enabled = tone.PedalList[pedalSlot].KnobValues.Any(); } } }; }