public ToolkitPedal ToPedal()
 {
     var tkPedal = new ToolkitPedal();
     tkPedal.Category = Category;
     tkPedal.Key = Key;
     if (Knobs != null)
         tkPedal.Knobs = (from k in Knobs
                          where k.Name != null
                          select k).Select(knob => knob.ToToolkitKnob()).ToList();
     tkPedal.Name = Name;
     tkPedal.Type = Type;
     tkPedal.Bass = Key.Contains("Bass");
     return tkPedal;
 }
        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;
                    }
                }
            };
        }