Skip to content
Howard Mansell edited this page Dec 9, 2013 · 3 revisions

Notes on code structure

VisInt.fsx

This script is in the VizInt.View directory and is used to start the visualizer. It creates an instance of the model and view and adds the model as a PrintTransformer for FSI, which is used as a mechanism to notify it that some new value might exist.

This script calls WPFEventLoop.fsx to install a WPF event loop, which is required for you to be able to show WPF windows (and properly process events) within FSI.

VizInt.Model

This contains the "model", which is basically a collection of ScopeEntry instances. ScopeEntry is so called because this was originally called "FSIScope". The Entry contains the static type, value and the state of its expander (open/closed/unset).

The Model takes care of scanning for variables in the FSI session. This code is borrowed (with permission) from FsEye.

It exposes an ObservableCollection which notifies the view of new entries in the list.

VizInt.View

This should probably be split up a bit..

View.xaml/.cs contain the main window definition. In the constructor this calls Bootstrapper.Prepare to add the dynamically loaded plugin stuff. In the XAML we have some direct usage of DataTemplates, but generally the idea is that plugins for particular types are used to render them.

Bootstrapper.cs loads MEF plugins (using DirectoryCatalog) named Visualizer.dll and uses them to provide plugins for the ComponentTemplateSelector.cs.

ComponentResourceLoader.cs loads exported resource dictionaries from plugins and merges them into one.

ComponentTemplateSelector.cs is a template selector, used in View.xaml, that finds the right data template for the given object that we are trying to visualize. It does it by asking each plugin if it can render the object.

DeedleHelpers.cs contains some stuff for wrapping Deedle frames so they can be visualized, but I had to rip out the actual view for the visualizer because it uses a commercial grid. Should probably be in a Deedle specific plugin.

ICanRender.cs is the interface that MEF plugins use to export themselves.

Resizer.cs allows visualizers in the view to be resized by the user.

RSymbolicExpressionConverter.cs converts values from the RProvider into their equivalent .NET types in order to visualize them. So, if you have the Deedle RProvider plugin and you have a SymbolicExpression that is an R data.frame, it will get converted to a Deedle frame, and then the visualizer for a Deedle frame will be used to visualize it. Pretty cool!

TypeUtils.cs is used to format a nice typename for the display.

ValueToSummaryConverter.cs is used to format the summary line of an item. For example, for a Deedle frame it will show the number of rows and the list of column names, even when the display of the frame is collapsed.

Clone this wiki locally