/// <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(nameof(component));
            }

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

            // Cast to correct type
            _ribbonCustomControl = (KryptonRibbonGroupCustomControl)component;
            _ribbonCustomControl.CustomControlDesigner = this;

            // Update designer properties with actual starting values
            Visible = _ribbonCustomControl.Visible;
            Enabled = _ribbonCustomControl.Enabled;

            // Update visible/enabled to always be showing/enabled at design time
            _ribbonCustomControl.Visible = true;
            _ribbonCustomControl.Enabled = true;

            // Hook into events
            _ribbonCustomControl.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;
        }
        /// <summary>
        /// Initialize a new instance of the CustomControlController class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon instance.</param>
        /// <param name="customControl">Source definition.</param>
        /// <param name="target">Target view element.</param>
        public CustomControlController(KryptonRibbon ribbon,
                                       KryptonRibbonGroupCustomControl customControl,
                                       ViewDrawRibbonGroupCustomControl target)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(customControl != null);
            Debug.Assert(customControl != null);

            _ribbon        = ribbon;
            _customControl = customControl;
            _target        = target;
        }
Esempio n. 3
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupCustom class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonCustom">Reference to source custom definition.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupCustomControl(KryptonRibbon ribbon,
                                                KryptonRibbonGroupCustomControl ribbonCustom,
                                                NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonCustom != null);
            Debug.Assert(needPaint != null);

            // Remember incoming references
            _ribbon            = ribbon;
            GroupCustomControl = ribbonCustom;
            _needPaint         = needPaint;
            _currentSize       = GroupCustomControl.ItemSizeCurrent;

            // Hook into the custom control events
            GroupCustomControl.MouseEnterControl += OnMouseEnterControl;
            GroupCustomControl.MouseLeaveControl += OnMouseLeaveControl;

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

            if (_ribbon.InDesignMode)
            {
                // At design time we need to know when the user right clicks the label
                ContextClickController controller = new ContextClickController();
                controller.ContextClick += OnContextClick;
                MouseController          = controller;
            }

            // Create controller needed for handling focus and key tip actions
            _controller      = new CustomControlController(_ribbon, GroupCustomControl, this);
            SourceController = _controller;
            KeyController    = _controller;

            // We need to rest visibility of the custom control for each layout cycle
            _ribbon.ViewRibbonManager.LayoutBefore += OnLayoutAction;
            _ribbon.ViewRibbonManager.LayoutAfter  += OnLayoutAction;

            // Provide back reference to the custom control definition
            GroupCustomControl.CustomControlView = this;

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

            // Hook into changes in the ribbon custom definition
            GroupCustomControl.PropertyChanged += OnCustomPropertyChanged;
        }