Integrating NOV in Mac with Visual Studio Code
In This Topic
Nevron Open Vision (NOV) can be integrated in Mac application projects. This topic provides a step-by-step tutorial on how to achieve this. This guide is for Visual Studio Code with the C# DevKit plugin.
Download and Install NOV
Download the NevronOpenVision.Mac package.
After you install the package go to Applications and launch Nevron Open Vision. The application has the following UI items:
- Start NOV Examples App - when pressed it will launch the NOV examples for Mac.
- Open NOV Examples Project - when pressed it will launch "Finder" and open the NOV Examples folder. Open this folder in Visual Studio Code and then open the NOV Examples solution from Visual Studio Code: "Nevron.Nov.Examples.Mac.sln.
- Open NOV Binary Files - when pressed it will launch "Finder" and open the NOV Bin folder, which contains the redistributable dlls of NOV for Xamarin Mac.
- View NOV Documentation - when pressed it will launch your default browser and open the NOV online documentation.
Below those buttons you can also view the generated machine id and the current evaluation key.
- Machine Id - contains the current machine id. This machine id is used to generate a development license key - see Activation for more details.
- License Key(s) - contains the license key currently applied on the examples. At install time the NOV installation will automatically generate a 60 days trial evaluation key which you can also use in your projects for testing.
Create a NOV Mac Application
- Download and extract the NovMacApp project template
The easiest way to create a Mac Application that uses Nevron Open Vision (NOV) is to use the NovMacApp project template. Click here to download the NovMacApp project. If the project doesn't extract automatically after downloading it, extract it. Move the "NovMacApp" folder to a location of your choice.
- Open the project in Visual Studio Code
Open the folder of the NovMacApp project with Visual Studio Code and the C# Dev Kit should then automatically open the "NovMacApp" solution and project in its Solution Explorer.
-
Fix the NOV references
Double-click the "NovMacApp" C# project in the Solution Explorer and edit the paths to the NOV DLLs. You can reference the dlls directly from the "System/Applications/NevronOpenVision.Mac/Contents/Bin" folder or copy those dlls to a folder, which is more convenient for referencing. Following is a list of the NOV DLLs:
- Nevron.Nov.Presentation.dll - core NOV assembly. Contains common NOV UI widgets like labels, buttons, drop downs, menus, toolbars, ribbon, etc.
- Nevron.Nov.Host.Mac.dll - NOV presentation host for macOS.
- Nevron.Nov.Barcode - barcode component.
- Nevron.Nov.Chart - chart component.
- Nevron.Nov.Diagram - diagram component. Requires the Barcode, Text and Grid components.
- Nevron.Nov.Grid - grid component.
- Nevron.Nov.Schedule - schedule component. Requires the Barcode component.
- Nevron.Nov.Text - rich text component. Requires the Barcode component.
- Nevron.Nov.RoslynCompilerService - add this reference if you plan to use diagram shapes with code-behind like family tree shapes.
- Build the solution
Right-click the solution in the Solution Explorer and select "Build" to build it.
- Run the application
Open the "Run" menu of Visual Studio Code and select "Run Without Debugging" to run the application. A window with a label saying "Hello from Nevron Open Vision!" should open.
-
Modify the application
To modify the application, open the "MainWindow.cs" file and change the code in the CreateNovContent() method of the MainWindow class.
Take a look at the "User Interface", "Chart", "Diagram", "Rich Text Editor" and the other chapters for information on how to create and configure specific NOV widgets. For example, the following code creates a simple chart:
Insert the following usings in "MainWindow.cs" |
Copy Code
|
using Nevron.Nov.Chart;
using Nevron.Nov.Graphics;
|
Create a simple NOV Chart |
Copy Code
|
private NWidget CreateNovContent()
{
NChartView chartView = new NChartView();
// Create a cartesian chart
chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian);
// Set the title
chartView.Surface.Titles[0].Text = "Bar Chart";
// Configure the chart
NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];
// Add an interlace stripe
NLinearScale linearScale = chart.Axes[ENCartesianAxis.PrimaryY].Scale as NLinearScale;
NScaleStrip strip = new NScaleStrip(new NColorFill(ENNamedColor.Beige), null, true, 0, 0, 1, 1);
strip.Interlaced = true;
linearScale.Strips.Add(strip);
// Setup a bar series
NBarSeries bar = new NBarSeries();
bar.Name = "Bar Series";
bar.InflateMargins = true;
bar.UseXValues = false;
bar.Shadow = new NShadow(NColor.LightGray, 2, 2);
// TODO: Add chart data
bar.LegendView.Mode = ENSeriesLegendMode.DataPoints;
bar.DataPoints.Add(new NBarDataPoint(18, "C++"));
bar.DataPoints.Add(new NBarDataPoint(15, "Ruby"));
bar.DataPoints.Add(new NBarDataPoint(21, "Python"));
bar.DataPoints.Add(new NBarDataPoint(23, "Java"));
bar.DataPoints.Add(new NBarDataPoint(27, "JavaScript"));
bar.DataPoints.Add(new NBarDataPoint(29, "C#"));
bar.DataPoints.Add(new NBarDataPoint(26, "PHP"));
chart.Series.Add(bar);
// Configure the X axis to show the language names
string[] labels = new string[bar.DataPoints.Count];
for (int i = 0; i < bar.DataPoints.Count; i++)
{
labels[i] = bar.DataPoints[i].Label;
}
NOrdinalScale xAxisScale = (NOrdinalScale)chart.Axes[ENCartesianAxis.PrimaryX].Scale;
xAxisScale.Labels.TextProvider = new NOrdinalScaleLabelTextProvider(labels);
return chartView;
}
|
See Also