private void LabelBox_Validated(object sender, EventArgs e)
 {
     if (String.IsNullOrWhiteSpace(FieldNameBox.Text) && !String.IsNullOrWhiteSpace(LabelBox.Text))
     {
         FieldNameBox.Text = AxHelper.GetTypeNameFromLabel(LabelBox.Text.Trim());
     }
 }
        public bool EnumLabelModified()
        {
            bool res = false;

            if (EnumName == "" && EnumLabel != "")
            {
                EnumName = AxHelper.GetTypeNameFromLabel(EnumLabel);
                res      = true;
            }
            return(res);
        }
        private List <AxEnumValue> GetAxEnumValues()
        {
            List <AxEnumValue> resList = new List <AxEnumValue>();

            List <string> listImp = new List <string>(
                EnumValuesStr.Split(new[] { Environment.NewLine },
                                    StringSplitOptions.RemoveEmptyEntries));

            bool isFirstElement = true;
            int  currentIndex   = EnumValueStartIndex;

            foreach (string lineImp in listImp)
            {
                string enumLabelLocal = "", enumNameLocal = "";

                if (lineImp.Contains(ValuesSeparator))
                {
                    List <string> listLineImp = new List <string>(
                        lineImp.Split(new[] { ValuesSeparator },
                                      StringSplitOptions.None));
                    enumLabelLocal = listLineImp[0].Trim();
                    enumNameLocal  = listLineImp[1].Trim();
                    if (enumLabelLocal == "" && enumNameLocal == "" && isFirstElement)
                    {
                        enumNameLocal = "None";
                    }
                }
                else
                {
                    enumLabelLocal = lineImp.Trim();
                    enumNameLocal  = AxHelper.GetTypeNameFromLabel(enumLabelLocal);
                    //enumNameLocal = textInfo.ToTitleCase(enumLabelLocal).Replace(" ", "");
                }

                isFirstElement = false;
                if (enumNameLocal != "")
                {
                    AxEnumValue enumValue = new AxEnumValue {
                        Label = enumLabelLocal, Name = enumNameLocal
                    };
                    enumValue.Value = currentIndex;
                    currentIndex++;
                    resList.Add(enumValue);
                }
                else
                {
                    break;
                }
            }
            return(resList);
        }
Exemple #4
0
        public void CalcResultName()
        {
            string res = "";

            res += ElementName;
            if (ElementType == ExtensionClassObject.Form ||
                ElementType == ExtensionClassObject.FormDataSource ||
                ElementType == ExtensionClassObject.FormDataField ||
                ElementType == ExtensionClassObject.FormControl)
            {
                res += "Form";
            }

            res += Prefix;

            if (ClassType == ExtensionClassType.Extension)
            {
                if (!string.IsNullOrWhiteSpace(SubElementName))
                {
                    res += "_" + AxHelper.GetTypeNameFromLabel(SubElementName);
                }
            }

            switch (ClassType)
            {
            case ExtensionClassType.Extension:
                res += "_Extension";
                break;

            case ExtensionClassType.EventHandler:
                res += "_EventHandler";
                break;
            }

            ResultClassName = res;
        }
        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;");
        }