Hi,
I got a problem when updating the size and position of DiagramObject using the API.
I have a Boundary object and that code works just fine. But then I try placing (for example an ArchiMate element). The same code will not move the element properly.
Attempt 1:
private void UpdateElementOnDiagram(
EAAPI.Diagram diagram, EAAPI.DiagramObject diagramObject,
int left, int right, int top, int bottom)
{
diagramObject.top = top;
diagramObject.left = left;
diagramObject.bottom = bottom;
diagramObject.right = right;
diagramObject.Update();
}
Attempt 2:
private void UpdateElementOnDiagram(
EAAPI.Diagram diagram, EAAPI.DiagramObject diagramObject,
int left, int right, int top, int bottom)
{
String styleString = diagramObject.Style.ToString();
String[] styleList = styleString.Split(';');
for (int nIndex = 0; nIndex < styleList.Count(); nIndex++) {
if (true == styleList[nIndex].Contains("l=")) {
styleList[nIndex] = String.Format("l={0}", left);
} else if (true == styleList[nIndex].Contains("r=")) {
styleList[nIndex] = String.Format("r={0}", right);
} else if (true == styleList[nIndex].Contains("t=")) {
styleList[nIndex] = String.Format("t={0}", top);
} else if (true == styleList[nIndex].Contains("b=")) {
styleList[nIndex] = String.Format("b={0}", left);
}
}
styleString = String.Join(";", styleList);
diagramObject.Style = styleString;
diagramObject.Update();
}
I also do the Diagram.Update()
Any ideas?
Thanks,
Eamonn J.