private void EntityListView_ItemActivate(object sender, EventArgs e) { if (EntityListView.SelectedItems.Count > 0) { var entity = EntityListView.SelectedItems[0].Tag as Entity; if (entity?.Type == Entity.EntityType.Person) { var form = new Forms.PersonForm(entity, _entities); form.AddLayers(_layers); if (form.ShowDialog() == DialogResult.OK) { // write the new entity _entities[_entities.IndexOf(entity)] = form.Person; } } else if (entity?.Type == Entity.EntityType.Trigger) { var form = new Forms.TriggerForm(entity); form.AddLayers(_layers); if (form.ShowDialog() == DialogResult.OK) { // write the new entity _entities[_entities.IndexOf(entity)] = form.Trigger; } } } }