public override void GetEntries() { var sql = String.Format(SelectString, SelectArgValues); var results = Database.QueryHelper.RunQuery(_connection, sql); foreach (var row in results) { var entry = new SpawnEntry(_queryConfig); entry.SetProperties(Queries, row); if (_entries.Where(x => x.NpcID == entry.NpcID).FirstOrDefault() == null) { _entries.Add(entry); entry.ObjectDirtied += new Database.ObjectDirtiedHandler(entry_ObjectDirtied); entry.Created(); OnSpawnChanceTotalChanged(); } } }
public void RemoveEntry(SpawnEntry entry) { if (NeedsInserted.Contains(entry)) { NeedsInserted.Remove(entry); } else { NeedsDeleted.Add(entry); } try { Entries.Remove(entry); } catch (NotSupportedException) { //GUI updates will fail if on a different thread... //a dependency here on the windows dispatcher is not wanted yet... }; entry.ObjectDirtied -= entry_ObjectDirtied; OnSpawnChanceTotalChanged(); }
public SpawnEntry CreateEntry() { var entry = new SpawnEntry(_queryConfig); entry.SpawnGroupID = Id; return entry; }
public void AddEntry(SpawnEntry entry) { var count = _entries.Count( x => { return x.SpawnGroupID == entry.SpawnGroupID && x.NpcID == entry.NpcID; }); if( count == 0 ) { NeedsInserted.Add(entry); try { _entries.Add(entry); } catch (NotSupportedException) { //GUI updates will fail if on a different thread... //the item will still be added this exception is preventing the GUI from updating / //in the case of a wpf control being bound to this collection }; entry.ObjectDirtied += new Database.ObjectDirtiedHandler(entry_ObjectDirtied); } OnSpawnChanceTotalChanged(); }