コード例 #1
0
 /// <summary>
 /// Raises the <see cref="SelectedIndexChanged"/> event.
 /// </summary>
 /// <param name="e">An <see cref="UpdateButtonsEventArgs"/> containing event data.</param>
 private void OnSelectedIndexChanged(EnableButtonsEventArgs e)
 {
     if (this.SelectedIndexChanged != null)
     {
         this.SelectedIndexChanged(this, e);
     }
 }
コード例 #2
0
        /// <summary>
        /// Updates the buttons on the control.
        /// </summary>
        private void UpdateButtons()
        {
            bool selected = this.ExclusionsListView.SelectedItems.Count > 0;

            if (!selected)
            {
                this.EditButton.Enabled    = selected;
                this.RemoveButton.Enabled  = selected;
                this.EnableButton.Enabled  = selected;
                this.DisableButton.Enabled = selected;
            }
            else if (selected)
            {
                ListViewItem item = this.ExclusionsListView.SelectedItems[0];

                if (item != null)
                {
                    EnableButtonsEventArgs e = new EnableButtonsEventArgs(item);
                    e.AddButton     = true;
                    e.EditButton    = selected;
                    e.RemoveButton  = selected;
                    e.EnableButton  = false;
                    e.DisableButton = false;

                    this.OnSelectedIndexChanged(e);

                    if (!e.Cancel)
                    {
                        this.AddButton.Enabled     = e.AddButton;
                        this.EditButton.Enabled    = e.EditButton;
                        this.RemoveButton.Enabled  = e.RemoveButton;
                        this.EnableButton.Enabled  = e.EnableButton;
                        this.DisableButton.Enabled = e.DisableButton;
                    }
                }
            }
        }