Inheritance: KryptonRibbonGroupItem
Exemple #1
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(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;
        }
Exemple #2
0
        /// <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;
        }
        /// <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;
        }
Exemple #4
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;
            _ribbonCustomControl = ribbonCustom;
            _needPaint           = needPaint;
            _currentSize         = _ribbonCustomControl.ItemSizeCurrent;

            // Hook into the custom control events
            _ribbonCustomControl.MouseEnterControl += new EventHandler(OnMouseEnterControl);
            _ribbonCustomControl.MouseLeaveControl += new EventHandler(OnMouseLeaveControl);

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

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

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

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

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

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

            // Hook into changes in the ribbon custom definition
            _ribbonCustomControl.PropertyChanged += new PropertyChangedEventHandler(OnCustomPropertyChanged);
        }
        /// <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;
            _ribbonCustomControl = ribbonCustom;
            _needPaint = needPaint;
            _currentSize = _ribbonCustomControl.ItemSizeCurrent;

            // Hook into the custom control events
            _ribbonCustomControl.MouseEnterControl += new EventHandler(OnMouseEnterControl);
            _ribbonCustomControl.MouseLeaveControl += new EventHandler(OnMouseLeaveControl);

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

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

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

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

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

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

            // Hook into changes in the ribbon custom definition
            _ribbonCustomControl.PropertyChanged += new PropertyChangedEventHandler(OnCustomPropertyChanged);
        }
Exemple #6
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 (_ribbonCustomControl != null)
                {
                    // Must unhook to prevent memory leaks
                    _ribbonCustomControl.MouseEnterControl -= new EventHandler(OnMouseEnterControl);
                    _ribbonCustomControl.MouseLeaveControl -= new EventHandler(OnMouseLeaveControl);
                    _ribbonCustomControl.ViewPaintDelegate  = null;
                    _ribbonCustomControl.PropertyChanged   -= new PropertyChangedEventHandler(OnCustomPropertyChanged);
                    _ribbon.ViewRibbonManager.LayoutAfter  -= new EventHandler(OnLayoutAction);
                    _ribbon.ViewRibbonManager.LayoutBefore -= new EventHandler(OnLayoutAction);

                    // Remove association with definition
                    _ribbonCustomControl.CustomControlView = null;
                    _ribbonCustomControl = null;
                }
            }

            base.Dispose(disposing);
        }
        /// <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 (_ribbonCustomControl != null)
                {
                    // Must unhook to prevent memory leaks
                    _ribbonCustomControl.MouseEnterControl -= new EventHandler(OnMouseEnterControl);
                    _ribbonCustomControl.MouseLeaveControl -= new EventHandler(OnMouseLeaveControl);
                    _ribbonCustomControl.ViewPaintDelegate = null;
                    _ribbonCustomControl.PropertyChanged -= new PropertyChangedEventHandler(OnCustomPropertyChanged);
                    _ribbon.ViewRibbonManager.LayoutAfter -= new EventHandler(OnLayoutAction);
                    _ribbon.ViewRibbonManager.LayoutBefore -= new EventHandler(OnLayoutAction);

                    // Remove association with definition
                    _ribbonCustomControl.CustomControlView = null;
                    _ribbonCustomControl = null;
                }
            }

            base.Dispose(disposing);
        }
        /// <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
            _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 += 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);
        }