This example demonstrates how to use document boxes. The document box is a widget that has a document. If you set the InheritStyleSheetsProperty of the document box's document to false, then the widgets hosted in it will not inherit the styling of the document the document box is placed in.
This example also demonstrates the UI themes incuded in Nevron Open Vision. Select a theme from the tree view on the right to apply it to the document box and see how the widgets look when that theme is applied.
The last item in the tree view is a custom theme that changes the mouse over state of buttons, flat buttons (i.e. buttons in ribbon and toolbars) and tab page headers. The custom theme is defined in the beginning of the example's source code.

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NDocumentBoxAndThemesExample";
// Create the NOV example and its controls
NWidget exampleContent = CreateExampleContent();
NWidget exampleControls = CreateExampleControls();
if (exampleControls != null)
{
exampleControls.PreferredWidth = 300;
}
// Place the example and its controls in a pair box
NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
pairBox.FillMode = ENStackFillMode.First;
pairBox.FitMode = ENStackFitMode.First;
pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);
// Host the example in the form
NNovWidgetHost host = new NNovWidgetHost(pairBox);
host.Dock = DockStyle.Fill;
Controls.Add(host);
}
#endregion
#region Example
public NWidget CreateExampleContent()
{
NTableFlowPanel table = new NTableFlowPanel();
table.HorizontalSpacing = 10;
table.VerticalSpacing = 10;
table.MaxOrdinal = 3;
table.Add(CreateGroupBox("Text Boxes and Buttons", CreateTextBoxesAndButtons()));
table.Add(CreateGroupBox("List Box", CreateListBox()));
table.Add(CreateGroupBox("Tree View", CreateTreeView()));
table.Add(CreateGroupBox("Drop Down Edits", CreateDropDownEdits()));
table.Add(CreateGroupBox("Tab", CreateTab()));
table.Add(CreateGroupBox("Range Based", CreateRangeBased()));
table.Add(CreateGroupBox("Ribbon", CreateRibbon()));
table.Add(CreateGroupBox("Command Bars", CreateCommandBars()));
table.Add(CreateGroupBox("Windows", CreateWindows()));
// Create the document box
m_DocumentBox = new NDocumentBox();
m_DocumentBox.HorizontalPlacement = ENHorizontalPlacement.Left;
m_DocumentBox.SetBorder(1, NColor.Red);
m_DocumentBox.Surface = new NDocumentBoxSurface(table);
return m_DocumentBox;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
stack.FillMode = ENStackFillMode.Last;
stack.FitMode = ENStackFitMode.Last;
NCheckBox enabledCheckBox = new NCheckBox("Enabled", true);
enabledCheckBox.CheckedChanged += OnEnabledCheckBoxCheckedChanged;
stack.Add(enabledCheckBox);
// Create the theme tree view
NTheme theme;
NTreeViewItem rootItem, themeItem;
NTreeView themeTreeView = new NTreeView();
stack.Add(themeTreeView);
//
// Add the "Inherit Styles" root tree view item
//
rootItem = new NTreeViewItem("Inherit Styles");
rootItem.Tag = "inherit";
themeTreeView.Items.Add(rootItem);
themeTreeView.SelectedItem = rootItem;
//
// Add the part based UI themes to the tree view
//
rootItem = new NTreeViewItem("Part Based");
rootItem.Expanded = true;
themeTreeView.Items.Add(rootItem);
themeItem = new NTreeViewItem("Windows XP Blue");
themeItem.Tag = new NWindowsXPBlueTheme();
rootItem.Items.Add(themeItem);
themeItem = new NTreeViewItem("Windows 7 Aero");
themeItem.Tag = new NWindowsAeroTheme();
rootItem.Items.Add(themeItem);
themeItem = new NTreeViewItem("Windows 8");
themeItem.Tag = new NWindows8Theme();
rootItem.Items.Add(themeItem);
themeItem = new NTreeViewItem("Windows 10");
themeItem.Tag = new NWindows10Theme();
rootItem.Items.Add(themeItem);
themeItem = new NTreeViewItem("Windows 11");
themeItem.Tag = new NWindows11Theme();
rootItem.Items.Add(themeItem);
themeItem = new NTreeViewItem("Mac OS X 10.7 Lion");
themeItem.Tag = new NMacLionTheme();
rootItem.Items.Add(themeItem);
themeItem = new NTreeViewItem("Mac OS X 10.11 El Capitan");
themeItem.Tag = new NMacElCapitanTheme();
rootItem.Items.Add(themeItem);
themeItem = new NTreeViewItem("Nevron Dark");
themeItem.Tag = new NNevronDarkTheme();
rootItem.Items.Add(themeItem);
themeItem = new NTreeViewItem("Nevron Light");
themeItem.Tag = new NNevronLightTheme();
rootItem.Items.Add(themeItem);
//
// Add the windows classic UI themes to the tree view
//
rootItem = new NTreeViewItem("Windows Classic");
rootItem.Expanded = true;
themeTreeView.Items.Add(rootItem);
ENUIThemeScheme[] windowsClassicSchemes = NEnum.GetValues();
for(int i = 0, count = windowsClassicSchemes.Length; i < count; i++)
{
ENUIThemeScheme scheme = windowsClassicSchemes[i];
theme = new NWindowsClassicTheme(scheme);
themeItem = new NTreeViewItem(NStringHelpers.InsertSpacesBeforeUppersAndDigits(scheme.ToString()));
themeItem.Tag = theme;
rootItem.Items.Add(themeItem);
}
//
// Add the custom themes to the tree view
//
rootItem = new NTreeViewItem("Custom");
rootItem.Expanded = true;
themeTreeView.Items.Add(rootItem);
themeItem = new NTreeViewItem("Custom Theme");
themeItem.Tag = new NCustomTheme();
rootItem.Items.Add(themeItem);
// Subscribe to the selected path changed event
themeTreeView.SelectedPathChanged += OnThemeTreeViewSelectedPathChanged;
return stack;
}
public string GetExampleDescription()
{
return @"
This example demonstrates how to use document boxes. The document box is a widget that has a document.
If you set the InheritStyleSheetsProperty of the document box's document to false, then the widgets hosted
in it will not inherit the styling of the document the document box is placed in.
This example also demonstrates the UI themes incuded in Nevron Open Vision. Select a theme from the tree view on
the right to apply it to the document box and see how the widgets look when that theme is applied.
The last item in the tree view is a custom theme that changes the mouse over state of buttons, flat buttons (i.e.
buttons in ribbon and toolbars) and tab page headers. The custom theme is defined in the beginning of the example's
source code.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Document Box", "https://www.nevron.com/docs/openvision/ui-document-box.html"),
("Using UI Themes", "https://www.nevron.com/docs/openvision/using-ui-themes.html"),
("UI Themes Overview", "https://www.nevron.com/docs/openvision/ui-themes-overview.html"),
};
}
#endregion
#region Implementation
private NStackPanel CreateTextBoxesAndButtons()
{
// Create buttons
NStackPanel stack = new NStackPanel();
stack.VerticalSpacing = 10;
stack.Add(new NTextBox("Text Box"));
NCheckBox checkBox = new NCheckBox("Check Box");
checkBox.Click += OnCheckBoxClick;
checkBox.ToggleCheckedOnClick = false;
stack.Add(checkBox);
NRadioButton radioButton = new NRadioButton("Radio Button");
stack.Add(radioButton);
NButton button = new NButton("Button");
stack.Add(button);
return stack;
}
private void OnCheckBoxClick(NEventArgs arg)
{
NCheckBox checkBox = (NCheckBox)arg.TargetNode;
if (checkBox.Checked)
{
checkBox.Checked = false;
if (checkBox.Indeterminate)
{
checkBox.Indeterminate = false;
}
else
{
checkBox.Indeterminate = true;
}
}
else
{
checkBox.Checked = true;
}
}
private NListBox CreateListBox()
{
NListBox listBox = new NListBox();
for (int i = 1; i <= 20; i++)
{
listBox.Items.Add(new NListBoxItem("Item " + i));
}
return listBox;
}
private NTreeView CreateTreeView()
{
NTreeView treeView = new NTreeView();
for (int i = 1; i <= 7; i++)
{
string itemName = "Item " + i;
NTreeViewItem item = new NTreeViewItem(itemName);
treeView.Items.Add(item);
itemName += ".";
for (int j = 1; j <= 3; j++)
{
NTreeViewItem childItem = new NTreeViewItem(itemName + j);
item.Items.Add(childItem);
}
}
return treeView;
}
private NStackPanel CreateDropDownEdits()
{
NStackPanel stack = new NStackPanel();
stack.VerticalSpacing = 10;
stack.Add(CreateComboBox());
NColorBox colorBox = new NColorBox();
stack.Add(colorBox);
NDateTimeBox dateTimeBox = new NDateTimeBox();
stack.Add(dateTimeBox);
NFillSplitButton splitButton = new NFillSplitButton();
stack.Add(splitButton);
return stack;
}
private NComboBox CreateComboBox()
{
NComboBox comboBox = new NComboBox();
comboBox.Items.Add(new NComboBoxItem("Item 1"));
comboBox.Items.Add(new NComboBoxItem("Item 2"));
comboBox.Items.Add(new NComboBoxItem("Item 3"));
comboBox.Items.Add(new NComboBoxItem("Item 4"));
comboBox.SelectedIndex = 0;
return comboBox;
}
private NTab CreateTab()
{
NTab tab = new NTab();
tab.TabPages.Add(new NTabPage("Page 1", "This is tab page 1"));
tab.TabPages.Add(new NTabPage("Page 2", "This is tab page 2"));
tab.TabPages.Add(new NTabPage("Page 3", "This is tab page 3"));
return tab;
}
private NStackPanel CreateRangeBased()
{
NStackPanel stack = new NStackPanel();
stack.VerticalSpacing = 10;
NNumericUpDown numericUpDown = new NNumericUpDown();
stack.Add(numericUpDown);
NSlider slider = new NSlider();
stack.Add(slider);
NProgressBar progressBar = new NProgressBar();
progressBar.PreferredHeight = 20;
progressBar.Value = 40;
stack.Add(progressBar);
return stack;
}
private NRibbon CreateRibbon()
{
NRibbon ribbon = new NRibbon();
ribbon.VerticalPlacement = ENVerticalPlacement.Top;
//
// Create the "Home" ribbon tab page
//
NRibbonTabPage pageHome = new NRibbonTabPage("Home");
ribbon.Tab.TabPages.Add(pageHome);
// Create the "Clipboard" group of the "Home" tab page
NRibbonGroup group = new NRibbonGroup("Clipboard");
group.Icon = Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAvklEQVR4AZWSQQrCMBBFBS8gCgjiWTzX/B7AA7gSgV5CsknoDQSXgndJx3yRQuPokIEHzVAej5CFiBwLweAEYLPwpuu6oKozuIsxUnIBsG4WAAg555BSouQMYOUKDnJ9w28n2i/gXkT0B3cAe6+Ae62HuxgjJU8Au78FlgCA5pw1pUTJA8C2LiAzQTmTmYDzkdyaCvq+/7qTpgLOOI4T/KelwLxU8ylXBSaTwJ6GAmNYtfQLfEFDgS0ZCuowvABHnjR+cwTY5AAAAABJRU5ErkJggg=="));
pageHome.Groups.Add(group);
NRibbonSplitButton pasteSplitButton = NRibbonSplitButton.CreateLarge("Paste", Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABL0lEQVR4AWMgBVRUVPgCcTwU+wMxIwPNAcLySCD+j4bj6emALpClMD7UAROpZsGr7WmdQPwLiP+D8MttaR/Or8isB8lVVpQvAFr2G2rpKyB+AWX/qagoX9zdVOIBUvd8a9pzmH6oWZ2kOOA3kmawTxtqyg5ALCKM66rLjkDN+Y+Ef5PigP/oDoD5mkj8B5s5ZDvg0ab0dlKj8cHG9B4KHUA5pqcDRh0w6oByIGZhoBYgx2ezZ88mtow4XVVVJUZ1B4AMxwf+/fsHdsDu3bv/V1ZWXoE6gv4OAAI0R9DfARiOoLoD7Co2I2NMByAcAU4TNA4BBMCVUOnjAERUoGCQPppHAR5AlxAYSQ5ARAEhPPhD4PcAOgDRLKdjFFAOKA8Byh0w6oDdIMPIwLsZBgsAAKC4xOr5AXZ9AAAAAElFTkSuQmCC")));
pasteSplitButton.CollapseToMedium = ENCollapseCondition.Never;
pasteSplitButton.CollapseToSmall = ENCollapseCondition.Never;
NMenu pasteMenu = new NMenu();
pasteMenu.Items.Add(new NMenuItem("Paste"));
pasteMenu.Items.Add(new NMenuItem("Paste Special..."));
pasteMenu.Items.Add(new NMenuItem("Paste as Link"));
pasteSplitButton.Popup.Content = pasteMenu;
group.Items.Add(pasteSplitButton);
NRibbonCollapsiblePanel collapsiblePanel = new NRibbonCollapsiblePanel();
collapsiblePanel.InitialState = ENRibbonWidgetState.Medium;
group.Items.Add(collapsiblePanel);
collapsiblePanel.Add(new NRibbonButton("Cut", null, Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABOElEQVR4AY3QM5SeQRiG4S+2bdtu4j5VbFsTm2hjVUkbc+122a2tZm0n797F+53zE3POVTzzjM5Y9jDGfMRSy8fQdQMRjp6uxVcUYZifA76h3lNxFYJvPjYfgiDKUzkb/yHY6aGfiBrtT3m7IQ6CCoxy6cK1q8EgbwdshKg/DvMnIequFcAniTqHRWjSnIk+/g4YiVII2lACQTNWWoGM/eb+0nPmQrXDSzqOmFu7fG5aZP4MxtlF5vfzZebr5ZXmS/gS80Mgy8y3klXm8/FF5tcz1lzHGNfNo5AHCVA5pjse8F6LFOzEa4iL79iNBDs7HlAKwUrN3dABQQUE07SbpbkJXewD7Odv0XwKovMfIHiC/tiuudY+wHHDfy1EncR8NENcPHT9yE0IRhoisMOhW4MQZCEWB+yuE+WUNEHiWZ7cAAAAAElFTkSuQmCC"))));
collapsiblePanel.Add(new NRibbonButton("Copy", null, Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAvklEQVR4AZWSQQrCMBBFBS8gCgjiWTzX/B7AA7gSgV5CsknoDQSXgndJx3yRQuPokIEHzVAej5CFiBwLweAEYLPwpuu6oKozuIsxUnIBsG4WAAg555BSouQMYOUKDnJ9w28n2i/gXkT0B3cAe6+Ae62HuxgjJU8Au78FlgCA5pw1pUTJA8C2LiAzQTmTmYDzkdyaCvq+/7qTpgLOOI4T/KelwLxU8ylXBSaTwJ6GAmNYtfQLfEFDgS0ZCuowvABHnjR+cwTY5AAAAABJRU5ErkJggg=="))));
collapsiblePanel.Add(new NRibbonButton("Format Painter", null, Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB4ElEQVR4AcXPA2woVgCF4TvbVjwEM2vjWbVt27Zt27Zt27bt9qzubPzJib8L8j/0AaOdY8mmjV3OESHkxh9VT5DT2AXsHYsO7J3HoCAXB3lpg4PfQuwJSam42AsvUatZWGbs2Dt1Q0igCYwUHqCluLf5a5j6BA0Nj6C2rgHDI6MIDA6Bk2cuRARPsCcovuLc/KUvPJMaIFFbkGCOns6U05tnZmZRWVWDnt4+6BmYQkjQEpRfcW1d4i8J+aYkSTWnLt92qjLTGquLGTg8KMbRYQkGBjLhFxiKsbFxWFrbIyYuEXfuc+NxQiLJRT21PhjsiMDeTuEJvMQnO9jJQn2lK3T0jeDrHwxtPSPIKamB7RYHjukj5KTSmPuB/Q3eWJpNvsT7u9nYWY3F6pgDFnr1UJSpDz4hCRiZWkJIVAos126fHPACuSja6iW1hkL700MO9vKxOeuHlVG7UzzWoIj2XD4Ee4iAk08ErNfvnOBb5KfZyDxtXJFhifFuVywNmp1jJbTn8aEsggVpLl/gBt1HJ/g2+bU0eN7zD3dXxnibIcYaFa+w6xdgoXjnBMuR3+vGJ8TOWFkYjdlSx5j5DH93if9YYuyvB2lJccBWgx6sFO9e4j+btuA9mtWnCMkg/2bfAxwyRdFvICBXAAAAAElFTkSuQmCC"))));
// Create the "Format" group of the "Home" tab page
group = new NRibbonGroup("Format");
pageHome.Groups.Add(group);
collapsiblePanel = new NRibbonCollapsiblePanel();
collapsiblePanel.InitialState = ENRibbonWidgetState.Medium;
group.Items.Add(collapsiblePanel);
NFillSplitButton fillSplitButton = new NFillSplitButton();
collapsiblePanel.Add(fillSplitButton);
NStrokeSplitButton strokeSplitButton = new NStrokeSplitButton();
collapsiblePanel.Add(strokeSplitButton);
//
// Add an "Insert" ribbon tab page
//
ribbon.Tab.TabPages.Add(new NRibbonTabPage("Insert"));
return ribbon;
}
private NCommandBarManager CreateCommandBars()
{
NCommandBarManager manager = new NCommandBarManager();
// Create a menu bar in the first lane
NCommandBarLane lane1 = new NCommandBarLane();
manager.TopDock.Add(lane1);
NMenuBar menuBar = new NMenuBar();
menuBar.HideGripperAndPendant();
lane1.Add(menuBar);
NMenuDropDown fileMenu = new NMenuDropDown("File");
menuBar.Items.Add(fileMenu);
NMenuItem newMenuItem = new NMenuItem(Nevron.Nov.Presentation.NResources.Image_File_New_svg, "New");
fileMenu.Items.Add(newMenuItem);
newMenuItem.Items.Add(new NMenuItem("Project"));
newMenuItem.Items.Add(new NMenuItem("Web Site"));
newMenuItem.Items.Add(new NMenuItem("File"));
fileMenu.Items.Add(new NMenuItem(Nevron.Nov.Presentation.NResources.Image_File_Open_svg, "Open"));
fileMenu.Items.Add(new NMenuItem(Nevron.Nov.Presentation.NResources.Image_File_Save_svg, "Save"));
fileMenu.Items.Add(new NMenuSeparator());
fileMenu.Items.Add(new NMenuItem(Nevron.Nov.Presentation.NResources.Image_File_Print_svg, "Print"));
NMenuDropDown editMenu = new NMenuDropDown("Edit");
menuBar.Items.Add(editMenu);
editMenu.Items.Add(new NMenuItem(Nevron.Nov.Presentation.NResources.Image_Edit_Undo_svg, "Undo"));
editMenu.Items.Add(new NMenuItem(Nevron.Nov.Presentation.NResources.Image_Edit_Redo_svg, "Redo"));
// Add a toolbar in the second lane
NCommandBarLane lane2 = new NCommandBarLane();
manager.TopDock.Add(lane2);
NToolBar toolbar = new NToolBar();
toolbar.HideGripperAndPendant();
lane2.Add(toolbar);
toolbar.Items.Add(NButton.CreateImageAndText(Nevron.Nov.Presentation.NResources.Image_File_New_svg, "New"));
toolbar.Items.Add(NButton.CreateImageAndText(Nevron.Nov.Presentation.NResources.Image_File_Open_svg, "Open"));
toolbar.Items.Add(NButton.CreateImageAndText(Nevron.Nov.Presentation.NResources.Image_File_Save_svg, "Save"));
toolbar.Items.Add(new NCommandBarSeparator());
toolbar.Items.Add(NButton.CreateImageAndText(Nevron.Nov.Presentation.NResources.Image_File_Print_svg, "Print"));
// Add a toolbar in the third lane
NCommandBarLane lane3 = new NCommandBarLane();
manager.TopDock.Add(lane3);
toolbar = new NToolBar();
toolbar.HideGripperAndPendant();
lane3.Add(toolbar);
toolbar.Items.Add(CreateComboBox());
toolbar.Items.Add(new NCommandBarSeparator());
toolbar.Items.Add(NToggleButton.CreateImageAndText(Nevron.Nov.Presentation.NResources.Image_FontStyle_Bold_svg, "Bold"));
toolbar.Items.Add(new NCheckBox("Plain Text"));
return manager;
}
private NStackPanel CreateWindows()
{
NStackPanel stack = new NStackPanel();
stack.VerticalSpacing = 10;
// create a button which shows a top-level window, added to the NDocumentBoxSurface.Windows collection.
// such top-level windows will use the style sheets applied to the NDocumentBox.
NButton windowButton = new NButton("Show Window...");
windowButton.Click += delegate (NEventArgs arg)
{
NTopLevelWindow window = NApplication.CreateTopLevelWindow(m_DocumentBox.Surface);
window.Title = "Top-Level Window";
NStackPanel windowStack = new NStackPanel();
NLabel label = new NLabel("Top-level windows that are added to the NDocumentBoxSurface Windows collection,\r\n will use the NDocumentBox styling.");
windowStack.Add(label);
NButtonStrip buttonStrip = new NButtonStrip();
buttonStrip.AddCloseButton();
windowStack.Add(buttonStrip);
window.Content = windowStack;
window.Open();
};
stack.Add(windowButton);
// message box
NButton showMessageBoxButton = new NButton("Show MessageBox...");
showMessageBoxButton.Click += delegate (NEventArgs arg)
{
NMessageBoxSettings msgBoxSettings = new NMessageBoxSettings("Message boxes that are added to the NDocumentBoxSurface Windows collection,\r\n will use the NDocumentBox styling.", "Message box title");
msgBoxSettings.WindowsContainer = m_DocumentBox.Surface;
NMessageBox.Show(msgBoxSettings);
};
stack.Add(showMessageBoxButton);
return stack;
}
private NGroupBox CreateGroupBox(object header, object content)
{
NGroupBox groupBox = new NGroupBox(header, content);
// Check whether the application is in touch mode and set the size of the group box accordingly
groupBox.PreferredSize = NApplication.Desktop.TouchMode ?
new NSize(360, 250) : // touch mode size
new NSize(260, 180); // regular mode size
return groupBox;
}
#endregion
#region Event Handlers
private void OnEnabledCheckBoxCheckedChanged(NValueChangeEventArgs arg)
{
m_DocumentBox.Surface.Content.Enabled = (bool)arg.NewValue;
}
private void OnThemeTreeViewSelectedPathChanged(NValueChangeEventArgs arg1)
{
NTreeView treeView = (NTreeView)arg1.CurrentTargetNode;
NTreeViewItem selectedItem = treeView.SelectedItem;
if (selectedItem == null)
return;
if (selectedItem.Tag is NTheme)
{
// Apply the selected theme to the document box's document
NTheme theme = (NTheme)selectedItem.Tag;
m_DocumentBox.Document.InheritStyleSheets = false;
m_DocumentBox.Document.StyleSheets.ApplyTheme(theme);
NStyleSheet styleSheet = new NStyleSheet();
NRule rule = styleSheet.CreateRule(
sb =>
{
sb.Type(NWrapFlowLayout.NWrapFlowLayoutSchema);
}
);
rule.AddValueDeclaration(NWrapFlowLayout.DirectionProperty, ENHVDirection.LeftToRight);
m_DocumentBox.Document.StyleSheets.Add(styleSheet);
}
else if (NStringHelpers.Equals(selectedItem.Tag, "inherit"))
{
// Make the document inherit its style sheets and clear all current ones
m_DocumentBox.Document.InheritStyleSheets = true;
m_DocumentBox.Document.StyleSheets.Clear();
}
}
#endregion
#region Fields
private NDocumentBox m_DocumentBox;
#endregion
#region Static Methods
#endregion
#region Constants
#endregion
#region Nested Types
///
/// A custom NOV theme based on the Windows 11 theme.
///
public class NCustomTheme : NWindows11Theme
{
///
/// Static constructor.
///
static NCustomTheme()
{
NCustomThemeSchema = NSchema.Create(typeof(NCustomTheme), NWindows11ThemeSchema);
}
///
/// Creates button styles.
///
protected override void CreateButtonStyles(NSchema buttonSchema)
{
// Change mouse over background fill to orange
NColorSkinState mouseOverState = (NColorSkinState)Skins.Button.GetState(NSkinState.MouseOver);
mouseOverState.BackgroundFill = new NColorFill(NColor.Orange);
// Change pressed button border to 3px purple border, background fill to dark red and text fill to white
NColorSkinState pressedState = (NColorSkinState)Skins.Button.GetState(NSkinState.Pressed);
pressedState.SetBorderFill(new NColorFill(NColor.Green));
pressedState.BorderThickness = new NMargins(3);
pressedState.BackgroundFill = new NColorFill(NColor.DarkRed);
pressedState.TextFill = new NColorFill(NColor.White);
// Call base to skin the buttons
base.CreateButtonStyles(buttonSchema);
}
///
/// Creates flat button styles, which are buttons commonly in ribbon and toolbars.
///
protected override void CreateFlatButtonStyles()
{
NColorSkinState mouseOverState = (NColorSkinState)Skins.FlatButton.GetState(NSkinState.MouseOver);
mouseOverState.BackgroundFill = new NColorFill(NColor.Orange);
// Call base to skin flat buttons
base.CreateFlatButtonStyles();
}
///
/// Creates the tab styles. Overriden to make the mouse over state orange.
///
protected override void CreateTabStyles()
{
// Modify the tab skins
NColor backgroundColor = NColor.Orange;
NSkin[] tabSkins = new NSkin[] {
TabSkins.Top.Far,
TabSkins.Top.Inner,
TabSkins.Top.NearAndFar,
TabSkins.Top.Near };
for (int i = 0; i < tabSkins.Length; i++)
{
NColorSkinState state = (NColorSkinState)tabSkins[i].GetState(NSkinState.MouseOver);
state.BackgroundFill = new NColorFill(backgroundColor);
}
// Call base to skin the tab widget
base.CreateTabStyles();
}
///
/// Schema associated with NCustomTheme.
///
public static readonly NSchema NCustomThemeSchema;
}
#endregion
}
} | Language: VB.NET |
Imports Nevron.Nov
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Forms
Public Class Form1
#Region "Constructors"
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
' Set form title
Text = "NOV WinForms - NDocumentBoxAndThemesExample"
' Create the NOV example and its controls
Dim exampleContent As NWidget = CreateExampleContent()
Dim exampleControls As NWidget = CreateExampleControls()
If Not exampleControls Is Nothing Then
exampleControls.PreferredWidth = 300
End If
' Place the example and its controls in a pair box
Dim pairBox As NPairBox = New NPairBox(exampleContent, exampleControls)
pairBox.FillMode = ENStackFillMode.First
pairBox.FitMode = ENStackFitMode.First
pairBox.Margins = New NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing)
' Host the example in the form
Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
host.Dock = DockStyle.Fill
Controls.Add(host)
End Sub
#End Region
#Region "Example"
Public Function CreateExampleContent() As NWidget
Dim table As NTableFlowPanel = New NTableFlowPanel()
table.HorizontalSpacing = 10
table.VerticalSpacing = 10
table.MaxOrdinal = 3
table.Add(CreateGroupBox("Text Boxes and Buttons", CreateTextBoxesAndButtons()))
table.Add(CreateGroupBox("List Box", CreateListBox()))
table.Add(CreateGroupBox("Tree View", CreateTreeView()))
table.Add(CreateGroupBox("Drop Down Edits", CreateDropDownEdits()))
table.Add(CreateGroupBox("Tab", CreateTab()))
table.Add(CreateGroupBox("Range Based", CreateRangeBased()))
table.Add(CreateGroupBox("Ribbon", CreateRibbon()))
table.Add(CreateGroupBox("Command Bars", CreateCommandBars()))
table.Add(CreateGroupBox("Windows", CreateWindows()))
' Create the document box
m_DocumentBox = New NDocumentBox()
m_DocumentBox.HorizontalPlacement = ENHorizontalPlacement.Left
m_DocumentBox.SetBorder(1, NColor.Red)
m_DocumentBox.Surface = New NDocumentBoxSurface(table)
Return m_DocumentBox
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
stack.FillMode = ENStackFillMode.Last
stack.FitMode = ENStackFitMode.Last
Dim enabledCheckBox As NCheckBox = New NCheckBox("Enabled", True)
enabledCheckBox.CheckedChanged += AddressOf OnEnabledCheckBoxCheckedChanged
stack.Add(enabledCheckBox)
' Create the theme tree view
Dim theme As NTheme
Dim rootItem, themeItem As NTreeViewItem
Dim themeTreeView As NTreeView = New NTreeView()
stack.Add(themeTreeView)
'
' Add the "Inherit Styles" root tree view item
'
rootItem = New NTreeViewItem("Inherit Styles")
rootItem.Tag = "inherit"
themeTreeView.Items.Add(rootItem)
themeTreeView.SelectedItem = rootItem
'
' Add the part based UI themes to the tree view
'
rootItem = New NTreeViewItem("Part Based")
rootItem.Expanded = True
themeTreeView.Items.Add(rootItem)
themeItem = New NTreeViewItem("Windows XP Blue")
themeItem.Tag = New NWindowsXPBlueTheme()
rootItem.Items.Add(themeItem)
themeItem = New NTreeViewItem("Windows 7 Aero")
themeItem.Tag = New NWindowsAeroTheme()
rootItem.Items.Add(themeItem)
themeItem = New NTreeViewItem("Windows 8")
themeItem.Tag = New NWindows8Theme()
rootItem.Items.Add(themeItem)
themeItem = New NTreeViewItem("Windows 10")
themeItem.Tag = New NWindows10Theme()
rootItem.Items.Add(themeItem)
themeItem = New NTreeViewItem("Windows 11")
themeItem.Tag = New NWindows11Theme()
rootItem.Items.Add(themeItem)
themeItem = New NTreeViewItem("Mac OS X 10.7 Lion")
themeItem.Tag = New NMacLionTheme()
rootItem.Items.Add(themeItem)
themeItem = New NTreeViewItem("Mac OS X 10.11 El Capitan")
themeItem.Tag = New NMacElCapitanTheme()
rootItem.Items.Add(themeItem)
themeItem = New NTreeViewItem("Nevron Dark")
themeItem.Tag = New NNevronDarkTheme()
rootItem.Items.Add(themeItem)
themeItem = New NTreeViewItem("Nevron Light")
themeItem.Tag = New NNevronLightTheme()
rootItem.Items.Add(themeItem)
'
' Add the windows classic UI themes to the tree view
'
rootItem = New NTreeViewItem("Windows Classic")
rootItem.Expanded = True
themeTreeView.Items.Add(rootItem)
Dim windowsClassicSchemes As ENUIThemeScheme() = NEnum.GetValues(Of ENUIThemeScheme)()
Dim i = 0, count = windowsClassicSchemes.Length
While i < count
Dim scheme = windowsClassicSchemes(i)
theme = New NWindowsClassicTheme(scheme)
themeItem = New NTreeViewItem(NStringHelpers.InsertSpacesBeforeUppersAndDigits(scheme.ToString()))
themeItem.Tag = theme
rootItem.Items.Add(themeItem)
i += 1
End While
'
' Add the custom themes to the tree view
'
rootItem = New NTreeViewItem("Custom")
rootItem.Expanded = True
themeTreeView.Items.Add(rootItem)
themeItem = New NTreeViewItem("Custom Theme")
themeItem.Tag = New NCustomTheme()
rootItem.Items.Add(themeItem)
' Subscribe to the selected path changed event
themeTreeView.SelectedPathChanged += AddressOf OnThemeTreeViewSelectedPathChanged
Return stack
End Function
Public Function GetExampleDescription() As String
Return "
This example demonstrates how to use document boxes. The document box is a widget that has a document.
If you set the InheritStyleSheetsProperty of the document box's document to false, then the widgets hosted
in it will not inherit the styling of the document the document box is placed in.
This example also demonstrates the UI themes incuded in Nevron Open Vision. Select a theme from the tree view on
the right to apply it to the document box and see how the widgets look when that theme is applied.
The last item in the tree view is a custom theme that changes the mouse over state of buttons, flat buttons (i.e.
buttons in ribbon and toolbars) and tab page headers. The custom theme is defined in the beginning of the example's
source code.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Document Box", "https://www.nevron.com/docs/openvision/ui-document-box.html"), ("Using UI Themes", "https://www.nevron.com/docs/openvision/using-ui-themes.html"), ("UI Themes Overview", "https://www.nevron.com/docs/openvision/ui-themes-overview.html")}
End Function
#End Region
#Region "Implementation"
Private Function CreateTextBoxesAndButtons() As NStackPanel
' Create buttons
Dim stack As NStackPanel = New NStackPanel()
stack.VerticalSpacing = 10
stack.Add(New NTextBox("Text Box"))
Dim checkBox As NCheckBox = New NCheckBox("Check Box")
checkBox.Click += AddressOf OnCheckBoxClick
checkBox.ToggleCheckedOnClick = False
stack.Add(checkBox)
Dim radioButton As NRadioButton = New NRadioButton("Radio Button")
stack.Add(radioButton)
Dim button As NButton = New NButton("Button")
stack.Add(button)
Return stack
End Function
Private Sub OnCheckBoxClick(arg As NEventArgs)
Dim checkBox = CType(arg.TargetNode, NCheckBox)
If checkBox.Checked Then
checkBox.Checked = False
If checkBox.Indeterminate Then
checkBox.Indeterminate = False
Else
checkBox.Indeterminate = True
End If
Else
checkBox.Checked = True
End If
End Sub
Private Function CreateListBox() As NListBox
Dim listBox As NListBox = New NListBox()
For i = 1 To 20
listBox.Items.Add(New NListBoxItem("Item " & i.ToString()))
Next
Return listBox
End Function
Private Function CreateTreeView() As NTreeView
Dim treeView As NTreeView = New NTreeView()
For i = 1 To 7
Dim itemName As String = "Item " & i.ToString()
Dim item As NTreeViewItem = New NTreeViewItem(itemName)
treeView.Items.Add(item)
itemName += "."
For j = 1 To 3
Dim childItem As NTreeViewItem = New NTreeViewItem(itemName & j.ToString())
item.Items.Add(childItem)
Next
Next
Return treeView
End Function
Private Function CreateDropDownEdits() As NStackPanel
Dim stack As NStackPanel = New NStackPanel()
stack.VerticalSpacing = 10
stack.Add(CreateComboBox())
Dim colorBox As NColorBox = New NColorBox()
stack.Add(colorBox)
Dim dateTimeBox As NDateTimeBox = New NDateTimeBox()
stack.Add(dateTimeBox)
Dim splitButton As NFillSplitButton = New NFillSplitButton()
stack.Add(splitButton)
Return stack
End Function
Private Function CreateComboBox() As NComboBox
Dim comboBox As NComboBox = New NComboBox()
comboBox.Items.Add(New NComboBoxItem("Item 1"))
comboBox.Items.Add(New NComboBoxItem("Item 2"))
comboBox.Items.Add(New NComboBoxItem("Item 3"))
comboBox.Items.Add(New NComboBoxItem("Item 4"))
comboBox.SelectedIndex = 0
Return comboBox
End Function
Private Function CreateTab() As NTab
Dim tab As NTab = New NTab()
tab.TabPages.Add(New NTabPage("Page 1", "This is tab page 1"))
tab.TabPages.Add(New NTabPage("Page 2", "This is tab page 2"))
tab.TabPages.Add(New NTabPage("Page 3", "This is tab page 3"))
Return tab
End Function
Private Function CreateRangeBased() As NStackPanel
Dim stack As NStackPanel = New NStackPanel()
stack.VerticalSpacing = 10
Dim numericUpDown As NNumericUpDown = New NNumericUpDown()
stack.Add(numericUpDown)
Dim slider As NSlider = New NSlider()
stack.Add(slider)
Dim progressBar As NProgressBar = New NProgressBar()
progressBar.PreferredHeight = 20
progressBar.Value = 40
stack.Add(progressBar)
Return stack
End Function
Private Function CreateRibbon() As NRibbon
Dim ribbon As NRibbon = New NRibbon()
ribbon.VerticalPlacement = ENVerticalPlacement.Top
'
' Create the "Home" ribbon tab page
'
Dim pageHome As NRibbonTabPage = New NRibbonTabPage("Home")
ribbon.Tab.TabPages.Add(pageHome)
' Create the "Clipboard" group of the "Home" tab page
Dim group As NRibbonGroup = New NRibbonGroup("Clipboard")
group.Icon = Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAvklEQVR4AZWSQQrCMBBFBS8gCgjiWTzX/B7AA7gSgV5CsknoDQSXgndJx3yRQuPokIEHzVAej5CFiBwLweAEYLPwpuu6oKozuIsxUnIBsG4WAAg555BSouQMYOUKDnJ9w28n2i/gXkT0B3cAe6+Ae62HuxgjJU8Au78FlgCA5pw1pUTJA8C2LiAzQTmTmYDzkdyaCvq+/7qTpgLOOI4T/KelwLxU8ylXBSaTwJ6GAmNYtfQLfEFDgS0ZCuowvABHnjR+cwTY5AAAAABJRU5ErkJggg=="))
pageHome.Groups.Add(group)
Dim pasteSplitButton = NRibbonSplitButton.CreateLarge("Paste", Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABL0lEQVR4AWMgBVRUVPgCcTwU+wMxIwPNAcLySCD+j4bj6emALpClMD7UAROpZsGr7WmdQPwLiP+D8MttaR/Or8isB8lVVpQvAFr2G2rpKyB+AWX/qagoX9zdVOIBUvd8a9pzmH6oWZ2kOOA3kmawTxtqyg5ALCKM66rLjkDN+Y+Ef5PigP/oDoD5mkj8B5s5ZDvg0ab0dlKj8cHG9B4KHUA5pqcDRh0w6oByIGZhoBYgx2ezZ88mtow4XVVVJUZ1B4AMxwf+/fsHdsDu3bv/V1ZWXoE6gv4OAAI0R9DfARiOoLoD7Co2I2NMByAcAU4TNA4BBMCVUOnjAERUoGCQPppHAR5AlxAYSQ5ARAEhPPhD4PcAOgDRLKdjFFAOKA8Byh0w6oDdIMPIwLsZBgsAAKC4xOr5AXZ9AAAAAElFTkSuQmCC")))
pasteSplitButton.CollapseToMedium = ENCollapseCondition.Never
pasteSplitButton.CollapseToSmall = ENCollapseCondition.Never
Dim pasteMenu As NMenu = New NMenu()
pasteMenu.Items.Add(New NMenuItem("Paste"))
pasteMenu.Items.Add(New NMenuItem("Paste Special..."))
pasteMenu.Items.Add(New NMenuItem("Paste as Link"))
pasteSplitButton.Popup.Content = pasteMenu
group.Items.Add(pasteSplitButton)
Dim collapsiblePanel As NRibbonCollapsiblePanel = New NRibbonCollapsiblePanel()
collapsiblePanel.InitialState = ENRibbonWidgetState.Medium
group.Items.Add(collapsiblePanel)
collapsiblePanel.Add(New NRibbonButton("Cut", Nothing, Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABOElEQVR4AY3QM5SeQRiG4S+2bdtu4j5VbFsTm2hjVUkbc+122a2tZm0n797F+53zE3POVTzzjM5Y9jDGfMRSy8fQdQMRjp6uxVcUYZifA76h3lNxFYJvPjYfgiDKUzkb/yHY6aGfiBrtT3m7IQ6CCoxy6cK1q8EgbwdshKg/DvMnIequFcAniTqHRWjSnIk+/g4YiVII2lACQTNWWoGM/eb+0nPmQrXDSzqOmFu7fG5aZP4MxtlF5vfzZebr5ZXmS/gS80Mgy8y3klXm8/FF5tcz1lzHGNfNo5AHCVA5pjse8F6LFOzEa4iL79iNBDs7HlAKwUrN3dABQQUE07SbpbkJXewD7Odv0XwKovMfIHiC/tiuudY+wHHDfy1EncR8NENcPHT9yE0IRhoisMOhW4MQZCEWB+yuE+WUNEHiWZ7cAAAAAElFTkSuQmCC"))))
collapsiblePanel.Add(New NRibbonButton("Copy", Nothing, Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAvklEQVR4AZWSQQrCMBBFBS8gCgjiWTzX/B7AA7gSgV5CsknoDQSXgndJx3yRQuPokIEHzVAej5CFiBwLweAEYLPwpuu6oKozuIsxUnIBsG4WAAg555BSouQMYOUKDnJ9w28n2i/gXkT0B3cAe6+Ae62HuxgjJU8Au78FlgCA5pw1pUTJA8C2LiAzQTmTmYDzkdyaCvq+/7qTpgLOOI4T/KelwLxU8ylXBSaTwJ6GAmNYtfQLfEFDgS0ZCuowvABHnjR+cwTY5AAAAABJRU5ErkJggg=="))))
collapsiblePanel.Add(New NRibbonButton("Format Painter", Nothing, Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAB4ElEQVR4AcXPA2woVgCF4TvbVjwEM2vjWbVt27Zt27Zt27bt9qzubPzJib8L8j/0AaOdY8mmjV3OESHkxh9VT5DT2AXsHYsO7J3HoCAXB3lpg4PfQuwJSam42AsvUatZWGbs2Dt1Q0igCYwUHqCluLf5a5j6BA0Nj6C2rgHDI6MIDA6Bk2cuRARPsCcovuLc/KUvPJMaIFFbkGCOns6U05tnZmZRWVWDnt4+6BmYQkjQEpRfcW1d4i8J+aYkSTWnLt92qjLTGquLGTg8KMbRYQkGBjLhFxiKsbFxWFrbIyYuEXfuc+NxQiLJRT21PhjsiMDeTuEJvMQnO9jJQn2lK3T0jeDrHwxtPSPIKamB7RYHjukj5KTSmPuB/Q3eWJpNvsT7u9nYWY3F6pgDFnr1UJSpDz4hCRiZWkJIVAos126fHPACuSja6iW1hkL700MO9vKxOeuHlVG7UzzWoIj2XD4Ee4iAk08ErNfvnOBb5KfZyDxtXJFhifFuVywNmp1jJbTn8aEsggVpLl/gBt1HJ/g2+bU0eN7zD3dXxnibIcYaFa+w6xdgoXjnBMuR3+vGJ8TOWFkYjdlSx5j5DH93if9YYuyvB2lJccBWgx6sFO9e4j+btuA9mtWnCMkg/2bfAxwyRdFvICBXAAAAAElFTkSuQmCC"))))
' Create the "Format" group of the "Home" tab page
group = New NRibbonGroup("Format")
pageHome.Groups.Add(group)
collapsiblePanel = New NRibbonCollapsiblePanel()
collapsiblePanel.InitialState = ENRibbonWidgetState.Medium
group.Items.Add(collapsiblePanel)
Dim fillSplitButton As NFillSplitButton = New NFillSplitButton()
collapsiblePanel.Add(fillSplitButton)
Dim strokeSplitButton As NStrokeSplitButton = New NStrokeSplitButton()
collapsiblePanel.Add(strokeSplitButton)
'
' Add an "Insert" ribbon tab page
'
ribbon.Tab.TabPages.Add(New NRibbonTabPage("Insert"))
Return ribbon
End Function
Private Function CreateCommandBars() As NCommandBarManager
Dim manager As NCommandBarManager = New NCommandBarManager()
' Create a menu bar in the first lane
Dim lane1 As NCommandBarLane = New NCommandBarLane()
manager.TopDock.Add(lane1)
Dim menuBar As NMenuBar = New NMenuBar()
menuBar.HideGripperAndPendant()
lane1.Add(menuBar)
Dim fileMenu As NMenuDropDown = New NMenuDropDown("File")
menuBar.Items.Add(fileMenu)
Dim newMenuItem As NMenuItem = New NMenuItem(Presentation.NResources.Image_File_New_svg, "New")
fileMenu.Items.Add(newMenuItem)
newMenuItem.Items.Add(New NMenuItem("Project"))
newMenuItem.Items.Add(New NMenuItem("Web Site"))
newMenuItem.Items.Add(New NMenuItem("File"))
fileMenu.Items.Add(New NMenuItem(Presentation.NResources.Image_File_Open_svg, "Open"))
fileMenu.Items.Add(New NMenuItem(Presentation.NResources.Image_File_Save_svg, "Save"))
fileMenu.Items.Add(New NMenuSeparator())
fileMenu.Items.Add(New NMenuItem(Presentation.NResources.Image_File_Print_svg, "Print"))
Dim editMenu As NMenuDropDown = New NMenuDropDown("Edit")
menuBar.Items.Add(editMenu)
editMenu.Items.Add(New NMenuItem(Presentation.NResources.Image_Edit_Undo_svg, "Undo"))
editMenu.Items.Add(New NMenuItem(Presentation.NResources.Image_Edit_Redo_svg, "Redo"))
' Add a toolbar in the second lane
Dim lane2 As NCommandBarLane = New NCommandBarLane()
manager.TopDock.Add(lane2)
Dim toolbar As NToolBar = New NToolBar()
toolbar.HideGripperAndPendant()
lane2.Add(toolbar)
toolbar.Items.Add(NButton.CreateImageAndText(Presentation.NResources.Image_File_New_svg, "New"))
toolbar.Items.Add(NButton.CreateImageAndText(Presentation.NResources.Image_File_Open_svg, "Open"))
toolbar.Items.Add(NButton.CreateImageAndText(Presentation.NResources.Image_File_Save_svg, "Save"))
toolbar.Items.Add(New NCommandBarSeparator())
toolbar.Items.Add(NButton.CreateImageAndText(Presentation.NResources.Image_File_Print_svg, "Print"))
' Add a toolbar in the third lane
Dim lane3 As NCommandBarLane = New NCommandBarLane()
manager.TopDock.Add(lane3)
toolbar = New NToolBar()
toolbar.HideGripperAndPendant()
lane3.Add(toolbar)
toolbar.Items.Add(CreateComboBox())
toolbar.Items.Add(New NCommandBarSeparator())
toolbar.Items.Add(NToggleButton.CreateImageAndText(Presentation.NResources.Image_FontStyle_Bold_svg, "Bold"))
toolbar.Items.Add(New NCheckBox("Plain Text"))
Return manager
End Function
Private Function CreateWindows() As NStackPanel
Dim stack As NStackPanel = New NStackPanel()
stack.VerticalSpacing = 10
' create a button which shows a top-level window, added to the NDocumentBoxSurface.Windows collection.
' such top-level windows will use the style sheets applied to the NDocumentBox.
Dim windowButton As NButton = New NButton("Show Window...")
windowButton.Click += Sub(arg As NEventArgs)
Dim window = NApplication.CreateTopLevelWindow(m_DocumentBox.Surface)
window.Title = "Top-Level Window"
Dim windowStack As NStackPanel = New NStackPanel()
Dim label As NLabel = New NLabel("Top-level windows that are added to the NDocumentBoxSurface Windows collection," & vbCrLf & " will use the NDocumentBox styling.")
windowStack.Add(label)
Dim buttonStrip As NButtonStrip = New NButtonStrip()
buttonStrip.AddCloseButton()
windowStack.Add(buttonStrip)
window.Content = windowStack
window.Open()
End Sub
stack.Add(windowButton)
' message box
Dim showMessageBoxButton As NButton = New NButton("Show MessageBox...")
showMessageBoxButton.Click += Sub(arg As NEventArgs)
Dim msgBoxSettings As NMessageBoxSettings = New NMessageBoxSettings("Message boxes that are added to the NDocumentBoxSurface Windows collection," & vbCrLf & " will use the NDocumentBox styling.", "Message box title")
msgBoxSettings.WindowsContainer = m_DocumentBox.Surface
NMessageBox.Show(msgBoxSettings)
End Sub
stack.Add(showMessageBoxButton)
Return stack
End Function
Private Function CreateGroupBox(header As Object, content As Object) As NGroupBox
Dim groupBox As NGroupBox = New NGroupBox(header, content)
' Check whether the application is in touch mode and set the size of the group box accordingly
groupBox.PreferredSize = If(NApplication.Desktop.TouchMode, New NSize(360, 250), New NSize(260, 180)) ' touch mode size
' regular mode size
Return groupBox
End Function
#End Region
#Region "Event Handlers"
Private Sub OnEnabledCheckBoxCheckedChanged(arg As NValueChangeEventArgs)
m_DocumentBox.Surface.Content.Enabled = CBool(arg.NewValue)
End Sub
Private Sub OnThemeTreeViewSelectedPathChanged(arg1 As NValueChangeEventArgs)
Dim treeView = CType(arg1.CurrentTargetNode, NTreeView)
Dim selectedItem = treeView.SelectedItem
If selectedItem Is Nothing Then Return
If TypeOf selectedItem.Tag Is NTheme Then
' Apply the selected theme to the document box's document
Dim theme As NTheme = selectedItem.Tag
m_DocumentBox.Document.InheritStyleSheets = False
m_DocumentBox.Document.StyleSheets.ApplyTheme(theme)
Dim styleSheet As NStyleSheet = New NStyleSheet()
Dim rule = styleSheet.CreateRule(Sub(sb) sb.Type(NWrapFlowLayout.NWrapFlowLayoutSchema))
rule.AddValueDeclaration(NDirectedBoxLayout.DirectionProperty, ENHVDirection.LeftToRight)
m_DocumentBox.Document.StyleSheets.Add(styleSheet)
ElseIf NStringHelpers.Equals(selectedItem.Tag, "inherit") Then
' Make the document inherit its style sheets and clear all current ones
m_DocumentBox.Document.InheritStyleSheets = True
m_DocumentBox.Document.StyleSheets.Clear()
End If
End Sub
#End Region
#Region "Fields"
Private m_DocumentBox As NDocumentBox
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
'''
''' A custom NOV theme based on the Windows 11 theme.
'''
Public Class NCustomTheme
Inherits NWindows11Theme
'''
''' Static constructor.
'''
Shared Sub New()
NCustomThemeSchema = NSchema.Create(GetType(NCustomTheme), NWindows11ThemeSchema)
End Sub
'''
''' Creates button styles.
'''
Protected Overrides Sub CreateButtonStyles(buttonSchema As NSchema)
' Change mouse over background fill to orange
Dim mouseOverState = CType(Skins.Button.GetState(NSkinState.MouseOver), NColorSkinState)
mouseOverState.BackgroundFill = New NColorFill(NColor.Orange)
' Change pressed button border to 3px purple border, background fill to dark red and text fill to white
Dim pressedState = CType(Skins.Button.GetState(NSkinState.Pressed), NColorSkinState)
pressedState.SetBorderFill(New NColorFill(NColor.Green))
pressedState.BorderThickness = New NMargins(3)
pressedState.BackgroundFill = New NColorFill(NColor.DarkRed)
pressedState.TextFill = New NColorFill(NColor.White)
' Call base to skin the buttons
MyBase.CreateButtonStyles(buttonSchema)
End Sub
'''
''' Creates flat button styles, which are buttons commonly in ribbon and toolbars.
'''
Protected Overrides Sub CreateFlatButtonStyles()
Dim mouseOverState = CType(Skins.FlatButton.GetState(NSkinState.MouseOver), NColorSkinState)
mouseOverState.BackgroundFill = New NColorFill(NColor.Orange)
' Call base to skin flat buttons
MyBase.CreateFlatButtonStyles()
End Sub
'''
''' Creates the tab styles. Overriden to make the mouse over state orange.
'''
Protected Overrides Sub CreateTabStyles()
' Modify the tab skins
Dim backgroundColor = NColor.Orange
Dim tabSkins = New NSkin() {MyBase.TabSkins.Top.Far, MyBase.TabSkins.Top.Inner, MyBase.TabSkins.Top.NearAndFar, MyBase.TabSkins.Top.Near}
For i = 0 To tabSkins.Length - 1
Dim state = CType(tabSkins(i).GetState(NSkinState.MouseOver), NColorSkinState)
state.BackgroundFill = New NColorFill(backgroundColor)
Next
' Call base to skin the tab widget
MyBase.CreateTabStyles()
End Sub
'''
''' Schema associated with NCustomTheme.
'''
Public Shared ReadOnly NCustomThemeSchema As NSchema
End Class
#End Region
End Class