public void TestPropertyAttributes() { IUIGridColumn uiProp = loader.LoadUIProperty( @"<column heading=""testlabel"" property=""testpropname"" ><parameter name=""TestAtt"" value=""TestValue"" /><parameter name=""TestAtt2"" value=""TestValue2"" /></column>"); Assert.AreEqual("TestValue", uiProp.GetParameterValue("TestAtt")); Assert.AreEqual("TestValue2", uiProp.GetParameterValue("TestAtt2")); }
protected static void SetupCurrencyWithParameters(Type propertyType, IUIGridColumn gridColDef, IDataGridViewColumn column) { if (propertyType != typeof(Double) && propertyType != typeof(Decimal)) { return; } string currencyFormat = gridColDef.GetParameterValue("currencyFormat") as string; if (currencyFormat != null) { column.DefaultCellStyle.Format = currencyFormat; } }
public void TestInitGrid_GlobalDateFormat_FormatsDateColumn() { //---------------Set up test pack------------------- IClassDef classDef = MyBO.LoadClassDefWithDateTimeParameterFormat(); IReadOnlyGridControl grid = CreateReadOnlyGridControl(); IGridInitialiser initialiser = new GridInitialiser(grid, GetControlFactory()); IUIDef uiDef = classDef.UIDefCol["default"]; IUIGrid uiGridDef = uiDef.UIGrid; AddControlToForm(grid); const string dateTimeNoFormatPropertyName = "TestDateTimeNoFormat"; const string expectedFormat = "dd.MMM.yyyy"; GlobalUIRegistry.DateDisplaySettings = new DateDisplaySettings(); GlobalUIRegistry.DateDisplaySettings.GridDateFormat = expectedFormat; //--------------Assert PreConditions---------------- IUIGridColumn dateTimeNoFormatGridColumn = uiGridDef[dateTimeNoFormatPropertyName]; Assert.IsNotNull(dateTimeNoFormatGridColumn); Assert.IsNull(dateTimeNoFormatGridColumn.GetParameterValue("dateFormat")); Assert.IsNotNull(GlobalUIRegistry.DateDisplaySettings); Assert.AreEqual(expectedFormat, GlobalUIRegistry.DateDisplaySettings.GridDateFormat); MyBO myBo = new MyBO(); DateTime currentDateTime = DateTime.Now; myBo.SetPropertyValue(dateTimeNoFormatPropertyName, currentDateTime); BusinessObjectCollection <MyBO> col = new BusinessObjectCollection <MyBO>(); col.Add(myBo); //---------------Execute Test ---------------------- initialiser.InitialiseGrid(classDef); grid.BusinessObjectCollection = col; //---------------Test Result ----------------------- Assert.AreEqual(1, col.Count); Assert.AreEqual(1, grid.Grid.Rows.Count); IDataGridViewCell dataGridViewCell = grid.Grid.Rows[0].Cells[dateTimeNoFormatPropertyName]; //((DataGridViewCellVWG) dataGridViewCell).DataGridViewCell.HasStyle = false; Assert.AreSame(typeof(DateTime), dataGridViewCell.ValueType); Assert.AreEqual(currentDateTime.ToString(expectedFormat), dataGridViewCell.FormattedValue); //---------------Tear Down ------------------------- }
private static void SetupDateTimeWithParameters(Type propertyType, IUIGridColumn gridColDef, IDataGridViewColumn col) { if (propertyType != typeof(DateTime)) { return; } string dateFormat = gridColDef.GetParameterValue("dateFormat") as string; if (string.IsNullOrEmpty(dateFormat) && GlobalUIRegistry.DateDisplaySettings != null) { dateFormat = GlobalUIRegistry.DateDisplaySettings.GridDateFormat; } if (dateFormat != null) { col.DefaultCellStyle.Format = dateFormat; } }
private static void SetupDateTimeWithParameters(Type propertyType, IUIGridColumn gridColDef, IDataGridViewColumn col) { if (propertyType != typeof(DateTime)) return; string dateFormat = gridColDef.GetParameterValue("dateFormat") as string; if (string.IsNullOrEmpty(dateFormat) && GlobalUIRegistry.DateDisplaySettings != null) { dateFormat = GlobalUIRegistry.DateDisplaySettings.GridDateFormat; } if (dateFormat != null) { col.DefaultCellStyle.Format = dateFormat; } }
protected static void SetupCurrencyWithParameters(Type propertyType, IUIGridColumn gridColDef, IDataGridViewColumn column) { if (propertyType != typeof(Double) && propertyType != typeof(Decimal)) return; string currencyFormat = gridColDef.GetParameterValue("currencyFormat") as string; if (currencyFormat != null) { column.DefaultCellStyle.Format = currencyFormat; } }