Example #1
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupClusterButton class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonButton">Reference to source button definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupClusterButton(KryptonRibbon ribbon,
                                                KryptonRibbonGroupClusterButton ribbonButton,
                                                NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonButton != null);
            Debug.Assert(needPaint != null);

            // Remember incoming references
            _ribbon            = ribbon;
            GroupClusterButton = ribbonButton;
            _needPaint         = needPaint;
            _currentSize       = GroupClusterButton.ItemSizeCurrent;

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

            // Create the small button view
            CreateView();

            // Update view reflect current button state
            UpdateEnabledState();
            UpdateCheckedState();
            UpdateDropDownState();
            UpdateItemSizeState();

            // Hook into changes in the ribbon button definition
            GroupClusterButton.PropertyChanged += OnButtonPropertyChanged;
            _smallImagePadding = new Padding((int)(3 * FactorDpiX), (int)(3 * FactorDpiY), (int)(3 * FactorDpiX), (int)(3 * FactorDpiY));
        }
        private void OnAddButton(object sender, EventArgs e)
        {
            if (_ribbonCluster?.Ribbon != null)
            {
                // Use a transaction to support undo/redo actions
                DesignerTransaction transaction = _designerHost.CreateTransaction(@"KryptonRibbonGroupCluster AddButton");

                try
                {
                    // Get access to the Items property
                    MemberDescriptor propertyItems = TypeDescriptor.GetProperties(_ribbonCluster)[@"Items"];

                    RaiseComponentChanging(propertyItems);

                    // Get designer to create a cluster button item
                    KryptonRibbonGroupClusterButton button = (KryptonRibbonGroupClusterButton)_designerHost.CreateComponent(typeof(KryptonRibbonGroupClusterButton));
                    _ribbonCluster.Items.Add(button);

                    RaiseComponentChanged(propertyItems, null, null);
                }
                finally
                {
                    // If we managed to create the transaction, then do it
                    transaction?.Commit();
                }
            }
        }
Example #3
0
        private void OnGroupClusterButtonClick(object sender, EventArgs e)
        {
            KryptonRibbonGroupClusterButton button = (KryptonRibbonGroupClusterButton)sender;

            MessageBox.Show(this,
                            "You selected the '" + button.TextLine + "' button.",
                            "Button");
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupClusterButtonImage class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonButton">Reference to ribbon group button definition.</param>
        public ViewDrawRibbonGroupClusterButtonImage(KryptonRibbon ribbon,
                                                     KryptonRibbonGroupClusterButton ribbonButton)
            : base(ribbon)
        {
            Debug.Assert(ribbonButton != null);

            _ribbonButton = ribbonButton;
            _smallSize    = new Size((int)(16 * FactorDpiX), (int)(16 * FactorDpiY));
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupButtonText class.
        /// </summary>
        /// <param name="ribbon">Source ribbon control.</param>
        /// <param name="ribbonButton">Group cluster button to display title for.</param>
        public ViewDrawRibbonGroupClusterButtonText(KryptonRibbon ribbon,
                                                    KryptonRibbonGroupClusterButton ribbonButton)

        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonButton != null);

            _ribbon       = ribbon;
            _ribbonButton = ribbonButton;

            // Use a class to convert from ribbon group to content interface
            _contentProvider = new RibbonGroupNormalDisabledTextToContent(ribbon.StateCommon.RibbonGeneral,
                                                                          ribbon.StateNormal.RibbonGroupButtonText,
                                                                          ribbon.StateDisabled.RibbonGroupButtonText);
        }
        /// <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
            _ribbonButton = component as KryptonRibbonGroupClusterButton;
            if (_ribbonButton != null)
            {
                _ribbonButton.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;
        }