public FormCreatureViewEdit( [NotNull] FormGrangerMain mainForm, [NotNull] GrangerContext context, [NotNull] ILogger logger, [NotNull] IWurmApi wurmApi, [CanBeNull] Creature creature, CreatureViewEditOpType optype, string herdId, [NotNull] CreatureColorDefinitions creatureColorDefinitions) { if (mainForm == null) { throw new ArgumentNullException(nameof(mainForm)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (wurmApi == null) { throw new ArgumentNullException(nameof(wurmApi)); } if (creatureColorDefinitions == null) { throw new ArgumentNullException(nameof(creatureColorDefinitions)); } this.mainForm = mainForm; this.creature = creature; this.context = context; this.herdId = herdId; this.creatureColorDefinitions = creatureColorDefinitions; this.logger = logger; this.wurmApi = wurmApi; InitializeComponent(); DisableAllFields(); comboBoxServerName.Items.AddRange( wurmApi.Servers.All.Select(server => server.ServerName.Original).Cast <object>().ToArray()); List <string> list = new List <string>(); list.AddRange(this.context.Creatures.Select(x => x.Name)); list.AddRange(this.context.Creatures.Select(x => x.MotherName)); list.AddRange(this.context.Creatures.Select(x => x.FatherName)); var allCreatureNamesInDatabase = list.Distinct().Where(x => x != null).Cast <object>().ToArray(); comboBoxFather.Items.AddRange(allCreatureNamesInDatabase); comboBoxMother.Items.AddRange(allCreatureNamesInDatabase); ; comboBoxColor.Items.AddRange( creatureColorDefinitions.GetColors().Select(color => color.CreatureColorId).Cast <object>().ToArray()); comboBoxColor.Text = CreatureColor.GetDefaultColor().CreatureColorId; comboBoxAge.Items.AddRange(CreatureAge.GetColorsEnumStrArray().Cast <object>().ToArray()); comboBoxAge.Text = CreatureAge.GetDefaultAgeStr(); this.OpMode = optype; }
private void buttonEdit_Click(object sender, EventArgs e) { OpMode = CreatureViewEditOpType.Edit; PrepareFieldsForEdit(); }