Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Problem whileDiagramZoomFactor change (Read 3931 times)
Bala
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 156
Joined: Apr 21st, 2009
Problem whileDiagramZoomFactor change
May 28th, 2009 at 1:41pm
Print Post  
Hi Stoyan,

You have seen a property window in my previous sent samples. I want to open that property window just beside the node i.e TopRight of the node should be TopLeft of the window.Its working well when zoomFactor of diagram is 100% but if zoomFactor is different it opens in some different places.How I can set its correct position even when zoomFactor changed.

I have used this code in my application.

Code
Select All
Point bottomRight = diagram.PointToScreen(new Point(sourceNode.Bounds.Right * diagram.ZoomFactor / 100,sourceNode.Bounds.Top * diagram.ZoomFactor / 100));
QuickProperties propertyWindow = new QuickProperties();
quickProperties = propertyWindow;
propertyWindow.Owner = Window.GetWindow(this);
propertyWindow.WindowStartupLocation = WindowStartupLocation.Manual;
propertyWindow.Left = point.X ;
propertyWindow.Top = point.Y ;
propertyWindow.Show(); 




Please give your valuable suggestion on this.

Thanks,
Bala
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem whileDiagramZoomFactor change
Reply #1 - May 29th, 2009 at 5:35am
Print Post  
Hi Bala,

Try this
Code
Select All
Point bottomRight = diagram.DocumentPlane.PointToScreen(
	new Point(sourceNode.Bounds.Right, sourceNode.Bounds.Top));
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Problem whileDiagramZoomFactor change
Reply #2 - May 30th, 2009 at 6:36am
Print Post  
Many thanks to you Stoyan Smiley
  
Back to top
 
IP Logged
 
harshal
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Feb 16th, 2009
Re: Problem whileDiagramZoomFactor change
Reply #3 - May 30th, 2009 at 2:16pm
Print Post  
Hi,

I have same type of problem. I want to show mini-toolbar on node selection for that I am giving nodes x and y position for its display location. It works fine for 100% zoom factor, but for other zoom value its position gets changing.

I tried above posted code, but still I am not getting correct points on change of zoom value.

The placement target for mini-toolbar is diagram and for its placement point it should have correct diagram points.

How can I get the correct diagram points for selected nodes regardless of zoom factor/value.

Thanks in advance.
Harshal
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem whileDiagramZoomFactor change
Reply #4 - Jun 1st, 2009 at 4:57am
Print Post  
Hi,

The code above gets the screen coordinates of a diagram point; are you assigning screen coordinates to the toolbar? If you need coordinates relative to the application's window, try calling the DocToClient method and adding to the result the diagram top-left position in the window. Or after getting the screen coordinates, call PointFromScreen to get ones relative to another UI element.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
harshal
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Feb 16th, 2009
Re: Problem whileDiagramZoomFactor change
Reply #5 - Jun 1st, 2009 at 3:31pm
Print Post  
Thanks for your quick reply.

I tried the suggested way but its not helping.

Let me explain the required scenario again.

On diagram's NODE click(mouse left button click), I want to show MiniToolBar(third-party control) on it.
To show mini tool bar, it requires
1) UIElement placementTarget
2) Point clientLocation

in placementTarget I am giving diagram instance and to Point "e.MousePosition.X,e.MousePosition.Y".
It works fine in 100% zoom factor but as zoom factor change it is not visible as its (location-co-ordinates)position getting changed.

I also tried following lines of code

Code
Select All
Point newPoint = diagram.DocumentPlane.PointFromScreen(new Point(e.MousePosition.X, e.MousePosition.Y));

Point newPoint = diagram.DocumentPlane.PointFromScreen(Mouse.GetPosition(sender as Diagram));
 



Please let know what should I give the UIElement and Point, so that for any zoom value toolbar will be visible in diagram above the node.

Thanks in advance.
Harshal
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem whileDiagramZoomFactor change
Reply #6 - Jun 1st, 2009 at 6:25pm
Print Post  
PointFromScreen would be useful if you pass a screen point to it, such as the "bottomRight" point from a few posts above.

Calling just Mouse.GetPosition(Diagram) should give you the correct result for the toolbar's location, as long as the toolbar is then positioned relatively to the diagram. If its coordinate are relative to the application's window or page, pass the window/page reference to Mouse.GetPosition.

Calling diagram.DocToClient(e.MousePosition) should also give you correct pixel coordinates relative to the diagram.
  
Back to top
 
IP Logged
 
harshal
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Feb 16th, 2009
Re: Problem whileDiagramZoomFactor change
Reply #7 - Jun 2nd, 2009 at 5:12am
Print Post  
Thanks a lot Stoyo.

With using Mouse.GetPosition(Diagram), I am getting correct position irrespective of zoom factor. Its working fine for any zoom value.

Again thanks a lot for your valuable inputs.

Thanks,
Harshal
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint