/// <summary>
        /// Initialize a new instance of the ViewDrawMenuMonthCalendar class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="monthCalendar">Reference to owning month calendar entry.</param>
        public ViewDrawMenuMonthCalendar(IContextMenuProvider provider,
                                         KryptonContextMenuMonthCalendar monthCalendar)
        {
            _provider = provider;
            _monthCalendar = monthCalendar;
            _firstDayOfWeek = _monthCalendar.FirstDayOfWeek;
            _minDate = _monthCalendar.MinDate;
            _maxDate = _monthCalendar.MaxDate;
            _todayDate = _monthCalendar.TodayDate;
            _maxSelectionCount = _monthCalendar.MaxSelectionCount;
            _scrollChange = _monthCalendar.ScrollChange;
            _todayText = _monthCalendar.TodayText;
            _todayFormat = _monthCalendar.TodayFormat;
            _dimensions = _monthCalendar.CalendarDimensions;

            // Decide on the enabled state of the display
            _itemEnabled = provider.ProviderEnabled && _monthCalendar.Enabled;

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

            // Create view that is used by standalone control as well as this context menu element
            _layoutMonths = new ViewLayoutMonths(provider, monthCalendar, provider.ProviderViewManager, this, provider.ProviderRedirector, provider.ProviderNeedPaintDelegate);
            _layoutMonths.CloseOnTodayClick = _monthCalendar.CloseOnTodayClick;
            _layoutMonths.ShowWeekNumbers = _monthCalendar.ShowWeekNumbers;
            _layoutMonths.ShowTodayCircle = _monthCalendar.ShowTodayCircle;
            _layoutMonths.ShowToday = _monthCalendar.ShowToday;
            _layoutMonths.Enabled = _itemEnabled;

            Add(_layoutMonths);
        }
        /// <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));
        }
        /// <summary>
        ///  Initialize a new instance of the VisualContextMenu class.
        /// </summary>
        /// <param name="provider">Original source of provider details</param>
        /// <param name="items">Enabled state of the context menu.</param>
        /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param>
        public VisualContextMenu(IContextMenuProvider provider,
                                 KryptonContextMenuCollection items,
                                 bool keyboardActivated)
            : base(true)
        {
            _redirector = provider.ProviderRedirector;

            // Create the view manager instance with root element
            ViewManager = new ViewContextMenuManager(this, new ViewLayoutNull());

            // Set the initial resolved palette to the appropriate setting
            if (provider.ProviderPalette != null)
                SetPalette(provider.ProviderPalette);
            else
                SetPalette(KryptonManager.GetPaletteForMode(provider.ProviderPaletteMode));

            // Set of context menu columns
            _viewColumns = new ViewLayoutStack(true);

            // Create provider instance
            _provider = new ContextMenuProvider(provider, (ViewContextMenuManager)ViewManager, _viewColumns, NeedPaintDelegate);
            _provider.Closing += new CancelEventHandler(OnProviderClosing);
            _provider.Close += new EventHandler<CloseReasonEventArgs>(OnProviderClose);
            _provider.Dispose += new EventHandler(OnProviderClose);

            Construct(items, keyboardActivated);
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuRadioButton class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="radioButton">Reference to owning radio button entry.</param>
        public ViewDrawMenuRadioButton(IContextMenuProvider provider,
                                       KryptonContextMenuRadioButton radioButton)
        {
            _provider = provider;
            _radioButton = radioButton;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(radioButton.Text,
                                                   radioButton.ExtraText,
                                                   radioButton.Image,
                                                   radioButton.ImageTransparentColor);

            // Decide on the enabled state of the display
            _itemEnabled = provider.ProviderEnabled && _radioButton.Enabled;

            // Give the heading object the redirector to use when inheriting values
            _radioButton.SetPaletteRedirect(provider.ProviderRedirector);

            // Create the content for the actual heading text/image
            _drawContent = new ViewDrawContent((_itemEnabled ? (IPaletteContent)_radioButton.OverrideNormal : (IPaletteContent)_radioButton.OverrideDisabled),
                                               _contentValues, VisualOrientation.Top);
            _drawContent.UseMnemonic = true;
            _drawContent.Enabled = _itemEnabled;

            // Create the radio button image drawer and place inside element so it is always centered
            _drawRadioButton = new ViewDrawRadioButton(_radioButton.StateRadioButtonImages);
            _drawRadioButton.CheckState = _radioButton.Checked;
            _drawRadioButton.Enabled = _itemEnabled;
            _layoutCenter = new ViewLayoutCenter();
            _layoutCenter.Add(_drawRadioButton);

            // Place the radio button on the left of the available space but inside separators
            _innerDocker = new ViewLayoutDocker();
            _innerDocker.Add(_drawContent, ViewDockStyle.Fill);
            _innerDocker.Add(_layoutCenter, ViewDockStyle.Left);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Right);
            _innerDocker.Add(new ViewLayoutSeparator(3), ViewDockStyle.Left);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Top);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Bottom);

            // 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);

            // Use context menu specific version of the radio button controller
            MenuRadioButtonController mrbc = new MenuRadioButtonController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate);
            mrbc.Click += new EventHandler(OnClick);
            _innerDocker.MouseController = mrbc;
            _innerDocker.KeyController = mrbc;

            // We need to be notified whenever the checked state changes
            _radioButton.CheckedChanged += new EventHandler(OnCheckedChanged);

            // Add docker as the composite content
            Add(_outerDocker);
        }
        /// <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);
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuLinkLabel class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="linkLabel">Reference to owning link label entry.</param>
        public ViewDrawMenuLinkLabel(IContextMenuProvider provider,
                                     KryptonContextMenuLinkLabel linkLabel)
        {
            _provider = provider;
            _linkLabel = linkLabel;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(linkLabel.Text,
                                                   linkLabel.ExtraText,
                                                   linkLabel.Image,
                                                   linkLabel.ImageTransparentColor);

            // Decide on the enabled state of the display
            _itemEnabled = provider.ProviderEnabled;

            // Give the heading object the redirector to use when inheriting values
            linkLabel.SetPaletteRedirect(provider.ProviderRedirector);

            // Create the content for the actual heading text/image
            _drawContent = new ViewDrawContent(linkLabel.OverrideFocusNotVisited, _contentValues, VisualOrientation.Top);
            _drawContent.UseMnemonic = true;
            _drawContent.Enabled = _itemEnabled;

            // Place label link in the center of the area but inside some separator to add spacing
            _innerDocker = new ViewLayoutDocker();
            _innerDocker.Add(_drawContent, ViewDockStyle.Fill);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Right);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Left);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Top);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Bottom);

            // 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);

            // Use context menu specific version of the link label controller
            MenuLinkLabelController mllc = new MenuLinkLabelController(provider.ProviderViewManager, _drawContent, this, provider.ProviderNeedPaintDelegate);
            mllc.Click += new EventHandler(OnClick);
            _drawContent.MouseController = mllc;
            _drawContent.KeyController = mllc;

            // Add docker as the composite content
            Add(_outerDocker);

            // Want to know when a property changes whilst displayed
            _linkLabel.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

            // We need to know if a property of the command changes
            if (_linkLabel.KryptonCommand != null)
            {
                _cachedCommand = _linkLabel.KryptonCommand;
                _linkLabel.KryptonCommand.PropertyChanged += new PropertyChangedEventHandler(OnCommandPropertyChanged);
            }
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonAppMenuRecentDec class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon instance.</param>
        /// <param name="provider">Provider of context menu information.</param>
        /// <param name="recentDoc">Source rencent document instance.</param>
        /// <param name="maxWidth">Maximum width allowed for the item.</param>
        /// <param name="needPaintDelegate">Delegate for requesting paint updates.</param>
        /// <param name="index">Recent documet index.</param>
        public ViewDrawRibbonAppMenuRecentDec(KryptonRibbon ribbon,
                                              IContextMenuProvider provider,
                                              KryptonRibbonRecentDoc recentDoc,
                                              int maxWidth,
                                              NeedPaintHandler needPaintDelegate,
                                              int index)
            : base(provider.ProviderStateNormal.ItemHighlight.Back,
                   provider.ProviderStateNormal.ItemHighlight.Border,
                   provider.ProviderStateNormal.ItemHighlight,
                   PaletteMetricPadding.ContextMenuItemHighlight,
                   VisualOrientation.Top)
        {
            _maxWidth = maxWidth;
            _provider = provider;
            _recentDoc = recentDoc;
            _shortcutText = (index < 10 ? @"&" + index.ToString() : "A");

            // Use docker to organize horizontal items
            ViewLayoutDocker docker = new ViewLayoutDocker();

            // End of line gap
            docker.Add(new ViewLayoutSeparator(5), ViewDockStyle.Right);

            // Add the text/extraText/Image entry
            FixedContentValue entryContent = new FixedContentValue(recentDoc.Text, recentDoc.ExtraText, recentDoc.Image, recentDoc.ImageTransparentColor);
            RibbonRecentDocsEntryToContent entryPalette = new RibbonRecentDocsEntryToContent(ribbon.StateCommon.RibbonGeneral, ribbon.StateCommon.RibbonAppMenuDocsEntry);
            ViewDrawContent entryDraw = new ViewDrawContent(entryPalette, entryContent, VisualOrientation.Top);
            docker.Add(entryDraw, ViewDockStyle.Fill);

            // Shortcut to Content gap
            docker.Add(new ViewLayoutSeparator(5), ViewDockStyle.Left);

            // Add the shortcut column
            FixedContentValue shortcutContent = new FixedContentValue(_shortcutText, null, null, Color.Empty);
            RibbonRecentDocsShortcutToContent shortcutPalette = new RibbonRecentDocsShortcutToContent(ribbon.StateCommon.RibbonGeneral, ribbon.StateCommon.RibbonAppMenuDocsEntry);
            ViewDrawRibbonRecentShortcut shortcutDraw = new ViewDrawRibbonRecentShortcut(shortcutPalette, shortcutContent);
            docker.Add(shortcutDraw, ViewDockStyle.Left);

            // Start of line gap
            docker.Add(new ViewLayoutSeparator(3), ViewDockStyle.Left);

            // Attach a controller so menu item can be tracked and pressed
            RecentDocController controller = new RecentDocController(_provider.ProviderViewManager, this, needPaintDelegate);
            MouseController = controller;
            KeyController = controller;
            SourceController = controller;

            Add(docker);
        }
        /// <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 ViewLayoutMenuItemSelect class.
        /// </summary>
        /// <param name="itemSelect">Reference to owning instance.</param>
        /// <param name="provider">Provider of context menu information.</param>
        public ViewLayoutMenuItemSelect(KryptonContextMenuImageSelect itemSelect,
            IContextMenuProvider provider)
        {
            Debug.Assert(itemSelect != null);
            Debug.Assert(provider != null);

            // Store incoming references
            _itemSelect = itemSelect;
            _provider = provider;

            _itemSelect.TrackingIndex = -1;
            _enabled = provider.ProviderEnabled;
            _viewManager = provider.ProviderViewManager;

            // Cache the values to use when running
            _imageList = _itemSelect.ImageList;
            _imageIndexStart = _itemSelect.ImageIndexStart;
            _imageIndexEnd = _itemSelect.ImageIndexEnd;
            _lineItems = _itemSelect.LineItems;
            _needPaint = provider.ProviderNeedPaintDelegate;
            _padding = _itemSelect.Padding;
            _imageCount = (_imageList == null ? 0 : _imageList.Images.Count);

            // Limit check the start and end values
            _imageIndexStart = Math.Max(0, _imageIndexStart);
            _imageIndexEnd = Math.Min(_imageIndexEnd, _imageCount - 1);
            _imageIndexCount = Math.Max(0, (_imageIndexEnd - _imageIndexStart) + 1);

            IPalette palette = provider.ProviderPalette;
            if (palette == null)
                palette = KryptonManager.GetPaletteForMode(provider.ProviderPaletteMode);

            // Create triple that can be used by the draw button
            _triple = new PaletteTripleToPalette(palette,
                                                 PaletteBackStyle.ButtonLowProfile,
                                                 PaletteBorderStyle.ButtonLowProfile,
                                                 PaletteContentStyle.ButtonLowProfile);

            // Update with current button style
            _triple.SetStyles(itemSelect.ButtonStyle);
        }
        /// <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;
        }
        /// <summary>
        /// Returns a view appropriate for this item based on the object it is inside.
        /// </summary>
        /// <param name="provider">Provider of context menu information.</param>
        /// <param name="parent">Owning object reference.</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>
        /// <returns>ViewBase that is the root of the view hierachy being added.</returns>
        public override ViewBase GenerateView(IContextMenuProvider provider,
                                              object parent,
                                              ViewLayoutStack columns,
                                              bool standardStyle,
                                              bool imageColumn)
        {
            if (Horizontal && (parent is KryptonContextMenuItemCollection))
            {
                // Create a stack of horizontal items inside the item
                ViewLayoutDocker docker = new ViewLayoutDocker();

                // Take up same space as the image column, so separator starts close to actual text
                ViewDrawContent         imageContent = new ViewDrawContent(provider.ProviderStateCommon.ItemImage.Content, new FixedContentValue(null, null, null, Color.Empty), VisualOrientation.Top);
                ViewDrawMenuImageCanvas imageCanvas  = new ViewDrawMenuImageCanvas(provider.ProviderStateCommon.ItemImage.Back, provider.ProviderStateCommon.ItemImage.Border, 0, true)
                {
                    imageContent
                };
                docker.Add(new ViewLayoutCenter(imageCanvas), ViewDockStyle.Left);
                docker.Add(new ViewLayoutSeparator(1, 0), ViewDockStyle.Left);

                // Gap that matches left padding of text/extra text
                docker.Add(new ViewLayoutMenuSepGap(provider.ProviderStateCommon, standardStyle), ViewDockStyle.Left);

                // Separator Display
                ViewLayoutStack separatorStack = new ViewLayoutStack(false)
                {
                    new ViewLayoutSeparator(1, 1),
                    new ViewDrawMenuSeparator(this, provider.ProviderStateCommon.Separator),
                    new ViewLayoutSeparator(1, 1)
                };
                docker.Add(separatorStack, ViewDockStyle.Fill);

                return(docker);
            }
            else
            {
                return(new ViewDrawMenuSeparator(this, provider.ProviderStateCommon.Separator));
            }
        }
        /// <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;
        }
        /// <summary>
        /// Initialize a new instance of the ViewLayoutMenuItemSelect class.
        /// </summary>
        /// <param name="itemSelect">Reference to owning instance.</param>
        /// <param name="provider">Provider of context menu information.</param>
        public ViewLayoutMenuItemSelect(KryptonContextMenuImageSelect itemSelect,
                                        IContextMenuProvider provider)
        {
            Debug.Assert(itemSelect != null);
            Debug.Assert(provider != null);

            // Store incoming references
            _itemSelect = itemSelect;
            _provider   = provider;

            _itemSelect.TrackingIndex = -1;
            ItemEnabled  = provider.ProviderEnabled;
            _viewManager = provider.ProviderViewManager;

            // Cache the values to use when running
            _imageList       = _itemSelect.ImageList;
            _imageIndexStart = _itemSelect.ImageIndexStart;
            _imageIndexEnd   = _itemSelect.ImageIndexEnd;
            _lineItems       = _itemSelect.LineItems;
            _needPaint       = provider.ProviderNeedPaintDelegate;
            _padding         = _itemSelect.Padding;
            _imageCount      = (_imageList == null ? 0 : _imageList.Images.Count);

            // Limit check the start and end values
            _imageIndexStart = Math.Max(0, _imageIndexStart);
            _imageIndexEnd   = Math.Min(_imageIndexEnd, _imageCount - 1);
            _imageIndexCount = Math.Max(0, (_imageIndexEnd - _imageIndexStart) + 1);

            IPalette palette = provider.ProviderPalette ?? KryptonManager.GetPaletteForMode(provider.ProviderPaletteMode);

            // Create triple that can be used by the draw button
            _triple = new PaletteTripleToPalette(palette,
                                                 PaletteBackStyle.ButtonLowProfile,
                                                 PaletteBorderStyle.ButtonLowProfile,
                                                 PaletteContentStyle.ButtonLowProfile);

            // Update with current button style
            _triple.SetStyles(itemSelect.ButtonStyle);
        }
 /// <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;
 }
