public virtual IClassDef GetClassDef() { IUIFormColumn column = this.UIFormColumn; if (column == null) { return(null); } IUIFormTab tab = column.UIFormTab; if (tab == null) { return(null); } IUIForm form = tab.UIForm; if (form == null) { return(null); } IUIDef uiDef = form.UIDef; if (uiDef == null) { return(null); } if (uiDef.ClassDef != null) { return(uiDef.ClassDef); } return(uiDef.UIDefCol == null ? null : uiDef.UIDefCol.ClassDef); }
public void Test_GetDefaultUIDef_WhenNotHasViewAndHasStringProp_ShouldCreateUIField() { //---------------Set up test pack------------------- var viewCreator = new UIViewCreator(GetFactory()); IClassDef classDef = typeof(FakeBo).MapClass(); //---------------Assert Precondition---------------- Assert.AreEqual(0, classDef.UIDefCol.Count); //---------------Execute Test ---------------------- IUIDef returnedUIDef = viewCreator.GetDefaultUIDef(classDef); //---------------Test Result ----------------------- IUIForm uiForm = returnedUIDef.UIForm; Assert.IsNotNull(uiForm); // Assert.AreSame(returnedUIDef, uiForm.UIDef); Assert.AreEqual(1, uiForm.Count, "Should create tab"); IUIFormTab uiFormTab = uiForm[0]; Assert.AreSame(uiForm, uiFormTab.UIForm); Assert.AreEqual("default", uiFormTab.Name); Assert.AreEqual(1, uiFormTab.Count, "Should create col"); IUIFormColumn uiFormColumn = uiFormTab[0]; Assert.AreSame(uiFormTab, uiFormColumn.UIFormTab); Assert.AreEqual(1, uiFormColumn.Count, "Should create field"); IUIFormField uiFormField = uiFormColumn[0]; Assert.AreEqual("Fake Bo Name", uiFormField.Label); Assert.AreEqual("FakeBoName", uiFormField.PropertyName); }
/// <summary> /// Checks if the form contains the specified tab /// </summary> /// <param name="tab">A UIFormTab object</param> public bool Contains(IUIFormTab tab) { if (tab == null) { return(false); } return(_tabList.Contains(tab)); }
/// <summary> /// Removes a tab from the form /// </summary> /// <param name="tab">A UIFormTab object</param> public void Remove(IUIFormTab tab) { if (tab == null) { return; } _tabList.Remove(tab); }
private IUIFormField GetFormField(IUIForm uiForm, int index) { IUIFormTab uiFormTab = uiForm[0]; IUIFormColumn uiFormColumn = uiFormTab[0]; IUIFormField uiFormField = uiFormColumn[index]; return(uiFormField); }
/// <summary> /// Adds a tab to the form /// </summary> /// <param name="tab">A UIFormTab object</param> public void Add(IUIFormTab tab) { if (tab == null) { return; } tab.UIForm = this; _tabList.Add(tab); }
private void AddFieldToClassDef(IClassDef classDef, IUIFormField uiFormField) { IUIDef def = classDef.UIDefCol["default"]; IUIForm form = def.UIForm; IUIFormTab tab = form[0]; IUIFormColumn column = tab[0]; column.Add(uiFormField); }
public void TestTabWithFields() { IUIFormTab col = loader.LoadUIFormTab( @" <tab name=""testname""> <field label=""testlabel1"" property=""testpropname1"" /> <field label=""testlabel2"" property=""testpropname2"" /> <field label=""testlabel3"" property=""testpropname3"" /> </tab>" ); Assert.AreEqual("testname", col.Name); Assert.AreEqual(1, col.Count, "There should be one column."); Assert.AreEqual(3, col[0].Count, "There should be two props in column 1"); Assert.AreEqual("testlabel1", col[0][0].Label); Assert.AreEqual("testlabel2", col[0][1].Label); Assert.AreEqual("testlabel3", col[0][2].Label); }
/// <summary> /// Loads form tab data from the reader /// </summary> protected override void LoadFromReader() { _tab = _defClassFactory.CreateUIFormTab(); _reader.Read(); _tab.Name = _reader.GetAttribute("name"); _reader.Read(); var fields = new List <IUIFormField>(); var contentType = ""; while (_reader.Name != "tab") { if (_reader.Name == "columnLayout") { if (contentType.Length > 0 && contentType != "columnLayout") { throw new InvalidXmlDefinitionException(MixedContentMessage); } contentType = "columnLayout"; var columnLoader = new XmlUIFormColumnLoader(DtdLoader, _defClassFactory); _tab.Add(columnLoader.LoadUIFormColumn(_reader.ReadOuterXml())); } else if (_reader.Name == "field") { if (contentType.Length > 0 && contentType != "field") { throw new InvalidXmlDefinitionException(MixedContentMessage); } contentType = "field"; var fieldLoader = new XmlUIFormFieldLoader(DtdLoader, _defClassFactory); fields.Add(fieldLoader.LoadUIProperty(_reader.ReadOuterXml())); } else { throw new InvalidXmlDefinitionException(MixedContentMessage); } } if (contentType == "field") { var col = _defClassFactory.CreateUIFormColumn(); fields.ForEach(col.Add); _tab.Add(col); } }
/// <summary> /// Loads form tab data from the reader /// </summary> protected override void LoadFromReader() { _tab = _defClassFactory.CreateUIFormTab(); _reader.Read(); _tab.Name = _reader.GetAttribute("name"); _reader.Read(); var fields = new List<IUIFormField>(); var contentType = ""; while (_reader.Name != "tab") { if (_reader.Name == "columnLayout") { if (contentType.Length > 0 && contentType != "columnLayout") { throw new InvalidXmlDefinitionException(MixedContentMessage); } contentType = "columnLayout"; var columnLoader = new XmlUIFormColumnLoader(DtdLoader, _defClassFactory); _tab.Add(columnLoader.LoadUIFormColumn(_reader.ReadOuterXml())); } else if (_reader.Name == "field") { if (contentType.Length > 0 && contentType != "field") { throw new InvalidXmlDefinitionException(MixedContentMessage); } contentType = "field"; var fieldLoader = new XmlUIFormFieldLoader(DtdLoader, _defClassFactory); fields.Add(fieldLoader.LoadUIProperty(_reader.ReadOuterXml())); } else { throw new InvalidXmlDefinitionException(MixedContentMessage); } } if (contentType == "field") { var col = _defClassFactory.CreateUIFormColumn(); fields.ForEach(col.Add); _tab.Add(col); } }
public void TestLoadColumn() { IUIFormTab col = loader.LoadUIFormTab( @" <tab name=""testname""> <columnLayout> <field label=""testlabel1"" property=""testpropname1"" /> <field label=""testlabel2"" property=""testpropname2"" /> </columnLayout> <columnLayout> <field label=""testlabel3"" property=""testpropname3"" /> </columnLayout> </tab>" ); Assert.AreEqual("testname", col.Name); Assert.AreEqual(2, col.Count, "There should be two column."); Assert.AreEqual(2, col[0].Count, "There should be two props in column 1"); Assert.AreEqual(1, col[1].Count, "There should be one prop in column 2"); Assert.AreEqual("testlabel1", col[0][0].Label); Assert.AreEqual("testlabel3", col[1][0].Label); }
public void TestCloneUIForm() { //---------------Set up test pack------------------- UIFormField field1 = new UIFormField("label1", "prop1", "control", null, null, null, true, null, null, null, LayoutStyle.Label); UIFormField field2 = new UIFormField("label2", "prop2", "control", null, null, null, true, null, null, null, LayoutStyle.Label); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field1); uiFormColumn.Add(field2); UIFormTab uiFormTab = new UIFormTab("Tab1"); uiFormTab.Add(uiFormColumn); UIForm uiForm = new UIForm(); uiForm.Add(uiFormTab); uiForm.Title = "ddd"; uiForm.Height = 1; uiForm.Width = 3; //---------------Execute Test ---------------------- IUIForm clonedForm = uiForm.Clone(); //---------------Test Result ----------------------- Assert.IsTrue(uiForm == (UIForm)clonedForm); Assert.IsTrue(uiForm.Equals(clonedForm)); Assert.AreNotSame(uiForm, clonedForm); IUIFormTab clonedUIFormTab = clonedForm[0]; Assert.AreEqual(uiForm[0], clonedUIFormTab, "Should be a deep copy and the columns should be equal but copied"); Assert.AreNotSame(uiFormTab, clonedUIFormTab, "Should be a deep copy and the columns should be equal but copied (not same)"); //Verif cloned columns Assert.AreEqual(uiFormTab[0], clonedUIFormTab[0]); Assert.AreNotSame(uiFormTab[0], clonedUIFormTab[0]); }
private static void SetupInputControlColumnWidth(IPanelInfo panelInfo, IUIFormTab formTab) { GridLayoutManager layoutManager = panelInfo.LayoutManager; int formColCount = 0; foreach (UIFormColumn formColumn in formTab) { if (formColumn.Width < 0) { continue; } int gridCol = formColCount * CONTROLS_PER_COLUMN; int labelColumnWidth = layoutManager.GetFixedColumnWidth(gridCol + LABEL_CONTROL_COLUMN_NO); int errorProviderColumnWidth = layoutManager.GetFixedColumnWidth(gridCol + ERROR_PROVIDER_COLUMN_NO); int totalGap = (CONTROLS_PER_COLUMN - 1) * layoutManager.HorizontalGapSize; if (formTab.Count == 1) { totalGap += 2 * layoutManager.BorderSize; // add extra border for single column } else if (formColCount == formTab.Count - 1) { totalGap += layoutManager.BorderSize + layoutManager.HorizontalGapSize; // last column in multi-column } else if (formColCount > 0 && formTab.Count > 0) { totalGap += layoutManager.HorizontalGapSize; //2 More gaps for internal column in multi-column } else if (formColCount == 0 && formTab.Count > 0) { totalGap += layoutManager.BorderSize; } layoutManager.FixColumn (gridCol + INPUT_CONTROL_COLUMN_NO, formColumn.Width - labelColumnWidth - errorProviderColumnWidth - totalGap); formColCount++; } }
public void TestCloneUIFormTab() { //---------------Set up test pack------------------- UIFormField field1 = CreateUIFormField("label1", "prop1", null); UIFormField field2 = CreateUIFormField("label2", "prop2", null); UIFormColumn uiFormColumn = new UIFormColumn(); uiFormColumn.Add(field1); uiFormColumn.Add(field2); UIFormTab uiFormTab = new UIFormTab("Tab1"); uiFormTab.Add(uiFormColumn); //---------------Execute Test ---------------------- IUIFormTab clonedFormTab = uiFormTab.Clone(); //---------------Test Result ----------------------- Assert.IsTrue(uiFormTab == (UIFormTab)clonedFormTab); Assert.IsTrue(uiFormTab.Equals(clonedFormTab)); Assert.AreEqual(uiFormTab[0], clonedFormTab[0], "Should be a deep copy and the columns should be equal but copied"); Assert.AreNotSame(uiFormTab[0], clonedFormTab[0], "Should be a deep copy and the columns should be equal but copied (not same)"); }
/// <summary> /// Loads form definition data from the reader /// </summary> protected override void LoadFromReader() { _uiForm = _defClassFactory.CreateUIFormDef(); _reader.Read(); _uiForm.Title = _reader.GetAttribute("title"); try { _uiForm.Width = Convert.ToInt32(_reader.GetAttribute("width")); _uiForm.Height = Convert.ToInt32(_reader.GetAttribute("height")); } catch (Exception ex) { throw new InvalidXmlDefinitionException("In a 'form' element, " + "either the 'width' or 'height' attribute has been given " + "an invalid integer pixel value.", ex); } _reader.Read(); List <IUIFormColumn> columns = new List <IUIFormColumn>(); List <IUIFormField> fields = new List <IUIFormField>(); string contentType = ""; while (_reader.Name != "form") { if (_reader.Name == "tab") { if (contentType.Length > 0 && contentType != "tab") { throw new InvalidXmlDefinitionException( "A form can have either a set of 'tab', 'columnLayout' or 'field' nodes, but not a mixture."); } contentType = "tab"; XmlUIFormTabLoader tabLoader = new XmlUIFormTabLoader(DtdLoader, _defClassFactory); _uiForm.Add(tabLoader.LoadUIFormTab(_reader.ReadOuterXml())); } else if (_reader.Name == "columnLayout") { if (contentType.Length > 0 && contentType != "columnLayout") { throw new InvalidXmlDefinitionException( "A form can have either a set of 'tab', 'columnLayout' or 'field' nodes, but not a mixture."); } contentType = "columnLayout"; XmlUIFormColumnLoader columnLoader = new XmlUIFormColumnLoader(DtdLoader, _defClassFactory); columns.Add(columnLoader.LoadUIFormColumn(_reader.ReadOuterXml())); } else if (_reader.Name == "field") { if (contentType.Length > 0 && contentType != "field") { throw new InvalidXmlDefinitionException( "A form can have either a set of 'tab', 'columnLayout' or 'field' nodes, but not a mixture."); } contentType = "field"; XmlUIFormFieldLoader fieldLoader = new XmlUIFormFieldLoader(DtdLoader, _defClassFactory); fields.Add(fieldLoader.LoadUIProperty(_reader.ReadOuterXml())); } else { throw new InvalidXmlDefinitionException( "A form can have either a set of 'tab', 'columnLayout' or 'field' nodes."); } } if (contentType == "columnLayout") { IUIFormTab tab = _defClassFactory.CreateUIFormTab(); columns.ForEach(tab.Add); _uiForm.Add(tab); } else if (contentType == "field") { IUIFormTab tab = _defClassFactory.CreateUIFormTab(); IUIFormColumn col = _defClassFactory.CreateUIFormColumn(); fields.ForEach(col.Add); tab.Add(col); _uiForm.Add(tab); } if (_uiForm.Count == 0) { throw new InvalidXmlDefinitionException("No 'tab', 'columnLayout' or 'field' " + "elements were specified in a 'form' element. Ensure " + "that the element contains one or more of either 'tab', 'columnLayout' or 'field' elements, " + "which each define what must appear in the editing form for " + "the business object."); } }
/// <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; }
private static void SetupInputControlColumnWidth(IPanelInfo panelInfo, IUIFormTab formTab) { GridLayoutManager layoutManager = panelInfo.LayoutManager; int formColCount = 0; foreach (UIFormColumn formColumn in formTab) { if (formColumn.Width < 0) continue; int gridCol = formColCount * CONTROLS_PER_COLUMN; int labelColumnWidth = layoutManager.GetFixedColumnWidth(gridCol + LABEL_CONTROL_COLUMN_NO); int errorProviderColumnWidth = layoutManager.GetFixedColumnWidth(gridCol + ERROR_PROVIDER_COLUMN_NO); int totalGap = (CONTROLS_PER_COLUMN - 1) * layoutManager.HorizontalGapSize; if (formTab.Count == 1) totalGap += 2 * layoutManager.BorderSize; // add extra border for single column else if (formColCount == formTab.Count - 1) totalGap += layoutManager.BorderSize + layoutManager.HorizontalGapSize; // last column in multi-column else if (formColCount > 0 && formTab.Count > 0) totalGap += layoutManager.HorizontalGapSize; //2 More gaps for internal column in multi-column else if (formColCount == 0 && formTab.Count > 0) totalGap += layoutManager.BorderSize; layoutManager.FixColumn (gridCol + INPUT_CONTROL_COLUMN_NO, formColumn.Width - labelColumnWidth - errorProviderColumnWidth - totalGap); formColCount++; } }
/// <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); }