Book a Demo

Author Topic: How to move DiagramObjects  (Read 4131 times)

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
How to move DiagramObjects
« on: November 06, 2010, 12:10:44 am »
Hi

I would like to move a couple of diagram objects on a diagram
My attempt to do so looks as follows:

private static void MakeRoom(Diagram diagram, Rectangle rect)
{
    DiagramObject[] objectsToMove = (from DiagramObject dgobj in diagram.DiagramObjects
                                        where dgobj.left < rect.Right
                                        select dgobj).ToArray();

    foreach (DiagramObject dgObject in objectsToMove)
    {
        dgObject.top -= rect.Height + 10;
        dgObject.bottom -= rect.Height + 10;
        dgObject.Update();                
    }
    diagram.Update();
}

In my case I receive 3 diagram object as a result of the LINQ statement, but changing top and buttom properties of them does not result in a move on the diagram.

What is wrong with my code?

Thanks for help and hints.

Regards
Rainer

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: How to move DiagramObjects
« Reply #1 on: November 06, 2010, 08:31:23 am »
do you reload the diagram?
like this:
repository.ReloadDiagram(actDiag.DiagramID);

stao

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: How to move DiagramObjects
« Reply #2 on: November 06, 2010, 06:13:06 pm »
Hi Stao,

thanks for the hint. That was it.

Regards
Rainer

mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: How to move DiagramObjects
« Reply #3 on: November 08, 2010, 09:18:33 am »
The dependancy on reloading the diagram to see the changes made to diagram objects should hopefully be removed in the next major release. Diagram Objects will have their style and position automatically applied in the UI when Update() is called on the DiagramObject object.
Best Regards,

Michael

[email protected]
"It is more complicated than you think." - RFC 1925, Section 2.8

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to move DiagramObjects
« Reply #4 on: November 08, 2010, 05:27:26 pm »
That would be a nice improvement.

Geert

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: How to move DiagramObjects
« Reply #5 on: November 08, 2010, 08:14:05 pm »
Yes, that would be great!

Regards
Rainer