Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic scroll the screen to node location (Read 4060 times)
madhan1
Full Member
***
Offline


FOLLOW NO ONE BUT LEARN
FROM EVERY ONE ..

Posts: 101
Location: India
Joined: Feb 17th, 2010
scroll the screen to node location
Jul 7th, 2012 at 6:04am
Print Post  
Dear stoyan,

            when i click the link i want to move my screen to the Node location.  i have return the following code.
      
             ShapeNode destination =(ShapeNode) e.Link.Destination;
            
            diagramView.ScrollTo(destination.Bounds.X, destination.Bounds.Y);

this scroll the diagramview up to the left edge.

kindly advise me.
  

if you want something then go and grab it
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: scroll the screen to node location
Reply #1 - Jul 9th, 2012 at 8:36am
Print Post  
This will center the link's destination in the view:

Code
Select All
PointF destCenter = e.Link.Destination.GetCenter();
SizeF viewportSize = diagramView.ClientToDoc(
	diagramView.ClientRectangle).Size;
diagramView.ScrollTo(
	destCenter.X - viewportSize.Width / 2,
	destCenter.Y - viewportSize.Height / 2); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
madhan1
Full Member
***
Offline


FOLLOW NO ONE BUT LEARN
FROM EVERY ONE ..

Posts: 101
Location: India
Joined: Feb 17th, 2010
Re: scroll the screen to node location
Reply #2 - Jul 10th, 2012 at 4:54am
Print Post  
Thanks stayon,

                    i want to move my cursor also to move that place.if possible i want to move the cursor over the link.
  

if you want something then go and grab it
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: scroll the screen to node location
Reply #3 - Jul 10th, 2012 at 7:08am
Print Post  
You will have to use the win32 SetCursorPos function, which takes screen coordinates:

[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);

You can convert from diagram to screen coordinates by calling the view's DocToClient and PointToScreen methods.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
madhan1
Full Member
***
Offline


FOLLOW NO ONE BUT LEARN
FROM EVERY ONE ..

Posts: 101
Location: India
Joined: Feb 17th, 2010
Re: scroll the screen to node location
Reply #4 - Jul 10th, 2012 at 10:34am
Print Post  
Dear stoyan,

i have follow this code

PointF p=new PointF(destination.Bounds.X,destination.Bounds.Y);
            Point p1 = new Point(diagramView.DocToClient(p).X, diagramView.DocToClient(p).Y);
            Point p2=  PointToScreen(p1);
         

            SetCursorPos(p2.X, p2.Y);

is it correct method
  

if you want something then go and grab it
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: scroll the screen to node location
Reply #5 - Jul 10th, 2012 at 10:55am
Print Post  
Currently you are calling the form's PointToScreen method. You should call diagramView.PointToScreen(), since p1 is relative to the view:

Code
Select All
PointF p = destination.Bounds.Location;
Point p1 = diagramView.DocToClient(p);
Point p2 = diagramView.PointToScreen(p1);

SetCursorPos(p2.X, p2.Y); 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
madhan1
Full Member
***
Offline


FOLLOW NO ONE BUT LEARN
FROM EVERY ONE ..

Posts: 101
Location: India
Joined: Feb 17th, 2010
Re: scroll the screen to node location
Reply #6 - Jul 10th, 2012 at 12:19pm
Print Post  
Thanks a lot stoyan
  

if you want something then go and grab it
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint