コード例 #1
0
        /// <summary>
        /// Initialize a new instance of the DomainUpDownController class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon instance.</param>
        /// <param name="domainUpDown">Source definition.</param>
        /// <param name="target">Target view element.</param>
        public DomainUpDownController(KryptonRibbon ribbon,
                                      KryptonRibbonGroupDomainUpDown domainUpDown,
                                      ViewDrawRibbonGroupDomainUpDown target)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(domainUpDown != null);
            Debug.Assert(target != null);

            _ribbon       = ribbon;
            _domainUpDown = domainUpDown;
            _target       = target;
        }
コード例 #2
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupDomainUpDown class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonDomainUpDown">Reference to source domain up-down.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupDomainUpDown(KryptonRibbon ribbon,
                                               KryptonRibbonGroupDomainUpDown ribbonDomainUpDown,
                                               NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonDomainUpDown != null);
            Debug.Assert(needPaint != null);

            // Remember incoming references
            _ribbon             = ribbon;
            _ribbonDomainUpDown = ribbonDomainUpDown;
            _needPaint          = needPaint;
            _currentSize        = _ribbonDomainUpDown.ItemSizeCurrent;

            // Hook into the domain up-down events
            _ribbonDomainUpDown.MouseEnterControl += new EventHandler(OnMouseEnterControl);
            _ribbonDomainUpDown.MouseLeaveControl += new EventHandler(OnMouseLeaveControl);

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

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

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

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

            // Define back reference to view for the domain up-down definition
            _ribbonDomainUpDown.DomainUpDownView = this;

            // Give paint delegate to domain up-down so its palette changes are redrawn
            _ribbonDomainUpDown.ViewPaintDelegate = needPaint;

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

                    // Remove association with definition
                    _ribbonDomainUpDown.DomainUpDownView = null;
                    _ribbonDomainUpDown = null;
                }
            }

            base.Dispose(disposing);
        }
コード例 #4
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("component");
            }

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

            // Cast to correct type
            _ribbonDomainUpDown = (KryptonRibbonGroupDomainUpDown)component;
            _ribbonDomainUpDown.DomainUpDownDesigner = this;

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

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

            // Tell the embedded domain up-down control it is in design mode
            _ribbonDomainUpDown.DomainUpDown.InRibbonDesignMode = true;

            // Hook into events
            _ribbonDomainUpDown.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);
        }