void DoFormCreate() { AxForm newForm = _axHelper.MetadataProvider.Forms.Read(FormName); if (newForm != null) { return; } newForm = new AxForm { Name = FormName }; AxMethod axMethod = new AxMethod(); axMethod.Name = "classDeclaration"; axMethod.Source = $"[Form]{Environment.NewLine}public class {newForm.Name} extends FormRun " + Environment.NewLine + "{" + Environment.NewLine + "}"; newForm.AddMethod(axMethod); string dsName = TableName; AxFormDataSourceRoot axFormDataSource = new AxFormDataSourceRoot(); axFormDataSource.Name = dsName; axFormDataSource.Table = TableName; axFormDataSource.InsertIfEmpty = NoYes.No; newForm.AddDataSource(axFormDataSource); //newForm.Design.Pattern = "SimpleList"; add apply pattern //newForm.Design.PatternVersion = "1.1"; newForm.Design.Caption = FormLabel; newForm.Design.TitleDataSource = dsName; newForm.Design.DataSource = dsName; newForm.Design.AddControl(new AxFormActionPaneControl { Name = "MainActionPane" }); var filterGrp = new AxFormGroupControl { Name = "FilterGroup", Pattern = "CustomAndQuickFilters", PatternVersion = "1.1" }; AxFormControlExtension quickFilterControl = new AxFormControlExtension { Name = "QuickFilterControl" }; AxFormControlExtensionProperty formControlExtensionProperty = new AxFormControlExtensionProperty(); formControlExtensionProperty.Name = "targetControlName"; formControlExtensionProperty.Type = CompilerBaseType.String; formControlExtensionProperty.Value = "MainGrid"; quickFilterControl.ExtensionProperties.Add(formControlExtensionProperty); filterGrp.AddControl(new AxFormControl { Name = "QuickFilter", FormControlExtension = quickFilterControl }); newForm.Design.AddControl(filterGrp); AxFormGridControl axFormGridControl = new AxFormGridControl { Name = "MainGrid", DataSource = dsName }; AxFormGroupControl overviewGroupControl = new AxFormGroupControl { Name = "Overview", DataGroup = "Overview", DataSource = dsName }; axFormGridControl.AddControl(overviewGroupControl); newForm.Design.AddControl(axFormGridControl); _axHelper.MetaModelService.CreateForm(newForm, _axHelper.ModelSaveInfo); _axHelper.AppendToActiveProject(newForm); AddLog($"Form: {newForm.Name}; "); }
void DoFormCreate() { AxForm newForm = _axHelper.MetadataProvider.Forms.Read(FormName); if (newForm != null) { throw new Exception($"Form {FormName} already exists"); } newForm = new AxForm { Name = FormName }; AxMethod axMethod = new AxMethod(); axMethod.Name = "classDeclaration"; axMethod.Source = $"[Form]{Environment.NewLine}public class {newForm.Name} extends FormRun " + Environment.NewLine + "{" + Environment.NewLine + "}"; newForm.AddMethod(axMethod); string dsName = TableName; AxFormDataSourceRoot axFormDataSource = new AxFormDataSourceRoot(); axFormDataSource.Name = dsName; axFormDataSource.Table = TableName; axFormDataSource.InsertIfEmpty = NoYes.No; newForm.AddDataSource(axFormDataSource); newForm.Design.Caption = FormLabel; newForm.Design.TitleDataSource = dsName; newForm.Design.DataSource = dsName; AxFormGroupControl filterGrp, detailsHeaderGroup; AxFormGridControl axFormGridControl; AxFormControlExtension quickFilterControl; AxFormControlExtensionProperty formControlExtensionProperty; AxFormGroupControl overviewGroupControl; AxFormTabControl formTabControl; switch (TemplateType) { case FormTemplateType.SimpleList: newForm.Design.AddControl(new AxFormActionPaneControl { Name = "MainActionPane" }); filterGrp = new AxFormGroupControl { Name = "FilterGroup", Pattern = "CustomAndQuickFilters", PatternVersion = "1.1" }; quickFilterControl = new AxFormControlExtension { Name = "QuickFilterControl" }; formControlExtensionProperty = new AxFormControlExtensionProperty(); formControlExtensionProperty.Name = "targetControlName"; formControlExtensionProperty.Type = CompilerBaseType.String; formControlExtensionProperty.Value = "MainGrid"; quickFilterControl.ExtensionProperties.Add(formControlExtensionProperty); filterGrp.AddControl(new AxFormControl { Name = "QuickFilter", FormControlExtension = quickFilterControl }); newForm.Design.AddControl(filterGrp); axFormGridControl = new AxFormGridControl { Name = "MainGrid", DataSource = dsName }; overviewGroupControl = new AxFormGroupControl { Name = GroupNameGrid, DataGroup = GroupNameGrid, DataSource = dsName }; axFormGridControl.AddControl(overviewGroupControl); newForm.Design.AddControl(axFormGridControl); break; case FormTemplateType.SimpleListDetails: newForm.Design.AddControl(new AxFormActionPaneControl { Name = "MainActionPane" }); filterGrp = new AxFormGroupControl { Name = "NavigationListGroup" }; quickFilterControl = new AxFormControlExtension { Name = "QuickFilterControl" }; formControlExtensionProperty = new AxFormControlExtensionProperty(); formControlExtensionProperty.Name = "targetControlName"; formControlExtensionProperty.Type = CompilerBaseType.String; formControlExtensionProperty.Value = "MainGrid"; quickFilterControl.ExtensionProperties.Add(formControlExtensionProperty); filterGrp.AddControl(new AxFormControl { Name = "NavListQuickFilter", FormControlExtension = quickFilterControl }); axFormGridControl = new AxFormGridControl { Name = "MainGrid", DataSource = dsName }; if (!string.IsNullOrWhiteSpace(GroupNameGrid)) { overviewGroupControl = new AxFormGroupControl { Name = GroupNameGrid, DataGroup = GroupNameGrid, DataSource = dsName }; axFormGridControl.AddControl(overviewGroupControl); } filterGrp.AddControl(axFormGridControl); newForm.Design.AddControl(filterGrp); detailsHeaderGroup = new AxFormGroupControl { Name = "DetailsHeaderGroup" }; detailsHeaderGroup.DataSource = dsName; detailsHeaderGroup.DataGroup = GroupNameHeader; newForm.Design.AddControl(detailsHeaderGroup); formTabControl = new AxFormTabControl { Name = "DetailsTab" }; List <string> listImp = new List <string>( TabLabels.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)); foreach (string lineImp in listImp) { string tabName = AxHelper.GetTypeNameFromLabel(lineImp) + "TabPage"; formTabControl.AddControl(new AxFormTabPageControl { Name = tabName, Caption = lineImp, DataSource = dsName }); } newForm.Design.AddControl(formTabControl); break; } _axHelper.MetaModelService.CreateForm(newForm, _axHelper.ModelSaveInfo); _axHelper.AppendToActiveProject(newForm); AddLog($"Form: {newForm.Name} - Restore it before use;"); }