private UserControl_LevelLayoutData CreateLevelLayoutDataControl(UserControl_LevelLayoutData.DataType dataValueType) { UserControl_LevelLayoutData control = null; switch (dataValueType) { case UserControl_LevelLayoutData.DataType.String: control = new UserControl_StringData("New String Data", string.Empty); break; case UserControl_LevelLayoutData.DataType.Int: control = new UserControl_IntData("New Int Data", 0); break; case UserControl_LevelLayoutData.DataType.Double: control = new UserControl_DoubleData("New Double Data", 0.0); break; case UserControl_LevelLayoutData.DataType.Bool: control = new UserControl_BoolData("New Bool Data", false); break; } return control; }
private UserControl_LevelLayoutData CreateLevelLayoutDataControl(string dataName, object dataValue) { UserControl_LevelLayoutData control = null; var dataValueType = dataValue.GetType(); if (dataValueType == typeof(string)) control = new UserControl_StringData(dataName, Convert.ToString(dataValue)); else if (dataValueType == typeof(int) || dataValueType == typeof(long)) control = new UserControl_IntData(dataName, Convert.ToInt32(dataValue)); else if (dataValueType == typeof(float) || dataValueType == typeof(double)) control = new UserControl_DoubleData(dataName, Convert.ToDouble(dataValue)); else if (dataValueType == typeof(bool)) control = new UserControl_BoolData(dataName, Convert.ToBoolean(dataValue)); return control; }
private void AddLevelLayoutDataControl(string dataName, double dataValue) { var userControl_levelLayoutData = new UserControl_DoubleData(dataName, dataValue); AddLevelLayoutDataControlGrid(userControl_levelLayoutData); }