Hi all,
I'm creating a screen in EA using automation with several associated UI controls. That works fine.
Now I want to create a new diagram and add both the screen and associated UI controls. The screen is added just fine. However, the controls are visible UNDER the screen until I either move or resize the screen. As soon as I do that, the controls disappear. However, they are still "on" the diagram because if I try to drag them back on from the project browser in EA, I get an error message that they are already on the diagram.
Any thoughts on why the controls are disappearing once the screen is touched? Here's a code snippet:
private void CreateEADiagram(EA.Repository rep, EA.Package pack, UIForm form, List<UIControl> controls)
{
StringBuilder pos = new StringBuilder();
EA.Diagram diagram = (EA.Diagram)pack.Diagrams.AddNew(form.Name, "Logical");
diagram.Update();
// Format for AddNew first parameter: "l=200;r=400;t=200;b=600;"
pos.AppendFormat("l={0};r={1};t={2};b={3}", new object[] { 0, form.Size.X, 0, form.Size.Y });
EA.DiagramObject diagObj = (EA.DiagramObject)diagram.DiagramObjects.AddNew(pos.ToString(), "");
diagObj.ElementID = rep.GetElementByGuid(form.EaGuid).ElementID;
diagObj.Update();
diagram.Update();
foreach (UIControl ctl in controls)
{
if (ctl.EaGuid != null)
{
int l = ctl.Position.Left;
int r = l + ctl.Position.Width;
int t = ctl.Position.Top;
int b = t + ctl.Position.Height;
pos = new StringBuilder();
pos.AppendFormat("l={0};r={1};t={2};b={3}", new object[] { l, r, t, b });
diagObj = (EA.DiagramObject)diagram.DiagramObjects.AddNew(pos.ToString(), "");
diagObj.ElementID = rep.GetElementByGuid(ctl.EaGuid).ElementID;
diagObj.Update();
}
diagram.Update();
}
rep.OpenDiagram(diagram.DiagramID);
}