public SetGridSize ( int rows, int cols ) : void | ||
rows | int | The number of rows |
cols | int | The number of columns |
리턴 | void |
///<summary> /// Constructor for the <see cref="HelpAboutBoxManager"/> ///</summary> ///<param name="controlFactory"></param> ///<param name="formHabanero"></param> ///<param name="programName"></param> ///<param name="producedForName"></param> ///<param name="producedByName"></param> ///<param name="versionNumber"></param> public HelpAboutBoxManager(IControlFactory controlFactory, IFormHabanero formHabanero, string programName, string producedForName, string producedByName, string versionNumber) { _FormHabanero = formHabanero; _mainPanel = controlFactory.CreatePanel(); GridLayoutManager mainPanelManager = new GridLayoutManager(_mainPanel, controlFactory); mainPanelManager.SetGridSize(4, 2); mainPanelManager.FixAllRowsBasedOnContents(); mainPanelManager.FixColumnBasedOnContents(0); mainPanelManager.FixColumnBasedOnContents(1); mainPanelManager.AddControl(controlFactory.CreateLabel("Programme Name:", false)); mainPanelManager.AddControl(controlFactory.CreateLabel(programName, false)); mainPanelManager.AddControl(controlFactory.CreateLabel("Produced For:", false)); mainPanelManager.AddControl(controlFactory.CreateLabel(producedForName, false)); mainPanelManager.AddControl(controlFactory.CreateLabel("Produced By:", false)); mainPanelManager.AddControl(controlFactory.CreateLabel(producedByName, false)); mainPanelManager.AddControl(controlFactory.CreateLabel("Version:", false)); mainPanelManager.AddControl(controlFactory.CreateLabel(versionNumber, false)); IButtonGroupControl buttons = controlFactory.CreateButtonGroupControl(); buttons.AddButton("OK", new EventHandler(OKButtonClickHandler)); BorderLayoutManager manager = controlFactory.CreateBorderLayoutManager(formHabanero); manager.AddControl(_mainPanel, BorderLayoutManager.Position.Centre); manager.AddControl(buttons, BorderLayoutManager.Position.South); formHabanero.Width = 300; formHabanero.Height = 200; formHabanero.Text = "About"; }
///<summary> /// Constructor for the <see cref="HelpAboutBoxManager"/> ///</summary> ///<param name="controlFactory"></param> ///<param name="formHabanero"></param> ///<param name="programName"></param> ///<param name="producedForName"></param> ///<param name="producedByName"></param> ///<param name="versionNumber"></param> public HelpAboutBoxManager(IControlFactory controlFactory, IFormHabanero formHabanero, string programName, string producedForName, string producedByName, string versionNumber) { _FormHabanero = formHabanero; _mainPanel = controlFactory.CreatePanel(); GridLayoutManager mainPanelManager = new GridLayoutManager(_mainPanel, controlFactory); mainPanelManager.SetGridSize(4, 2); mainPanelManager.FixAllRowsBasedOnContents(); mainPanelManager.FixColumnBasedOnContents(0); mainPanelManager.FixColumnBasedOnContents(1); mainPanelManager.AddControl(controlFactory.CreateLabel("Programme Name:", false)); mainPanelManager.AddControl(controlFactory.CreateLabel(programName, false)); mainPanelManager.AddControl(controlFactory.CreateLabel("Produced For:", false)); mainPanelManager.AddControl(controlFactory.CreateLabel(producedForName, false)); mainPanelManager.AddControl(controlFactory.CreateLabel("Produced By:", false)); mainPanelManager.AddControl(controlFactory.CreateLabel(producedByName, false)); mainPanelManager.AddControl(controlFactory.CreateLabel("Version:", false)); mainPanelManager.AddControl(controlFactory.CreateLabel(versionNumber, false)); IButtonGroupControl buttons = controlFactory.CreateButtonGroupControl(); buttons.AddButton("OK", new EventHandler(OKButtonClickHandler)); BorderLayoutManager manager = controlFactory.CreateBorderLayoutManager(formHabanero); manager.AddControl(_mainPanel, BorderLayoutManager.Position.Centre); manager.AddControl(buttons, BorderLayoutManager.Position.South); formHabanero.Width = 300; formHabanero.Height = 200; formHabanero.Text = "About"; }
private void SetupLayoutManager(IFilterControl filterControl, IFilterDef filterDef) { if (filterDef.Columns <= 0) return; GridLayoutManager layoutManager = new GridLayoutManager(filterControl.FilterPanel, _controlFactory); int rows = filterDef.FilterPropertyDefs.Count/filterDef.Columns + 1; int cols = filterDef.Columns * 2; layoutManager.SetGridSize(rows, cols); filterControl.LayoutManager = layoutManager; }
private void SetupControlAndGridLayout() { _ctl = GetControlFactory().CreateControl(); _ctl.Width = 74; _ctl.Height = 72; _manager = new GridLayoutManager(_ctl, GetControlFactory()); _manager.SetGridSize(2, 3); _manager.HorizontalGapSize = 2; _manager.VerticalGapSize = 2; }
private void SetupLayoutManager(IFilterControl filterControl, IFilterDef filterDef) { if (filterDef.Columns <= 0) { return; } GridLayoutManager layoutManager = new GridLayoutManager(filterControl.FilterPanel, _controlFactory); int rows = filterDef.FilterPropertyDefs.Count / filterDef.Columns + 1; int cols = filterDef.Columns * 2; layoutManager.SetGridSize(rows, cols); filterControl.LayoutManager = layoutManager; }
public void Test_Visually_Advanced() { //---------------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 = 1 }; int controlNumber = 1; IPanel panel1 = CreateColoredPanel(controlFactory, controlNumber++ + ":"); panel1.Controls.Clear(); GridLayoutManager gridLayoutManager = new GridLayoutManager(panel1, controlFactory); gridLayoutManager.SetGridSize(4, 3); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "a:")); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "b:")); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "c:")); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "d:")); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "e:")); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "f:")); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "g:")); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "h:")); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "i:")); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "j:")); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "k:")); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, "l:")); columnLayoutManager.AddControl(panel1); 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 GridLayoutManager SetupLayoutManager(UIFormTab formTab, IPanel panel) { GridLayoutManager layoutManager = new GridLayoutManager(panel, ControlFactory); int maxRowsInColumns = formTab.GetMaxRowsInColumns(); int colCount = formTab.Count * CONTROLS_PER_COLUMN; layoutManager.SetGridSize(maxRowsInColumns, colCount); layoutManager.FixColumnBasedOnContents(0); for (int i = 0; i < colCount; i += CONTROLS_PER_COLUMN) { layoutManager.FixColumnBasedOnContents(i + LABEL_CONTROL_COLUMN_NO); layoutManager.FixColumn(i + ERROR_PROVIDER_COLUMN_NO, ERROR_PROVIDER_WIDTH); } ITextBox sampleTextBoxForHeight = ControlFactory.CreateTextBox(); for (int row = 0; row < maxRowsInColumns; row++) { layoutManager.FixRow(row, sampleTextBoxForHeight.Height); } return(layoutManager); }
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); GridLayoutManager gridLayoutManager = new GridLayoutManager(panel, controlFactory); gridLayoutManager.SetGridSize(6, 2); int controlNumber = 1; gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++.ToString())); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++.ToString())); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++.ToString()), 2, 1); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++.ToString())); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++.ToString()), 2, 1); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++.ToString())); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++.ToString())); gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++.ToString())); //IButtonGroupControl buttonGroupControl = controlFactory.CreateButtonGroupControl(); //buttonGroupControl.Dock = DockStyle.Top; //groupBox.Controls.Add(buttonGroupControl); //buttonGroupControl.AddButton("Add Control", (sender, e) => gridLayoutManager.AddControl(CreateColoredPanel(controlFactory, controlNumber++ + ":"))); //buttonGroupControl.AddButton("-Columns", (sender, e) => //{ // if (gridLayoutManager.ColumnCount > 1) // { // gridLayoutManager.ColumnCount--; // gridLayoutManager.Refresh(); // } //}); //buttonGroupControl.AddButton("+Columns", (sender, e) => { gridLayoutManager.ColumnCount++; gridLayoutManager.Refresh(); }); IFormHabanero form = controlFactory.CreateOKCancelDialogFactory().CreateOKCancelForm(groupBox, "Test Grid Layout Manager"); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- form.ShowDialog(); //---------------Test Result ----------------------- }
public void TestShowDatePickerForm() { //---------------Set up test pack------------------- IFormHabanero formWin = new FormWin(); IDateTimePicker dateTimePicker = GetControlFactory().CreateDateTimePicker(); dateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Custom; dateTimePicker.CustomFormat = @"Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: dd MMM yyyy"; dateTimePicker.NullDisplayValue = "Please Click"; //dateTimePicker.ShowCheckBox = true; ITextBox textBox = GetControlFactory().CreateTextBox(); IButton button = GetControlFactory().CreateButton("Check/Uncheck", delegate { //dateTimePicker.Checked = !dateTimePicker.Checked; if (dateTimePicker.ValueOrNull.HasValue) { dateTimePicker.ValueOrNull = null; } else { dateTimePicker.ValueOrNull = dateTimePicker.Value; } }); IButton enableButton = GetControlFactory().CreateButton("Enable/Disable", delegate { dateTimePicker.Enabled = !dateTimePicker.Enabled; }); GridLayoutManager gridLayoutManager = new GridLayoutManager(formWin, GetControlFactory()); gridLayoutManager.SetGridSize(5, 1); gridLayoutManager.AddControl(dateTimePicker); gridLayoutManager.AddControl(button); gridLayoutManager.AddControl(textBox); gridLayoutManager.AddControl(enableButton); gridLayoutManager.AddControl(GetControlFactory().CreateButton("ChangeColor", delegate { Random random = new Random(); dateTimePicker.ForeColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)); dateTimePicker.BackColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)); })); dateTimePicker.ValueChanged += delegate { textBox.Text = dateTimePicker.ValueOrNull.HasValue ? dateTimePicker.Value.ToString() : ""; }; //---------------Execute Test ---------------------- formWin.ShowDialog(); //---------------Test Result ----------------------- //---------------Tear down ------------------------- }
public void TestShowDatePickersFormWithVisualStyles() { //---------------Set up test pack------------------- //Application.EnableVisualStyles(); IFormHabanero formWin = new FormWin(); IControlFactory controlFactory = GetControlFactory(); IDateTimePicker dateTimePicker = controlFactory.CreateDateTimePicker(); dateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Custom; dateTimePicker.CustomFormat = @"dddd MMMM yyyy"; dateTimePicker.NullDisplayValue = "Please Click"; //dateTimePicker.ShowCheckBox = true; ITextBox textBox = controlFactory.CreateTextBox(); IButton button = controlFactory.CreateButton("Check/Uncheck", delegate { //dateTimePicker.Checked = !dateTimePicker.Checked; if (dateTimePicker.ValueOrNull.HasValue) { dateTimePicker.ValueOrNull = null; } else { dateTimePicker.ValueOrNull = dateTimePicker.Value; } }); IButton enableButton = controlFactory.CreateButton("Enable/Disable", delegate { dateTimePicker.Enabled = !dateTimePicker.Enabled; }); IPanel panel = controlFactory.CreatePanel(); panel.Dock = DockStyle.Fill; formWin.Controls.Add(panel); GridLayoutManager gridLayoutManager = new GridLayoutManager(panel, controlFactory); gridLayoutManager.SetGridSize(9, 1); gridLayoutManager.BorderSize = 25; gridLayoutManager.AddControl(dateTimePicker); gridLayoutManager.AddControl(button); gridLayoutManager.AddControl(textBox); gridLayoutManager.AddControl(enableButton); gridLayoutManager.AddControl(controlFactory.CreateButton("ChangeColor", delegate { Random random = new Random(); dateTimePicker.ForeColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)); dateTimePicker.BackColor = Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)); })); IDateTimePicker anotherDateTimePicker; anotherDateTimePicker = controlFactory.CreateDateTimePicker(); anotherDateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Long; gridLayoutManager.AddControl(anotherDateTimePicker); anotherDateTimePicker = controlFactory.CreateDateTimePicker(); anotherDateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Short; gridLayoutManager.AddControl(anotherDateTimePicker); anotherDateTimePicker = controlFactory.CreateDateTimePicker(); anotherDateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Time; gridLayoutManager.AddControl(anotherDateTimePicker); anotherDateTimePicker = controlFactory.CreateDateTimePicker(); anotherDateTimePicker.Format = Habanero.Faces.Base.DateTimePickerFormat.Long; anotherDateTimePicker.Font = new Font(FontFamily.GenericSansSerif, 18); anotherDateTimePicker.Height = 60; gridLayoutManager.AddControl(anotherDateTimePicker); dateTimePicker.ValueChanged += delegate { textBox.Text = dateTimePicker.ValueOrNull.HasValue ? dateTimePicker.Value.ToString() : ""; }; //---------------Execute Test ---------------------- formWin.ShowDialog(); //---------------Test Result ----------------------- //---------------Tear down ------------------------- }
private GridLayoutManager SetupLayoutManager(UIFormTab formTab, IPanel panel) { GridLayoutManager layoutManager = new GridLayoutManager(panel, ControlFactory); int maxRowsInColumns = formTab.GetMaxRowsInColumns(); int colCount = formTab.Count * CONTROLS_PER_COLUMN; layoutManager.SetGridSize(maxRowsInColumns, colCount); layoutManager.FixColumnBasedOnContents(0); for (int i = 0; i < colCount; i += CONTROLS_PER_COLUMN) { layoutManager.FixColumnBasedOnContents(i + LABEL_CONTROL_COLUMN_NO); layoutManager.FixColumn(i + ERROR_PROVIDER_COLUMN_NO, ERROR_PROVIDER_WIDTH); } ITextBox sampleTextBoxForHeight = ControlFactory.CreateTextBox(); for (int row = 0; row < maxRowsInColumns; row++) { layoutManager.FixRow(row, sampleTextBoxForHeight.Height); } return layoutManager; }
/// <summary> /// Creates a panel with the controls and dimensions as prescribed /// </summary> /// <param name="uiFormTab">The UIFormTab object</param> /// <returns>Returns the object containing the new panel</returns> private IPanelFactoryInfo CreateOnePanel(IUIFormTab uiFormTab) { if (uiFormTab.UIFormGrid != null) { return(CreatePanelWithGrid(uiFormTab.UIFormGrid)); } IPanel panel = _controlFactory.CreatePanel(_controlFactory); IToolTip toolTip = _controlFactory.CreateToolTip(); GridLayoutManager manager = new GridLayoutManager(panel, _controlFactory); int rowCount = 0; int colCount = 0; colCount += uiFormTab.Count; foreach (UIFormColumn uiFormColumn in uiFormTab) { if (uiFormColumn.Count > rowCount) { rowCount = uiFormColumn.Count; } } const int intNoOfLayoutGridColumnsPerPanel = 3; manager.SetGridSize(rowCount, colCount * intNoOfLayoutGridColumnsPerPanel); for (int col = 0; col < colCount; col++) { //Fixing the labels column widths manager.FixColumnBasedOnContents(col * intNoOfLayoutGridColumnsPerPanel); } ControlMapperCollection controlMappers = new ControlMapperCollection(); controlMappers.BusinessObject = _currentBusinessObject; ITextBox temptb = _controlFactory.CreateTextBox(); for (int row = 0; row < rowCount; row++) { manager.FixRow(row, temptb.Height); } manager.FixAllRowsBasedOnContents(); GridLayoutManager.ControlInfo[,] controls = new GridLayoutManager.ControlInfo[rowCount, colCount *intNoOfLayoutGridColumnsPerPanel]; int currentColumn = 0; foreach (UIFormColumn uiFormColumn in uiFormTab) { int currentRow = 0; foreach (UIFormField field in uiFormColumn) { bool isCompulsory; ClassDef classDef = _currentBusinessObject.ClassDef; PropDef propDef = (PropDef)field.GetPropDefIfExists(classDef); if (propDef != null) { isCompulsory = propDef.Compulsory; } else { isCompulsory = false; } string labelCaption = field.GetLabel(classDef); // BOPropCol boPropCol = _currentBusinessObject.Props; // if (boPropCol.Contains(field.PropertyName)) // { // IBOProp boProp = boPropCol[field.PropertyName]; // if (!boProp.HasDisplayName()) // { // boProp.DisplayName = labelCaption; // } // } IControlHabanero ctl = CreateControl(field, _controlFactory); bool editable = CheckIfEditable(field, ctl); ILabel labelControl = _controlFactory.CreateLabel(labelCaption, isCompulsory && editable); controls[currentRow, currentColumn + 0] = new GridLayoutManager.ControlInfo(labelControl); if (ctl is ITextBox && propDef != null) { if (propDef.PropertyType == typeof(bool)) { ctl = _controlFactory.CreateCheckBox(); } else if (propDef.PropertyType == typeof(string) && propDef.KeepValuePrivate) { ctl = _controlFactory.CreatePasswordTextBox(); } else if (field.GetParameterValue("numLines") != null) { int numLines; try { numLines = Convert.ToInt32(field.GetParameterValue("numLines")); } catch (Exception) { throw new InvalidXmlDefinitionException ("An error " + "occurred while reading the 'numLines' parameter " + "from the class definitions. The 'value' " + "attribute must be a valid integer."); } if (numLines > 1) { ctl = _controlFactory.CreateTextBoxMultiLine(numLines); } } } if (ctl is ITextBox) { if (field.GetParameterValue("isEmail") != null) { string isEmailValue = (string)field.GetParameterValue("isEmail"); if (isEmailValue != "true" && isEmailValue != "false") { throw new InvalidXmlDefinitionException ("An error " + "occurred while reading the 'isEmail' parameter " + "from the class definitions. The 'value' " + "attribute must hold either 'true' or 'false'."); } //bool isEmail = Convert.ToBoolean(isEmailValue); //if (isEmail) //{ // ITextBox tb = (ITextBox) ctl; // tb.DoubleClick += _emailTextBoxDoubleClickedHandler; //} } } //if (ctl is IDateTimePicker) //{ // IDateTimePicker editor = (IDateTimePicker) ctl; // editor.Enter += DateTimePickerEnterHandler; //} //if (ctl is INumericUpDown) //{ // INumericUpDown upDown = (INumericUpDown) ctl; // upDown.Enter += UpDownEnterHandler; //} CheckGeneralParameters(field, ctl); IControlMapper ctlMapper = ControlMapper.Create (field.MapperTypeName, field.MapperAssembly, ctl, field.PropertyName, !editable, _controlFactory); if (ctlMapper is ControlMapper) { ControlMapper controlMapper = (ControlMapper)ctlMapper; controlMapper.SetPropertyAttributes(field.Parameters); } controlMappers.Add(ctlMapper); ctlMapper.BusinessObject = _currentBusinessObject; int colSpan = 1; if (field.GetParameterValue("colSpan") != null) { try { colSpan = Convert.ToInt32(field.GetParameterValue("colSpan")); } catch (Exception) { throw new InvalidXmlDefinitionException ("An error " + "occurred while reading the 'colSpan' parameter " + "from the class definitions. The 'value' " + "attribute must be a valid integer."); } } colSpan = (colSpan - 1) * intNoOfLayoutGridColumnsPerPanel + 1; // must span label columns too int rowSpan = 1; if (field.GetParameterValue("rowSpan") != null) { try { rowSpan = Convert.ToInt32(field.GetParameterValue("rowSpan")); } catch (Exception) { throw new InvalidXmlDefinitionException ("An error " + "occurred while reading the 'rowSpan' parameter " + "from the class definitions. The 'value' " + "attribute must be a valid integer."); } } if (rowSpan == 1) { manager.FixRow(currentRow, ctl.Height); } controls[currentRow, currentColumn + 1] = new GridLayoutManager.ControlInfo(ctl, rowSpan, colSpan); currentRow++; string toolTipText = field.GetToolTipText(classDef); if (!String.IsNullOrEmpty(toolTipText)) { toolTip.SetToolTip(labelControl, toolTipText); toolTip.SetToolTip(ctl, toolTipText); } //Hack brett trying to fix prob with dynamic properties ctl.Width = 100; } currentColumn += 3; } for (int i = 0; i < rowCount; i++) { for (int j = 0; j < colCount * intNoOfLayoutGridColumnsPerPanel; j++) { if (controls[i, j] == null) { manager.AddControl(null); } else { manager.AddControl(controls[i, j]); controls[i, j].Control.TabIndex = rowCount * j + i; } } } for (int col = 0; col < colCount; col++) { if (uiFormTab[col].Width > -1) { //Fix width of the control column e.g. textbox or combobox. manager.FixColumn(col * intNoOfLayoutGridColumnsPerPanel + 1, uiFormTab[col].Width - manager.GetFixedColumnWidth(col * intNoOfLayoutGridColumnsPerPanel)); } manager.FixColumn(col * intNoOfLayoutGridColumnsPerPanel + 2, 15); } panel.Height = manager.GetFixedHeightIncludingGaps(); panel.Width = manager.GetFixedWidthIncludingGaps(); IPanelFactoryInfo panelFactoryInfo = new PanelFactoryInfo(panel, controlMappers, _uiDefName, _firstControl); panelFactoryInfo.MinimumPanelHeight = panel.Height; panelFactoryInfo.MinumumPanelWidth = panel.Width; panelFactoryInfo.ToolTip = toolTip; panelFactoryInfo.PanelTabText = uiFormTab.Name; panelFactoryInfo.UIForm = _uiForm; panelFactoryInfo.UiFormTab = uiFormTab; return(panelFactoryInfo); }
public void TestTooManyRows_2Rows() { //---------------Set up test pack------------------- IControlHabanero ctl1 = CreateControl(10, 11, -5, -5); GridLayoutManager gridLayoutManager = new GridLayoutManager(ctl1, GetControlFactory()); //--------------Assert PreConditions---------------- //---------------Execute Test ---------------------- gridLayoutManager.SetGridSize(2, 1); gridLayoutManager.AddControl(GetControlFactory().CreateTextBox()); gridLayoutManager.AddControl(GetControlFactory().CreateTextBox()); try { gridLayoutManager.AddControl(GetControlFactory().CreateTextBox()); Assert.Fail("err expected"); } catch (HabaneroDeveloperException ex) { StringAssert.Contains("You cannot add a control to the grid layout manager since it exceeds the grids size of '2' row and '1' column", ex.Message); } //---------------Test Result ----------------------- //---------------Tear Down ------------------------- }
public void TestLayoutWithColSpan() { //---------------Set up test pack------------------- IControlHabanero managedControl = GetControlFactory().CreateControl(); managedControl.Width = 100; managedControl.Height = 100; GridLayoutManager layoutManager = new GridLayoutManager(managedControl, GetControlFactory()); layoutManager.SetGridSize(2, 2); IControlHabanero control1 = GetControlFactory().CreateControl(); IControlHabanero control2 = GetControlFactory().CreateControl(); IControlHabanero control3 = GetControlFactory().CreateControl(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- layoutManager.AddControl(new GridLayoutManager.ControlInfo(control1, 2, 1)); layoutManager.AddControl(control2); layoutManager.AddControl(control3); //---------------Test Result ----------------------- Assert.AreEqual(LayoutManager.DefaultBorderSize, control1.Top); Assert.AreEqual(LayoutManager.DefaultBorderSize, control1.Left); Assert.AreEqual(managedControl.Width - LayoutManager.DefaultBorderSize, control1.Right); Assert.AreEqual((managedControl.Height - LayoutManager.DefaultGapSize) / 2, control1.Bottom); Assert.AreEqual(control1.Left, control2.Left); Assert.AreEqual(control1.Right, control3.Right); Assert.AreEqual(control3.Top, control2.Top); Assert.AreEqual(control2.Width + control3.Width + LayoutManager.DefaultGapSize, control1.Width); }
public void TestColumnSpanWithOneFixedColumn() { //---------------Set up test pack------------------- IControlHabanero controlHabanero = GetControlFactory().CreateControl(); controlHabanero.Width = 100; GridLayoutManager manager = new GridLayoutManager(controlHabanero, GetControlFactory()); manager.SetGridSize(1, 3); manager.FixColumnBasedOnContents(0); manager.FixColumnBasedOnContents(2); IControlHabanero col1Control = GetControlFactory().CreateControl(); col1Control.Width = 20; IControlHabanero col3Control = GetControlFactory().CreateControl(); col3Control.Width = 10; //---------------Execute Test ---------------------- manager.AddControl(col1Control, 1, 2); manager.AddControl(col3Control); //---------------Test Result ----------------------- Assert.AreEqual(LayoutManager.DefaultBorderSize, col1Control.Left); Assert.AreEqual(controlHabanero.Width - LayoutManager.DefaultBorderSize - col3Control.Width - LayoutManager.DefaultGapSize, col1Control.Left + col1Control.Width); //---------------Tear Down ------------------------- }
/// <summary> /// Creates a panel with the controls and dimensions as prescribed /// </summary> /// <param name="uiFormTab">The UIFormTab object</param> /// <returns>Returns the object containing the new panel</returns> private IPanelFactoryInfo CreateOnePanel(IUIFormTab uiFormTab) { if (uiFormTab.UIFormGrid != null) { return CreatePanelWithGrid(uiFormTab.UIFormGrid); } IPanel panel = _controlFactory.CreatePanel(_controlFactory); IToolTip toolTip = _controlFactory.CreateToolTip(); GridLayoutManager manager = new GridLayoutManager(panel, _controlFactory); int rowCount = 0; int colCount = 0; colCount += uiFormTab.Count; foreach (UIFormColumn uiFormColumn in uiFormTab) { if (uiFormColumn.Count > rowCount) { rowCount = uiFormColumn.Count; } } const int intNoOfLayoutGridColumnsPerPanel = 3; manager.SetGridSize(rowCount, colCount * intNoOfLayoutGridColumnsPerPanel); for (int col = 0; col < colCount; col++) { //Fixing the labels column widths manager.FixColumnBasedOnContents(col * intNoOfLayoutGridColumnsPerPanel); } ControlMapperCollection controlMappers = new ControlMapperCollection(); controlMappers.BusinessObject = _currentBusinessObject; ITextBox temptb = _controlFactory.CreateTextBox(); for (int row = 0; row < rowCount; row++) { manager.FixRow(row, temptb.Height); } manager.FixAllRowsBasedOnContents(); GridLayoutManager.ControlInfo[,] controls = new GridLayoutManager.ControlInfo[rowCount, colCount * intNoOfLayoutGridColumnsPerPanel]; int currentColumn = 0; foreach (UIFormColumn uiFormColumn in uiFormTab) { int currentRow = 0; foreach (UIFormField field in uiFormColumn) { bool isCompulsory; ClassDef classDef = _currentBusinessObject.ClassDef; PropDef propDef = (PropDef) field.GetPropDefIfExists(classDef); if (propDef != null) { isCompulsory = propDef.Compulsory; } else { isCompulsory = false; } string labelCaption = field.GetLabel(classDef); // BOPropCol boPropCol = _currentBusinessObject.Props; // if (boPropCol.Contains(field.PropertyName)) // { // IBOProp boProp = boPropCol[field.PropertyName]; // if (!boProp.HasDisplayName()) // { // boProp.DisplayName = labelCaption; // } // } IControlHabanero ctl = CreateControl(field, _controlFactory); bool editable = CheckIfEditable(field, ctl); ILabel labelControl = _controlFactory.CreateLabel(labelCaption, isCompulsory && editable); controls[currentRow, currentColumn + 0] = new GridLayoutManager.ControlInfo(labelControl); if (ctl is ITextBox && propDef != null) { if (propDef.PropertyType == typeof(bool)) { ctl = _controlFactory.CreateCheckBox(); } else if (propDef.PropertyType == typeof(string) && propDef.KeepValuePrivate) { ctl = _controlFactory.CreatePasswordTextBox(); } else if (field.GetParameterValue("numLines") != null) { int numLines; try { numLines = Convert.ToInt32(field.GetParameterValue("numLines")); } catch (Exception) { throw new InvalidXmlDefinitionException ("An error " + "occurred while reading the 'numLines' parameter " + "from the class definitions. The 'value' " + "attribute must be a valid integer."); } if (numLines > 1) { ctl = _controlFactory.CreateTextBoxMultiLine(numLines); } } } if (ctl is ITextBox) { if (field.GetParameterValue("isEmail") != null) { string isEmailValue = (string)field.GetParameterValue("isEmail"); if (isEmailValue != "true" && isEmailValue != "false") { throw new InvalidXmlDefinitionException ("An error " + "occurred while reading the 'isEmail' parameter " + "from the class definitions. The 'value' " + "attribute must hold either 'true' or 'false'."); } //bool isEmail = Convert.ToBoolean(isEmailValue); //if (isEmail) //{ // ITextBox tb = (ITextBox) ctl; // tb.DoubleClick += _emailTextBoxDoubleClickedHandler; //} } } //if (ctl is IDateTimePicker) //{ // IDateTimePicker editor = (IDateTimePicker) ctl; // editor.Enter += DateTimePickerEnterHandler; //} //if (ctl is INumericUpDown) //{ // INumericUpDown upDown = (INumericUpDown) ctl; // upDown.Enter += UpDownEnterHandler; //} CheckGeneralParameters(field, ctl); IControlMapper ctlMapper = ControlMapper.Create (field.MapperTypeName, field.MapperAssembly, ctl, field.PropertyName, !editable, _controlFactory); if (ctlMapper is ControlMapper) { ControlMapper controlMapper = (ControlMapper)ctlMapper; controlMapper.SetPropertyAttributes(field.Parameters); } controlMappers.Add(ctlMapper); ctlMapper.BusinessObject = _currentBusinessObject; int colSpan = 1; if (field.GetParameterValue("colSpan") != null) { try { colSpan = Convert.ToInt32(field.GetParameterValue("colSpan")); } catch (Exception) { throw new InvalidXmlDefinitionException ("An error " + "occurred while reading the 'colSpan' parameter " + "from the class definitions. The 'value' " + "attribute must be a valid integer."); } } colSpan = (colSpan - 1) * intNoOfLayoutGridColumnsPerPanel + 1; // must span label columns too int rowSpan = 1; if (field.GetParameterValue("rowSpan") != null) { try { rowSpan = Convert.ToInt32(field.GetParameterValue("rowSpan")); } catch (Exception) { throw new InvalidXmlDefinitionException ("An error " + "occurred while reading the 'rowSpan' parameter " + "from the class definitions. The 'value' " + "attribute must be a valid integer."); } } if (rowSpan == 1) { manager.FixRow(currentRow, ctl.Height); } controls[currentRow, currentColumn + 1] = new GridLayoutManager.ControlInfo(ctl, rowSpan, colSpan); currentRow++; string toolTipText = field.GetToolTipText(classDef); if (!String.IsNullOrEmpty(toolTipText)) { toolTip.SetToolTip(labelControl, toolTipText); toolTip.SetToolTip(ctl, toolTipText); } //Hack brett trying to fix prob with dynamic properties ctl.Width = 100; } currentColumn += 3; } for (int i = 0; i < rowCount; i++) { for (int j = 0; j < colCount * intNoOfLayoutGridColumnsPerPanel; j++) { if (controls[i, j] == null) { manager.AddControl(null); } else { manager.AddControl(controls[i, j]); controls[i, j].Control.TabIndex = rowCount * j + i; } } } for (int col = 0; col < colCount; col++) { if (uiFormTab[col].Width > -1) { //Fix width of the control column e.g. textbox or combobox. manager.FixColumn(col * intNoOfLayoutGridColumnsPerPanel + 1, uiFormTab[col].Width - manager.GetFixedColumnWidth(col * intNoOfLayoutGridColumnsPerPanel)); } manager.FixColumn(col * intNoOfLayoutGridColumnsPerPanel + 2, 15); } panel.Height = manager.GetFixedHeightIncludingGaps(); panel.Width = manager.GetFixedWidthIncludingGaps(); IPanelFactoryInfo panelFactoryInfo = new PanelFactoryInfo(panel, controlMappers, _uiDefName, _firstControl); panelFactoryInfo.MinimumPanelHeight = panel.Height; panelFactoryInfo.MinumumPanelWidth = panel.Width; panelFactoryInfo.ToolTip = toolTip; panelFactoryInfo.PanelTabText = uiFormTab.Name; panelFactoryInfo.UIForm = _uiForm; panelFactoryInfo.UiFormTab = uiFormTab; return panelFactoryInfo; }