First Look Example for WinForms

Nevron NOV UserInterface for WinForms ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All WinForms UserInterface examples are also available as a stand-alone Visual Studio solution in C# and VB.NET, which you can download from the links below.

First Look Example for WinForms Description

This example demonstrates how to create a pair box. The pair box is a widget, which consists of 2 other widgets - Box1 and Box2. You can change the relative alignment, the spacing and the size mode of this widgets using the controls to the right.


Pair Box Example

C# First Look Example Code for Nevron UserInterface for WinForms
Language: C#

using Nevron.Nov;
using Nevron.Nov.DataStructures;
using Nevron.Nov.Dom;
using Nevron.Nov.Editors;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.Presentation;
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 - NPairBoxExample";

			// 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()
		{
			m_PairBox = new NPairBox(CreateBoxContent("Box 1", NColor.Blue), CreateBoxContent("Box 2", NColor.Red));
			m_PairBox.HorizontalPlacement = ENHorizontalPlacement.Left;
			m_PairBox.VerticalPlacement = ENVerticalPlacement.Top;

			// The Spacing property is automatically set from the UI theme to NDesign.HorizontalSpacing,
			// so you don't need to set it. It is set here only for the purposes of the example.
			m_PairBox.Spacing = NDesign.HorizontalSpacing;

			return m_PairBox;
		}
		public NWidget CreateExampleControls()
		{
			NStackPanel stack = new NStackPanel();
			
			NList editors = NDesigner.GetDesigner(m_PairBox).CreateMemberEditors(m_PairBox,
				NPairBox.EnabledProperty,
				NPairBox.HorizontalPlacementProperty,
				NPairBox.VerticalPlacementProperty,
				NPairBox.BoxesRelationProperty,
				NPairBox.FitModeProperty,
				NPairBox.FillModeProperty,
				NPairBox.SpacingProperty);

			for (int i = 0, count = editors.Count; i < count; i++)
			{
				stack.Add(editors[i]);
			}

			return new NUniSizeBoxGroup(stack);
		}
		public string GetExampleDescription()
		{
			return @"

This example demonstrates how to create a pair box. The pair box is a widget, which consists of 2 other widgets - Box1 and Box2. You can change the relative alignment, the spacing and the size mode of this widgets using the controls to the right.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Pair Box", "https://www.nevron.com/docs/openvision/ui-pair-box.html"), ("Containers Overview", "https://www.nevron.com/docs/openvision/ui-containers-overview.html"), }; } #endregion #region Implementation private NWidget CreateBoxContent(string text, NColor borderColor) { NLabel label = new NLabel(text); label.HorizontalPlacement = ENHorizontalPlacement.Center; label.VerticalPlacement = ENVerticalPlacement.Center; NContentHolder contentElement = new NContentHolder(label); contentElement.Border = NBorder.CreateFilledBorder(borderColor); contentElement.BorderThickness = new NMargins(1); contentElement.Padding = new NMargins(2); return contentElement; } #endregion #region Event Handlers #endregion #region Fields private NPairBox m_PairBox; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) First Look Example for WinForms Solution

VB.NET First Look Example Code for Nevron UserInterface for WinForms
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Editors
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 - NPairBoxExample"

        ' 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
            m_PairBox = New NPairBox(CreateBoxContent("Box 1", NColor.Blue), CreateBoxContent("Box 2", NColor.Red))
            m_PairBox.HorizontalPlacement = ENHorizontalPlacement.Left
            m_PairBox.VerticalPlacement = ENVerticalPlacement.Top

            ' The Spacing property is automatically set from the UI theme to NDesign.HorizontalSpacing,
            ' so you don't need to set it. It is set here only for the purposes of the example.
            m_PairBox.Spacing = NDesign.HorizontalSpacing

            Return m_PairBox
        End Function
        Public Function CreateExampleControls() As NWidget
            Dim stack As NStackPanel = New NStackPanel()

            Dim editors = NDesigner.GetDesigner(m_PairBox).CreateMemberEditors(m_PairBox, NInputElement.EnabledProperty, NWidget.HorizontalPlacementProperty, NWidget.VerticalPlacementProperty, NPairBox.BoxesRelationProperty, NPairBox.FitModeProperty, NPairBox.FillModeProperty, NPairBox.SpacingProperty)

            Dim i = 0, count = editors.Count

            While i < count
                stack.Add(editors(i))
                i += 1
            End While

            Return New NUniSizeBoxGroup(stack)
        End Function
        Public Function GetExampleDescription() As String
            Return "

This example demonstrates how to create a pair box. The pair box is a widget, which consists of 2 other widgets - Box1 and Box2. You can change the relative alignment, the spacing and the size mode of this widgets using the controls to the right.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Pair Box", "https://www.nevron.com/docs/openvision/ui-pair-box.html"), ("Containers Overview", "https://www.nevron.com/docs/openvision/ui-containers-overview.html")} End Function #End Region #Region "Implementation" Private Function CreateBoxContent(text As String, borderColor As NColor) As NWidget Dim label As NLabel = New NLabel(text) label.HorizontalPlacement = ENHorizontalPlacement.Center label.VerticalPlacement = ENVerticalPlacement.Center Dim contentElement As NContentHolder = New NContentHolder(label) contentElement.Border = NBorder.CreateFilledBorder(borderColor) contentElement.BorderThickness = New NMargins(1) contentElement.Padding = New NMargins(2) Return contentElement End Function #End Region #Region "Event Handlers" #End Region #Region "Fields" Private m_PairBox As NPairBox #End Region #Region "Static Methods" #End Region #Region "Constants" #End Region #Region "Nested Types" #End Region End Class

Download a fully functional VB.NET (.vb) First Look Example for WinForms Solution

Related Documentation Links