Hi,
I'm trying to create a UI screen along with its associated UI controls through automation and place them on a new diagram. The controls are created just fine, but when I build the diagram, they seem to be "behind" the screen. If I select them in the Project Browser and do "Locate in current diagram" I can see the arrow-shaped grab bar for the UI control in question, but he UI control itself remains hidden.
I can see no way in the API to change the Z-Order of the controls on the diagram, though I add them to the diagram in a way that seems logical... first I create the screen, then add the screen to the diagram, then create the first UI control, then add it to the diagram, then create the second UI control, ...
I'm using EA 6.5.805.
This is reproducable with a small sample app:
namespace Canonic.EAPlugin.DocumentParser
{
class Testbed
{
public void MakeScreen(EA.Repository rep)
{
EA.Package pack = rep.GetTreeSelectedPackage();
EA.Diagram diag = (EA.Diagram)pack.Diagrams.AddNew("Test UI Diagram", "Logical");
diag.Update();
EA.Element screen = (EA.Element)pack.Elements.AddNew("My Test Screen", "Screen");
pack.Update();
screen.Notes = "My Notes";
screen.Update();
string screenPosition = "l=100;t=100;r=600;b=700";
EA.DiagramObject diagObjScreen =
(EA.DiagramObject)diag.DiagramObjects.AddNew(screenPosition, "");
diagObjScreen.ElementID = screen.ElementID;
diagObjScreen.Update();
CreateControl(screen, diag, "Label One", "label", 110, 200, 110, 120);
CreateControl(screen, diag, "Textbox One", "textbox", 210, 300, 110, 120);
CreateControl(screen, diag, "Label One", "label", 110, 200, 210, 220);
CreateControl(screen, diag, "Textbox One", "textbox", 210, 300, 210, 220);
CreateControl(screen, diag, "Button One", "button", 150, 180, 300, 320);
}
private void CreateControl(EA.Element screen, EA.Diagram diag, string name, string stereotype,
int l, int r, int t, int b)
{
EA.Element ctl = null;
ctl = (EA.Element)screen.Elements.AddNew(name, "UI Control");
screen.Update();
ctl.Stereotype = stereotype;
ctl.Update();
StringBuilder sb = new StringBuilder();
sb.AppendFormat("l={0};r={1};", l, r).AppendFormat("t={0};b={1};", t, b);
string controlPosition = sb.ToString();
EA.DiagramObject diagObjCtl =
(EA.DiagramObject)diag.DiagramObjects.AddNew(controlPosition, "");
diagObjCtl.ElementID = ctl.ElementID;
diagObjCtl.Update();
diag.Update();
}
}
}
Thanks!
Eric