/// <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)
        {
            // Let base class do standard stuff
            base.Initialize(component);

            Debug.Assert(component != null);

            // Cast to correct type
            _ribbonRichTextBox = component as KryptonRibbonGroupRichTextBox;
            if (_ribbonRichTextBox != null)
            {
                _ribbonRichTextBox.RichTextBoxDesigner = this;

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

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

                // Tell the embedded text box it is in design mode
                _ribbonRichTextBox.RichTextBox.InRibbonDesignMode = true;

                // Hook into events
                _ribbonRichTextBox.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;
        }
예제 #2
0
        /// <summary>
        /// Initialize a new instance of the RichTextBoxController class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon instance.</param>
        /// <param name="richTextBox">Source definition.</param>
        /// <param name="target">Target view element.</param>
        public RichTextBoxController(KryptonRibbon ribbon,
                                     KryptonRibbonGroupRichTextBox richTextBox,
                                     ViewDrawRibbonGroupRichTextBox target)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(richTextBox != null);
            Debug.Assert(target != null);

            _ribbon      = ribbon;
            _richTextBox = richTextBox;
            _target      = target;
        }
예제 #3
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonGroupRichTextBox class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="ribbonRichTextBox">Reference to source richtextbox.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonGroupRichTextBox(KryptonRibbon ribbon,
                                              KryptonRibbonGroupRichTextBox ribbonRichTextBox,
                                              NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(ribbonRichTextBox != null);
            Debug.Assert(needPaint != null);

            // Remember incoming references
            _ribbon          = ribbon;
            GroupRichTextBox = ribbonRichTextBox;
            _needPaint       = needPaint;
            _currentSize     = GroupRichTextBox.ItemSizeCurrent;

            // Hook into the richtextbox events
            GroupRichTextBox.MouseEnterControl += OnMouseEnterControl;
            GroupRichTextBox.MouseLeaveControl += OnMouseLeaveControl;

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

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

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

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

            // Define back reference to view for the rich text box definition
            GroupRichTextBox.RichTextBoxView = this;

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

            // Hook into changes in the ribbon custom definition
            GroupRichTextBox.PropertyChanged += OnRichTextBoxPropertyChanged;
            NULL_CONTROL_WIDTH = (int)(50 * FactorDpiX);
        }
예제 #4
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 (_ribbonRichTextBox != null)
                {
                    // Must unhook to prevent memory leaks
                    _ribbonRichTextBox.MouseEnterControl   -= new EventHandler(OnMouseEnterControl);
                    _ribbonRichTextBox.MouseLeaveControl   -= new EventHandler(OnMouseLeaveControl);
                    _ribbonRichTextBox.ViewPaintDelegate    = null;
                    _ribbonRichTextBox.PropertyChanged     -= new PropertyChangedEventHandler(OnRichTextBoxPropertyChanged);
                    _ribbon.ViewRibbonManager.LayoutAfter  -= new EventHandler(OnLayoutAction);
                    _ribbon.ViewRibbonManager.LayoutBefore -= new EventHandler(OnLayoutAction);

                    // Remove association with definition
                    _ribbonRichTextBox.RichTextBoxView = null;
                    _ribbonRichTextBox = null;
                }
            }

            base.Dispose(disposing);
        }
예제 #5
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
            _ribbonRichTextBox = (KryptonRibbonGroupRichTextBox)component;
            _ribbonRichTextBox.RichTextBoxDesigner = this;

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

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

            // Tell the embedded text box it is in design mode
            _ribbonRichTextBox.RichTextBox.InRibbonDesignMode = true;

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