private void featureCollectionChoiceFeatureToolStripMenuItem_Click(object sender, EventArgs e) { CollectionChoiceFeature f = new CollectionChoiceFeature() { Collection = "Category = 'Feats'" }; f = new FeatureForms.CollectionChoiceFeatureForm(f).edit(HistoryManager); list.Add(f); fill(); }
public static void AddControl(List <System.Windows.Forms.Control> control, int level, CollectionChoiceFeature f) { if (!ccfboxes.ContainsKey(f)) { ccfboxes.Add(f, new List <System.Windows.Forms.ListBox>(f.Amount)); } if (!ccflabels.ContainsKey(f)) { ccflabels.Add(f, new List <System.Windows.Forms.Label>(f.Amount)); } List <System.Windows.Forms.ListBox> choiceboxes = ccfboxes[f]; List <System.Windows.Forms.Label> choicelabels = ccflabels[f]; List <String> taken = new List <string>(); if (f.Collection == null || f.Collection == "") { taken.AddRange(Program.Context.Player.GetFeatNames()); } int offset = Program.Context.Player.GetChoiceOffset(f, f.UniqueID, f.Amount); for (int c = 0; c < Program.Context.Player.GetChoiceTotal(f.UniqueID); c++) { String counter = ""; if (c > 0) { counter = "_" + (c).ToString(); } Choice cho = Program.Context.Player.GetChoice(f.UniqueID + counter); if (cho != null && cho.Value != "") { taken.Add(cho.Value); } } for (int c = 0; c < f.Amount; c++) { String counter = ""; if (c + offset > 0) { counter = "_" + (c + offset).ToString(); } if (choiceboxes.Count <= c) { choiceboxes.Add(new System.Windows.Forms.ListBox()); System.Windows.Forms.ListBox choicebox = choiceboxes[c]; choicebox.Dock = System.Windows.Forms.DockStyle.Top; choicebox.FormattingEnabled = true; choicebox.Name = f.UniqueID + counter; choicebox.Size = new System.Drawing.Size(472, 95); choicebox.SelectedIndexChanged += new System.EventHandler(Program.MainWindow.Choice_DisplayFeature); choicebox.DoubleClick += new System.EventHandler(Program.MainWindow.Choice_DoubleClick); choicebox.Leave += new System.EventHandler(Program.MainWindow.listbox_Deselect_on_Leave); choicebox.MouseWheel += Program.MainWindow.listbox_MouseWheel; } if (choicelabels.Count <= c) { choicelabels.Add(new System.Windows.Forms.Label()); System.Windows.Forms.Label choicelabel = choicelabels[c]; choicelabel.AutoSize = true; choicelabel.Dock = System.Windows.Forms.DockStyle.Top; choicelabel.Name = f.UniqueID + counter + "_label"; choicelabel.Padding = new System.Windows.Forms.Padding(0, (c > 0 ? 3 : 8), 0, 3); choicelabel.Text = f.Name + (f.Amount > 1 ? " (" + (c + 1) + "/" + f.Amount + ")" : ""); } control.Add(choicelabels[c]); Choice cho = Program.Context.Player.GetChoice(f.UniqueID + counter); System.Windows.Forms.ListBox cbox = choiceboxes[c]; cbox.Items.Clear(); cbox.ForeColor = System.Drawing.SystemColors.WindowText; List <Feature> fl = Program.Context.GetFeatureCollection(f.Collection); if (cho == null || cho.Value == "" || !fl.Exists(feat => ConfigManager.SourceInvariantComparer.Equals(feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source, cho.Value))) { cbox.Items.AddRange(fl.FindAll(e => f.AllowSameChoice || !taken.Exists(t => ConfigManager.SourceInvariantComparer.Equals(t, e.Name + " " + ConfigManager.SourceSeperator + " " + e.Source)) && e.Level <= level).ToArray()); } else { cbox.ForeColor = Config.SelectColor; Feature res = Program.Context.GetFeatureCollection(f.Collection).Find(feat => feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source == cho.Value); if (res == null) { res = Program.Context.GetFeatureCollection(f.Collection).Find(feat => ConfigManager.SourceInvariantComparer.Equals(feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source, cho.Value)); } cbox.Items.Add(res); } cbox.Height = cbox.Items.Count * cbox.ItemHeight + 10; control.Add(cbox); } }
public CollectionChoice(PlayerModel model, CollectionChoiceFeature feature, int level) : base(model, feature.UniqueID, feature.Amount, feature, from f in model.Context.GetFeatureCollection(((CollectionChoiceFeature)feature).Collection) where f.Level <= level select f, feature.AllowSameChoice) { }