ComponentFactory.Krypton.Ribbon.KryptonRibbonGroupColorButton.HookContextMenuEvents C# (CSharp) Method

HookContextMenuEvents() private method

private HookContextMenuEvents ( KryptonContextMenuCollection collection, bool hook ) : void
collection KryptonContextMenuCollection
hook bool
return void
        private void HookContextMenuEvents(KryptonContextMenuCollection collection, bool hook)
        {
            // Search for items of interest
            foreach (KryptonContextMenuItemBase item in collection)
            {
                // Hook into color events
                if (item is KryptonContextMenuColorColumns)
                {
                    KryptonContextMenuColorColumns columns = (KryptonContextMenuColorColumns)item;
                    columns.SelectedColor = _selectedColor;

                    if (hook)
                    {
                        columns.TrackingColor += new EventHandler<ColorEventArgs>(OnColumnsTrackingColor);
                        columns.SelectedColorChanged += new EventHandler<ColorEventArgs>(OnColumnsSelectedColorChanged);
                    }
                    else
                    {
                        columns.TrackingColor -= new EventHandler<ColorEventArgs>(OnColumnsTrackingColor);
                        columns.SelectedColorChanged -= new EventHandler<ColorEventArgs>(OnColumnsSelectedColorChanged);
                    }
                }
            }
        }