AddControl() public method

Add a control to those being managed in the layout
public AddControl ( IControlHabanero control ) : IControlHabanero
control IControlHabanero The control to add
return IControlHabanero
        /// <summary>
        /// Creates the panel on the form
        /// </summary>
        /// <returns>Returns the panel created</returns>
        public IPanel CreateControlPanel()
        {
            IPanel panel = _controlFactory.CreatePanel();
            ILabel label = _controlFactory.CreateLabel(_message, false);
            ColumnLayoutManager columnLayoutManager = new ColumnLayoutManager(panel, _controlFactory);

            columnLayoutManager.AddControl(label);
            columnLayoutManager.AddControl(_comboBox);
            panel.Height = _comboBox.Height + label.Height + columnLayoutManager.BorderSize + columnLayoutManager.VerticalGapSize;
            int preferredWidth          = label.PreferredWidth + 20;
            int preferredWidthFromCombo = GetLongestComboText() + 40;

            if (preferredWidthFromCombo > preferredWidth)
            {
                preferredWidth = preferredWidthFromCombo;
            }
            if (preferredWidth < 200)
            {
                preferredWidth = 200;
            }
            panel.Width       = preferredWidth;
            _comboBox.Width   = panel.Width - 30;
            panel.MinimumSize = panel.Size;
            return(panel);
        }
 public void Test_Visually()
 {
     //---------------Set up test pack-------------------
     IControlFactory controlFactory = GetControlFactory();
     IGroupBox groupBox = controlFactory.CreateGroupBox("Test Layout");
     IPanel panel = controlFactory.CreatePanel();
     panel.Dock = DockStyle.Fill;
     groupBox.Controls.Add(panel);
     ColumnLayoutManager columnLayoutManager = new ColumnLayoutManager(panel, controlFactory) { ColumnCount = 2 };
     int controlNumber = 1;
     columnLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++ + ":"));
     columnLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++ + ":"));
     columnLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++ + ":"));
     IButtonGroupControl buttonGroupControl = controlFactory.CreateButtonGroupControl();
     buttonGroupControl.Dock = DockStyle.Top;
     groupBox.Controls.Add(buttonGroupControl);
     buttonGroupControl.AddButton("Add Control", (sender, e) => columnLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++ + ":")));
     buttonGroupControl.AddButton("-Columns", (sender, e) =>
                                                  {
                                                      if (columnLayoutManager.ColumnCount > 1)
                                                      {
                                                          columnLayoutManager.ColumnCount--;
                                                          columnLayoutManager.Refresh();
                                                      }
                                                  });
     buttonGroupControl.AddButton("+Columns", (sender, e) => { columnLayoutManager.ColumnCount++; columnLayoutManager.Refresh(); });
     IFormHabanero form = controlFactory.CreateOKCancelDialogFactory().CreateOKCancelForm(groupBox, "Test Column Layout Manager");
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     form.ShowDialog();
     //---------------Test Result -----------------------
 }
 private void AddCollapsiblePanel(ICollapsiblePanel collapsiblePanel, int minimumControlHeight)
 {
     ColumnLayoutManager.AddControl(collapsiblePanel);
     this.PanelsList.Add(collapsiblePanel);
     collapsiblePanel.Height       = collapsiblePanel.CollapseButton.Height + minimumControlHeight;
     collapsiblePanel.Collapsed    = true;
     collapsiblePanel.Uncollapsed += delegate
     {
         CollapseUnpinnedPanels(collapsiblePanel);
     };
 }
 /// <summary>
 /// Creates the panel on the form
 /// </summary>
 /// <returns>Returns the panel created</returns>
 public IPanel CreateControlPanel()
 {
     IPanel panel = _controlFactory.CreatePanel();
     ILabel label = _controlFactory.CreateLabel(_message, false);
     ColumnLayoutManager columnLayoutManager = new ColumnLayoutManager(panel, _controlFactory);
     columnLayoutManager.AddControl(label);
     columnLayoutManager.AddControl(_comboBox);
     panel.Height = _comboBox.Height + label.Height + columnLayoutManager.BorderSize + columnLayoutManager.VerticalGapSize;
     int preferredWidth = label.PreferredWidth + 20;
     int preferredWidthFromCombo = GetLongestComboText() + 40;
     if (preferredWidthFromCombo > preferredWidth) 
         preferredWidth = preferredWidthFromCombo;
     if (preferredWidth < 200) 
         preferredWidth = 200;
     panel.Width = preferredWidth;
     _comboBox.Width = panel.Width - 30;
     panel.MinimumSize = panel.Size;
     return panel;
 }
        public void TestResizeManagedControl()
        {
            //---------------Set up test pack-------------------
            IControlHabanero managedControl = GetControlFactory().CreatePanel();
            int originalWidth = 400;
            managedControl.Width = originalWidth;
            ColumnLayoutManager columnLayoutManager = new ColumnLayoutManager(managedControl, GetControlFactory());
            columnLayoutManager.HorizontalGapSize = 0;
            columnLayoutManager.VerticalGapSize = 0;
            columnLayoutManager.BorderSize = 0;
            IControlHabanero createdControl1 = GetControlFactory().CreateControl();
            IControlHabanero createdControl2 = GetControlFactory().CreateControl();
            columnLayoutManager.AddControl(createdControl1);
            columnLayoutManager.AddControl(createdControl2);
            //---------------Assert preconditions---------------
            Assert.AreEqual(originalWidth, createdControl1.Width);
            Assert.AreEqual(originalWidth, createdControl2.Width);
            //---------------Execute Test ----------------------
            int newWidth = 500;
            managedControl.Width = newWidth;
            //---------------Test Result -----------------------
            Assert.AreEqual(newWidth, createdControl1.Width);
            Assert.AreEqual(newWidth, createdControl2.Width);

            //---------------Tear Down -------------------------
        }
 public void TestResizeControlOnManagedControl()
 {
     //---------------Set up test pack-------------------
     IControlHabanero managedControl = GetControlFactory().CreatePanel();
     ColumnLayoutManager columnLayoutManager = new ColumnLayoutManager(managedControl, GetControlFactory());
     columnLayoutManager.HorizontalGapSize = 0;
     columnLayoutManager.VerticalGapSize = 0;
     columnLayoutManager.BorderSize = 0;
     IControlHabanero createdControl1 = GetControlFactory().CreateControl();
     IControlHabanero createdControl2 = GetControlFactory().CreateControl();
     //---------------Execute Test ----------------------
     columnLayoutManager.AddControl(createdControl1);
     columnLayoutManager.AddControl(createdControl2);
     createdControl1.Height += 10;
     //---------------Test Result -----------------------
     Assert.AreEqual(createdControl1.Height, createdControl2.Top );
     //---------------Tear Down -------------------------
 }
 public void TestRemoveControl()
 {
     //---------------Set up test pack-------------------
     IControlHabanero managedControl = GetControlFactory().CreatePanel();
     IControlHabanero createdControl = GetControlFactory().CreateControl();
     ColumnLayoutManager columnLayoutManager = new ColumnLayoutManager(managedControl, GetControlFactory());
     columnLayoutManager.AddControl(createdControl);
     //---------------Assert Pre-Conditions--------------
     Assert.AreEqual(1, managedControl.Controls.Count);
     //---------------Execute Test ----------------------
     columnLayoutManager.RemoveControl(createdControl);
     //---------------Test Result -----------------------
     Assert.AreEqual(0, managedControl.Controls.Count);
 }
 public void TestAddControl()
 {
     //---------------Set up test pack-------------------
     IControlHabanero managedControl = GetControlFactory().CreatePanel();
     ColumnLayoutManager columnLayoutManager = new ColumnLayoutManager(managedControl, GetControlFactory());
     //---------------Execute Test ----------------------
     IControlHabanero createdControl = GetControlFactory().CreateControl();
     IControlHabanero addedControl = columnLayoutManager.AddControl(createdControl);
     //---------------Test Result -----------------------
     Assert.AreEqual(1, managedControl.Controls.Count);
     Assert.AreSame(addedControl, createdControl);
 }