Storage for KryptonContextMenuItem state values.
Inheritance: Storage
Exemplo n.º 1
0
        /// <summary>
        /// Initialize a new instance of the ContextMenuProvider class.
        /// </summary>
        /// <param name="viewManager">Reference to view manager.</param>
        /// <param name="viewColumns">Columns view element.</param>
        /// <param name="palette">Local palette setting to use initially.</param>
        /// <param name="paletteMode">Palette mode setting to use initially.</param>
        /// <param name="stateCommon">State used to provide common palette values.</param>
        /// <param name="stateNormal">State used to provide normal palette values.</param>
        /// <param name="stateDisabled">State used to provide disabled palette values.</param>
        /// <param name="stateHighlight">State used to provide highlight palette values.</param>
        /// <param name="stateChecked">State used to provide checked palette values.</param>
        /// <param name="redirector">Redirector used for obtaining palette values.</param>
        /// <param name="redirectorImages">Redirector used for obtaining images.</param>
        /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param>
        /// <param name="enabled">Enabled state of the context menu.</param>
        public ContextMenuProvider(ViewContextMenuManager viewManager,
                                   ViewLayoutStack viewColumns,
                                   IPalette palette,
                                   PaletteMode paletteMode,
                                   PaletteContextMenuRedirect stateCommon,
                                   PaletteContextMenuItemState stateDisabled,
                                   PaletteContextMenuItemState stateNormal,
                                   PaletteContextMenuItemStateHighlight stateHighlight,
                                   PaletteContextMenuItemStateChecked stateChecked,
                                   PaletteRedirect redirector,
                                   PaletteRedirectContextMenu redirectorImages,
                                   NeedPaintHandler needPaintDelegate,
                                   bool enabled)
        {
            _showHorz = KryptonContextMenuPositionH.Left;
            _showVert = KryptonContextMenuPositionV.Below;

            _enabled           = enabled;
            _viewManager       = viewManager;
            _viewColumns       = viewColumns;
            _stateCommon       = stateCommon;
            _stateDisabled     = stateDisabled;
            _stateNormal       = stateNormal;
            _stateHighlight    = stateHighlight;
            _stateChecked      = stateChecked;
            _redirectorImages  = redirectorImages;
            _palette           = palette;
            _paletteMode       = paletteMode;
            _redirector        = redirector;
            _needPaintDelegate = needPaintDelegate;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initialize a new instance of the KryptonPaletteContextMenu class.
 /// </summary>
 /// <param name="redirect">Redirector to inherit values from.</param>
 /// <param name="needPaint">Delegate for notifying paint requests.</param>
 internal KryptonPaletteContextMenu(PaletteRedirect redirect,
                                    NeedPaintHandler needPaint)
 {
     // Create the storage objects
     StateCommon    = new PaletteContextMenuRedirect(redirect, needPaint);
     StateNormal    = new PaletteContextMenuItemState(StateCommon);
     StateDisabled  = new PaletteContextMenuItemState(StateCommon);
     StateHighlight = new PaletteContextMenuItemStateHighlight(StateCommon);
     StateChecked   = new PaletteContextMenuItemStateChecked(StateCommon);
 }
 /// <summary>
 /// Initialize a new instance of the KryptonPaletteContextMenu class.
 /// </summary>
 /// <param name="redirect">Redirector to inherit values from.</param>
 /// <param name="needPaint">Delegate for notifying paint requests.</param>
 internal KryptonPaletteContextMenu(PaletteRedirect redirect,
                                    NeedPaintHandler needPaint)
 {
     // Create the storage objects
     _stateCommon = new PaletteContextMenuRedirect(redirect, needPaint);
     _stateNormal = new PaletteContextMenuItemState(_stateCommon);
     _stateDisabled = new PaletteContextMenuItemState(_stateCommon);
     _stateHighlight = new PaletteContextMenuItemStateHighlight(_stateCommon);
     _stateChecked = new PaletteContextMenuItemStateChecked(_stateCommon);
 }
        /// <summary>
        ///  Initialize a new instance of the KryptonContextMenu class.
        /// </summary>
        public KryptonContextMenu()
        {
            // Setup the need paint delegate
            _needPaintDelegate = OnNeedPaint;

            // Set default settings
            Palette           = null;
            PaletteMode       = PaletteMode.Global;
            Images            = new ContextMenuImages(_needPaintDelegate);
            _redirector       = new PaletteRedirect(null);
            _redirectorImages = new PaletteRedirectContextMenu(_redirector, Images);
            Enabled           = true;

            // Create the palette storage
            StateCommon    = new PaletteContextMenuRedirect(_redirector, _needPaintDelegate);
            StateNormal    = new PaletteContextMenuItemState(StateCommon);
            StateDisabled  = new PaletteContextMenuItemState(StateCommon);
            StateHighlight = new PaletteContextMenuItemStateHighlight(StateCommon);
            StateChecked   = new PaletteContextMenuItemStateChecked(StateCommon);

            // Create the top level collection for menu items
            Items = new KryptonContextMenuCollection();
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initialize a new instance of the ContextMenuProvider class.
 /// </summary>
 /// <param name="provider">Original provider.</param>
 /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param>
 /// <param name="viewManager">Reference to view manager.</param>
 /// <param name="viewColumns">Columns view element.</param>
 public ContextMenuProvider(IContextMenuProvider provider,
                            ViewContextMenuManager viewManager,
                            ViewLayoutStack viewColumns,
                            NeedPaintHandler needPaintDelegate)
 {
     _parent            = provider;
     _enabled           = provider.ProviderEnabled;
     _canCloseMenu      = provider.ProviderCanCloseMenu;
     _viewManager       = viewManager;
     _viewColumns       = viewColumns;
     _stateCommon       = provider.ProviderStateCommon;
     _stateDisabled     = provider.ProviderStateDisabled;
     _stateNormal       = provider.ProviderStateNormal;
     _stateHighlight    = provider.ProviderStateHighlight;
     _stateChecked      = provider.ProviderStateChecked;
     _redirectorImages  = provider.ProviderImages;
     _palette           = provider.ProviderPalette;
     _paletteMode       = provider.ProviderPaletteMode;
     _redirector        = provider.ProviderRedirector;
     _needPaintDelegate = needPaintDelegate;
     _showHorz          = provider.ProviderShowHorz;
     _showVert          = provider.ProviderShowVert;
 }
Exemplo n.º 6
0
        /// <summary>
        ///  Initialize a new instance of the KryptonContextMenu class.
        /// </summary>
        public KryptonContextMenu()
        {
            // Setup the need paint delegate
            _needPaintDelegate = new NeedPaintHandler(OnNeedPaint);

            // Set default settings
            _localPalette     = null;
            _paletteMode      = PaletteMode.Global;
            _images           = new ContextMenuImages(_needPaintDelegate);
            _redirector       = new PaletteRedirect(null);
            _redirectorImages = new PaletteRedirectContextMenu(_redirector, _images);
            _enabled          = true;

            // Create the palette storage
            _stateCommon    = new PaletteContextMenuRedirect(_redirector, _needPaintDelegate);
            _stateNormal    = new PaletteContextMenuItemState(_stateCommon);
            _stateDisabled  = new PaletteContextMenuItemState(_stateCommon);
            _stateHighlight = new PaletteContextMenuItemStateHighlight(_stateCommon);
            _stateChecked   = new PaletteContextMenuItemStateChecked(_stateCommon);

            // Create the top level collection for menu items
            _items = new KryptonContextMenuCollection();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Initialize a new instance of the ContextMenuProvider class.
 /// </summary>
 /// <param name="provider">Original provider.</param>
 /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param>
 /// <param name="viewManager">Reference to view manager.</param>
 /// <param name="viewColumns">Columns view element.</param>
 public ContextMenuProvider(IContextMenuProvider provider,
                            ViewContextMenuManager viewManager,
                            ViewLayoutStack viewColumns,
                            NeedPaintHandler needPaintDelegate)
 {
     _parent = provider;
     _enabled = provider.ProviderEnabled;
     _canCloseMenu = provider.ProviderCanCloseMenu;
     _viewManager = viewManager;
     _viewColumns = viewColumns;
     _stateCommon = provider.ProviderStateCommon;
     _stateDisabled = provider.ProviderStateDisabled;
     _stateNormal = provider.ProviderStateNormal;
     _stateHighlight = provider.ProviderStateHighlight;
     _stateChecked = provider.ProviderStateChecked;
     _redirectorImages = provider.ProviderImages;
     _palette = provider.ProviderPalette;
     _paletteMode = provider.ProviderPaletteMode;
     _redirector = provider.ProviderRedirector;
     _needPaintDelegate = needPaintDelegate;
     _showHorz = provider.ProviderShowHorz;
     _showVert = provider.ProviderShowVert;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Initialize a new instance of the KryptonContextMenuItem class.
        /// </summary>
        /// <param name="initialText">Initial text string.</param>
        /// <param name="initialImage">Initial image.</param>
        /// <param name="clickHandler">Click handler.</param>
        /// <param name="shortcut">Shortcut key combination.</param>
        public KryptonContextMenuItem(string initialText,
                                      Image initialImage,
                                      EventHandler clickHandler,
                                      Keys shortcut)
        {
            // Initial values
            _text  = initialText;
            _image = initialImage;

            // Initial click handler
            if (clickHandler != null)
            {
                Click += clickHandler;
            }

            // Default fields
            _enabled                  = true;
            _autoClose                = true;
            _splitSubMenu             = false;
            _checkOnClick             = false;
            _showShortcutKeys         = true;
            _largeKryptonCommandImage = false;
            _extraText                = string.Empty;
            _imageTransparentColor    = Color.Empty;
            _shortcutKeys             = shortcut;
            _shortcutKeyDisplayString = string.Empty;
            _checkState               = CheckState.Unchecked;
            Items = new KryptonContextMenuCollection();

            // Create the common storage for palette override values
            _stateRedirect = new PaletteContextMenuItemStateRedirect();
            StateNormal    = new PaletteContextMenuItemState(_stateRedirect);
            StateDisabled  = new PaletteContextMenuItemState(_stateRedirect);
            StateHighlight = new PaletteContextMenuItemStateHighlight(_stateRedirect);
            StateChecked   = new PaletteContextMenuItemStateChecked(_stateRedirect);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Discover the preferred size of the element.
        /// </summary>
        /// <param name="context">Layout context.</param>
        /// <exception cref="ArgumentNullException"></exception>
        public override Size GetPreferredSize(ViewLayoutContext context)
        {
            Debug.Assert(context != null);

            // Always update to the latest correct check state
            if (_imageCanvas != null)
            {
                if (ResolveChecked)
                {
                    _imageCanvas.ElementState = PaletteState.CheckedNormal;
                    _imageCanvas.Enabled      = ResolveEnabled;
                }
                else
                {
                    _imageCanvas.ElementState = PaletteState.Normal;
                    _imageCanvas.Enabled      = true;
                }
            }

            PaletteDouble splitPalette;

            // Make sure we are using the correct palette for state
            switch (State)
            {
            default:
            case PaletteState.Normal:
                SetPalettes(KryptonContextMenuItem.StateNormal.ItemHighlight.Back,
                            KryptonContextMenuItem.StateNormal.ItemHighlight.Border,
                            KryptonContextMenuItem.StateNormal.ItemHighlight);
                splitPalette = KryptonContextMenuItem.StateNormal.ItemSplit;
                break;

            case PaletteState.Disabled:
                SetPalettes(KryptonContextMenuItem.StateDisabled.ItemHighlight.Back,
                            KryptonContextMenuItem.StateDisabled.ItemHighlight.Border,
                            KryptonContextMenuItem.StateDisabled.ItemHighlight);
                splitPalette = KryptonContextMenuItem.StateDisabled.ItemSplit;
                break;

            case PaletteState.Tracking:
                SetPalettes(KryptonContextMenuItem.StateHighlight.ItemHighlight.Back,
                            KryptonContextMenuItem.StateHighlight.ItemHighlight.Border,
                            KryptonContextMenuItem.StateHighlight.ItemHighlight);
                splitPalette = KryptonContextMenuItem.StateHighlight.ItemSplit;
                break;
            }


            // Validate incoming reference
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            // If we have image display
            if (_fixedImage != null)
            {
                Image itemColumnImage      = ResolveImage;
                Color itemImageTransparent = ResolveImageTransparentColor;

                // If no image found then...
                if (itemColumnImage == null)
                {
                    // Ensure we have a fixed size if we are showing an image column
                    if (_imageColumn)
                    {
                        itemColumnImage      = _empty16x16;
                        itemImageTransparent = Color.Magenta;
                    }

                    switch (ResolveCheckState)
                    {
                    case CheckState.Checked:
                        itemColumnImage      = _provider.ProviderImages.GetContextMenuCheckedImage();
                        itemImageTransparent = Color.Empty;
                        break;

                    case CheckState.Indeterminate:
                        itemColumnImage      = _provider.ProviderImages.GetContextMenuIndeterminateImage();
                        itemImageTransparent = Color.Empty;
                        break;
                    }
                }

                // Decide on the enabled state of the display
                ItemEnabled = _provider.ProviderEnabled && ResolveEnabled;
                PaletteContextMenuItemState menuItemState = (ItemEnabled ? KryptonContextMenuItem.StateNormal : KryptonContextMenuItem.StateDisabled);

                // Update palettes based on Checked state
                PaletteTripleJustImage justImage = (ResolveChecked ? KryptonContextMenuItem.StateChecked.ItemImage : menuItemState.ItemImage);
                _imageCanvas?.SetPalettes(justImage.Back, justImage.Border);

                // Update the Enabled state
                _imageContent.SetPalette(justImage.Content);
                _imageContent.Enabled   = ItemEnabled;
                _textContent.Enabled    = ItemEnabled;
                SplitSeparator.Enabled  = ItemEnabled;
                _subMenuContent.Enabled = ItemEnabled;
                if (_shortcutContent != null)
                {
                    _shortcutContent.Enabled = ItemEnabled;
                }

                // Update the Text/ExtraText
                _fixedTextExtraText.ShortText = ResolveText;
                _fixedTextExtraText.LongText  = ResolveExtraText;

                // Update the Image
                _fixedImage.Image = itemColumnImage;
                _fixedImage.ImageTransparentColor = itemImageTransparent;
            }

            SplitSeparator?.SetPalettes(splitPalette.Back, splitPalette.Border);

            return(base.GetPreferredSize(context));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuItem class.
        /// </summary>
        /// <param name="provider">Provider of context menu information.</param>
        /// <param name="menuItem">Menu item definition.</param>
        /// <param name="columns">Containing columns.</param>
        /// <param name="standardStyle">Draw items with standard or alternate style.</param>
        /// <param name="imageColumn">Draw an image background for the item images.</param>
        public ViewDrawMenuItem(IContextMenuProvider provider,
                                KryptonContextMenuItem menuItem,
                                ViewLayoutStack columns,
                                bool standardStyle,
                                bool imageColumn)
            : base(menuItem.StateNormal.ItemHighlight.Back,
                   menuItem.StateNormal.ItemHighlight.Border,
                   menuItem.StateNormal.ItemHighlight,
                   PaletteMetricPadding.ContextMenuItemHighlight,
                   VisualOrientation.Top)
        {
            // Remember values
            _provider = provider;
            KryptonContextMenuItem = menuItem;
            _imageColumn           = imageColumn;
            _standardStyle         = standardStyle;

            // Give the item object the redirector to use when inheriting values
            KryptonContextMenuItem.SetPaletteRedirect(provider);

            // Create a stack of horizontal items inside the item
            ViewLayoutDocker docker = new ViewLayoutDocker();

            // Decide on the enabled state of the display
            ItemEnabled = provider.ProviderEnabled && ResolveEnabled;
            PaletteContextMenuItemState menuItemState = (ItemEnabled ? KryptonContextMenuItem.StateNormal : KryptonContextMenuItem.StateDisabled);

            // Calculate the image to show inside in the image column
            Image itemColumnImage      = ResolveImage;
            Color itemImageTransparent = ResolveImageTransparentColor;

            // If no image found then...
            if (itemColumnImage != null)
            {
                // Ensure we have a fixed size if we are showing an image column
                if (_imageColumn)
                {
                    itemColumnImage      = _empty16x16;
                    itemImageTransparent = Color.Magenta;
                }

                switch (ResolveCheckState)
                {
                case CheckState.Checked:
                    itemColumnImage      = provider.ProviderImages.GetContextMenuCheckedImage();
                    itemImageTransparent = Color.Empty;
                    break;

                case CheckState.Indeterminate:
                    itemColumnImage      = provider.ProviderImages.GetContextMenuIndeterminateImage();
                    itemImageTransparent = Color.Empty;
                    break;
                }
            }

            // Column Image
            PaletteTripleJustImage justImage = (ResolveChecked ? KryptonContextMenuItem.StateChecked.ItemImage : menuItemState.ItemImage);

            _fixedImage   = new FixedContentValue(null, null, itemColumnImage, itemImageTransparent);
            _imageContent = new ViewDrawContent(justImage.Content, _fixedImage, VisualOrientation.Top);
            _imageCanvas  = new ViewDrawMenuImageCanvas(justImage.Back, justImage.Border, 0, false)
            {
                _imageContent
            };
            docker.Add(new ViewLayoutCenter(_imageCanvas), ViewDockStyle.Left);
            _imageContent.Enabled = ItemEnabled;

            // Text/Extra Text
            PaletteContentJustText menuItemStyle = (standardStyle ? menuItemState.ItemTextStandard : menuItemState.ItemTextAlternate);

            _fixedTextExtraText = new FixedContentValue(ResolveText, ResolveExtraText, null, Color.Empty);
            _textContent        = new ViewDrawMenuItemContent(menuItemStyle, _fixedTextExtraText, 1);
            docker.Add(_textContent, ViewDockStyle.Fill);
            _textContent.Enabled = ItemEnabled;

            // Shortcut
            if (KryptonContextMenuItem.ShowShortcutKeys)
            {
                string shortcutString = KryptonContextMenuItem.ShortcutKeyDisplayString;
                if (string.IsNullOrEmpty(shortcutString))
                {
                    shortcutString = (KryptonContextMenuItem.ShortcutKeys != Keys.None) ? new KeysConverter().ConvertToString(KryptonContextMenuItem.ShortcutKeys) : string.Empty;
                }

                if (shortcutString.Length > 0)
                {
                    _shortcutContent = new ViewDrawMenuItemContent(menuItemState.ItemShortcutText, new FixedContentValue(shortcutString, null, null, Color.Empty), 2);
                    docker.Add(_shortcutContent, ViewDockStyle.Right);
                    _shortcutContent.Enabled = ItemEnabled;
                }
            }

            // Add split item separator
            SplitSeparator = new ViewDrawMenuSeparator(menuItemState.ItemSplit);
            docker.Add(SplitSeparator, ViewDockStyle.Right);
            SplitSeparator.Enabled = ItemEnabled;
            SplitSeparator.Draw    = (KryptonContextMenuItem.Items.Count > 0) && KryptonContextMenuItem.SplitSubMenu;

            // SubMenu Indicator
            HasSubMenu      = (KryptonContextMenuItem.Items.Count > 0);
            _subMenuContent = new ViewDrawMenuItemContent(menuItemState.ItemImage.Content, new FixedContentValue(null, null, (!HasSubMenu ? _empty16x16 : provider.ProviderImages.GetContextMenuSubMenuImage()), (KryptonContextMenuItem.Items.Count == 0 ? Color.Magenta : Color.Empty)), 3);
            docker.Add(new ViewLayoutCenter(_subMenuContent), ViewDockStyle.Right);
            _subMenuContent.Enabled = ItemEnabled;

            Add(docker);

            // Add a controller for handing mouse and keyboard events
            MenuItemController mic = new MenuItemController(provider.ProviderViewManager, this, provider.ProviderNeedPaintDelegate);

            MouseController = mic;
            KeyController   = mic;

            // Want to know when a property changes whilst displayed
            KryptonContextMenuItem.PropertyChanged += OnPropertyChanged;

            // We need to know if a property of the command changes
            if (KryptonContextMenuItem.KryptonCommand != null)
            {
                _cachedCommand = KryptonContextMenuItem.KryptonCommand;
                KryptonContextMenuItem.KryptonCommand.PropertyChanged += OnCommandPropertyChanged;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        ///  Initialize a new instance of the KryptonContextMenu class.
        /// </summary>
        public KryptonContextMenu()
        {
            // Setup the need paint delegate
            _needPaintDelegate = new NeedPaintHandler(OnNeedPaint);

            // Set default settings
            _localPalette = null;
            _paletteMode = PaletteMode.Global;
            _images = new ContextMenuImages(_needPaintDelegate);
            _redirector = new PaletteRedirect(null);
            _redirectorImages = new PaletteRedirectContextMenu(_redirector, _images);
            _enabled = true;

            // Create the palette storage
            _stateCommon = new PaletteContextMenuRedirect(_redirector, _needPaintDelegate);
            _stateNormal = new PaletteContextMenuItemState(_stateCommon);
            _stateDisabled = new PaletteContextMenuItemState(_stateCommon);
            _stateHighlight = new PaletteContextMenuItemStateHighlight(_stateCommon);
            _stateChecked = new PaletteContextMenuItemStateChecked(_stateCommon);

            // Create the top level collection for menu items
            _items = new KryptonContextMenuCollection();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initialize a new instance of the ContextMenuProvider class.
        /// </summary>
        /// <param name="viewManager">View manager used to organize keyboard events.</param>
        /// <param name="menuCollection">Top level set of menu items.</param>
        /// <param name="viewColumns">Stack used for adding new columns.</param>
        /// <param name="palette">Local palette setting to use initially.</param>
        /// <param name="paletteMode">Palette mode setting to use initially.</param>
        /// <param name="redirector">Redirector used for obtaining palette values.</param>
        /// <param name="needPaintDelegate">Delegate used to when paint changes occur.</param>
        public AppButtonMenuProvider(ViewContextMenuManager viewManager,
                                     KryptonContextMenuItemCollection menuCollection,
                                     ViewLayoutStack viewColumns,
                                     IPalette palette,
                                     PaletteMode paletteMode,
                                     PaletteRedirect redirector,
                                     NeedPaintHandler needPaintDelegate)
        {
            // Store incoming state
            _viewManager = viewManager;
            _menuCollection = menuCollection;
            _viewColumns = viewColumns;
            _palette = palette;
            _paletteMode = paletteMode;
            _redirector = redirector;
            _needPaintDelegate = needPaintDelegate;

            // Create all other state
            _parent = null;
            _enabled = true;
            _canCloseMenu = true;
            _showHorz = KryptonContextMenuPositionH.After;
            _showVert = KryptonContextMenuPositionV.Top;
            _stateCommon = new PaletteContextMenuRedirect(redirector, needPaintDelegate);
            _stateNormal = new PaletteContextMenuItemState(_stateCommon);
            _stateDisabled = new PaletteContextMenuItemState(_stateCommon);
            _stateHighlight = new PaletteContextMenuItemStateHighlight(_stateCommon);
            _stateChecked = new PaletteContextMenuItemStateChecked(_stateCommon);
            _redirectorImages = new PaletteRedirectContextMenu(redirector, new ContextMenuImages(needPaintDelegate));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initialize a new instance of the ContextMenuProvider class.
        /// </summary>
        /// <param name="contextMenu">Originating context menu instance.</param>
        /// <param name="viewManager">Reference to view manager.</param>
        /// <param name="viewColumns">Columns view element.</param>
        /// <param name="palette">Local palette setting to use initially.</param>
        /// <param name="paletteMode">Palette mode setting to use initially.</param>
        /// <param name="redirector">Redirector used for obtaining palette values.</param>
        /// <param name="redirectorImages">Redirector used for obtaining images.</param>
        /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param>
        /// <param name="enabled">Enabled state of the context menu.</param>
        public ContextMenuProvider(KryptonContextMenu contextMenu,
                                   ViewContextMenuManager viewManager,
                                   ViewLayoutStack viewColumns,
                                   IPalette palette,
                                   PaletteMode paletteMode,
                                   PaletteRedirect redirector,
                                   PaletteRedirectContextMenu redirectorImages,
                                   NeedPaintHandler needPaintDelegate,
                                   bool enabled)
        {
            _showHorz = KryptonContextMenuPositionH.Left;
            _showVert = KryptonContextMenuPositionV.Below;

            _enabled = enabled;
            _viewManager = viewManager;
            _viewColumns = viewColumns;
            _stateCommon = contextMenu.StateCommon;
            _stateDisabled = contextMenu.StateDisabled;
            _stateNormal = contextMenu.StateNormal;
            _stateHighlight = contextMenu.StateHighlight;
            _stateChecked = contextMenu.StateChecked;
            _redirectorImages = redirectorImages;
            _palette = palette;
            _paletteMode = paletteMode;
            _redirector = redirector;
            _needPaintDelegate = needPaintDelegate;
            _canCloseMenu = true;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initialize a new instance of the KryptonContextMenuItem class.
        /// </summary>
        /// <param name="initialText">Initial text string.</param>
        /// <param name="initialImage">Initial image.</param>
        /// <param name="clickHandler">Click handler.</param>
        /// <param name="shortcut">Shortcut key combination.</param>
        public KryptonContextMenuItem(string initialText,
                                      Image initialImage,
                                      EventHandler clickHandler,
                                      Keys shortcut)
        {
            // Initial values
            _text = initialText;
            _image = initialImage;

            // Initial click handler
            if (clickHandler != null)
                Click += clickHandler;

            // Default fields
            _enabled = true;
            _autoClose = true;
            _splitSubMenu = false;
            _checkOnClick = false;
            _showShortcutKeys = true;
            _largeKryptonCommandImage = false;
            _extraText = string.Empty;
            _imageTransparentColor = Color.Empty;
            _shortcutKeys = shortcut;
            _shortcutKeyDisplayString = string.Empty;
            _checkState = CheckState.Unchecked;
            _items = new KryptonContextMenuCollection();

            // Create the common storage for palette override values
            _stateRedirect = new PaletteContextMenuItemStateRedirect();
            _stateNormal = new PaletteContextMenuItemState(_stateRedirect);
            _stateDisabled = new PaletteContextMenuItemState(_stateRedirect);
            _stateHighlight = new PaletteContextMenuItemStateHighlight(_stateRedirect);
            _stateChecked = new PaletteContextMenuItemStateChecked(_stateRedirect);
        }