AddControl() public abstract method

Add a control to the layout
public abstract AddControl ( IControlHabanero control ) : IControlHabanero
control IControlHabanero The control to add
return IControlHabanero
コード例 #1
0
        /// <summary>
        /// Adds an <see cref="IControlHabanero"/> to this control. The <paramref name="contentControl"/> is
        ///    wrapped in the appropriate Child Control Type.
        /// </summary>
        /// <param name="contentControl">The control that is being placed as a child within this control. The content control could be
        ///  a Panel of <see cref="IBusinessObject"/>.<see cref="IBOProp"/>s or any other child control</param>
        /// <param name="headingText">The heading text that will be shown as the Header for this Group e.g. For a <see cref="ITabControl"/>
        ///   this will be the Text shown in the Tab for a <see cref="ICollapsiblePanelGroupControl"/> this will be the text shown
        ///   on the Collapse Panel and for an <see cref="IGroupBox"/> this will be the title of the Group Box.</param>
        /// <param name="minimumControlHeight">The minimum height that the <paramref name="contentControl"/> can be.
        ///   This height along with any other spacing required will be used as the minimum height for the ChildControlCreated</param>
        ///  <param name="minimumControlWidth">The minimum width that the <paramref name="contentControl"/> can be</param>
        ///  <returns></returns>
        public virtual IControlHabanero AddControl
            (IControlHabanero contentControl, string headingText, int minimumControlHeight, int minimumControlWidth)
        {
            IControlFactory factory = GlobalUIRegistry.ControlFactory;

            if (factory == null)
            {
                const string errMessage =
                    "There is a serious error since the GlobalUIRegistry.ControlFactory  has not been set up.";
                throw new HabaneroDeveloperException(errMessage, errMessage);
            }
            var groupBox = factory.CreateGroupBox(headingText);

            groupBox.Width  = minimumControlWidth + 30;
            groupBox.Height = minimumControlHeight + 30;
            var layoutManager = factory.CreateBorderLayoutManager(groupBox);

            layoutManager.BorderSize = 20;
            layoutManager.AddControl(contentControl);

            CollapsiblePanelGroup.Width  = groupBox.Width + LayoutManager.BorderSize * 2;
            CollapsiblePanelGroup.Height = groupBox.Height + LayoutManager.BorderSize * 2;
            LayoutManager.AddControl(groupBox);
            return(groupBox);
        }
コード例 #2
0
        private void AddControlToLayoutManager(IControlHabanero label, IControlHabanero entryControl)
        {
            if (label == null)
            {
                throw new ArgumentNullException("label");
            }
            if (entryControl == null)
            {
                throw new ArgumentNullException("entryControl");
            }
            var reversed = (entryControl is ICheckBox);

            _layoutManager.AddControl(reversed ? entryControl : label);
            if (_layoutManager is FlowLayoutManager)
            {
                ((FlowLayoutManager)_layoutManager).AddGlue();
            }
            _layoutManager.AddControl(reversed ? label : entryControl);
        }