Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: bakawakalaka on May 24, 2019, 11:07:02 pm

Title: create a form that is centered relative to EA window
Post by: bakawakalaka on May 24, 2019, 11:07:02 pm
Hi, I created Add-in that show form with some data. I want this form shown in the center of EA winodws, but I can't find any information of how to do it. Is there any way to do so?
Title: Re: create a form that is centered relative to EA window
Post by: Geert Bellekens on May 24, 2019, 11:14:59 pm
Yes you can.

You have to pass the main window of EA as parent in the operation ShowDialog()

usage:

Code: [Select]
        private void startImportMapping()
        {
            var importDialog = new ImportMappingForm();
            var selectedElement = this.model.selectedElement as TSF_EA.Element;
            if (selectedElement is UML.Classes.Kernel.Class
                || selectedElement is UML.Classes.Kernel.Package)
            {
                importDialog.sourcePathElement = selectedElement;
                importDialog.targetPathElement = this.findTarget(selectedElement);
            }
            importDialog.ImportButtonClicked += this.importMapping;
            importDialog.SourcePathBrowseButtonClicked += this.browseSourcePath;
            importDialog.TargetPathBrowseButtonClicked += this.browseTargetPath;
            importDialog.ShowDialog(this.model.mainEAWindow);
        }

for the property mainEAWindow see https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework/blob/master/EAAddinFramework/EAWrappers/Model.cs (https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework/blob/master/EAAddinFramework/EAWrappers/Model.cs)

Geert