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);
}
}
}
}