This allows you to add controls to a layout where the controls will be added to the columns from left to right until the number of columns is exceeded. When this happens the control will be added on the next row. The row height is determined by the heighest control in the row. All controls added will have an identical width (width = managed control width - borders size)
Inheritance: LayoutManager
コード例 #1
0
 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 -----------------------
 }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
 /// <summary>
 /// Constructs the <see cref="CollapsiblePanelGroupManager"/>
 /// </summary>
 // ReSharper disable SuggestBaseTypeForParameter
 public CollapsiblePanelGroupManager
     (ICollapsiblePanelGroupControl collapsiblePanelGroup, IControlFactory controlFactory)
 {
     ControlFactory = controlFactory;
     PanelsList = new List<ICollapsiblePanel>();
     ColumnLayoutManager = new ColumnLayoutManager(collapsiblePanelGroup, ControlFactory);
 }
コード例 #4
0
 /// <summary>
 /// Constructs the <see cref="CollapsiblePanelGroupManager"/>
 /// </summary>
 // ReSharper disable SuggestBaseTypeForParameter
 public CollapsiblePanelGroupManager
     (ICollapsiblePanelGroupControl collapsiblePanelGroup, IControlFactory controlFactory)
 {
     ControlFactory      = controlFactory;
     PanelsList          = new List <ICollapsiblePanel>();
     ColumnLayoutManager = new ColumnLayoutManager(collapsiblePanelGroup, ControlFactory);
 }
コード例 #5
0
 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);
     };
 }
コード例 #6
0
 public void TestCreateColumnLayoutManager()
 {
     //---------------Set up test pack-------------------
     IControlHabanero controlHabanero = GetControlFactory().CreatePanel();
     //---------------Execute Test ----------------------
     ColumnLayoutManager columnLayoutManager = new ColumnLayoutManager(controlHabanero, GetControlFactory());
     //---------------Test Result -----------------------
     Assert.IsNotNull(columnLayoutManager.ManagedControl);
     Assert.AreSame(controlHabanero, columnLayoutManager.ManagedControl);
     Assert.AreEqual(1, columnLayoutManager.ColumnCount);
     //---------------Tear Down   -----------------------
 }
コード例 #7
0
 /// <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;
 }
コード例 #8
0
        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 -------------------------
        }
コード例 #9
0
 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 -------------------------
 }
コード例 #10
0
 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);
 }
コード例 #11
0
 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);
 }