Exemplo n.º 1
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuColorColumns class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="colorColumns">Reference to owning color columns entry.</param>
        public ViewDrawMenuColorColumns(IContextMenuProvider provider,
                                        KryptonContextMenuColorColumns colorColumns)
        {
            _provider     = provider;
            _colorColumns = colorColumns;

            // Use separators to create space around the colors areas
            _innerDocker = new ViewLayoutDocker();

            // Redraw when the selected color changes
            colorColumns.SelectedColorChanged += OnSelectedColorChanged;

            Color[][] colors  = colorColumns.Colors;
            int       columns = colors.Length;
            int       rows    = ((columns > 0) && (colors[0] != null) ? colors[0].Length : 0);
            bool      enabled = provider.ProviderEnabled;

            // Always assume there is a first row of colors
            ViewLayoutStack fillStack = new ViewLayoutStack(false)
            {
                CreateColumns(provider, colorColumns, colors, 0, 1, enabled)
            };

            // If there are other rows to show
            if (rows > 1)
            {
                if (_colorColumns.GroupNonFirstRows)
                {
                    // Create a view to show the rest of the rows
                    fillStack.Add(new ViewLayoutSeparator(5));
                    fillStack.Add(CreateColumns(provider, colorColumns, colors, 1, rows, enabled));
                }
                else
                {
                    // Otherwise show each row as separate
                    for (int i = 1; i < rows; i++)
                    {
                        fillStack.Add(new ViewLayoutSeparator(5));
                        fillStack.Add(CreateColumns(provider, colorColumns, colors, i, i + 1, enabled));
                    }
                }
            }

            // Create a gap around the contents
            _innerDocker.Add(fillStack, ViewDockStyle.Fill);
            _innerDocker.Add(new ViewLayoutSeparator(3), ViewDockStyle.Top);
            _innerDocker.Add(new ViewLayoutSeparator(3), ViewDockStyle.Bottom);
            _innerDocker.Add(new ViewLayoutSeparator(2), ViewDockStyle.Left);
            _innerDocker.Add(new ViewLayoutSeparator(2), ViewDockStyle.Right);

            // Use outer docker so that any extra space not needed is used by the null
            _outerDocker = new ViewLayoutDocker
            {
                { _innerDocker, ViewDockStyle.Top },
                { new ViewLayoutNull(), ViewDockStyle.Fill }
            };

            // Add docker as the composite content
            Add(_outerDocker);
        }
Exemplo n.º 2
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 ViewLayoutStack(true)
            {
                FillLastChild = false
            };

            // Add each color column
            for (int 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 ViewDrawMenuColorColumn(provider, colorColumns, colors[i], start, end, enabled);
                columns.Add(colorColumn);
            }

            return(columns);
        }
Exemplo n.º 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 ViewLayoutColorStack();

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

            Add(vertical);
        }
Exemplo n.º 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 MenuColorBlockController(provider.ProviderViewManager, this, this, provider.ProviderNeedPaintDelegate);

            mcbc.Click     += OnClick;
            MouseController = mcbc;
            KeyController   = mcbc;
        }