Beispiel #15
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;
 }
        /// <summary>
        ///  Initialize a new instance of the VisualContextMenu class.
        /// </summary>
        /// <param name="provider">Original source of provider details</param>
        /// <param name="items">Enabled state of the context menu.</param>
        /// <param name="keyboardActivated">Was the context menu activate by a keyboard action.</param>
        public VisualContextMenu(IContextMenuProvider provider,
                                 KryptonContextMenuCollection items,
                                 bool keyboardActivated)
            : base(true)
        {
            Redirector = provider.ProviderRedirector;

            // Create the view manager instance with root element
            ViewManager = new ViewContextMenuManager(this, new ViewLayoutNull());

            // Set the initial resolved palette to the appropriate setting
            SetPalette(provider.ProviderPalette ?? KryptonManager.GetPaletteForMode(provider.ProviderPaletteMode));

            // Set of context menu columns
            _viewColumns = new ViewLayoutStack(true);

            // Create provider instance
            _provider          = new ContextMenuProvider(provider, (ViewContextMenuManager)ViewManager, _viewColumns, NeedPaintDelegate);
            _provider.Closing += OnProviderClosing;
            _provider.Close   += OnProviderClose;
            _provider.Dispose += OnProviderClose;

            Construct(items, keyboardActivated);
        }
