Book a Demo

Author Topic: How to center objects in Diagrams  (Read 5720 times)

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
How to center objects in Diagrams
« on: February 25, 2012, 12:58:18 am »
Hi @all
I using the functionalities to select diagramLinks and diagramObjects on diagrams.
But what i still need is the possibility to center the diagram on the currently selected diagramLink or diagramObject so the selected objects are always visible for the user.

Any ideas how this can be achieved?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to center objects in Diagrams
« Reply #1 on: February 25, 2012, 02:38:07 am »
You mean you have a couple of elements and want the window to be focused so the appear "in the middle"? I don't get exactly what you want.

q.

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: How to center objects in Diagrams
« Reply #2 on: February 25, 2012, 03:14:41 am »
i have an object on a diagram (e.g a selected uml class)
and this object should appear in the middle of the screen.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to center objects in Diagrams
« Reply #3 on: February 25, 2012, 03:56:16 am »
I guess in this case you need to do the same awkward thing I suggested in your other thread: simulate a point and click. Or maybe there's some other strange way to manipulate windoze handles. EA doesn't offer it.

q.

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: How to center objects in Diagrams
« Reply #4 on: February 25, 2012, 08:48:10 pm »
i dont see any possibilty to achieve this with simulated mouseclicks.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to center objects in Diagrams
« Reply #5 on: February 26, 2012, 01:27:34 am »
I'm not a windozer but I once used a tool which led me through all these windoze handles. (Sorry, I don't remember the name. Maybe it was part of the psutil package?) So somehow it must be possible to get these and (most likely?) to manipulate them. I'd expect some method ScrollVert/Hor to be called which will send an event to the owner (EA) doing the actual window scroll/rebuild. But thats just speculation. And finally it is what I said: awkward!

Probably the better way is to ask Sparx for some API extension.

q.

[edit:] By coincidence I found the tool again. It is called WinSpy and you can google for it.
« Last Edit: March 06, 2012, 01:20:52 am by qwerty »

stao

  • EA User
  • **
  • Posts: 137
  • Karma: +0/-0
    • View Profile
Re: How to center objects in Diagrams
« Reply #6 on: September 02, 2012, 04:27:19 am »
I have a "solution" for that (expect some dirty stuff ;)).
EA has the functionality inside (Select a diagramObject and press CTRL + U).

Im using simulated keyboard presses to use this functionality from c#.
Problem 1: if the selected Object is on more than one diagrams (or Objects which has the selected object as as Classifier) a window is opened in EA to select the diagram to be opened.

For my case i only need diagrams where the real object is on and no classifiers. It seems that this EA window is sorted so that the "real object diagrams" are always the last items in the list.

So the solution would be to send a sufficient number of "page down" keys from c# to reach the end of the list and then send enter ;)

if there are cases where the desired diagram is not at the end im finished :)

Framework to send Keyboard Keys and Mouse Clicks:

http://inputsimulator.codeplex.com/

Keys can be send like this

Code: [Select]
KeyboardSimulator kSim = new KeyboardSimulator();
kSim.KeyDown(VirtualKeyCode.LCONTROL);
kSim.KeyPress(VirtualKeyCode.VK_U);
kSim.KeyUp(VirtualKeyCode.LCONTROL);