Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Version 4 beta (Read 1190 times)
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3303
Joined: Oct 19th, 2005
Version 4 beta
Oct 4th, 2023 at 10:49am
Print Post  
Version 4 of our WPF diagramming library contains the following new features and improvements -

Model / view separation
Diagram is now considered a model class and must be displayed inside DiagramView control. DiagramView contains a built-in ScrollViewer, so updating applications should be a matter of replacing old ScrollViewer with new DiagramView, and using zoom, scroll and behavior properties of the view class.

For compatibility with legacy code, Diagram still inherits from Control and can be used on its own for time being, but following new features are only available through the new DiagramView class. In addition, view-related properties of Diagram, such as ZoomFactor, Scroll position, Behavior, are now marked as obsolete and will display compile warnings when used.

UI virtualization
DiagramView and ContainerNode add UI elements to WPF visual tree only for diagram items they are currently visible in respective viewports. This should improve diagram's rendering / refresh speed.

Note that rendering speed improves only when showing a smaller part of the diagram inside DiagramView's viewport. Rendering a lot of items at small zoom levels or in overview's fit-all mode will still need a lot of processing, so you might want to apply constraints on minimal zoom level of diagram view and overview controls for large diagrams.

Spatial index
Set the EnableSpatialIndex property of Diagram to create an index of item positions for faster hit-testing and viewport clipping queries. When combined with UI virtualization, this should greatly improve user interaction and rendering speed for diagrams containing tens of thousands or more items.
Code
Select All
// create 20000 links + nodes in total
for (int i = 0; i < 10000; i++)
{
	var node = diagram.Factory.CreateShapeNode(x, y, size, size);
	node.Text = i.ToString();
	if (x > diagram.Bounds.Left)
	{
		diagram.Factory.CreateDiagramLink(
			diagram.Nodes[i - 1], diagram.Nodes[i]);
	}

	x += dist;
	if (x >= diagram.Bounds.Right)
	{
		x = diagram.Bounds.Left;
		y += dist;
	}
}

diagram.EnableSpatialIndex = true;
 


Multi-touch support
DiagramView handles WPF touch messages and implement multitouch gestures that can be controlled via following properties:
  • If MultiTouchZoom property is enabled (default), the view can be zoomed or panned using two-touch pinch / flick gestures.
  • If MultiTouchModify property is enabled (default), diagram nodes can be moved, scaled and rotated using two-touch pinch / flick gestures.
  • If MultiTouchZoom property is disabled, each touch draws diagram items corresponding to current behavior.
  • If MultiTouchModify property is disabled, each touch started from a node draws a diagram link.
  • Latter modes can be used for collaborative whiteboarding / classroom scenarios.
  • Setting MultiTouchDraw to false lets you prevent drawing multiple items simultaneously, while keeping other multitouch gestures enabled.
  • If MultiTouchDraw is enabled (default), a second touch will still cancel first-touch drawing if added within TouchGestureInterval time and TouchGestureDistance distance, and start a multi-touch gesture.
  • Additional Diagram.TouchHitDistance property makes it easier to grab adjustment handles on touch screens, without increasing the AdjustmentHandlesSize value.

Async serialization
Files can now be saved and loaded asynchronously. Async methods create a copy of the diagram to process it in a worker thread, and custom item classes must implement Clone method or copy constructor in order to serialize them as expected.
  • async SaveToXmlAsync and LoadFromXmlAsync methods of Diagram and DiagramDocument implement serialization in XML format.
  • async SaveToJsonFileAsync, SaveToJsonAsync, LoadFromJsonFileAsync, LoadFromJsonAsync methods of Diagram and DiagramDocument implement serialization in JSON format.

Miscellaneous
  • PageMoved and PageRenaming events added to TabbedDiagramView.
  • Different arrowhead shapes can be filled with distinct brushes as set through HeadBrush, BaseBrush and IntermediateBrush.
  • DiagramDocument JSON serialization methods.
  • Selectively prevent adding or removing child nodes to/from a container by handling the ContainerChildAdding and ContainerChildRemoving events.
  • FoldIconSize property added to ContainerNode.
  • Clone methods of Diagram and DiagramDocument return a copy of the diagram / document and its items.
  • Fix for ShapeNode.Clone not copying ImagePadding value.
  • Set GridPatternHatch and GridPatternThreshold to replace alignment grid with hatch pattern at low zoom levels for faster drawing.
  • More precise baseline alignment in exported SVG texts.
  • SvgNode parser now supports multiple class names in the "class" attribute of SVG elements.
  • Fixed CreateImage results when called with Windows display scaling enabled.

API changes
  • Diagram should now be hosted inside DiagramView. For time being it can still be used as a standalone control, but support for this will be removed in a future release.
  • Set Behavior, ZoomFactor, Scroll*, *ButtonActions properties of DiagramView instead of Diagram.
  • Instead of setting Document property of Overview to a Diagram instance, set its DiagramView property.
  • Instead of setting Document property of Ruler to a Diagram instance, set its DiagramView property. The latter is the default content property now. If you still need to show stand-alone diagram inside Ruler from Xaml, you must explicitly set it through <diag:Ruler.Document> tag.
  • For consistency with other MindFusion diagram libraries, DiagramNodeAdapter has been renamed to ControlNode. Its UIElement property has been renamed to Control.

If anyone is interested in trying the beta version, please download this archive containing updated assemblies, help file and sample projects -
https://mindfusion.eu/_beta/wpfdiag4.zip

Any comments, questions and general feedback are welcome.
« Last Edit: Nov 27th, 2023 at 11:10am by Slavcho »  
Back to top
 
IP Logged
 
nullable
Full Member
***
Offline


I Love MindFusion!

Posts: 112
Joined: Aug 25th, 2022
Re: Version 4 beta
Reply #1 - Jan 22nd, 2024 at 11:51am
Print Post  
Hello. Is there a possibility to disable virtualization for concrete diagrams as I render them in console application? These diagrams don't display items now.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3303
Joined: Oct 19th, 2005
Re: Version 4 beta
Reply #2 - Jan 22nd, 2024 at 12:26pm
Print Post  
Hi,

What do you mean by rendering from console application? DiagramView creates UIElements during its MeasureOverride, so if you are populating it without adding to WPF window, you might try explicitly calling view.Measure and view.Override with large enough values to cover all of diagram.Bounds. You should also be able to continue using Diagram instance as standalone control to avoid changes for your scenario.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
nullable
Full Member
***
Offline


I Love MindFusion!

Posts: 112
Joined: Aug 25th, 2022
Re: Version 4 beta
Reply #3 - Jan 22nd, 2024 at 12:45pm
Print Post  
By rendering in console application I do mean that there is no WPF window attached to the process. And also I don't use DiagramView, but still diagram items are not visible on diagram after the update.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3303
Joined: Oct 19th, 2005
Re: Version 4 beta
Reply #4 - Jan 22nd, 2024 at 3:10pm
Print Post  
In what way are you rendering diagram without window?
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint