/// <summary> /// display dialog for adding a component /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addComponentButton_Click(object sender, EventArgs e) { var chooseComponent = new ChooseComponentForm(ComponentCompatibility.GetCompatibleComponents(_target)); chooseComponent.ShowDialog(); if (chooseComponent.DialogResult != DialogResult.OK) { return; } var componentType = chooseComponent.Selected; var component = Activator.CreateInstance(componentType, _target); _target.AddComponents((AbstractComponent)component); Invalidate(); }
/// <summary> /// display dialog for deleting a component /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void deleteComponentButton_Click_1(object sender, EventArgs e) { // Cannot delete transforms var currentComponents = _target.Components.Values .Where((AbstractComponent ac) => !(ac is TransformComponent)) .Select((ac) => ac.GetType()).ToList(); var chooseComponent = new ChooseComponentForm(currentComponents); chooseComponent.ShowDialog(); if (chooseComponent.DialogResult != DialogResult.OK) { return; } var componentType = chooseComponent.Selected; _target.RemoveComponent(componentType); }