/// <summary> /// Occurs when the <see cref="ExclusionsControl"/> is editing an item. /// </summary> /// <param name="sender">The <see cref="System.Object"/> that raised the event.</param> /// <param name="e">An <see cref="System.EventArgs"/> containing event data.</param> private void ExclusionsControl_EditingItem(object sender, ItemEventArgs e) { IPolicyExclusion policy = (IPolicyExclusion)e.Item.Tag; using (BaseEditorDialog dialog = this.CreateEditorDialog()) { dialog.EditMode = EditorMode.Edit; dialog.Value = policy; if (dialog.ShowDialog(this) != DialogResult.OK) { e.Cancel = true; } else { // Update the policy description. e.Item.Text = policy.Description; } } }
/// <summary> /// Edits a policy exclusion. /// </summary> /// <param name="mode">The editor mode to load.</param> /// <param name="exclusionType">The type of exclusion.</param> /// <param name="config">The exclusion configuration being modified.</param> /// <returns><b>true</b> if the item was modified, otherwise <b>false</b>.</returns> private bool EditPolicyExclusion(EditorMode mode, PolicyExclusionType exclusionType, ref PolicyExclusionConfigInfo config) { bool retval = false; if (exclusionType != PolicyExclusionType.None) { ExclusionAttribute attribute = Utilities.GetExclusionAttributeByEnum(exclusionType); if (attribute != null) { using (BaseEditorDialog dialog = (BaseEditorDialog)Activator.CreateInstance(attribute.EditorType)) { dialog.EditMode = mode; dialog.Value = config.Configuration; retval = dialog.ShowDialog(this) == DialogResult.OK; } } } return(retval); }
/// <summary> /// Occurs when the <see cref="ExclusionsControl"/> is adding an item. /// </summary> /// <param name="sender">The <see cref="System.Object"/> that raised the event.</param> /// <param name="e">An <see cref="AddingItemEventArgs"/> containing event data.</param> private void ExclusionsControl_AddingItem(object sender, ItemEventArgs e) { using (BaseEditorDialog dialog = this.CreateEditorDialog()) { dialog.EditMode = EditorMode.Add; if (dialog.ShowDialog(this) != DialogResult.OK) { e.Cancel = true; } else { IPolicyExclusion newExclusion = dialog.Value; newExclusion.Active = true; bool found = false; foreach (IPolicyExclusion exclusion in this.Exclusions) { if (exclusion.CompareTo(newExclusion) == 0) { // The new exclusion already exists, notify the user and do not add it again. found = true; break; } } if (!found) { this.Exclusions.Add(newExclusion); e.Item.Text = newExclusion.Description; e.Item.Tag = newExclusion; } this.EnableSubmitButton(); } } }