Beispiel #17
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);
 /// <summary>
 /// Returns a view appropriate for this item based on the object it is inside.
 /// </summary>
 /// <param name="provider">Provider of context menu information.</param>
 /// <param name="parent">Owning object reference.</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>
 /// <returns>ViewBase that is the root of the view hierachy being added.</returns>
 public override ViewBase GenerateView(IContextMenuProvider provider,
                                       object parent,
                                       ViewLayoutStack columns,
                                       bool standardStyle,
                                       bool imageColumn)
 {
     // Add child items into columns of display views
     ViewLayoutStack itemsColumns = new ViewLayoutStack(true);
     Items.GenerateView(provider, this, this, itemsColumns, StandardStyle, ImageColumn);
     return itemsColumns;
 }
 public ContextMenuOpeningEventArgs(IContextMenuProvider provider, RadDropDownMenu contextMenu)
 {
     this.contextMenu = contextMenu;
     this.provider    = provider;
 }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuLinkLabel class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="linkLabel">Reference to owning link label entry.</param>
        public ViewDrawMenuLinkLabel(IContextMenuProvider provider,
                                     KryptonContextMenuLinkLabel linkLabel)
        {
            _provider = provider;
            KryptonContextMenuLinkLabel = linkLabel;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(linkLabel.Text,
                                                   linkLabel.ExtraText,
                                                   linkLabel.Image,
                                                   linkLabel.ImageTransparentColor);

            // Decide on the enabled state of the display
            ItemEnabled = provider.ProviderEnabled;

            // Give the heading object the redirector to use when inheriting values
            linkLabel.SetPaletteRedirect(provider.ProviderRedirector);

            // Create the content for the actual heading text/image
            _drawContent = new ViewDrawContent(linkLabel.OverrideFocusNotVisited, _contentValues, VisualOrientation.Top)
            {
                UseMnemonic = true,
                Enabled     = ItemEnabled
            };

            // Place label link in the center of the area but inside some separator to add spacing
            _innerDocker = new ViewLayoutDocker
            {
                { _drawContent, ViewDockStyle.Fill },
                { new ViewLayoutSeparator(1), ViewDockStyle.Right },
                { new ViewLayoutSeparator(1), ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Top },
                { new ViewLayoutSeparator(1), ViewDockStyle.Bottom }
            };

            // 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 }
            };

            // Use context menu specific version of the link label controller
            MenuLinkLabelController mllc = new MenuLinkLabelController(provider.ProviderViewManager, _drawContent, this, provider.ProviderNeedPaintDelegate);

            mllc.Click += OnClick;
            _drawContent.MouseController = mllc;
            _drawContent.KeyController   = mllc;

            // Add docker as the composite content
            Add(_outerDocker);

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

            // We need to know if a property of the command changes
            if (KryptonContextMenuLinkLabel.KryptonCommand != null)
            {
                _cachedCommand = KryptonContextMenuLinkLabel.KryptonCommand;
                KryptonContextMenuLinkLabel.KryptonCommand.PropertyChanged += OnCommandPropertyChanged;
            }
        }
        /// <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;
            }
        }
 /// <summary>
 /// Returns a view appropriate for this item based on the object it is inside.
 /// </summary>
 /// <param name="provider">Provider of context menu information.</param>
 /// <param name="parent">Owning object reference.</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>
 /// <returns>ViewBase that is the root of the view hierachy being added.</returns>
 public override ViewBase GenerateView(IContextMenuProvider provider,
     object parent,
     ViewLayoutStack columns,
     bool standardStyle,
     bool imageColumn)
 {
     return new ViewDrawMenuHeading(this, provider.ProviderStateCommon.Heading);
 }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuCheckBox class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="checkBox">Reference to owning check box entry.</param>
        public ViewDrawMenuCheckBox(IContextMenuProvider provider,
                                    KryptonContextMenuCheckBox checkBox)
        {
            _provider = provider;
            KryptonContextMenuCheckBox = checkBox;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(ResolveText,
                                                   ResolveExtraText,
                                                   ResolveImage,
                                                   ResolveImageTransparentColor);

            // Decide on the enabled state of the display
            ItemEnabled = provider.ProviderEnabled && ResolveEnabled;

            // Give the heading object the redirector to use when inheriting values
            KryptonContextMenuCheckBox.SetPaletteRedirect(provider.ProviderRedirector);

            // Create the content for the actual heading text/image
            ViewDrawContent = new ViewDrawContent((ItemEnabled ? KryptonContextMenuCheckBox.OverrideNormal : KryptonContextMenuCheckBox.OverrideDisabled),
                                                  _contentValues, VisualOrientation.Top)
            {
                UseMnemonic = true,
                Enabled     = ItemEnabled
            };

            // Create the check box image drawer and place inside element so it is always centered
            ViewDrawCheckBox = new ViewDrawCheckBox(KryptonContextMenuCheckBox.StateCheckBoxImages)
            {
                CheckState = ResolveCheckState,
                Enabled    = ItemEnabled
            };
            _layoutCenter = new ViewLayoutCenter
            {
                ViewDrawCheckBox
            };

            // Place the check box on the left of the available space but inside separators
            _innerDocker = new ViewLayoutDocker
            {
                { ViewDrawContent, ViewDockStyle.Fill },
                { _layoutCenter, ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Right },
                { new ViewLayoutSeparator(3), ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Top },
                { new ViewLayoutSeparator(1), ViewDockStyle.Bottom }
            };

            // 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 }
            };

            // Use context menu specific version of the check box controller
            MenuCheckBoxController mcbc = new MenuCheckBoxController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate);

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

            // Add docker as the composite content
            Add(_outerDocker);

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

            // We need to know if a property of the command changes
            if (KryptonContextMenuCheckBox.KryptonCommand != null)
            {
                _cachedCommand = KryptonContextMenuCheckBox.KryptonCommand;
                KryptonContextMenuCheckBox.KryptonCommand.PropertyChanged += OnCommandPropertyChanged;
            }
        }
