Search
Document-View Architecture

MindFusion.Diagramming implements the Model-View-Controller (MVC) architectural pattern in its new version 5. The MVC design pattern as applied to MindFusion.Diagramming separates the diagram data (model) from its representation to the user (view) and controlling it by the user (controller).

Single Diagram Canvas

The Diagram class represents the diagram data model and provides operations to process the data. It exposes properties and methods for adding new diagram elements, finding and accessing existing elements, or removing them.

The DiagramView class presents the relevant data from the Diagram class by drawing on the screen using .NET GDI+. When the diagram is changed, the view automatically redraws the affected part of the image to reflect the changes. Multiple views can display the same diagram, set by their Diagram property. Each view can have a different zoom level and scroll position.

The DiagramView class also integrates the Controller part of the MVC, represented mostly by the view's Behavior property. That property specifies how GUI actions to manipulate the data should be interpreted.

Multiple Diagram Pages

The DiagramDocument class represents a collection of diagram pages or sheets, represented by DiagramPage objects. Document's pages are stored in its Pages collection. The SaveToXml and SaveToFile methods of DiagramDocument save all pages in a single file, and respectively the LoadFromXml and LoadFromFile methods load all pages from the file.

DiagramPage is derived from Diagram and only adds a few properties, so any code that processes Diagram objects will work with DiagramPage objects too. A diagram document forwards each event raised by its pages, giving you a chance to use the same handler for events raised by different pages. If a page should implement distinct user interaction or validation logic, it is also possible to attach handlers to the Diagram events inherited by DiagramPage.

A single DiagramPage could be assigned to the Diagram property of DiagramView, and that lets you create your own user interface for presenting a list of pages to the user and selecting a current page.

The library includes a TabbedDiagramView that presents all pages of a document in a tabbed user interface where each tab corresponds to a page. The page displayed in the active tab is exposed by the CurrentPage property of TabbedDiagramView. The active page can be changed interactively by activating its associated tab. New pages can be added and removed to / from the document through buttons in the tab strip and the pages can be rearranged by dragging their associated tabs with the mouse.

An alternative view for displaying DiagramDocument objects is the PagedDiagramView. It arranges all pages vertically and lets users scroll through them, while still providing navigation buttons at the bottom for changing pages, similar to the tabbed view.