private void listSplits_SelectedIndexChanged(object sender, EventArgs e) { panelSplitEdit.Controls.Clear(); var index = listSplits.SelectedIndices.Count == 0 ? -1 : listSplits.SelectedIndices[0]; var rule = index < 0 ? null : settings.SplitRules[index]; SplitRuleEditControl editControl = rule switch { null => new EmptySplitRuleControl(autosplitter), SplitRuleGettingCards gc => new GettingCardsEditControl(gc, database), SplitRuleGettingFairiesOfClass gfoc => new GettingFairiesOfClassEditControl(gfoc, database), SplitRuleGettingTotalFairies gtf => new GettingTotalFairiesEditControl(gtf, database), SplitRuleReaching r => new ReachingEditControl(r, database), SplitRuleDefeating d => new DefeatingEditControl(d, database), SplitRuleWatching w => new WatchingEditControl(w, database), _ => throw new NotImplementedException($"Unimplemented edit control for {rule}") }; if (editControl == null) { return; } editControl.Dock = DockStyle.Fill; if (index >= 0) { editControl.OnRuleChanged += () => ModifySplitItem(listSplits.Items[index], index, rule); } panelSplitEdit.Controls.Add(editControl); }
public DefeatingEditControl(SplitRuleDefeating rule, Database database) { this.rule = rule; this.database = database; InitializeComponent(); comboPreset.DataSource = database.NPCPresets; comboPreset.DisplayMember = nameof(SplitRuleDefeating.Name); textUID.ValidatingType = typeof(DefeatingEditControl); textUID.Text = rule.UID.ToString("X8"); textName.Text = rule.Name; isInitialised = true; UpdateIcon(); }