Beispiel #24
0
 /// <summary>
 /// Returns a view appropriate for this item based on the object it is inside.
 /// </summary>
 /// <param name="provider">Provider of context menu information.</param>
 /// <param name="parent">Owning object reference.</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>
 /// <returns>ViewBase that is the root of the view hierachy being added.</returns>
 public abstract ViewBase GenerateView(IContextMenuProvider provider,
                                       object parent,
                                       ViewLayoutStack columns,
                                       bool standardStyle,
                                       bool imageColumn);
Beispiel #25
0
		public TabGroup(TabGroupService tabGroupService, IMenuService menuService, IWpfFocusService wpfFocusService, TabGroupServiceOptions options) {
			this.options = options;
			tabContentAttached = new WeakEventList<TabContentAttachedEventArgs>();
			this.tabGroupService = tabGroupService;
			this.wpfFocusService = wpfFocusService;
			tabControl = new TabControl();
			tabControl.DataContext = this;
			tabControl.SetStyle(options.TabControlStyle ?? "FileTabGroupTabControlStyle");
			tabControl.SelectionChanged += TabControl_SelectionChanged;
			tabControl.PreviewKeyDown += TabControl_PreviewKeyDown;
			if (options.InitializeContextMenu != null)
				contextMenuProvider = options.InitializeContextMenu(menuService, this, tabControl);
			else if (options.TabGroupGuid != Guid.Empty)
				contextMenuProvider = menuService.InitializeContextMenu(tabControl, options.TabGroupGuid, new GuidObjectsProvider(this));
		}
 internal void SetPaletteRedirect(IContextMenuProvider provider)
 {
     _stateRedirect.SetRedirector(provider);
 }
