Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Query about zoom-out (Read 5249 times)
harshal
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Feb 16th, 2009
Query about zoom-out
Mar 12th, 2009 at 1:07pm
Print Post  
Hi,

We are using wpfDiagram as a user control in a container with its "Stretch" horizontal & vertical alignment value. For current example the size of container/diagram is "300 x 300" and diagram's "ShowGrid" property is true.

We have handled the zoom-in and zoom-out on the mouse wheel event. Following is the code for that
Code
Select All
private void OnDiagramMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (e.Delta < 0)
                diagram.ZoomFactor = Math.Max(10, diagram.ZoomFactor - 15);
            else
                diagram.ZoomFactor = Math.Min(500, diagram.ZoomFactor + 15);
        }

 



We are facing some problem while zooming out the diagram.
1) When we zoom-out the diagram (from 100% to 10%) the size of diagram gets shrink along with its element. Mouse wheel events are handled only in the document's visible area (ruler = 300 x 300). When the diagram has zoom value 100% the document's visible area is equal to diagram's client area but when zoom(zoom-out) is set to 10%, document's visible are is reduces and most of the diagram's client area looks blank(unused space).
We are not getting the mouse wheel events on this diagram's blank client area.
Actually user has to go or place the mouse to that 10% diagram area to do zoom-in/zoom-out. How can this be avoided?

2) How can we make the size of document's visible area equal to diagram's client area so that on 10% zoom-out we should see the (visible area) Grids in whole client area?
Actually what we want that for any zoom-out value the diagram's visible area should be equal to diagram's client area i.e. if "ShowGrid" property is true then grids should be there for any zoom-out value even for negative ruler values.

The ultimate requirement is that user need not be worried about placing the mouse in the 10% visible area when it is present in diagram's client to do zoom-in/out and whole client area should be filled with the document's visible area.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Query about zoom-out
Reply #1 - Mar 12th, 2009 at 1:24pm
Print Post  
Hi,

1. You could handle the MouseWheel or PreviewMouseWheel event of the container control.

2. You can't. At this time the diagram's client area is always equal to its Bounds, scaled for the ZoomFactor.

Stoyan
  
Back to top
 
IP Logged
 
harshal
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Feb 16th, 2009
Re: Query about zoom-out
Reply #2 - Mar 12th, 2009 at 1:58pm
Print Post  
Thank you for your reply.

2) - Up to when this feature will be added?
- What could be the alternative solution for this? (like dynamically set the Bounds of diagram to fit the whole client area) It will be appreciate if you can share any sample program for the same.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Query about zoom-out
Reply #3 - Mar 13th, 2009 at 6:51am
Print Post  
If you know what's the size of the container, you could set diagram.Bounds = diagram.ClientToDoc(clientRect) after changing ZoomFactor.
  
Back to top
 
IP Logged
 
anurodhora
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Query about zoom-out
Reply #4 - Mar 14th, 2009 at 9:54am
Print Post  
Hi,

On the same line, I too have some problems:

1) We have a diagram with ruler on

The above code is there to take care of clipping of diagram items. Say we are adding two nodes on the diagram with wpfpoint (200,-80) and (400,100) respectively. In this case you will not see the first node. i do not know why but it should have worked

Any suggestion on above.

The workaround we did was to set:
diagram.ResizeToFitItems(20);

but doing above is resizing the diagram area to fit items but we need diagram to fill whole client area always like ruler is doing.

How to achieve above?

2) When we zoom-in/out with say mouse wheel the diagram elements should always be in center of diagram.In our case on zoom-out the elements seems to get to the top left corner of the diagram if we set diagram.Bounds = diagram.ClientToDoc(clientRect)

what to do in this case?

3) It would be good if we have a feature to adjust diagram's client area to fill client area on zoom-in/out.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Query about zoom-out
Reply #5 - Mar 15th, 2009 at 11:50am
Print Post  
Hi,

1) You could set diagram.Bounds to the union of diagram.Bounds and diagram.GetContentBounds().

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

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: Query about zoom-out
Reply #6 - Mar 16th, 2009 at 11:59am
Print Post  
Hi Stoyo,

Thank you very much for reply.

For 1) Please elaborate we are still getting the same issue.

For 2) can you convert the following code as per wpfDiagram:

private void diagramView_MouseWheel(object sender, MouseEventArgs e)
{
Point p = diagramView.PointToClient(Cursor.Position);
PointF oldcurpos = diagramView.ClientToDoc(p);

diagramView.ZoomFactor += e.Delta / 60f;

PointF newcurpos = diagramView.ClientToDoc(diagramView.PointToClient(Cursor.Position));
float diffx = (oldcurpos.X - newcurpos.X);
float diffy = (oldcurpos.Y - newcurpos.Y);

diagramView.ScrollTo(
diagramView.ScrollX + diffx < 0 ? 0 : diagramView.ScrollX + diffx,
diagramView.ScrollY + diffy < 0 ? 0 : diagramView.ScrollY + diffy);
}

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Query about zoom-out
Reply #7 - Mar 16th, 2009 at 1:49pm
Print Post  
Hi Anurodh,

This seems to work:

Code
Select All
private void OnDiagramMouseWheel(object sender, MouseWheelEventArgs e)
{
	e.Handled = true;
	Point p = e.GetPosition(Parent as ScrollViewer);
	Point oldcurpos = diagram.ClientToDoc(p);

	diagram.ZoomFactor += e.Delta / 60;

	Point newcurpos = diagram.ClientToDoc(e.GetPosition(Parent as ScrollViewer));// diagram.ClientToDoc(e.GetPosition(diagram));
	double diffx = (oldcurpos.X - newcurpos.X);
	double diffy = (oldcurpos.Y - newcurpos.Y);

	diagram.ScrollTo(new Point(
	diagram.ScrollX + diffx < 0 ? 0 : diagram.ScrollX + diffx,
	diagram.ScrollY + diffy < 0 ? 0 : diagram.ScrollY + diffy));
}
 



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


I love YaBB 1G - SP1!

Posts: 103
Joined: Jan 19th, 2009
Re: Query about zoom-out
Reply #8 - Mar 17th, 2009 at 4:52am
Print Post  
Please suggest about
1) We have a diagram with ruler on 

Say we are adding two nodes on the diagram with wpfpoint (200,-80) and (400,100) respectively. In this case you will not see the first node. i do not know why but it should have worked

Any suggestion on above.

The workaround we did was to set:
diagram.ResizeToFitItems(20);

but doing above is resizing the diagram area to fit items but we need diagram to fill whole client area always like ruler is doing.

How to achieve above?

Could you please elaborate on your suggestion :
You could set diagram.Bounds to the union of diagram.Bounds and diagram.GetContentBounds().

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Query about zoom-out
Reply #9 - Mar 17th, 2009 at 9:52am
Print Post  
Rect diagBounds = diagram.Bounds;
Rect rect = diagram.GetContentBounds(false, false);

diagBounds.Union(rect);
diagram.Bounds = diagBounds;
           
diagram.ScrollTo(rect.TopLeft);
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint