/// <summary> /// Initialize a new instance of the VisualPopupGroup class. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="ribbonGroup">Reference to ribbon group for display.</param> /// <param name="renderer">Drawing renderer.</param> public VisualPopupGroup(KryptonRibbon ribbon, KryptonRibbonGroup ribbonGroup, IRenderer renderer) : base(renderer, true) { Debug.Assert(ribbon != null); Debug.Assert(ribbonGroup != null); // Remember references needed later _ribbon = ribbon; _ribbonGroup = ribbonGroup; // Create a view element for drawing the group ViewGroup = new ViewDrawRibbonGroup(ribbon, ribbonGroup, NeedPaintDelegate) { Collapsed = false }; // Create the background that will contain the actual group instance _viewBackground = new ViewDrawRibbonGroupsBorder(ribbon, true, NeedPaintDelegate) { ViewGroup }; // Attach the root to the view manager instance ViewManager = new ViewRibbonPopupGroupManager(this, ribbon, _viewBackground, ViewGroup, NeedPaintDelegate); // Create and add a hidden button to act as the focus target _hiddenFocusTarget = new Button { TabStop = false }; _hiddenFocusTarget.Location = new Point(-_hiddenFocusTarget.Width, -_hiddenFocusTarget.Height); CommonHelper.AddControlToParent(this, _hiddenFocusTarget); }
/// <summary> /// Initialize a new instance of the ViewLayoutControl class. /// </summary> /// <param name="viewControl">View control to use as child.</param> /// <param name="rootControl">Top level visual control.</param> /// <param name="viewChild">View used to size and position the child control.</param> public ViewLayoutControl(ViewControl viewControl, VisualControl rootControl, ViewBase viewChild) { Debug.Assert(viewControl != null); Debug.Assert(rootControl != null); Debug.Assert(viewChild != null); // Default values _layoutOffset = Point.Empty; // Remember the view _viewChild = viewChild; // Ensure the child is hooked into the hierarchy of elements _viewChild.Parent = this; // Create the view control instance _viewControl = viewControl; // Back reference hookup _viewControl.ViewLayoutControl = this; // Start off invisible until first layed out _viewControl.Visible = false; // Ensure that all view elements inside here use our control OwningControl = _viewControl; // Add our new control to the provided parent collection CommonHelper.AddControlToParent(rootControl, _viewControl); }
private void CreateScrollBar(Control parent) { // Do we need to create a scrollbar? if (_scrollBar == null) { // Create the correct type of control if (Vertical) { _scrollBar = new VScrollBar(); } else { _scrollBar = new HScrollBar(); } // Hook into scroll position changes _scrollBar.Scroll += new ScrollEventHandler(OnScrollBarChange); // Create it hidden _scrollBar.Hide(); // Set the scrolling values _scrollBar.Minimum = _min; _scrollBar.Maximum = _max; _scrollBar.SmallChange = _smallChange; _scrollBar.LargeChange = _largeChange; _scrollBar.Value = _offset; // Add our new control to the provided parent collection CommonHelper.AddControlToParent(parent, _scrollBar); } }
/// <summary> /// Reparent the provided control as a child of ourself. /// </summary> /// <param name="c">Control to reparent.</param> public void MakeParent(Control c) { // Remove control from current collection CommonHelper.RemoveControlFromParent(c); // Add to our child control CommonHelper.AddControlToParent(_viewControl, c); }
/// <summary> /// Revert the provided control back to a different control. /// </summary> /// <param name="newParent">Control to become parent.</param> /// <param name="c">Control to reparent.</param> public void RevertParent(Control newParent, Control c) { // Remove control from current collection CommonHelper.RemoveControlFromParent(c); // Add to our child control CommonHelper.AddControlToParent(newParent, c); }
/// <summary> /// Initialize a new instance of the ViewControl class. /// </summary> /// <param name="ribbon">Top level ribbon control.</param> public RibbonViewControl(KryptonRibbon ribbon) : base(ribbon) { Debug.Assert(ribbon != null); _ribbon = ribbon; // Create and add a hidden button to act as the focus target _hiddenFocusTarget = new Button(); _hiddenFocusTarget.TabStop = false; _hiddenFocusTarget.Location = new Point(-_hiddenFocusTarget.Width, -_hiddenFocusTarget.Height); CommonHelper.AddControlToParent(this, _hiddenFocusTarget); }
private void UpdateParent(Control parentControl) { // During disposal the view control will no longer exist if (_viewControl != null) { // If the view control is not inside the correct parent if (parentControl != _viewControl.Parent) { // Ensure the control is not in the display area when first added _viewControl.Location = new Point(-_viewControl.Width, -_viewControl.Height); // Add our control to the provided parent collection CommonHelper.AddControlToParent(parentControl, _viewControl); // Let the actual control hook into correct parent for view manager processing _viewControl.UpdateParent(parentControl); } } }