/// <summary>
        /// Initialise a new instance of the KryptonRibbonGroupColorButton class.
        /// </summary>
        public KryptonRibbonGroupColorButton()
        {
            // Default fields
            _enabled                     = true;
            _visible                     = true;
            _checked                     = false;
            _visibleThemes               = true;
            _visibleStandard             = true;
            _visibleRecent               = true;
            _visibleNoColor              = true;
            _visibleMoreColors           = true;
            _autoRecentColors            = true;
            ShortcutKeys                 = Keys.None;
            _imageSmall                  = _defaultButtonImageSmall;
            _imageLarge                  = _defaultButtonImageLarge;
            _textLine1                   = "Color";
            _textLine2                   = string.Empty;
            _keyTip                      = "B";
            _selectedColor               = Color.Red;
            _emptyBorderColor            = Color.DarkGray;
            _selectedRectSmall           = new Rectangle(0, 12, 16, 4);
            _selectedRectLarge           = new Rectangle(2, 26, 28, 4);
            _schemeThemes                = ColorScheme.OfficeThemes;
            _schemeStandard              = ColorScheme.OfficeStandard;
            _buttonType                  = GroupButtonType.Split;
            _itemSizeMax                 = GroupItemSize.Large;
            _itemSizeMin                 = GroupItemSize.Small;
            _itemSizeCurrent             = GroupItemSize.Large;
            ToolTipImageTransparentColor = Color.Empty;
            ToolTipTitle                 = string.Empty;
            ToolTipBody                  = string.Empty;
            ToolTipStyle                 = LabelStyle.SuperTip;
            _maxRecentColors             = 10;
            _recentColors                = new List <Color>();

            // Create the context menu items
            _kryptonContextMenu = new KryptonContextMenu();
            _separatorTheme     = new KryptonContextMenuSeparator();
            _headingTheme       = new KryptonContextMenuHeading("Theme Colors");
            _colorsTheme        = new KryptonContextMenuColorColumns(ColorScheme.OfficeThemes);
            _separatorStandard  = new KryptonContextMenuSeparator();
            _headingStandard    = new KryptonContextMenuHeading("Standard Colors");
            _colorsStandard     = new KryptonContextMenuColorColumns(ColorScheme.OfficeStandard);
            _separatorRecent    = new KryptonContextMenuSeparator();
            _headingRecent      = new KryptonContextMenuHeading("Recent Colors");
            _colorsRecent       = new KryptonContextMenuColorColumns(ColorScheme.None);
            _separatorNoColor   = new KryptonContextMenuSeparator();
            _itemNoColor        = new KryptonContextMenuItem("&No Color", Properties.Resources.ButtonNoColor, OnClickNoColor);
            _itemsNoColor       = new KryptonContextMenuItems();
            _itemsNoColor.Items.Add(_itemNoColor);
            _separatorMoreColors = new KryptonContextMenuSeparator();
            _itemMoreColors      = new KryptonContextMenuItem("&More Colors...", OnClickMoreColors);
            _itemsMoreColors     = new KryptonContextMenuItems();
            _itemsMoreColors.Items.Add(_itemMoreColors);
            _kryptonContextMenu.Items.AddRange(new KryptonContextMenuItemBase[] { _separatorTheme, _headingTheme, _colorsTheme,
                                                                                  _separatorStandard, _headingStandard, _colorsStandard,
                                                                                  _separatorRecent, _headingRecent, _colorsRecent,
                                                                                  _separatorNoColor, _itemsNoColor,
                                                                                  _separatorMoreColors, _itemsMoreColors });
        }
コード例 #2
0
        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 != Color.Empty)
                {
                    bool found = false;
                    foreach (Color recentColor in _recentColors)
                    {
                        if (recentColor == 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);
                        }
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuColorColumn class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="colorColumns">Reference to owning color columns entry.</param>
        /// <param name="colors">Set of colors to initialize from.</param>\
        /// <param name="start">Stating index to use.</param>
        /// <param name="end">Ending index to use.</param>
        /// <param name="enabled">Is this column enabled</param>
        public ViewDrawMenuColorColumn(IContextMenuProvider provider,
                                       KryptonContextMenuColorColumns colorColumns,
                                       Color[] colors,
                                       int start,
                                       int end,
                                       bool enabled)
        {
            ViewLayoutColorStack vertical = new();

            for (var i = start; i < end; i++)
            {
                vertical.Add(new ViewDrawMenuColorBlock(provider, colorColumns, colors[i],
                                                        i == start, i == (end - 1), enabled));
            }

            Add(vertical);
        }
コード例 #4
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuColorBlock class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="colorColumns">Reference to owning color columns entry.</param>
        /// <param name="color">Drawing color for the block.</param>
        /// <param name="first">Is this element first in column.</param>
        /// <param name="last">Is this element last in column.</param>
        /// <param name="enabled">Is this column enabled</param>
        public ViewDrawMenuColorBlock(IContextMenuProvider provider,
                                      KryptonContextMenuColorColumns colorColumns,
                                      Color color,
                                      bool first,
                                      bool last,
                                      bool enabled)
        {
            _provider = provider;
            KryptonContextMenuColorColumns = colorColumns;
            Color       = color;
            _first      = first;
            _last       = last;
            ItemEnabled = enabled;
            _blockSize  = colorColumns.BlockSize;

            // Use context menu specific version of the radio button controller
            MenuColorBlockController mcbc = new(provider.ProviderViewManager, this, this, provider.ProviderNeedPaintDelegate);

            mcbc.Click     += OnClick;
            MouseController = mcbc;
            KeyController   = mcbc;
        }
コード例 #5
0
        private ViewLayoutStack CreateColumns(IContextMenuProvider provider,
                                              KryptonContextMenuColorColumns colorColumns,
                                              Color[][] colors,
                                              int start,
                                              int end,
                                              bool enabled)
        {
            // Create a horizontal stack of columns
            ViewLayoutStack columns = new(true)
            {
                FillLastChild = false
            };

            // Add each color column
            for (var i = 0; i < colors.Length; i++)
            {
                // Use a separator between each column
                if (i > 0)
                {
                    columns.Add(new ViewLayoutSeparator(4));
                }

                // Add container for the column, this draws the background
                ViewDrawMenuColorColumn colorColumn = new(provider, colorColumns, colors[i], start, end, enabled);
コード例 #6
0
        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);
                    }
                }
            }
        }