/// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupLabel class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonLabel">Reference to source label definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupLabel(KryptonRibbon ribbon,
                                        KryptonRibbonGroupLabel ribbonLabel,
                                        NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonLabel != null);
            Debug.Assert(needPaint != null);

            // Remember incoming references
            _ribbon    = ribbon;
            GroupLabel = ribbonLabel;
            _needPaint = needPaint;

            // Associate this view with the source component (required for design time selection)
            Component = GroupLabel;

            // Give paint delegate to label so its palette changes are redrawn
            GroupLabel.ViewPaintDelegate = needPaint;

            // Create the different views for different sizes of the label
            CreateLargeLabelView();
            CreateMediumSmallLabelView();

            // Update all views to reflect current label state
            UpdateEnabledState();
            UpdateImageSmallState();
            UpdateItemSizeState();

            // Hook into changes in the ribbon button definition
            GroupLabel.PropertyChanged += OnLabelPropertyChanged;
            _largeImagePadding          = new Padding((int)(3 * FactorDpiX), (int)(2 * FactorDpiY), (int)(3 * FactorDpiX), (int)(3 * FactorDpiY));
            _smallImagePadding          = new Padding((int)(3 * FactorDpiX), (int)(3 * FactorDpiY), (int)(3 * FactorDpiX), (int)(3 * FactorDpiY));
        }
示例#2
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupLabelImage class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonLabel">Reference to ribbon group label definition.</param>
        /// <param name="large">Show the large image.</param>
        public ViewDrawRibbonGroupLabelImage(KryptonRibbon ribbon,
                                             KryptonRibbonGroupLabel ribbonLabel,
                                             bool large)
            : base(ribbon)
        {
            Debug.Assert(ribbonLabel != null);

            _ribbonLabel = ribbonLabel;
            _large       = large;
            _smallSize   = new Size((int)(16 * FactorDpiX), (int)(16 * FactorDpiY));
            _largeSize   = new Size((int)(32 * FactorDpiX), (int)(32 * FactorDpiY));
        }
示例#3
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupLabelText class.
        /// </summary>
        /// <param name="ribbon">Source ribbon control.</param>
        /// <param name="ribbonLabel">Group label to display title for.</param>
        /// <param name="firstText">Should show the first button text.</param>
        public ViewDrawRibbonGroupLabelText(KryptonRibbon ribbon,
                                            KryptonRibbonGroupLabel ribbonLabel,
                                            bool firstText)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonLabel != null);

            _ribbon      = ribbon;
            _ribbonLabel = ribbonLabel;
            _firstText   = firstText;

            // Use a class to convert from ribbon group to content interface
            _contentProvider = new RibbonGroupLabelTextToContent(ribbon.StateCommon.RibbonGeneral,
                                                                 ribbon.StateNormal.RibbonGroupLabelText,
                                                                 ribbon.StateDisabled.RibbonGroupLabelText,
                                                                 ribbonLabel.StateNormal,
                                                                 ribbonLabel.StateDisabled);
        }
示例#4
0
        /// <summary>
        /// Initializes the designer with the specified component.
        /// </summary>
        /// <param name="component">The IComponent to associate the designer with.</param>
        public override void Initialize(IComponent component)
        {
            // Let base class do standard stuff
            base.Initialize(component);

            Debug.Assert(component != null);

            // Cast to correct type
            _ribbonLabel = component as KryptonRibbonGroupLabel;
            if (_ribbonLabel != null)
            {
                _ribbonLabel.DesignTimeContextMenu += OnContextMenu;
            }

            // Get access to the services
            _designerHost  = (IDesignerHost)GetService(typeof(IDesignerHost));
            _changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            // We need to know when we are being removed/changed
            _changeService.ComponentChanged += OnComponentChanged;
        }