private static AxFormGroupControl GetFilterGroup(string filterGroup = "FilterGroup",
                                                         string quickFilter = "QuickFilter")
        {
            var filterGrp = new AxFormGroupControl
            {
                Name    = filterGroup,
                Pattern = "CustomAndQuickFilters"
            };

            filterGrp.AddControl(new AxFormControl
            {
                Name = quickFilter,
                FormControlExtension = new AxFormControlExtension {
                    Name = "QuickFilterControl"
                }
            });
            return(filterGrp);
        }
示例#2
0
        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}; ");
        }
示例#3
0
        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;");
        }
        /// <summary>
        ///     Called when user clicks on the add-in menu
        /// </summary>
        /// <param name="e">The context of the VS tools and metadata</param>
        public override void OnClick(AddinDesignerEventArgs e)
        {
            try
            {
                var metaModelProviders = CoreUtility.ServiceProvider.GetService(typeof(IMetaModelProviders)) as IMetaModelProviders;
                var metaModelService   = metaModelProviders.CurrentMetaModelService;



                var form   = (IForm)e.SelectedElement;
                var axForm = (AxForm)form.GetMetadataType();


                switch (axForm.Design.Pattern)
                {
                case "SimpleList":
                case "ListPage":

                    axForm.Design.AddControl(new AxFormActionPaneControl {
                        Name = "MainActionPane"
                    });
                    axForm.Design.AddControl(GetFilterGroup());
                    axForm.Design.AddControl(new AxFormGridControl {
                        Name = "MainGrid"
                    });

                    break;


                case "DetailsMaster":

                    //<Main>
                    axForm.Design.AddControl(new AxFormActionPaneControl {
                        Name = "MainActionPane"
                    });
                    var myNavigationListGroup = new AxFormGroupControl {
                        Name = "NavigationListGroup"
                    };

                    // <NavigationListGroup>
                    myNavigationListGroup.AddControl(new AxFormControl
                    {
                        Name = "NavListQuickFilter",
                        FormControlExtension = new AxFormControlExtension {
                            Name = "QuickFilterControl"
                        }
                    });

                    myNavigationListGroup.AddControl(new AxFormGridControl {
                        Name = "MainGrid"
                    });
                    // </NavigationListGroup>

                    axForm.Design.AddControl(myNavigationListGroup);
                    var myPanelTab = new AxFormTabControl {
                        Name = "PanelTab"
                    };


                    var gridPanel = new AxFormTabPageControl {
                        Name = "GridPanel"
                    };
                    gridPanel.AddControl(GetFilterGroup("DetailsFilterGroup", "DetailsQuickFilter"));
                    gridPanel.AddControl(new AxFormGridControl {
                        Name = "DetailsGrid"
                    });
                    gridPanel.AddControl(new AxFormCommandButtonControl {
                        Name = "DetailsButtonCommand"
                    });

                    var detailsPanel = new AxFormTabPageControl {
                        Name = "DetailsPanel"
                    };

                    var titleGroup = new AxFormGroupControl {
                        Name = "TitleGroup"
                    };
                    titleGroup.AddControl(new AxFormStringControl {
                        Name = "HeaderTitle"
                    });

                    detailsPanel.AddControl(titleGroup);

                    var detailsPanelTab = new AxFormTabControl {
                        Name = "DetailsTab"
                    };
                    detailsPanelTab.AddControl(new AxFormTabPageControl {
                        Name = "DetailsTabPage"
                    });
                    detailsPanel.AddControl(detailsPanelTab);

                    myPanelTab.AddControl(detailsPanel);
                    myPanelTab.AddControl(gridPanel);
                    axForm.Design.AddControl(myPanelTab);
                    //</Main>

                    break;

                case "SimpleListDetails":
                    //<Main>
                    axForm.Design.AddControl(new AxFormActionPaneControl {
                        Name = "MainActionPane"
                    });
                    var myNavigationListGroup1 = new AxFormGroupControl {
                        Name = "NavigationListGroup"
                    };

                    // <NavigationListGroup>
                    myNavigationListGroup1.AddControl(new AxFormControl
                    {
                        Name = "NavListQuickFilter",
                        FormControlExtension = new AxFormControlExtension {
                            Name = "QuickFilterControl"
                        }
                    });
                    myNavigationListGroup1.AddControl(new AxFormGridControl {
                        Name = "MainGrid"
                    });
                    // </NavigationListGroup>

                    axForm.Design.AddControl(myNavigationListGroup1);

                    var detailsHeader = new AxFormGroupControl {
                        Name = "DetailsHeaderGroup"
                    };
                    axForm.Design.AddControl(detailsHeader);

                    var myPanelTab1 = new AxFormTabControl {
                        Name = "DetailsTab"
                    };

                    myPanelTab1.AddControl(new AxFormTabPageControl {
                        Name = "DetailsTabPage"
                    });
                    axForm.Design.AddControl(myPanelTab1);

                    //</Main>

                    break;
                }


                var model =
                    DesignMetaModelService.Instance.CurrentMetadataProvider.Forms.GetModelInfo(axForm.Name)
                    .FirstOrDefault();


                metaModelService.UpdateForm(axForm, new ModelSaveInfo(model));
            }

            catch (Exception ex)
            {
                CoreUtility.HandleExceptionWithErrorMessage(ex);
            }
        }