/// <summary> /// Removes the currently selected property item. /// </summary> public void DeleteSelectedItem() { DataGridViewRow row = GetSelectedRow(); if (row == null) { MessageBox.Show("You must first select the property to delete"); return; } IEditProperty p = (IEditProperty)row.Tag; p.Delete(); RefreshList(); }
/// <summary> /// Asks the user to specify a revised value for the property item attached /// to the supplied row. /// </summary> /// <param name="row">The row associated with the property item to update.</param> void UpdateProperty(DataGridViewRow row) { IEditProperty p = (IEditProperty)row.Tag; using (PropertyForm dial = new PropertyForm(p.Name, p.Value)) { if (dial.ShowDialog() == DialogResult.OK) { p.BeginEdit(); p.Value = dial.PropertyValue; p.FinishEdit(); RefreshList(); } } }
/// <summary> /// Prompts the user for information for a new property item. /// </summary> public void NewItem() { using (PropertyForm dial = new PropertyForm(String.Empty, String.Empty)) { if (dial.ShowDialog() == DialogResult.OK) { IEnvironmentFactory f = EnvironmentContainer.Factory; IEditProperty newProp = f.CreateProperty(); newProp.BeginEdit(); newProp.Name = dial.PropertyName; newProp.Value = dial.PropertyValue; newProp.FinishEdit(); RefreshList(); } } }
/// <summary> /// Ensures all mandatory properties have been added /// </summary> /// <returns>True if any properties were added.</returns> bool AddMandatoryProperties(IProperty[] data) { bool result = false; string[] props = PropertyNaming.MandatoryProperties; foreach (string p in props) { if (!Array.Exists <IProperty>(data, delegate(IProperty t) { return(t.Name == p); })) { IEnvironmentFactory f = EnvironmentContainer.Factory; IEditProperty newProp = f.CreateProperty(); newProp.BeginEdit(); newProp.Name = p; newProp.Value = String.Empty; newProp.FinishEdit(); result = true; } } return(result); }