Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Some requirements (Read 5408 times)
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Some requirements
Mar 14th, 2009 at 10:10am
Print Post  
Hi,

Can you suggest me how to achieve following:

1) Magnifier Effect - Say we will be having a magnifier button in the toolbar clicking on that will change the diagram cursor (to +) and now if you draw a square on the diagram that area should then be displayed in center of the diagram with proper zooming.

Can anybody suggest the steps to achieve this.

2) We have a group of nodes all with Y values say 400 but when the application loads the user sees only diagram area with height (Y) 0 to 200 and thus has to scroll down to see the group so he may get a feeling that there is no node present on the diagram.
So we want whenever the diagram loads the diagram should adjust its coordinates according to diagram element position.
And we do not want diagram to resize as in ResizeToFitItems().

So what should be done here.

Thanks in advance,
Anurodh
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some requirements
Reply #1 - Mar 15th, 2009 at 11:44am
Print Post  
Hi,

1) Try this solution:
http://mindfusion.eu/Forum/YaBB.pl?board=fcnet_disc;action=display;num=122542302...

2) Call GetContentBounds, and scroll to the top-left of the returned rectangle.

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


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Some requirements
Reply #2 - Mar 16th, 2009 at 5:17am
Print Post  
Hi Stoyo,

Thanks for the reply.

for 1) Thanks your solution is working fine for magnifier but on few things we need your help

a) Clientarea that is magnifief should be displayed in the center of the diagram.
b) The rectangle that is displaying the area to zoom should be dashed line.
c) Want to change cursor to + sign when in magnify mode but the code is not working.

The code is:

public bool ZoomToRect
{
   get { return zoomToRect;}
   set {
zoomToRect= value;
if (zoomToRect)
{
      diagram.Behavior = Behavior.DrawShapes;
      diagram.Cursor = Cursors.Cross;
  }
     }
}

void diagram_NodeCreated(object sender, NodeEventArgs e)

{
ShapeNode node = e.Node as ShapeNode;
if (zoomToRect && node != null)
{
diagram.ZoomToRect(node.Bounds);
diagram.Nodes.Remove(node);
zoomToRect= false;
diagram.Behavior = Behavior.Modify;
    diagram.Cursor = Cursors.Arrow;
}
}


void diagram_InitializeNode(object sender, NodeEventArgs e)

{
ShapeNode node = e.Node as ShapeNode;
if (zoomToRect && node != null)
{
node.Shape = Shapes.Rectangle;
node.Pen = new Pen(Brushes.Black, 2);
node.Brush = new SolidColorBrush(Colors.Transparent);
node.Text = "select the area to zoom to";
}
}


for 2) i tried following code:

Rect rect = diagram.GetContentBounds(false, false);
diagram.ScrollTo(rect.TopLeft);

and on diagram we have nodes:
1) Node1 - (200, -80),
2) Node2 - (100, -40) and
3) Node3 - (400, 100).

Node2 and Node3 are linked.

But with above code also we are not able to see Node1 completely and Node2 is getting clipped off.
As earlier. please suggest what i am missing here.

Thanks,
Anurodh
« Last Edit: Mar 16th, 2009 at 11:56am by anurodhora »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some requirements
Reply #3 - Mar 16th, 2009 at 8:43am
Print Post  
Hi Anurodh,

If you set a breakpoint on the ScrollTo line, is rect.TopLeft equal to (100,-80)?

Stoyan
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Some requirements
Reply #4 - Mar 16th, 2009 at 11:39am
Print Post  
No, i am getting:
rect.TopLeft :{81.4409448818898,-88.5590551181102}
I am also following attached node method, but i don't think it will make any difference.

Thanks,
Anurodh
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Some requirements
Reply #5 - Mar 17th, 2009 at 1:56pm
Print Post  
Any updates on 1) Magnifier additional requirements and rect.TopLeft issue.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some requirements
Reply #6 - Mar 17th, 2009 at 2:02pm
Print Post  
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Some requirements
Reply #7 - Mar 17th, 2009 at 2:06pm
Print Post  
Thanks i will try this.

Please suggest on below too:

1) For your solution for magnifier we need your help on:

a) Clientarea that is magnifief should be displayed in the center of the diagram.
b) The rectangle that is displaying the area to zoom should be dashed line.

Thanks again,
Anurodh
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Some requirements
Reply #8 - Mar 27th, 2009 at 7:16am
Print Post  
Hi,

The magnifier code as suggested in this link is working fine. However i have following requirements to meet of which the first one is very important.

1) Calling zoomtorect should never get the diagram zoomfactor to more than 200.
After calling zoomtorect if i place a constraint that if zoomfactor>200 then zoomfactor=200 is getting the selected area out of view.
How should we modify our magnifier code (presented above in the thread) to do this?

2) Additional requirements:
a) Clientarea that is magnified should be displayed in the center of the diagram.
b) The rectangle that is displaying the area to zoom should be dashed line.

Thanks,
Anurodh
« Last Edit: Mar 27th, 2009 at 11:54am by anurodhora »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some requirements
Reply #9 - Mar 27th, 2009 at 2:18pm
Print Post  
Hi Anurodh,

When you detect that ZoomToRect makes the ZoomFactor greater than 200%, you could find the ratio of the new ZoomFactor value to 200, apply it to the rectangle you tried to zoom to, and call ZoomToRect again.

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


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Some requirements
Reply #10 - Mar 27th, 2009 at 2:41pm
Print Post  
Thanks for the reply.

Please explain, how to find the ratio and apply it to the rectangle.

diagram.ZoomToRect(node.Bounds);

if (diagram.ZoomFactor > 200)
{
// What to do here
}

Thanks,
Anurodh
« Last Edit: Mar 29th, 2009 at 5:28am by anurodhora »  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Some requirements
Reply #11 - Mar 30th, 2009 at 1:41pm
Print Post  
Please suggest something about this
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Some requirements
Reply #12 - Mar 30th, 2009 at 1:56pm
Print Post  
Try this

Code
Select All
diagram.ZoomToRect(r);

if (diagram.ZoomFactor > 200)
{
	Point ctPt = new Point(r.X + r.Width / 2, r.Y + r.Height / 2);
	if (diagram.Bounds.X < 0)
		ctPt.X += diagram.Bounds.X / 2;
	if (diagram.Bounds.Y < 0)
		ctPt.Y += diagram.Bounds.Y / 2;

	diagram.ZoomFactor = 200;

	Point size = diagram.ClientToDoc(new Point(scrollViewer.ViewportWidth, scrollViewer.ViewportHeight));
	Point newPt = new Point(ctPt.X - size.X / 2, ctPt.Y - size.Y / 2);

	if (newPt.X < 0)
		newPt.X = 0;
	if (newPt.Y < 0)
		newPt.Y = 0;

	diagram.ScrollTo(newPt);
}
 



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


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Some requirements
Reply #13 - Mar 31st, 2009 at 5:19am
Print Post  
Thanks a lot. Its working very well.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint