private void AddContainer(ContainerData data) { if (ItemManager.ContainerData.ContainsKey(data.Name)) { DialogResult result = MessageBox.Show(data.Name + " already exists. Overwrite it?", "Container Exists", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result != DialogResult.Yes) return; ItemManager.ContainerData[data.Name] = data; LoadContainers(); return; } ItemManager.ContainerData.Add(data.Name, data); DetailList.Items.Add(data); }
public override object Clone() { var data = new ContainerData { Name = _data.Name, Difficulty = _data.Difficulty, IsTrapped = _data.IsTrapped, IsLocked = _data.IsLocked, TrapName = _data.TrapName, KeyName = _data.KeyName, KeyType = _data.KeyType, KeysRequired = _data.KeysRequired, MinGold = _data.MinGold, MaxGold = _data.MaxGold }; foreach (KeyValuePair<string, string> pair in _data.ItemCollection) data.ItemCollection.Add(pair.Key, pair.Value); return new Container(data); }
public Container(ContainerData data) : base(data.Name, "") { _data = data; }
private void FormCancelButtonClick(object sender, EventArgs e) { ContainerData = null; CloseForm(); }
private void OkButtonClick(object sender, EventArgs e) { if (!IsValid()) { MessageBox.Show( "Name cannot be empty. Key details must be specified if Locked mode is enabled. Trap details must be specified if Trapped mode is enabled. Minimum gold value cannot be greater than maximum gold value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var data = new ContainerData { Name = NameBox.Text, IsLocked = LockCheck.Checked, IsTrapped = TrapCheck.Checked, MinGold = (int) MinGoldBox.Value, MaxGold = (int) MaxGoldBox.Value }; if (LockCheck.Checked) { data.Difficulty = (Difficulty) Enum.GetValues(typeof(Difficulty)).GetValue(LockDifficultyBox.SelectedIndex); data.KeyName = KeyNameBox.Text; data.KeyType = KeyTypeBox.Text; data.KeysRequired = (int) KeysNeededBox.Value; } if (TrapCheck.Checked) data.TrapName = TrapNameBox.Text; ContainerData = data; CloseForm(); }