private static string GetDataGridColumnFromProperty(ColumnSetting columnSetting, string baseTab) { var columnName = columnSetting.GetColumnNameForCodeGen(); var lowerFirstCharColumnName = ToLowerFirstChar(columnName); var editorType = ""; var dataType = ""; var filterOperatorType = ""; var tab1 = baseTab + Constant.Tab; var isReadOnly = columnSetting.IsReadOnly ? " [isReadOnly]=\"true\"" : ""; var isTabStop = columnSetting.IsTabStop ? "" : " [isTabStop]=\"false\""; var sb = new StringBuilder(); if (columnSetting.DataGridColumnType == "DataGridComboBoxColumnExt") { sb.AppendLineExWithTabAndFormat(baseTab, "<h-column [type]=\"EditorTypeEnum.HComboBox\" cellValueProperty=\"{0}\" [cellValueType]=\"DataTypeEnum.Int\" itemsSourceName=\"{0}Source\" itemTextPath=\"displayText\" itemValuePath=\"id\"{1}{2}>", lowerFirstCharColumnName, isReadOnly, isTabStop); sb.AppendLineExWithTabAndFormat(tab1, "<h-header headerText=\"{0}\" [filterOperatorType]=\"FilterOperatorTypeEnum.NUMBER\" [filterType]=\"EditorTypeEnum.HComboBox\" itemTextPath=\"displayText\" itemValuePath=\"id\"></h-header>", columnName); sb.AppendTab(baseTab, "</h-column>"); return(sb.ToString()); } if (columnSetting.DataGridColumnType == "DataGridForeignKeyColumn") { sb.AppendLineExWithTabAndFormat(baseTab, "<h-column [type]=\"EditorTypeEnum.HForeignKeyPicker\" cellValueProperty=\"{0}\" [cellValueType]=\"DataTypeEnum.Int\" itemValuePath=\"id\" itemTextPath=\"displayText\" itemName=\"{0}Navigation\" [component]=\"{0}Window\"{1}{2}>", lowerFirstCharColumnName, isReadOnly, isTabStop); sb.AppendLineExWithTabAndFormat(tab1, "<h-header headerText=\"{0}\" [filterOperatorType]=\"FilterOperatorTypeEnum.NUMBER\" [filterType]=\"EditorTypeEnum.TextBox\"></h-header>", columnName); sb.AppendTab(baseTab, "</h-column>"); return(sb.ToString()); } switch (columnSetting.DataGridColumnType) { case "DataGridTextColumnExt": editorType = "TextBox"; dataType = "String"; filterOperatorType = "TEXT"; break; case "DataGridDateColumn": editorType = "DatePicker"; dataType = "Date"; filterOperatorType = "NUMBER"; break; case "DataGridCheckBoxColumnExt": editorType = "CheckBox"; dataType = "Bool"; filterOperatorType = "NUMBER"; break; case "DataGridRightAlignTextColumn": editorType = "HNumber"; dataType = "Int"; filterOperatorType = "NUMBER"; break; } sb.AppendLineExWithTabAndFormat(baseTab, "<h-column [type]=\"EditorTypeEnum.{0}\" cellValueProperty=\"{1}\" [cellValueType]=\"DataTypeEnum.{2}\"{3}{4}>", editorType, lowerFirstCharColumnName, dataType, isReadOnly, isTabStop); sb.AppendLineExWithTabAndFormat(tab1, "<h-header headerText=\"{0}\" [filterOperatorType]=\"FilterOperatorTypeEnum.{1}\" [filterType]=\"EditorTypeEnum.{2}\"></h-header>", columnName, filterOperatorType, editorType); sb.AppendTab(baseTab, "</h-column>"); return(sb.ToString()); }
public void ResetSelectedTableSetting() { if (selectedTableSetting == null) { return; } selectedTableSetting.ColumnSettings.Clear(); foreach (var item in selectedTableSetting.DbTable.Columns) { var column = new ColumnSetting() { ColumnName = item.ColumnName, DbColumn = item }; column.InitColumnSettingFromDbColumn(); column.Order = selectedTableSetting.ColumnSettings.Count; selectedTableSetting.ColumnSettings.Add(column); } }
private static string GetHeaderFilterModelType(ColumnSetting columnSetting) { switch (columnSetting.DataGridColumnType) { case "DataGridTextColumnExt": case "DataGridRightAlignTextColumn": return("HeaderTextFilterModel"); case "DataGridForeignKeyColumn": return("HeaderForeignKeyFilterModel"); case "DataGridComboBoxColumnExt": return("HeaderComboBoxFilterModel"); case "DataGridCheckBoxColumnExt": return("HeaderCheckFilterModel"); case "DataGridDateColumn": return("HeaderDateFilterModel"); } return("HeaderTextFilterModel"); }
private static string GetDataGridColumnFromProperty(ColumnSetting columnSetting, string baseTab) { var columnName = columnSetting.GetColumnNameForCodeGen(); var columnType = columnSetting.DataGridColumnType; var header = string.Format(" Header=\"{0}\"", columnName); var width = columnSetting.Width > 0 ? string.Format(" Width=\"{0}\"", 80) : ""; var tabStop = columnSetting.IsReadOnly ? "" : columnSetting.IsTabStop ? "" : " SimpleDataGrid:DataGridColumnAttachedProperty.IsTabStop=\"False\""; if (columnType == "DataGridComboBoxColumnExt") { var tab1 = baseTab + Constant.Tab; var sb = new StringBuilder(); sb.AppendLineExWithTabAndFormat(baseTab, "<SimpleDataGrid:{0}{1}{2}", columnType, header, width); if (string.IsNullOrEmpty(tabStop) == false) { sb.AppendLineExWithTabAndFormat(tab1, "SimpleDataGrid:DataGridColumnAttachedProperty.IsTabStop=\"False\""); } sb.AppendLineExWithTab(tab1, "SelectedValuePath=\"ID\""); sb.AppendLineExWithTab(tab1, "DisplayMemberPath=\"DisplayText\""); sb.AppendLineExWithTabAndFormat(tab1, "SelectedValueBinding=\"{{Binding {0}, UpdateSourceTrigger=PropertyChanged}}\"", columnName); sb.AppendTabAndFormat(tab1, "ItemsSource=\"{{Binding {0}DataSource}}\"/>", columnName); return(sb.ToString()); } if (columnType == "DataGridForeignKeyColumn") { var tab1 = baseTab + Constant.Tab; var tab2 = tab1 + Constant.Tab; var sb = new StringBuilder(); sb.AppendLineExWithTabAndFormat(baseTab, "<SimpleDataGrid:{0}{1}{2}", columnType, header, width); if (string.IsNullOrEmpty(tabStop) == false) { sb.AppendLineExWithTabAndFormat(tab1, "SimpleDataGrid:DataGridColumnAttachedProperty.IsTabStop=\"False\""); } sb.AppendLineExWithTabAndFormat(tab1, "Binding=\"{{Binding {0}}}\"", columnName); sb.AppendLineExWithTabAndFormat(tab1, "DisplayTextBinding=\"{{Binding {0}Navigation.DisplayText}}\">", columnName); sb.AppendLineExWithTabAndFormat(tab1, "<SimpleDataGrid:{0}.PopupView>", columnType); sb.AppendLineExWithTabAndFormat(tab2, "<view:{0}View KeepSelectionType=\"KeepSelectedValue\"/>", columnSetting.DbColumn.ForeignKeyTableName); sb.AppendLineExWithTabAndFormat(tab1, "</SimpleDataGrid:{0}.PopupView>", columnType); sb.AppendTabAndFormat(baseTab, "</SimpleDataGrid:{0}>", columnType); return(sb.ToString()); } var readOnly = columnSetting.IsReadOnly ? " IsReadOnly=\"True\"" : ""; var binding = string.Format(" Binding=\"{{Binding {0}{1}, UpdateSourceTrigger=PropertyChanged}}\"", columnName, columnSetting.IsReadOnly ? ", Mode=OneWay" : ""); var customProperty = string.Empty; switch (columnSetting.DataGridColumnType) { case "DataGridTextColumnExt": case "DataGridDateColumn": case "DataGridCheckBoxColumnExt": break; case "DataGridRightAlignTextColumn": binding = string.Format(" Binding=\"{{Binding {0}, UpdateSourceTrigger=PropertyChanged, StringFormat=\\{{0:N0\\}}{1}}}\"", columnName, columnSetting.IsReadOnly ? ", Mode=OneWay" : ""); break; } return(string.Format("{0}<SimpleDataGrid:{1}{2}{3}{4}{5}{6}{7}/>", baseTab, columnType, width, header, tabStop, readOnly, binding, customProperty)); }