Beispiel #27
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutMonths class.
        /// </summary>
        /// <param name="provider">Provider of context menu information.</param>
        /// <param name="monthCalendar">Reference to owning month calendar entry.</param>
        /// <param name="viewManager">Owning view manager instance.</param>
        /// <param name="calendar">Reference to calendar provider.</param>
        /// <param name="redirector">Redirector for getting values.</param>
        /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param>
        public ViewLayoutMonths(IContextMenuProvider provider,
                                KryptonContextMenuMonthCalendar monthCalendar,
                                ViewContextMenuManager viewManager,
                                IKryptonMonthCalendar calendar,
                                PaletteRedirect redirector,
                                NeedPaintHandler needPaintDelegate)
        {
            Provider                = provider;
            Calendar                = calendar;
            _oldSelectionStart      = Calendar.SelectionStart;
            _oldSelectionEnd        = Calendar.SelectionEnd;
            _displayMonth           = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            _redirector             = redirector;
            _needPaintDelegate      = needPaintDelegate;
            _showToday              = true;
            _showTodayCircle        = true;
            CloseOnTodayClick       = false;
            _firstTimeSync          = true;
            AllowButtonSpecToolTips = false;

            // Use a controller that can work against all the displayed months
            MonthCalendarController controller = new MonthCalendarController(monthCalendar, viewManager, this, _needPaintDelegate);

            MouseController  = controller;
            SourceController = controller;
            KeyController    = controller;

            _borderForced = new PaletteBorderInheritForced(Calendar.StateNormal.Header.Border);
            _borderForced.ForceBorderEdges(PaletteDrawBorders.None);
            _drawHeader   = new ViewDrawDocker(Calendar.StateNormal.Header.Back, _borderForced, null);
            _emptyContent = new ViewDrawEmptyContent(Calendar.StateDisabled.Header.Content, Calendar.StateNormal.Header.Content);
            _drawHeader.Add(_emptyContent, ViewDockStyle.Fill);
            Add(_drawHeader);

            // Using a button spec manager to add the buttons to the header
            ButtonSpecs   = new MonthCalendarButtonSpecCollection(this);
            ButtonManager = new ButtonSpecManagerDraw(Calendar.CalendarControl, redirector, ButtonSpecs, null,
                                                      new ViewDrawDocker[] { _drawHeader },
                                                      new IPaletteMetric[] { Calendar.StateCommon },
                                                      new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetCalendar },
                                                      new PaletteMetricPadding[] { PaletteMetricPadding.None },
                                                      Calendar.GetToolStripDelegate, _needPaintDelegate);

            // Create the manager for handling tooltips
            _toolTipManager                = new ToolTipManager();
            _toolTipManager.ShowToolTip   += OnShowToolTip;
            _toolTipManager.CancelToolTip += OnCancelToolTip;
            ButtonManager.ToolTipManager   = _toolTipManager;

            // Create the bottom header used for showing 'today' and defined button specs
            _remapPalette            = (ButtonSpecRemapByContentView)ButtonManager.CreateButtonSpecRemap(redirector, new ButtonSpecAny());
            _remapPalette.Foreground = _emptyContent;

            // Use a redirector to get button values directly from palette
            _palette = new PaletteTripleRedirect(_remapPalette,
                                                 PaletteBackStyle.ButtonButtonSpec,
                                                 PaletteBorderStyle.ButtonButtonSpec,
                                                 PaletteContentStyle.ButtonButtonSpec,
                                                 _needPaintDelegate);

            _drawToday        = new ViewDrawToday(Calendar, _palette, _palette, _palette, _palette, _needPaintDelegate);
            _drawToday.Click += OnTodayClick;
            _drawHeader.Add(_drawToday, ViewDockStyle.Left);
        }
 public override ViewBase GenerateView(IContextMenuProvider provider, object parent, ViewLayoutStack columns, bool standardStyle,
                                       bool imageColumn)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuCheckButton class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="checkButton">Reference to owning check button entry.</param>
        public ViewDrawMenuCheckButton(IContextMenuProvider provider,
                                       KryptonContextMenuCheckButton checkButton)
        {
            _provider = provider;
            _checkButton = checkButton;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(ResolveText,
                                                   ResolveExtraText,
                                                   ResolveImage,
                                                   ResolveImageTransparentColor);

            // Decide on the enabled state of the display
            _itemEnabled = provider.ProviderEnabled && ResolveEnabled;

            // Give the heading object the redirector to use when inheriting values
            _checkButton.SetPaletteRedirect(provider.ProviderRedirector);

            // Create the view button instance
            _drawButton = new ViewDrawButton(checkButton.OverrideDisabled,
                                             checkButton.OverrideNormal,
                                             checkButton.OverrideTracking,
                                             checkButton.OverridePressed,
                                             new PaletteMetricRedirect(provider.ProviderRedirector),
                                             _contentValues,
                                             VisualOrientation.Top,
                                             true);

            // Add the checked specific palettes to the existing view button
            _drawButton.SetCheckedPalettes(checkButton.OverrideCheckedNormal,
                                           checkButton.OverrideCheckedTracking,
                                           checkButton.OverrideCheckedPressed);

            _drawButton.Enabled = _itemEnabled;
            _drawButton.Checked = ResolveChecked;

            // Place the check box on the left of the available space but inside separators
            _innerDocker = new ViewLayoutDocker();
            _innerDocker.Add(_drawButton, ViewDockStyle.Fill);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Right);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Left);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Top);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Bottom);

            // 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);

            // Use context menu specific version of the check box controller
            MenuCheckButtonController mcbc = new MenuCheckButtonController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate);
            mcbc.Click += new EventHandler(OnClick);
            _innerDocker.MouseController = mcbc;
            _innerDocker.KeyController = mcbc;

            // Add docker as the composite content
            Add(_outerDocker);

            // Want to know when a property changes whilst displayed
            _checkButton.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

            // We need to know if a property of the command changes
            if (_checkButton.KryptonCommand != null)
            {
                _cachedCommand = _checkButton.KryptonCommand;
                _checkButton.KryptonCommand.PropertyChanged += new PropertyChangedEventHandler(OnCommandPropertyChanged);
            }
        }
        /// <summary>
        /// Initialize a new instance of the ViewLayoutMonths class.
        /// </summary>
        /// <param name="provider">Provider of context menu information.</param>
        /// <param name="monthCalendar">Reference to owning month calendar entry.</param>
        /// <param name="viewManager">Owning view manager instance.</param>
        /// <param name="calendar">Reference to calendar provider.</param>
        /// <param name="redirector">Redirector for getting values.</param>
        /// <param name="needPaintDelegate">Delegate for requesting paint changes.</param>
        public ViewLayoutMonths(IContextMenuProvider provider,
                                KryptonContextMenuMonthCalendar monthCalendar,
                                ViewContextMenuManager viewManager,
                                IKryptonMonthCalendar calendar,
                                PaletteRedirect redirector,
                                NeedPaintHandler needPaintDelegate)
        {
            _provider = provider;
            _calendar = calendar;
            _oldSelectionStart = _calendar.SelectionStart;
            _oldSelectionEnd = _calendar.SelectionEnd;
            _displayMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            _redirector = redirector;
            _needPaintDelegate = needPaintDelegate;
            _showToday = true;
            _showTodayCircle = true;
            _closeOnTodayClick = false;
            _firstTimeSync = true;
            _allowButtonSpecToolTips = false;

            // Use a controller that can work against all the displayed months
            MonthCalendarController controller = new MonthCalendarController(monthCalendar, viewManager, this, _needPaintDelegate);
            MouseController = controller;
            SourceController = controller;
            KeyController = controller;

            _borderForced = new PaletteBorderInheritForced(_calendar.StateNormal.Header.Border);
            _borderForced.ForceBorderEdges(PaletteDrawBorders.None);
            _drawHeader = new ViewDrawDocker(_calendar.StateNormal.Header.Back, _borderForced, null);
            _emptyContent = new ViewDrawEmptyContent(_calendar.StateDisabled.Header.Content, _calendar.StateNormal.Header.Content);
            _drawHeader.Add(_emptyContent, ViewDockStyle.Fill);
            Add(_drawHeader);

            // Using a button spec manager to add the buttons to the header
            _buttonSpecs = new MonthCalendarButtonSpecCollection(this);
            _buttonManager = new ButtonSpecManagerDraw(_calendar.CalendarControl, redirector, _buttonSpecs, null,
                                                       new ViewDrawDocker[] { _drawHeader },
                                                       new IPaletteMetric[] { _calendar.StateCommon },
                                                       new PaletteMetricInt[] { PaletteMetricInt.HeaderButtonEdgeInsetCalendar },
                                                       new PaletteMetricPadding[] { PaletteMetricPadding.None },
                                                       _calendar.GetToolStripDelegate, _needPaintDelegate);

            // Create the manager for handling tooltips
            _toolTipManager = new ToolTipManager();
            _toolTipManager.ShowToolTip += new EventHandler<ToolTipEventArgs>(OnShowToolTip);
            _toolTipManager.CancelToolTip += new EventHandler(OnCancelToolTip);
            _buttonManager.ToolTipManager = _toolTipManager;

            // Create the bottom header used for showing 'today' and defined button specs
            _remapPalette = (ButtonSpecRemapByContentView)_buttonManager.CreateButtonSpecRemap(redirector, new ButtonSpecAny());
            _remapPalette.Foreground = _emptyContent;

            // Use a redirector to get button values directly from palette
            _palette = new PaletteTripleRedirect(_remapPalette,
                                                 PaletteBackStyle.ButtonButtonSpec,
                                                 PaletteBorderStyle.ButtonButtonSpec,
                                                 PaletteContentStyle.ButtonButtonSpec,
                                                 _needPaintDelegate);

            _drawToday = new ViewDrawToday(_calendar, _palette, _palette, _palette, _palette, _needPaintDelegate);
            _drawToday.Click += new EventHandler(OnTodayClick);
            _drawHeader.Add(_drawToday, ViewDockStyle.Left);
        }
 /// <summary>
 /// Returns a view appropriate for this item based on the object it is inside.
 /// </summary>
 /// <param name="provider">Provider of context menu information.</param>
 /// <param name="parent">Owning object reference.</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>
 /// <returns>ViewBase that is the root of the view hierarchy being added.</returns>
 public override ViewBase GenerateView(IContextMenuProvider provider,
                                       object parent,
                                       ViewLayoutStack columns,
                                       bool standardStyle,
                                       bool imageColumn) =>
 new ViewDrawMenuHeading(this, provider.ProviderStateCommon.Heading);
