Nevron Open Vision Documentation
Hosting NOV in Xamarin.Mac

NOV can integrate with Xamarin.Mac projects. This topic teaches you how to achieve integration with a Xamarin.Mac project.

Downloading and Installing

Download the NevronOpenVision.XamarinMac package.

After you install the package go to Applications and launch Nevron Open Vision. The application has the following UI:

- 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. You can double click on the .sln file contained there (Nevron.Nov.Examples.XamarinMac.sln) in order to open the examples in Xamarin Studio.

- 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.

 

1. Create a new Xamarin.Mac project in Xamarin Studio on your Mac.

This step is not mandatory, because you can integrate NOV in an already existing MonoMac project. It is performed just for the purpose of making a complete installation scenario.

2. Reference the NOV Assemblies

Ensure that your application references the following NOV dlls:

You can reference the dlls directly from the System/Applications/NevronOpenVision.XamarinMac/Contents/Bin folder or copy those dlls to a folder which is more convenient for referencing.

3. Initialize the NOV Application

Open the Main.cs file and ensure that the NNOVApplicationInstaller.Install() method is called before the MonoMac application runs the main form of the application.

Installing NOV for Xamarin.Mac

Copy Code
       
using AppKit;

using Nevron.Nov;
using Nevron.Nov.Mac;
namespace MonoMac1
{
    class MainClass
    {
        static void Main(string[] args)
        {
            NSApplication.Init();
            NLicenseManager.Instance.SetLicense(new NLicense("LICENSE KEY"));
            // install NOV
            NModule[] modules = new NModule[]
            {
                // TODO: Create modules here
            };
            NNovApplicationInstaller.Install(modules);
            NSApplication.Main(args);
        }
    }
}

The installation will automatically generate an evaluation license key, which you can obtain from the License Key text box in the NevronOpenVision application.

4. Say Hello World from NOV

Open the ViewController.cs file and replace its content with the following code:

Say Hello World from NOV
Copy Code
        
using System;
using AppKit;
using Foundation;
using Nevron.Nov.Mac;
using Nevron.Nov.UI;
namespace NovTest
{
    public partial class ViewController : NSViewController
    {
        public ViewController(IntPtr handle) : base(handle)
        {
        }
        
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            
            
            // Do any additional setup after loading the view.
            NNovWidgetHost host = new NNovWidgetHost(new NLabel("Hello World"));
            host.SetFrameSize(new CoreGraphics.CGSize(this.View.Frame.Size.Width, this.View.Frame.Size.Height));
            host.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;
            
            this.View.AddSubview(host);
        }
        
        public override NSObject RepresentedObject
        {
            get
            {
                return base.RepresentedObject;
            }
            set
            {
                base.RepresentedObject = value;
                // Update the view, if already loaded.
            }
        }
    }
}

Run the application - it should display a simple form with a "Hello World from Nevron Open Vision" label inside.

This is as much as is required to host some NOV content in Xamarin Mac.

The sample just makes a simple label, as content of the NNovWidgetHost is a native XamarinMac control, but this control can actually contain any NOV widget. See the UI Overview topic for an overview of the User Interface that comes along with NOV.

Send Feedback