Exemple #1
0
        /// <summary>
        /// Occurs when the <see cref="ExclusionsControl"/> is disabling an item.
        /// </summary>
        /// <param name="sender">The <see cref="System.Object"/> that raised the event.</param>
        /// <param name="e">An <see cref="ItemEventArgs"/> containing event data.</param>
        private void ExclusionControl_DisablingItem(object sender, ItemEventArgs e)
        {
            PolicyExclusionConfigInfo exclusion = (PolicyExclusionConfigInfo)e.Item.Tag;

            if (exclusion != null)
            {
                exclusion.Configuration[PolicyExclusion.EnabledProperty] = "false";

                DisableListViewItem(e.Item);
            }
        }
Exemple #2
0
        /// <summary>
        /// Occurs when the <see cref="ExclusionsControl"/> index has changed.
        /// </summary>
        /// <param name="sender">The <see cref="System.Object"/> that raised the event.</param>
        /// <param name="e">An <see cref="EnableButtonsEventArgs"/> containing event data.</param>
        private void ExclusionControl_SelectedIndexChanged(object sender, EnableButtonsEventArgs e)
        {
            PolicyExclusionConfigInfo exclusion = (PolicyExclusionConfigInfo)e.Item.Tag;

            if (exclusion != null)
            {
                bool enabled = bool.Parse(exclusion.Configuration[PolicyExclusion.EnabledProperty]);

                e.EnableButton  = !enabled;
                e.DisableButton = enabled;
            }
        }
Exemple #3
0
        /// <summary>
        /// Edits the selected item.
        /// </summary>
        /// <returns><b>true</b> if the item was edited, otherwise <b>false</b>.</returns>
        private bool EditItem()
        {
            bool retval = false;

            if (this.ExclusionControl.SelectedItems.Count > 0)
            {
                ListViewItem item = this.ExclusionControl.SelectedItems[0];

                PolicyExclusionConfigInfo current = (PolicyExclusionConfigInfo)item.Tag;
                if (current != null)
                {
                    retval = this.EditPolicyExclusion(EditorMode.Edit, current.ExclusionType, ref current);
                }
            }

            return(retval);
        }
Exemple #4
0
        /// <summary>
        /// Loads the policy exclusion.
        /// </summary>
        /// <param name="exclusion">A policy exclusion to load.</param>
        private void LoadPolicyExclusion(PolicyExclusionConfigInfo exclusion)
        {
            if (exclusion == null)
            {
                return;
            }

            ExclusionAttribute attribute = Utilities.GetExclusionAttributeByEnum(exclusion.ExclusionType);

            if (attribute != null)
            {
                ListViewItem item = new ListViewItem();

                item.Text = Resources.ResourceManager.GetString(attribute.NameResourceId);

                StringBuilder sb = new StringBuilder();
                foreach (string key in exclusion.Configuration.AllKeys)
                {
                    if (string.Equals(key, PolicyExclusion.EnabledProperty, StringComparison.CurrentCultureIgnoreCase))
                    {
                        continue;
                    }

                    string value = exclusion.Configuration[key];

                    sb.Append(key).Append('=').Append(value).Append(';');
                }

                item.SubItems.Add(sb.ToString());
                item.Tag = exclusion;

                if (bool.Parse(exclusion.Configuration[PolicyExclusion.EnabledProperty]))
                {
                    EnableListViewItem(item);
                }
                else
                {
                    DisableListViewItem(item);
                }

                this.ExclusionControl.Items.Add(item);
            }
        }
Exemple #5
0
        /// <summary>
        /// Adds a new policy exclusion.
        /// </summary>
        /// <returns><b>true</b> if the item was added, otherwise <b>false</b>.</returns>
        private bool AddItem()
        {
            bool retval = false;

            PolicyExclusionType exclusionType = this.SelectExclusionType();

            if (exclusionType != PolicyExclusionType.None)
            {
                PolicyExclusionConfigInfo config = new PolicyExclusionConfigInfo();
                config.ExclusionType = exclusionType;

                retval = this.EditPolicyExclusion(EditorMode.Add, exclusionType, ref config);
                if (retval)
                {
                    config.Configuration[PolicyExclusion.EnabledProperty] = "true";

                    this.Settings.Exclusions.Add(config);
                }
            }

            return(retval);
        }
Exemple #6
0
        /// <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);
        }