Beispiel #32
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;
            _menuItem = menuItem;
            _imageColumn = imageColumn;
            _standardStyle = standardStyle;

            // Give the item object the redirector to use when inheriting values
            _menuItem.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 ? _menuItem.StateNormal : _menuItem.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 ? _menuItem.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);
            _imageCanvas.Add(_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 (_menuItem.ShowShortcutKeys)
            {
                string shortcutString = _menuItem.ShortcutKeyDisplayString;
                if (string.IsNullOrEmpty(shortcutString))
                    shortcutString = (_menuItem.ShortcutKeys != Keys.None) ? new KeysConverter().ConvertToString(_menuItem.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 = (_menuItem.Items.Count > 0) && _menuItem.SplitSubMenu;

            // SubMenu Indicator
            _hasSubMenu = (_menuItem.Items.Count > 0);
            _subMenuContent = new ViewDrawMenuItemContent(menuItemState.ItemImage.Content, new FixedContentValue(null, null, (!_hasSubMenu ? _empty16x16 : provider.ProviderImages.GetContextMenuSubMenuImage()), (_menuItem.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
            _menuItem.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

            // We need to know if a property of the command changes
            if (_menuItem.KryptonCommand != null)
            {
                _cachedCommand = _menuItem.KryptonCommand;
                _menuItem.KryptonCommand.PropertyChanged += new PropertyChangedEventHandler(OnCommandPropertyChanged);
            }
        }
Beispiel #33
0
 internal void SetPaletteRedirect(IContextMenuProvider provider)
 {
     _stateRedirect.SetRedirector(provider);
 }
 /// <summary>
 /// Returns a view appropriate for this item based on the object it is inside.
 /// </summary>
 /// <param name="provider">Provider of context menu information.</param>
 /// <param name="parent">Owning object reference.</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>
 /// <returns>ViewBase that is the root of the view hierachy being added.</returns>
 public override ViewBase GenerateView(IContextMenuProvider provider,
                                       object parent,
                                       ViewLayoutStack columns,
                                       bool standardStyle,
                                       bool imageColumn)
 {
     return new ViewDrawMenuRadioButton(provider, this);
 }
 /// <summary>
 /// Returns a view appropriate for this item based on the object it is inside.
 /// </summary>
 /// <param name="provider">Provider of context menu information.</param>
 /// <param name="parent">Owning object reference.</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>
 /// <returns>ViewBase that is the root of the view hierachy being added.</returns>
 public override ViewBase GenerateView(IContextMenuProvider provider,
                                       object parent,
                                       ViewLayoutStack columns,
                                       bool standardStyle,
                                       bool imageColumn)
 {
     return new ViewLayoutMenuItemSelect(this, provider);
 }
        /// <summary>
        /// Update the redirector with new reference.
        /// </summary>
        /// <param name="provider">Provider for acquiring context menu information.</param>
        public void SetRedirector(IContextMenuProvider provider)
        {
            _itemHighlight.Target = provider.ProviderStateCommon.ItemHighlight.GetRedirector();
            _itemImage.Target = provider.ProviderStateCommon.ItemImage.GetRedirector();
            _itemShortcutText.Target = provider.ProviderStateCommon.ItemShortcutTextRedirect.GetRedirector();
            _itemSplit.Target = provider.ProviderStateCommon.ItemSplit.GetRedirector();
            _itemStandard.Target = provider.ProviderStateCommon.ItemTextStandardRedirect.GetRedirector();
            _itemAlternate.Target = provider.ProviderStateCommon.ItemTextAlternateRedirect.GetRedirector();

            _itemHighlight.SetRedirectStates(provider.ProviderStateDisabled.ItemHighlight, provider.ProviderStateNormal.ItemHighlight);
            _itemImage.SetRedirectStates(provider.ProviderStateDisabled.ItemImage, provider.ProviderStateNormal.ItemImage);
            _itemShortcutText.SetRedirectStates(provider.ProviderStateDisabled.ItemShortcutText, provider.ProviderStateNormal.ItemShortcutText);
            _itemSplit.SetRedirectStates(provider.ProviderStateDisabled.ItemSplit, provider.ProviderStateNormal.ItemSplit, provider.ProviderStateHighlight.ItemSplit, provider.ProviderStateHighlight.ItemSplit);
            _itemStandard.SetRedirectStates(provider.ProviderStateDisabled.ItemTextStandard, provider.ProviderStateNormal.ItemTextStandard);
            _itemAlternate.SetRedirectStates(provider.ProviderStateDisabled.ItemTextAlternate, provider.ProviderStateNormal.ItemTextAlternate);
        }
Beispiel #37
0
 public virtual RadDropDownMenu MergeMenus(
     IContextMenuProvider contextMenuProvider,
     params object[] parameters)
 {
     return((RadDropDownMenu)null);
 }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuCheckBox class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="checkBox">Reference to owning check box entry.</param>
        public ViewDrawMenuCheckBox(IContextMenuProvider provider,
                                    KryptonContextMenuCheckBox checkBox)
        {
            _provider = provider;
            _checkBox = checkBox;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(ResolveText,
                                                   ResolveExtraText,
                                                   ResolveImage,
                                                   ResolveImageTransparentColor);

            // Decide on the enabled state of the display
            _itemEnabled = provider.ProviderEnabled && ResolveEnabled;

            // Give the heading object the redirector to use when inheriting values
            _checkBox.SetPaletteRedirect(provider.ProviderRedirector);

            // Create the content for the actual heading text/image
            _drawContent = new ViewDrawContent((_itemEnabled ? (IPaletteContent)_checkBox.OverrideNormal : (IPaletteContent)_checkBox.OverrideDisabled),
                                               _contentValues, VisualOrientation.Top);
            _drawContent.UseMnemonic = true;
            _drawContent.Enabled = _itemEnabled;

            // Create the check box image drawer and place inside element so it is always centered
            _drawCheckBox = new ViewDrawCheckBox(_checkBox.StateCheckBoxImages);
            _drawCheckBox.CheckState = ResolveCheckState;
            _drawCheckBox.Enabled = _itemEnabled;
            _layoutCenter = new ViewLayoutCenter();
            _layoutCenter.Add(_drawCheckBox);

            // Place the check box on the left of the available space but inside separators
            _innerDocker = new ViewLayoutDocker();
            _innerDocker.Add(_drawContent, ViewDockStyle.Fill);
            _innerDocker.Add(_layoutCenter, ViewDockStyle.Left);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Right);
            _innerDocker.Add(new ViewLayoutSeparator(3), ViewDockStyle.Left);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Top);
            _innerDocker.Add(new ViewLayoutSeparator(1), ViewDockStyle.Bottom);

            // 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);

            // Use context menu specific version of the check box controller
            MenuCheckBoxController mcbc = new MenuCheckBoxController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate);
            mcbc.Click += new EventHandler(OnClick);
            _innerDocker.MouseController = mcbc;
            _innerDocker.KeyController = mcbc;

            // Add docker as the composite content
            Add(_outerDocker);

            // Want to know when a property changes whilst displayed
            _checkBox.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

            // We need to know if a property of the command changes
            if (_checkBox.KryptonCommand != null)
            {
                _cachedCommand = _checkBox.KryptonCommand;
                _checkBox.KryptonCommand.PropertyChanged += new PropertyChangedEventHandler(OnCommandPropertyChanged);
            }
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuRadioButton class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="radioButton">Reference to owning radio button entry.</param>
        public ViewDrawMenuRadioButton(IContextMenuProvider provider,
                                       KryptonContextMenuRadioButton radioButton)
        {
            _provider = provider;
            KryptonContextMenuRadioButton = radioButton;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(radioButton.Text,
                                                   radioButton.ExtraText,
                                                   radioButton.Image,
                                                   radioButton.ImageTransparentColor);

            // Decide on the enabled state of the display
            ItemEnabled = provider.ProviderEnabled && KryptonContextMenuRadioButton.Enabled;

            // Give the heading object the redirector to use when inheriting values
            KryptonContextMenuRadioButton.SetPaletteRedirect(provider.ProviderRedirector);

            // Create the content for the actual heading text/image
            ViewDrawContent = new ViewDrawContent((ItemEnabled ? KryptonContextMenuRadioButton.OverrideNormal : KryptonContextMenuRadioButton.OverrideDisabled),
                                                  _contentValues, VisualOrientation.Top)
            {
                UseMnemonic = true,
                Enabled     = ItemEnabled
            };

            // Create the radio button image drawer and place inside element so it is always centered
            ViewDrawRadioButton = new ViewDrawRadioButton(KryptonContextMenuRadioButton.StateRadioButtonImages)
            {
                CheckState = KryptonContextMenuRadioButton.Checked,
                Enabled    = ItemEnabled
            };
            _layoutCenter = new ViewLayoutCenter
            {
                ViewDrawRadioButton
            };

            // Place the radio button on the left of the available space but inside separators
            _innerDocker = new ViewLayoutDocker
            {
                { ViewDrawContent, ViewDockStyle.Fill },
                { _layoutCenter, ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Right },
                { new ViewLayoutSeparator(3), ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Top },
                { new ViewLayoutSeparator(1), ViewDockStyle.Bottom }
            };

            // 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 }
            };

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

            mrbc.Click += OnClick;
            _innerDocker.MouseController = mrbc;
            _innerDocker.KeyController   = mrbc;

            // We need to be notified whenever the checked state changes
            KryptonContextMenuRadioButton.CheckedChanged += OnCheckedChanged;

            // Add docker as the composite content
            Add(_outerDocker);
        }
        /// <summary>
        /// Returns a view appropriate for this item based on the object it is inside.
        /// </summary>
        /// <param name="provider">Provider of context menu information.</param>
        /// <param name="parent">Owning object reference.</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>
        /// <returns>ViewBase that is the root of the view hierachy being added.</returns>
        public override ViewBase GenerateView(IContextMenuProvider provider,
                                              object parent,
                                              ViewLayoutStack columns,
                                              bool standardStyle,
                                              bool imageColumn)
        {
            if (Horizontal && (parent is KryptonContextMenuItemCollection))
            {
                // Create a stack of horizontal items inside the item
                ViewLayoutDocker docker = new ViewLayoutDocker();

                // Take up same space as the image column, so separator starts close to actual text
                ViewDrawContent imageContent = new ViewDrawContent(provider.ProviderStateCommon.ItemImage.Content, new FixedContentValue(null, null, null, Color.Empty), VisualOrientation.Top);
                ViewDrawMenuImageCanvas imageCanvas = new ViewDrawMenuImageCanvas(provider.ProviderStateCommon.ItemImage.Back, provider.ProviderStateCommon.ItemImage.Border, 0, true);
                imageCanvas.Add(imageContent);
                docker.Add(new ViewLayoutCenter(imageCanvas), ViewDockStyle.Left);
                docker.Add(new ViewLayoutSeparator(1, 0), ViewDockStyle.Left);

                // Gap that matches left padding of text/extra text
                docker.Add(new ViewLayoutMenuSepGap(provider.ProviderStateCommon, standardStyle), ViewDockStyle.Left);

                // Separator Display
                ViewLayoutStack separatorStack = new ViewLayoutStack(false);
                separatorStack.Add(new ViewLayoutSeparator(1, 1));
                separatorStack.Add(new ViewDrawMenuSeparator(this, provider.ProviderStateCommon.Separator));
                separatorStack.Add(new ViewLayoutSeparator(1, 1));
                docker.Add(separatorStack, ViewDockStyle.Fill);

                return docker;
            }
            else
                return new ViewDrawMenuSeparator(this, provider.ProviderStateCommon.Separator);
        }
Beispiel #41
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawMenuCheckButton class.
        /// </summary>
        /// <param name="provider">Reference to provider.</param>
        /// <param name="checkButton">Reference to owning check button entry.</param>
        public ViewDrawMenuCheckButton(IContextMenuProvider provider,
                                       KryptonContextMenuCheckButton checkButton)
        {
            _provider = provider;
            KryptonContextMenuCheckButton = checkButton;

            // Create fixed storage of the content values
            _contentValues = new FixedContentValue(ResolveText,
                                                   ResolveExtraText,
                                                   ResolveImage,
                                                   ResolveImageTransparentColor);

            // Decide on the enabled state of the display
            ItemEnabled = provider.ProviderEnabled && ResolveEnabled;

            // Give the heading object the redirector to use when inheriting values
            KryptonContextMenuCheckButton.SetPaletteRedirect(provider.ProviderRedirector);

            // Create the view button instance
            ViewDrawButton = new ViewDrawButton(checkButton.OverrideDisabled,
                                                checkButton.OverrideNormal,
                                                checkButton.OverrideTracking,
                                                checkButton.OverridePressed,
                                                new PaletteMetricRedirect(provider.ProviderRedirector),
                                                _contentValues,
                                                VisualOrientation.Top,
                                                true);

            // Add the checked specific palettes to the existing view button
            ViewDrawButton.SetCheckedPalettes(checkButton.OverrideCheckedNormal,
                                              checkButton.OverrideCheckedTracking,
                                              checkButton.OverrideCheckedPressed);

            ViewDrawButton.Enabled = ItemEnabled;
            ViewDrawButton.Checked = ResolveChecked;

            // Place the check box on the left of the available space but inside separators
            _innerDocker = new ViewLayoutDocker
            {
                { ViewDrawButton, ViewDockStyle.Fill },
                { new ViewLayoutSeparator(1), ViewDockStyle.Right },
                { new ViewLayoutSeparator(1), ViewDockStyle.Left },
                { new ViewLayoutSeparator(1), ViewDockStyle.Top },
                { new ViewLayoutSeparator(1), ViewDockStyle.Bottom }
            };

            // 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 }
            };

            // Use context menu specific version of the check box controller
            MenuCheckButtonController mcbc = new MenuCheckButtonController(provider.ProviderViewManager, _innerDocker, this, provider.ProviderNeedPaintDelegate);

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

            // Add docker as the composite content
            Add(_outerDocker);

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

            // We need to know if a property of the command changes
            if (KryptonContextMenuCheckButton.KryptonCommand != null)
            {
                _cachedCommand = KryptonContextMenuCheckButton.KryptonCommand;
                KryptonContextMenuCheckButton.KryptonCommand.PropertyChanged += OnCommandPropertyChanged;
            }
        }
 /// <summary>
 /// Returns a view appropriate for this item based on the object it is inside.
 /// </summary>
 /// <param name="provider">Provider of context menu information.</param>
 /// <param name="parent">Owning object reference.</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>
 /// <returns>ViewBase that is the root of the view hierachy being added.</returns>
 public abstract ViewBase GenerateView(IContextMenuProvider provider,
                                       object parent,
                                       ViewLayoutStack columns,
                                       bool standardStyle,
                                       bool imageColumn);
Beispiel #43
0
 /// <summary>
 /// Returns a view appropriate for this item based on the object it is inside.
 /// </summary>
 /// <param name="provider">Provider of context menu information.</param>
 /// <param name="parent">Owning object reference.</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>
 /// <returns>ViewBase that is the root of the view hierarchy being added.</returns>
 public override ViewBase GenerateView(IContextMenuProvider provider,
                                       object parent,
                                       ViewLayoutStack columns,
                                       bool standardStyle,
                                       bool imageColumn) =>
 new ViewLayoutMenuItemSelect(this, provider);
Beispiel #44
0
 public virtual bool ShowContextMenu(IContextMenuProvider contextMenuProvider)
 {
   Point client = this.rootElement.ElementTree.Control.PointToClient(Control.MousePosition);
   return this.ShowContextMenu(contextMenuProvider, client);
 }
Beispiel #45
0
 /// <summary>
 /// Returns a view appropriate for this item based on the object it is inside.
 /// </summary>
 /// <param name="provider">Provider of context menu information.</param>
 /// <param name="parent">Owning object reference.</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>
 /// <returns>ViewBase that is the root of the view hierarchy being added.</returns>
 public override ViewBase GenerateView(IContextMenuProvider provider,
                                       object parent,
                                       ViewLayoutStack columns,
                                       bool standardStyle,
                                       bool imageColumn) =>
 new ViewDrawMenuLinkLabel(provider, this);
        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;
        }