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

            // Remember incoming references
            _ribbon            = ribbon;
            _ribbonRadioButton = ribbonRadioButton;
            _needPaint         = needPaint;
            _currentSize       = _ribbonRadioButton.ItemSizeCurrent;

            // Create delegate used to process end of click action
            _finishDelegateLarge       = new EventHandler(ActionFinishedLarge);
            _finishDelegateMediumSmall = new EventHandler(ActionFinishedMediumSmall);

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

            // Create the different views for different sizes of the radio button
            CreateLargeRadioButtonView();
            CreateMediumSmallRadioButtonView();

            // Update all views to reflect current radio button state
            UpdateEnabledState();
            UpdateCheckedState();
            UpdateItemSizeState();

            // Hook into changes in the ribbon radio button definition
            _ribbonRadioButton.PropertyChanged += new PropertyChangedEventHandler(OnRadioButtonPropertyChanged);
        }
示例#2
0
        private void AutoUpdateContainer(IRibbonGroupContainer Container)
        {
            // Process each component inside the container
            foreach (Component component in Container.GetChildComponents())
            {
                // If the component is itself a container...
                if (component is IRibbonGroupContainer)
                {
                    AutoUpdateContainer(component as IRibbonGroupContainer);
                }
                else
                {
                    // If this is another radio button...
                    if (component is KryptonRibbonGroupRadioButton)
                    {
                        KryptonRibbonGroupRadioButton radioButton = (KryptonRibbonGroupRadioButton)component;

                        // Do not process ourself!
                        if (radioButton != this)
                        {
                            // If the target is checked and allowed to be auto unchecked
                            if (radioButton.AutoCheck && radioButton.Checked)
                            {
                                radioButton.Checked = false;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupRadioButtonText class.
        /// </summary>
        /// <param name="ribbon">Source ribbon control.</param>
        /// <param name="ribbonRadioButton">Group radio button to display title for.</param>
        /// <param name="firstText">Should show the first button text.</param>
        public ViewDrawRibbonGroupRadioButtonText(KryptonRibbon ribbon,
                                                  KryptonRibbonGroupRadioButton ribbonRadioButton,
                                                  bool firstText)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonRadioButton != null);

            _ribbon            = ribbon;
            _ribbonRadioButton = ribbonRadioButton;
            _firstText         = firstText;

            // Use a class to convert from ribbon group to content interface
            _contentProvider = new RibbonGroupNormalDisabledTextToContent(ribbon.StateCommon.RibbonGeneral,
                                                                          ribbon.StateNormal.RibbonGroupRadioButtonText,
                                                                          ribbon.StateDisabled.RibbonGroupRadioButtonText);
        }
        /// <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 (_ribbonRadioButton != null)
                {
                    // Must unhook to prevent memory leaks
                    _ribbonRadioButton.PropertyChanged -= new PropertyChangedEventHandler(OnRadioButtonPropertyChanged);

                    // Remove association with definition
                    _ribbonRadioButton.RadioButtonView = null;
                    _ribbonRadioButton = null;
                }
            }

            base.Dispose(disposing);
        }
示例#5
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupRadioButtonImage class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonRadioButton">Reference to ribbon group radio button definition.</param>
        /// <param name="large">Show the large image.</param>
        public ViewDrawRibbonGroupRadioButtonImage(KryptonRibbon ribbon,
                                                   KryptonRibbonGroupRadioButton ribbonRadioButton,
                                                   bool large)
        {
            Debug.Assert(ribbonRadioButton != null);

            // Remember incoming parameters
            _ribbonRadioButton = ribbonRadioButton;
            _large             = large;

            // Use redirector to get the radio button images and redirect to parent palette
            PaletteRedirectRadioButton redirectImages = new PaletteRedirectRadioButton(ribbon.GetRedirector(), ribbon.StateCommon.RibbonImages.RadioButton);

            // Create drawing element
            _drawRadioButton = new ViewDrawRadioButton(redirectImages);

            // Add as only child
            Add(_drawRadioButton);
        }
        /// <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
            _ribbonRadioButton = (KryptonRibbonGroupRadioButton)component;
            _ribbonRadioButton.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);
        }