private void languageChoiceFeatureToolStripMenuItem1_Click(object sender, EventArgs e) { LanguageChoiceFeature f = new LanguageChoiceFeature(); f = new FeatureForms.LanguageChoiceFeatureForm(f).edit(HistoryManager); list.Add(f); fill(); }
public static void AddControl(List <System.Windows.Forms.Control> control, int level, LanguageChoiceFeature f) { if (langs == null) { langs = new List <Language>(Program.Context.Languages.Values); langs.Sort(); } if (!lcfboxes.ContainsKey(f)) { lcfboxes.Add(f, new List <System.Windows.Forms.ListBox>(f.Amount)); } if (!lcflabels.ContainsKey(f)) { lcflabels.Add(f, new List <System.Windows.Forms.Label>(f.Amount)); } List <System.Windows.Forms.ListBox> choiceboxes = lcfboxes[f]; List <System.Windows.Forms.Label> choicelabels = lcflabels[f]; List <String> taken = new List <string>(); 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_DisplayLanguage); 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"; String name = f.Name; if (f.Name == "") { name = "Language"; } choicelabel.Padding = new System.Windows.Forms.Padding(0, (c > 0 ? 3 : 8), 0, 3); choicelabel.Text = 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; if (cho == null || cho.Value == "") { cbox.Items.AddRange(langs.FindAll(e => !taken.Exists(t => ConfigManager.SourceInvariantComparer.Equals(t, e.Name + " " + ConfigManager.SourceSeperator + " " + e.Source))).ToArray()); } else { cbox.ForeColor = Config.SelectColor; cbox.Items.Add(Program.Context.GetLanguage(cho.Value, f.Source)); } cbox.Height = cbox.Items.Count * cbox.ItemHeight + 10; control.Add(cbox); } }
public LanguageChoice(PlayerModel model, LanguageChoiceFeature feature) : base(model, feature.UniqueID, feature.Amount, feature, model.Context.Languages.Values.OrderBy(s => s.Name).ToList(), false) { }