Вопрос

I am using the following code to generate a diagram in Enterprise-Architect (Add-In with C#):

using EA;
...
public int AddDiagram(string name)
    {
        Package treeSelectedPackage = repository.GetTreeSelectedPackage();
        Diagram dgr = treeSelectedPackage.Diagrams.AddNew(name, "Extended::Requirements");
        dgr.Update();
        treeSelectedPackage.Diagrams.Refresh();
        treeSelectedPackage.Update();
        return dgr.DiagramID;
    }

repository is an EA.Repository-Object.

I am able to add elements to the diagram, but I need to turn on the display of tags/tagged values in the diagram. In Enterprise-Architect you enable it by:

right click in diagram -> Properties... -> Tab 'Elements' -> Show Compartments: Check 'Tags'

What do I have to add to the method above to enable this for a new diagram?

Это было полезно?

Решение

In the Diagram class, some of the diagram's properties are available for setting (eg ShowPackageContents), while others are not. The element tag property is one of the latter.

However, there are two additional attributes which encapsulate the other properties, StyleEx and ExtendedStyle, which correspond to the t_diagram table's StyleEx and PDATA columns, respectively. Both of these are read/write, but their contents are undocumented so there is no guarantee that the layout won't change from one version of EA to the next (although in practice you're safe since EA is typically very good at maintaining backward compatibility).

Each is on the form keyword=value;, where the value in most cases is 1 or 0 for true/false. The element tag property is in ExtendedStyle and is called ShowTags.

EA sets all these properties when the diagram is created, but you only want to change one. So what you need to do is create the diagram including the Update() call, do a search of ExtendedStyle, replacing ShowTags=0; with ShowTags=1;, and then call Update() again.

Другие советы

You might have to update the database, "ShowTags=0;" in t_diagram table, use repository.SQLQuery method

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top