Add NOV Schedule control in MonoMac project at runtime
To get started and host NOV in your Mac OS X (MonoMac) application, take a look at:
Getting Started with NOV in MonoMac project
The following topic shows how to add a NOV Schedule Widget (control) in MonoMac project at runtime.
1. Reference the NOV Assemblies
Ensure that your application references the following NOV dlls:
Nevron.Nov.Presentation.dll - core NOV portable assembly;
Nevron.Nov.Host.MonoMac.dll - presentation host for MonoMac;
MonoMac.dll - make sure to reference the MonoMac.dll that comes with the NOV installation and remove the default one, which is created by Xamarin Studio;
Nevron.Nov.Schedule.dll - assembly for the NScheduleModule;
You can reference the dlls directly from the System/Applications/NevronOpenVision.MonoMac.app/Contents/Bin folder or copy those dlls to a folder which is more convenient for referencing.
2. When initializing the NOV Application, make sure to create the Schedule module
Open the Main.cs file and use the following code:
using
System;
using
Nevron.Nov;
using
Nevron.Nov.Mac;
using
Nevron.Nov.Schedule;
#if UNIFIEDAPI
using
Foundation;
using
AppKit;
#else
using
MonoMac.Foundation;
using
MonoMac.AppKit;
#endif
namespace
MonoMacApplication1
{
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
NScheduleModule.Instance
};
NNOVApplicationInstaller.Install(modules);
NSApplication.Main(args);
}
}
}
3. Create the Schedule and add an appointment
Open the MainWindow.cs file and use the following code to create the Schedule:
using
System;
using
Nevron.Nov.Mac;
using
Nevron.Nov.UI;
using
Nevron.Nov;
using
Nevron.Nov.Schedule;
#if UNIFIEDAPI
using
Foundation;
using
AppKit;
#else
using
MonoMac.Foundation;
using
MonoMac.AppKit;
#endif
namespace
MonoMacApplication1
{
public
partial
class
MainWindow : NSWindow
{
#region Constructors
// Called when created from unmanaged code
public
MainWindow(IntPtr handle)
:
base
(handle)
{
Initialize();
}
// Called when created directly from a XIB file
[Export(
"initWithCoder:"
)]
public
MainWindow(NSCoder coder)
:
base
(coder)
{
Initialize();
}
// Shared initialization code
void
Initialize()
{
NApplication.ApplyTheme(
new
NMacElCapitanTheme());
// Create a simple schedule
NScheduleView scheduleView =
new
NScheduleView();
NSchedule schedule = scheduleView.Content;
DateTime today = DateTime.Today;
schedule.ViewMode = ENScheduleViewMode.Day;
// Add an appointment
schedule.Appointments.Add(
new
NAppointment(
"Travel to Work"
, today.AddHours(2.0), today.AddHours(4.5)));
// create NOV host
this
.ContentView =
new
NNovWidgetHost(scheduleView);
}
#endregion
}
}
Run the application - it should display a simple Mac window with the Schedule and the new appointment.
For more information about the NOV Schedule component, take a look at the Help Documentation:
Schedule > Schedule Overview
Article ID: 263, Created On: 8/19/2016, Modified: 8/19/2016