Inheritance: KryptonContextMenuItemBase
Ejemplo n.º 1
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);

            columns.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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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 += new EventHandler<ColorEventArgs>(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);
            fillStack.Add(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();
            _outerDocker.Add(_innerDocker, ViewDockStyle.Top);
            _outerDocker.Add(new ViewLayoutNull(), ViewDockStyle.Fill);

            // Add docker as the composite content
            Add(_outerDocker);
        }
Ejemplo n.º 4
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);
        }
        /// <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);
        }
Ejemplo n.º 6
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;
            _colorColumns = colorColumns;
            _color = color;
            _first = first;
            _last = last;
            _enabled = 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 += new EventHandler(OnClick);
            MouseController = mcbc;
            KeyController = mcbc;
        }
Ejemplo n.º 7
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;
            _colorColumns = colorColumns;
            _color        = color;
            _first        = first;
            _last         = last;
            _enabled      = 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     += new EventHandler(OnClick);
            MouseController = mcbc;
            KeyController   = mcbc;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initialize a new instance of the KryptonColorButton class.
        /// </summary>
        public KryptonColorButton()
        {
            // We generate click events manually, suppress default
            // production of them by the base Control class
            SetStyle(ControlStyles.StandardClick |
                     ControlStyles.StandardDoubleClick, false);

            // Set default color button properties
            _style = ButtonStyle.Standalone;
            _visibleThemes = true;
            _visibleStandard = true;
            _visibleRecent = true;
            _visibleNoColor = true;
            _visibleMoreColors = true;
            _autoRecentColors = true;
            _schemeThemes = ColorScheme.OfficeThemes;
            _schemeStandard = ColorScheme.OfficeStandard;
            _selectedRect = new Rectangle(0, 12, 16, 4);
            _selectedColor = Color.Red;
            _emptyBorderColor = Color.DarkGray;
            _dialogResult = DialogResult.None;
            _useMnemonic = true;
            _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, new EventHandler(OnClickNoColor));
            _itemsNoColor = new KryptonContextMenuItems();
            _itemsNoColor.Items.Add(_itemNoColor);
            _separatorMoreColors = new KryptonContextMenuSeparator();
            _itemMoreColors = new KryptonContextMenuItem("&More Colors...", new EventHandler(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});

            // Create content storage
            _buttonValues = CreateButtonValues(NeedPaintDelegate);
            _buttonValues.TextChanged += new EventHandler(OnButtonTextChanged);
            _images = new DropDownButtonImages(NeedPaintDelegate);

            // Image need an extra redirector to check the local images first
            _paletteDropDownButtonImages = new PaletteRedirectDropDownButton(Redirector, _images);

            // Create the palette storage
            _strings = new PaletteColorButtonStrings();
            _stateCommon = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone, NeedPaintDelegate);
            _stateDisabled = new PaletteTriple(_stateCommon, NeedPaintDelegate);
            _stateNormal = new PaletteTriple(_stateCommon, NeedPaintDelegate);
            _stateTracking = new PaletteTriple(_stateCommon, NeedPaintDelegate);
            _statePressed = new PaletteTriple(_stateCommon, NeedPaintDelegate);
            _stateDefault = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone, NeedPaintDelegate);
            _stateFocus = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone, NeedPaintDelegate);

            // Create the override handling classes
            _overrideFocus = new PaletteTripleOverride(_stateFocus, _stateNormal,  PaletteState.FocusOverride);
            _overrideNormal = new PaletteTripleOverride(_stateDefault, _overrideFocus, PaletteState.NormalDefaultOverride);
            _overrideTracking = new PaletteTripleOverride(_stateFocus, _stateTracking, PaletteState.FocusOverride);
            _overridePressed = new PaletteTripleOverride(_stateFocus, _statePressed, PaletteState.FocusOverride);

            // Create the view color button instance
            _drawButton = new ViewDrawButton(_stateDisabled,
                                             _overrideNormal,
                                             _overrideTracking,
                                             _overridePressed,
                                             new PaletteMetricRedirect(Redirector),
                                             this,
                                             VisualOrientation.Top,
                                             UseMnemonic);

            // Set default color button state
            _drawButton.DropDown = true;
            _drawButton.Splitter = true;
            _drawButton.TestForFocusCues = true;
            _drawButton.DropDownPalette = _paletteDropDownButtonImages;

            // Create a color button controller to handle button style behaviour
            _buttonController = new ButtonController(_drawButton, NeedPaintDelegate);
            _buttonController.BecomesFixed = true;

            // Assign the controller to the view element to treat as a button
            _drawButton.MouseController = _buttonController;
            _drawButton.KeyController = _buttonController;
            _drawButton.SourceController = _buttonController;

            // Need to know when user clicks the button view or mouse selects it
            _buttonController.Click += new MouseEventHandler(OnButtonClick);
            _buttonController.MouseSelect += new MouseEventHandler(OnButtonSelect);

            // Create the view manager instance
            ViewManager = new ViewManager(this, _drawButton);
        }
