protected void OnAddButtonClicked(object sender, EventArgs e) { if (ObjectGroup == null) { return; } AddObjectDialog d = new AddObjectDialog(); d.Run(); if (d.ObjectTypeToAdd != ObjectType.End) { if (ObjectGroup == null) { return; } ObjectGroup.InsertObject(indexSpinButton.ValueAsInt + 1, d.ObjectTypeToAdd); UpdateBoundaries(); indexSpinButton.Value = indexSpinButton.ValueAsInt + 1; } }