ComponentFactory.Krypton.Toolkit.KryptonColorButton.UpdateRecentColors C# (CSharp) Method

UpdateRecentColors() private method

private UpdateRecentColors ( Color color ) : void
color Color
return void
        private void UpdateRecentColors(Color color)
        {
            // Do we need to update the recent colors collection?
            if (AutoRecentColors)
            {
                // We do not add to recent colors if it is inside another color columns
                foreach (KryptonContextMenuItemBase item in _kryptonContextMenu.Items)
                {
                    // Only interested in the non-recent colors color columns
                    if ((item is KryptonContextMenuColorColumns) && (item != _colorsRecent))
                    {
                        // Cast to correct type
                        KryptonContextMenuColorColumns colors = (KryptonContextMenuColorColumns)item;

                        // We do not change the theme or standard entries if they are not to be used
                        if (((item == _colorsTheme) && !VisibleThemes) ||
                            ((item == _colorsStandard) && !VisibleStandard))
                            continue;

                        // If matching color found, do not add to recent colors
                        if (colors.ContainsColor(color))
                            return;
                    }
                }

                // If this color valid and so possible to become a recent color
                if ((color != null) && !color.Equals(Color.Empty))
                {
                    bool found = false;
                    foreach (Color recentColor in _recentColors)
                        if (recentColor.Equals(color))
                        {
                            found = true;
                            break;
                        }

                    // If the color is not already part of the recent colors
                    if (!found)
                    {
                        // Add to start of the list
                        _recentColors.Insert(0, color);

                        // Enforce the maximum number of recent colors
                        if (_recentColors.Count > MaxRecentColors)
                            _recentColors.RemoveRange(MaxRecentColors, _recentColors.Count - MaxRecentColors);
                    }
                }
            }
        }