public GroupArmour(XmlNode n) : base(n) { // Проверяем, что таких ID, Name и ImageIndex нет foreach (GroupArmour ga in FormMain.Config.GroupArmours) { if (ga.ID == ID) { throw new Exception("Группа доспехов с ID = " + ga.ID + " уже существует."); } if (ga.Name == Name) { throw new Exception("Группа доспехов с Name = " + ga.Name + " уже существует."); } if (ga.ImageIndex == ImageIndex) { throw new Exception("Группа доспехов с ImageIndex = " + ga.ImageIndex.ToString() + " уже существует."); } } XmlNode nl = n.SelectSingleNode("Armours"); if (nl != null) { Armour a; foreach (XmlNode l in nl.SelectNodes("Armour")) { a = new Armour(this, l); Armours.Add(a); } } }
/// <summary> /// Add edited armour. /// </summary> public async void Insert(string armourType) { await _data.Set(_mapper.Map <ArmourProtModel>(_editedArmour)); Armours.Add(new ArmourProtDisplay(_editedArmour)); SelectedArmour = null; }
public Armours[] InitArmours() { Armours[] armArr = new Armours[4]; armArr[0] = new Wool(); armArr[1] = new Leather(); armArr[2] = new Steel(); armArr[3] = new Chainmail(); return(armArr); }
/// <summary> /// Update armour with the same type as edited armour. /// </summary> public async void Update(string armourType) { await _data.Set(_mapper.Map <ArmourProtModel>(_editedArmour)); foreach (var armour in Armours.ToList()) { if (armour.ArmourType == armourType) { int index = Armours.IndexOf(armour); Armours.Insert(index, new ArmourProtDisplay(_editedArmour)); Armours.Remove(armour); Armours.Refresh(); } } SelectedArmour = null; }
/// <summary> /// Remove armour with the same type as edited armour. /// </summary> public async void Remove(string armourType) { var msg = await _data.Remove(_mapper.Map <ArmourProtModel>(_editedArmour)); if (msg != null) { MessageBox.Show(msg, "Error", MessageBoxButton.OK, MessageBoxImage.Warning); return; } foreach (var armour in Armours.ToList()) { if (armour.ArmourType == armourType) { Armours.Remove(armour); } } _editedArmour = new ArmourProtDisplay(); SelectedArmour = null; }
public void RemoveItem(Armour armour) => Armours.Remove(armour);
public void AddItem(Armour armour) => Armours.Add(armour);
public bool Contains(Armour armour) => Armours.Contains(armour);