Ejemplo n.º 9
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);
            columns.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;
        }
        /// <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, new EventHandler(OnClickNoColor));
            _itemsNoColor = new KryptonContextMenuItems();
            _itemsNoColor.Items.Add(_itemNoColor);
            _separatorMoreColors = new KryptonContextMenuSeparator();
            _itemMoreColors = new KryptonContextMenuItem("&More Colors...", new EventHandler(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});
        }
        private void InitMenuItems()
        {
            itemAlignTop = new KryptonContextMenuItem(Strings.MenuAlignTop, Resources.AlignTop, itemAlignTop_Click);
            itemAlignLeft = new KryptonContextMenuItem(Strings.MenuAlignLeft, Resources.AlignLeft, itemAlignLeft_Click);
            itemAlignBottom = new KryptonContextMenuItem(Strings.MenuAlignBottom, Resources.AlignBottom, itemAlignBottom_Click);
            itemAlignRight = new KryptonContextMenuItem(Strings.MenuAlignRight, Resources.AlignRight, itemAlignRight_Click);
            itemAlignHorizontal = new KryptonContextMenuItem(Strings.MenuAlignHorizontal, Resources.AlignHorizontal, itemAlignHorizontal_Click);
            itemAlignVertical = new KryptonContextMenuItem(Strings.MenuAlignVertical, Resources.AlignVertical, itemAlignVertical_Click);
            itemAlign = new KryptonContextMenuItem(Strings.MenuAlign);

            itemBackColor = new KryptonContextMenuItem(Strings.MenuBackColor);
            itemBackColorColumns = new KryptonContextMenuColorColumns();
            itemStanderBackColorColumns = new KryptonContextMenuColorColumns();
            itemStanderBackColorColumns.ColorScheme = ColorScheme.OfficeStandard;
            itemNoBackColor = new KryptonContextMenuItem(Strings.MenuNoColor, /*Resources.ButtonNoColor, */itemNoBackColor_Click);

            itemBackColorColumns.SelectedColorChanged += new EventHandler<ColorEventArgs>(itemBackColorColumns_SelectedColorChanged);
            itemStanderBackColorColumns.SelectedColorChanged += new EventHandler<ColorEventArgs>(itemBackColorColumns_SelectedColorChanged);

            itemForeColor = new KryptonContextMenuItem(Strings.MenuForeColor);
            itemForeColorColumns = new KryptonContextMenuColorColumns();
            itemStanderForeColorColumns = new KryptonContextMenuColorColumns();
            itemStanderForeColorColumns.ColorScheme = ColorScheme.OfficeStandard;
            itemNoForeColor = new KryptonContextMenuItem(Strings.MenuNoColor, /*Resources.ButtonNoColor, */itemNoForeColor_Click);

            itemForeColorColumns.SelectedColorChanged += new EventHandler<ColorEventArgs>(itemForeColorColumns_SelectedColorChanged);
            itemStanderForeColorColumns.SelectedColorChanged += new EventHandler<ColorEventArgs>(itemForeColorColumns_SelectedColorChanged);

            itemBackColor.Items.AddRange(new KryptonContextMenuItemBase[]{ 
                itemBackColorColumns,
                itemStanderBackColorColumns,
                new KryptonContextMenuItems(new[] { itemNoBackColor })
            });

            itemForeColor.Items.AddRange(new KryptonContextMenuItemBase[]{ 
                itemForeColorColumns,
                itemStanderForeColorColumns,
                new KryptonContextMenuItems(new[] { itemNoForeColor })
            });

            itemAlign.Items.Add(new KryptonContextMenuItems(new KryptonContextMenuItemBase[] {
                itemAlignTop,
                itemAlignLeft,
                itemAlignBottom,
                itemAlignRight,
                new KryptonContextMenuSeparator(),
                itemAlignHorizontal,
                itemAlignVertical
            }));

            itemSameWidth = new KryptonContextMenuItem(Strings.MenuSameWidth, itemSameWidth_Click);
            itemSameHeight = new KryptonContextMenuItem(Strings.MenuSameHeight, itemSameHeight_Click);
            itemSameSize = new KryptonContextMenuItem(Strings.MenuSameSize, itemSameSize_Click);
            itemMakeSameSize = new KryptonContextMenuItem(Strings.MenuMakeSameSize);
            itemMakeSameSize.Items.Add(new KryptonContextMenuItems(new KryptonContextMenuItemBase[] {
                itemSameWidth,
                itemSameHeight,
                itemSameSize
            }));

            MenuList.AddRange(GeneralKryptonContextMenu.Default.MenuItems);
            MenuList.AddRange(new KryptonContextMenuItemBase[] {
				new KryptonContextMenuSeparator(),
                itemBackColor,
                itemForeColor,
				itemAlign,
				itemMakeSameSize,
			});
        }