Пример #1
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupCheckBox class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonCheckBox">Reference to source check box definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupCheckBox(KryptonRibbon ribbon,
                                           KryptonRibbonGroupCheckBox ribbonCheckBox,
                                           NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonCheckBox != null);
            Debug.Assert(needPaint != null);

            // Remember incoming references
            _ribbon         = ribbon;
            _ribbonCheckBox = ribbonCheckBox;
            _needPaint      = needPaint;
            _currentSize    = _ribbonCheckBox.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 = _ribbonCheckBox;

            // Create the different views for different sizes of the check box
            CreateLargeCheckBoxView();
            CreateMediumSmallCheckBoxView();

            // Update all views to reflect current check box state
            UpdateEnabledState();
            UpdateCheckState();
            UpdateItemSizeState();

            // Hook into changes in the ribbon check box definition
            _ribbonCheckBox.PropertyChanged += new PropertyChangedEventHandler(OnCheckBoxPropertyChanged);
        }
Пример #2
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupCheckBoxText class.
        /// </summary>
        /// <param name="ribbon">Source ribbon control.</param>
        /// <param name="ribbonCheckBox">Group check box to display title for.</param>
        /// <param name="firstText">Should show the first button text.</param>
        public ViewDrawRibbonGroupCheckBoxText(KryptonRibbon ribbon,
                                               KryptonRibbonGroupCheckBox ribbonCheckBox,
                                               bool firstText)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonCheckBox != null);

            _ribbon         = ribbon;
            _ribbonCheckBox = ribbonCheckBox;
            _firstText      = firstText;

            // Use a class to convert from ribbon group to content interface
            _contentProvider = new RibbonGroupNormalDisabledTextToContent(ribbon.StateCommon.RibbonGeneral,
                                                                          ribbon.StateNormal.RibbonGroupCheckBoxText,
                                                                          ribbon.StateDisabled.RibbonGroupCheckBoxText);
        }
Пример #3
0
        /// <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 (_ribbonCheckBox != null)
                {
                    // Must unhook to prevent memory leaks
                    _ribbonCheckBox.PropertyChanged -= new PropertyChangedEventHandler(OnCheckBoxPropertyChanged);

                    // Remove association with definition
                    _ribbonCheckBox.CheckBoxView = null;
                    _ribbonCheckBox = null;
                }
            }

            base.Dispose(disposing);
        }
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupCheckBoxImage class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonCheckBox">Reference to ribbon group check box definition.</param>
        /// <param name="large">Show the large image.</param>
        public ViewDrawRibbonGroupCheckBoxImage(KryptonRibbon ribbon,
                                                KryptonRibbonGroupCheckBox ribbonCheckBox,
                                                bool large)
        {
            Debug.Assert(ribbonCheckBox != null);

            // Remember incoming parameters
            _ribbonCheckBox = ribbonCheckBox;
            _large          = large;

            // Use redirector to get the check box images and redirect to parent palette
            PaletteRedirectCheckBox redirectImages = new PaletteRedirectCheckBox(ribbon.GetRedirector(), ribbon.StateCommon.RibbonImages.CheckBox);

            // Create drawing element
            _drawCheckBox = new ViewDrawCheckBox(redirectImages);

            // Add as only child
            Add(_drawCheckBox);
        }
        /// <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
            _ribbonCheckBox = (KryptonRibbonGroupCheckBox)component;
            _ribbonCheckBox.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);
        }