Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic TabbedDiagramView zoom & ruler problems... (Read 3329 times)
Sabrina C.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 35
Joined: Dec 20th, 2012
TabbedDiagramView zoom & ruler problems...
Feb 8th, 2013 at 11:09am
Print Post  
Hi,

I'm trying to figure how to:

1) add a ruler to a TabbedDiagramView

2) make a zoom to cursor working (i've already tried the code in the FractalLayout example) but the behaviour is not consistent at all when applied to a DiagramPage shown by the TabbedDiagramView

Bye, Agus
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TabbedDiagramView zoom & ruler problems...
Reply #1 - Feb 8th, 2013 at 12:57pm
Print Post  
Hi,

1. You will have to add a <diag:Ruler Document="{TemplateBinding SelectedContent}" />
to the template of the DiagramTabControl class. The sample project here shows that:
https://mindfusion.eu/_samples/TabbedView_Ruler.zip

2. This seems to work fine in my test:

Code
Select All
<diag:TabbedDiagramView PreviewMouseWheel="OnMouseWheel">

private void OnMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
	// zoom in or out at the mouse position
	var newZoom = tabbedDiagramView.CurrentPage.ZoomFactor + e.Delta / 60.0;
	if (newZoom > 5)
	{
		var zoomCenter = e.GetPosition(tabbedDiagramView.CurrentPage.DocumentPlane);
		tabbedDiagramView.CurrentPage.SetZoomFactor(newZoom, zoomCenter);
	}

	// stop the scrollviewer from scrolling
	e.Handled = true;
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Sabrina C.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 35
Joined: Dec 20th, 2012
Re: TabbedDiagramView zoom & ruler problems...
Reply #2 - Feb 8th, 2013 at 2:13pm
Print Post  
Great!

I did not thought about retemplating the TabbedDiagramView, a fine solution.

About the zoom, the problem was that I bound the Mouse Wheel delegate to the page and not to the TabbedeDiagramView, so the zoom behaviour was very weird.

Now It's fine.

Just another question. I've tried to serialize a custom class attached to the Tag property of a DiagramPage.
The class gets serialized in a Base64 format because it's decorated with the Serializable attribute


In the documentation you say that we can implement the ISerializable, but in my solution if I implement this interface, there is no way to serialize the class anymore (an exception is thrown on saving the XML).

Can you provide me with a working example of a custom class, bound to the Tag property of a DiagramPage, that get's correctly serialized as a XML string?

Bye, Agus
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TabbedDiagramView zoom & ruler problems...
Reply #3 - Feb 8th, 2013 at 2:27pm
Print Post  
You will need to handle SerializeTag and DeserializeTag events to save tag values to XML. You can find sample handlers in the SiteMap sample project.

Quote:
About the zoom, the problem was that I bound the Mouse Wheel delegate to the page and not to the TabbedeDiagramView, so the zoom behaviour was very weird.


Might happen because ScrollViewer scrolls by default, and you get the event only after that. In FractalLayout it does not scroll because of the <Scrollviewer Focusable="False"...> setting - wheel events are sent only to focused controls.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint