Пример #1
0
        /// <summary>
        /// Initialize a new instance of the KryptonGroupBox class.
        /// </summary>
        public KryptonGroupBox()
        {
            SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.OptimizedDoubleBuffer, true);

            // Set default values
            _captionStyle       = LabelStyle.GroupBoxCaption;
            _captionEdge        = VisualOrientation.Top;
            _captionOrientation = ButtonOrientation.Auto;
            _captionVisible     = true;

            // Create storage objects
            Values              = new CaptionValues(NeedPaintDelegate);
            Values.TextChanged += OnValuesTextChanged;

            // Create the palette storage
            StateCommon   = new PaletteGroupBoxRedirect(Redirector, NeedPaintDelegate);
            StateDisabled = new PaletteGroupBox(StateCommon, NeedPaintDelegate);
            StateNormal   = new PaletteGroupBox(StateCommon, NeedPaintDelegate);

            // Create the internal panel used for containing content
            Panel = new KryptonGroupBoxPanel(this, StateCommon, StateDisabled, StateNormal, OnGroupPanelPaint)
            {
                // Make sure the panel back style always mimics our back style
                PanelBackStyle = PaletteBackStyle.ControlGroupBox
            };

            _drawContent = new ViewDrawContent(StateNormal.Content, Values, VisualOrientation.Top);

            // Create view for the control border and background
            _drawDocker = new ViewDrawGroupBoxDocker(StateNormal.Back, StateNormal.Border);

            // Create the element that fills the remainder space and remembers fill rectangle
            _layoutFill = new ViewLayoutFill(Panel);

            // Add caption into the docker with initial dock edges defined
            _drawDocker.Add(_drawContent, ViewDockStyle.Top);
            _drawDocker.Add(_layoutFill, ViewDockStyle.Fill);

            // Create the view manager instance
            ViewManager = new ViewManager(this, _drawDocker);

            // We want to default to shrinking and growing (base class defaults to GrowOnly)
            AutoSizeMode = AutoSizeMode.GrowAndShrink;

            // Create the delegate used when we need to ensure obscurer is removed
            _removeObscurer = OnRemoveObscurer;

            // Need to prevent the AddInternal from causing a layout, otherwise the
            // layout will probably try to measure text which causes the handle for the
            // control to be created which means the handle is created at the wrong time
            // and so child controls are not added properly in the future! (for the TabControl
            // at the very least).
            _ignoreLayout = true;

            // Add panel to the controls collection
            ((KryptonReadOnlyControls)Controls).AddInternal(Panel);

            _ignoreLayout = false;
        }
Пример #2
0
 /// <summary>
 /// Initialize a new instance of the PaletteGroupBox class.
 /// </summary>
 /// <param name="inherit">Source for inheriting palette defaulted values.</param>
 /// <param name="needPaint">Delegate for notifying paint requests.</param>
 public PaletteGroupBox(PaletteGroupBoxRedirect inherit,
                        NeedPaintHandler needPaint)
     : base(inherit, needPaint) =>