public CreatureColorViewObject(CreatureColor creatureColor) { Id = creatureColor.CreatureColorId; Color = creatureColor.SystemDrawingColor; DisplayName = creatureColor.DisplayName; WurmLogText = creatureColor.WurmLogText; BlockedForEditing = creatureColor.IsReadOnly; }
private void buttonAddNew_Click(object sender, EventArgs e) { var newId = textBoxId.Text.Trim(); if (string.IsNullOrWhiteSpace(newId)) { MessageBox.Show("New Id must not be empty"); } else if (creatureColorDefinitions.GetForId(newId) != CreatureColor.GetDefaultColor()) { MessageBox.Show($"CreatureColor with Id {newId} already exists on the list."); } else { creatureColorDefinitions.AddNew(newId); RefreshView(); } }
void UpdateCreaturesColors(CreatureColor color) { var selected = objectListView1.SelectedObjects.Cast <Creature>().ToArray(); if (selected.Length > 2) { if (System.Windows.Forms.MessageBox.Show("Color will be changed for creatures:\r\n" + string.Join(", ", (IEnumerable <Creature>)selected) + "\r\nContinue?", "Confirm", System.Windows.Forms.MessageBoxButtons.OKCancel) != System.Windows.Forms.DialogResult.OK) { return; } } foreach (var creature in selected) { creature.Color = color; } context.SubmitChanges(); }