Exemplo n.º 1
0
        /// <summary>
        /// Initialize a new instance of the ViewLayoutRibbonGalleryItems class.
        /// </summary>
        /// <param name="palette">Reference to palette for display values.</param>
        /// <param name="gallery">Reference to owning gallery.</param>
        /// <param name="needPaint">Delegate for requesting paints.</param>
        /// <param name="buttonUp">Reference to the up button.</param>
        /// <param name="buttonDown">Reference to the down button.</param>
        /// <param name="buttonContext">Reference to the context button.</param>
        public ViewLayoutRibbonGalleryItems(IPalette palette,
                                            KryptonGallery gallery,
                                            NeedPaintHandler needPaint,
                                            ViewDrawRibbonGalleryButton buttonUp,
                                            ViewDrawRibbonGalleryButton buttonDown,
                                            ViewDrawRibbonGalleryButton buttonContext)
        {
            Debug.Assert(palette != null);
            Debug.Assert(gallery != null);
            Debug.Assert(needPaint != null);
            Debug.Assert(buttonUp != null);
            Debug.Assert(buttonDown != null);
            Debug.Assert(buttonContext != null);

            _gallery       = gallery;
            _needPaint     = needPaint;
            _buttonUp      = buttonUp;
            _buttonDown    = buttonDown;
            _buttonContext = buttonContext;
            _bringIntoView = -1;
            ScrollIntoView = true;

            // Need to know when any button is clicked
            _buttonUp.Click      += OnButtonUp;
            _buttonDown.Click    += OnButtonDown;
            _buttonContext.Click += OnButtonContext;

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

            // Setup timer to use for scrolling lines
            _scrollTimer = new Timer
            {
                Interval = 40
            };
            _scrollTimer.Tick += OnScrollTick;
        }
Exemplo n.º 2
0
        /// <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);
        }