/// <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;
            _ribbonLabel = ribbonLabel;
            _needPaint   = needPaint;

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

            // Give paint delegate to label so its palette changes are redrawn
            _ribbonLabel.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
            _ribbonLabel.PropertyChanged += new PropertyChangedEventHandler(OnLabelPropertyChanged);
        }
Esempio n. 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;
        }
        /// <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);
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_ribbonLabel != null)
                {
                    // Remove back reference to the paint delegate
                    _ribbonLabel.ViewPaintDelegate = null;

                    // Must unhook to prevent memory leaks
                    _ribbonLabel.PropertyChanged -= new PropertyChangedEventHandler(OnLabelPropertyChanged);

                    // Remove association with definition
                    _ribbonLabel.LabelView = null;
                    _ribbonLabel           = null;
                }
            }

            base.Dispose(disposing);
        }
Esempio n. 5
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)
        {
            Debug.Assert(component != null);

            // Validate the parameter reference
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }

            // Let base class do standard stuff
            base.Initialize(component);

            // Cast to correct type
            _ribbonLabel = (KryptonRibbonGroupLabel)component;
            _ribbonLabel.DesignTimeContextMenu += new MouseEventHandler(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 += new ComponentChangedEventHandler(OnComponentChanged);
        }