To apply a UI theme to your application, call the ApplyTheme method of NApplication in the entry point of your application:
Apply a theme |
Copy Code
|
---|---|
NApplication.ApplyTheme(new NWindows8Theme());
|
The entry point of the application is:
When you apply the theme in the entry point of your application, all windows, dialogs and widgets you create after that will be styled with this theme. Only the frame and the title bar of the main window of the application will not be styled with the Nevron theme, because by default the main window of the application is a native window and is styled by the operating system. If you want to style the title bar and the frame of the main window, too, you should create it to be a Nevron top level window (NTopLevelWindow) instead of creating it as a form/window using the designer. Here's a sample implementation of the entry point of a WinForms application (the Program class in the Program.cs file) that demonstrates how to create a NOV main window that will be fully styled with the theme:
NOV main window |
Copy Code
|
---|---|
using System; using System.Windows.Forms; using Nevron.Nov; using Nevron.Nov.Dom; using Nevron.Nov.Graphics; using Nevron.Nov.Layout; using Nevron.Nov.UI; using Nevron.Nov.Windows.Forms; static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // TODO: Apply license for redistribution here. You can skip this code when evaluating NOV. NLicenseManager.Instance.SetLicense(new NLicense("LICENSE KEY")); // Install Nevron Open Vision for Windows Forms NNovApplicationInstaller.Install(); // Apply theme - by default the "Windows 8" theme is applied for Windows applications, // so if you skip this line, the "Windows 8" theme will be used NApplication.ApplyTheme(new NMacElCapitanTheme()); // Create a top level window and use it as the main window of the application. // This makes it possible to style the main window of the application with the NOV theme, too. NTopLevelWindow window = NApplication.CreateTopLevelWindow(); window.Content = CreateNovContent(); window.Title = "NOV Themes"; window.AllowXResize = true; window.AllowYResize = true; window.Modal = true; window.Bounds = new NRectangle(300, 300, 500, 500); window.Closed += OnMainWindowClosed; window.Open(); // Run the application ApplicationContext context = new ApplicationContext(); Application.Run(context); } private static NWidget CreateNovContent() { NStackPanel stackPanel = new NStackPanel(); stackPanel.Direction = ENHVDirection.TopToBottom; stackPanel.Add(new NLabel("This is a label")); stackPanel.Add(new NCheckBox("Check box")); stackPanel.Add(new NButton("Button")); return stackPanel; } private static void OnMainWindowClosed(NEventArgs arg) { if (arg.EventPhase == ENEventPhase.AtTarget) { // The main window of the application has been closed, so exit the application Application.Exit(); } } } |