/// <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 _ribbonTextBox = component as KryptonRibbonGroupTextBox; if (_ribbonTextBox != null) { _ribbonTextBox.TextBoxDesigner = this; // Update designer properties with actual starting values Visible = _ribbonTextBox.Visible; Enabled = _ribbonTextBox.Enabled; // Update visible/enabled to always be showing/enabled at design time _ribbonTextBox.Visible = true; _ribbonTextBox.Enabled = true; // Tell the embedded text box it is in design mode _ribbonTextBox.TextBox.InRibbonDesignMode = true; // Hook into events _ribbonTextBox.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 TextBoxController class. /// </summary> /// <param name="ribbon">Reference to owning ribbon instance.</param> /// <param name="textBox">Source definition.</param> /// <param name="target">Target view element.</param> public TextBoxController(KryptonRibbon ribbon, KryptonRibbonGroupTextBox textBox, ViewDrawRibbonGroupTextBox target) { Debug.Assert(ribbon != null); Debug.Assert(textBox != null); Debug.Assert(target != null); _ribbon = ribbon; _textBox = textBox; _target = target; }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonGroupTextBox class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonTextBox">Reference to source textbox.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public ViewDrawRibbonGroupTextBox(KryptonRibbon ribbon, KryptonRibbonGroupTextBox ribbonTextBox, NeedPaintHandler needPaint) { Debug.Assert(ribbon != null); Debug.Assert(ribbonTextBox != null); Debug.Assert(needPaint != null); // Remember incoming references _ribbon = ribbon; GroupTextBox = ribbonTextBox; _needPaint = needPaint; _currentSize = GroupTextBox.ItemSizeCurrent; // Hook into the textbox events GroupTextBox.MouseEnterControl += OnMouseEnterControl; GroupTextBox.MouseLeaveControl += OnMouseLeaveControl; // Associate this view with the source component (required for design time selection) Component = GroupTextBox; 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 TextBoxController(_ribbon, GroupTextBox, this); SourceController = _controller; KeyController = _controller; // We need to rest visibility of the textbox for each layout cycle _ribbon.ViewRibbonManager.LayoutBefore += OnLayoutAction; _ribbon.ViewRibbonManager.LayoutAfter += OnLayoutAction; // Define back reference to view for the text box definition GroupTextBox.TextBoxView = this; // Give paint delegate to textbox so its palette changes are redrawn GroupTextBox.ViewPaintDelegate = needPaint; // Hook into changes in the ribbon custom definition GroupTextBox.PropertyChanged += OnTextBoxPropertyChanged; NULL_CONTROL_WIDTH = (int)(50 * FactorDpiX); }