The example demonstrates the properties of the text led display.

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.Dom;
using Nevron.Nov.Editors;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System;
using System.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NTextLedDisplayExample";
// 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()
{
NStackPanel stack = new NStackPanel();
stack.HorizontalPlacement = ENHorizontalPlacement.Left;
m_TextDisplay1 = CreateTextLedDisplay();
stack.Add(m_TextDisplay1);
m_TextDisplay2 = CreateTextLedDisplay();
stack.Add(m_TextDisplay2);
m_TextDisplay3 = CreateTextLedDisplay();
stack.Add(m_TextDisplay3);
return stack;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NStackPanel propertyStack = new NStackPanel();
stack.Add(new NUniSizeBoxGroup(propertyStack));
m_CellCountUpDown = new NNumericUpDown();
m_CellCountUpDown.ValueChanged += OnCellCountValueChanged;
m_CellCountUpDown.Value = 20;
propertyStack.Add(NPairBox.Create("Cell Count:", m_CellCountUpDown));
// init form controls
m_CellSizeComboBox = new NComboBox();
propertyStack.Add(new NPairBox("Cell Size:", m_CellSizeComboBox, true));
m_CellSizeComboBox.Items.Add(new NComboBoxItem("Small"));
m_CellSizeComboBox.Items.Add(new NComboBoxItem("Normal"));
m_CellSizeComboBox.Items.Add(new NComboBoxItem("Large"));
m_CellSizeComboBox.SelectedIndex = 1;
m_CellSizeComboBox.SelectedIndexChanged += OnCellSizeComboBoxSelectedIndexChanged;
m_DisplayStyleComboBox = new NComboBox();
propertyStack.Add(new NPairBox("Display Style:", m_DisplayStyleComboBox, true));
m_DisplayStyleComboBox.Items.FillFromEnum();
m_DisplayStyleComboBox.SelectedIndexChanged += OnDisplayStyleComboBoxSelectedIndexChanged;
m_DisplayStyleComboBox.SelectedIndex = (int)ENDisplayStyle.MatrixCircle;
NButton litFillButton = new NButton("Lit Fill");
litFillButton.Click += OnLitFillButtonClick;
propertyStack.Add(litFillButton);
NButton dimFillButton = new NButton("Dim Fill");
dimFillButton.Click += OnDimFillButtonClick;
propertyStack.Add(dimFillButton);
NTextBox textBox1 = new NTextBox();
textBox1.TextChanged += OnTextBox1TextChanged;
textBox1.Text = "Custom Text 1";
propertyStack.Add(NPairBox.Create("Text 1", textBox1));
NTextBox textBox2 = new NTextBox();
textBox2.TextChanged += OnTextBox2TextChanged;
textBox2.Text = "Custom Text 2";
propertyStack.Add(NPairBox.Create("Text 2", textBox2));
NTextBox textBox3 = new NTextBox();
textBox3.TextChanged += OnTextBox3TextChanged;
textBox3.Text = "Custom Text 3";
propertyStack.Add(NPairBox.Create("Text 3", textBox3));
return stack;
}
public string GetExampleDescription()
{
return @"The example demonstrates the properties of the text led display.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Numeric LED Display", "https://www.nevron.com/docs/openvision/numeric-led-display.html"),
("Instrumentation Overview", "https://www.nevron.com/docs/openvision/instrumentation-overview.html"),
};
}
#endregion
#region Implementation
private NTextLedDisplay CreateTextLedDisplay()
{
NTextLedDisplay textLedDisply = new NTextLedDisplay();
textLedDisply.CellCountMode = ENDisplayCellCountMode.Fixed;
textLedDisply.CellCount = 7;
textLedDisply.BackgroundFill = new NColorFill(NColor.Black);
textLedDisply.Border = NBorder.CreateSunken3DBorder(new NUIThemeColorMap(ENUIThemeScheme.WindowsClassic));
textLedDisply.BorderThickness = new NMargins(6);
textLedDisply.Margins = new NMargins(5);
textLedDisply.Padding = new NMargins(5);
textLedDisply.CapEffect = new NGelCapEffect();
return textLedDisply;
}
#endregion
#region Event Handlers
void OnLitFillButtonClick(NEventArgs arg)
{
NEditorWindow.CreateForType(
(NFill)m_TextDisplay1.LitFill.DeepClone(),
null,
m_TextDisplay1.DisplayWindow,
false,
OnLitFillEdited).Open();
}
void OnLitFillEdited(NFill fill)
{
m_TextDisplay1.LitFill = (NFill)(fill.DeepClone());
m_TextDisplay2.LitFill = (NFill)(fill.DeepClone());
m_TextDisplay3.LitFill = (NFill)(fill.DeepClone());
}
void OnDimFillButtonClick(NEventArgs arg)
{
NEditorWindow.CreateForType(
(NFill)m_TextDisplay1.DimFill.DeepClone(),
null,
m_TextDisplay1.DisplayWindow,
false,
OnDimFillEdited).Open();
}
void OnDimFillEdited(NFill fill)
{
m_TextDisplay1.DimFill = (NFill)(fill.DeepClone());
m_TextDisplay2.DimFill = (NFill)(fill.DeepClone());
m_TextDisplay3.DimFill = (NFill)(fill.DeepClone());
}
void OnCellSizeComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
double segmentWidth = 0.0;
double segmentGap = 0.0;
NSize cellSize = new NSize(0.0, 0.0);
switch (m_CellSizeComboBox.SelectedIndex)
{
case 0: // small
segmentWidth = 2.0;
segmentGap = 1.0;
cellSize = new NSize(15, 30);
break;
case 1: // normal
segmentWidth = 3;
segmentGap = 1;
cellSize = new NSize(20, 40);
break;
case 2: // large
segmentWidth = 4;
segmentGap = 2;
cellSize = new NSize(26, 52);
break;
}
NTextLedDisplay[] displays = new NTextLedDisplay[] { m_TextDisplay1, m_TextDisplay2, m_TextDisplay3 };
for (int i = 0; i < displays.Length; i++)
{
NTextLedDisplay display = displays[i];
display.CellSize = cellSize;
display.SegmentGap = segmentGap;
display.SegmentWidth = segmentWidth;
}
}
void OnDisplayStyleComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
m_TextDisplay1.DisplayStyle = (ENDisplayStyle)m_DisplayStyleComboBox.SelectedIndex;
m_TextDisplay2.DisplayStyle = (ENDisplayStyle)m_DisplayStyleComboBox.SelectedIndex;
m_TextDisplay3.DisplayStyle = (ENDisplayStyle)m_DisplayStyleComboBox.SelectedIndex;
}
private void OnTextBox1TextChanged(NValueChangeEventArgs arg)
{
m_TextDisplay1.Text = (string)arg.NewValue;
}
private void OnTextBox2TextChanged(NValueChangeEventArgs arg)
{
m_TextDisplay2.Text = (string)arg.NewValue;
}
private void OnTextBox3TextChanged(NValueChangeEventArgs arg)
{
m_TextDisplay3.Text = (string)arg.NewValue;
}
private void OnCellCountValueChanged(NValueChangeEventArgs arg)
{
m_TextDisplay1.CellCount = (int)m_CellCountUpDown.Value;
m_TextDisplay2.CellCount = (int)m_CellCountUpDown.Value;
m_TextDisplay3.CellCount = (int)m_CellCountUpDown.Value;
}
#endregion
#region Fields
private NComboBox m_DisplayStyleComboBox;
private NTextLedDisplay m_TextDisplay1;
private NTextLedDisplay m_TextDisplay2;
private NTextLedDisplay m_TextDisplay3;
private NComboBox m_CellSizeComboBox;
private NNumericUpDown m_CellCountUpDown;
#endregion
#region Static Methods
#endregion
#region Constants
#endregion
#region Nested Types
#endregion
}
} | Language: VB.NET |
Imports Nevron.Nov
Imports Nevron.Nov.Chart
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Editors
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Wpf
Class MainWindow
#Region "Constructors"
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
' Set form title
Title = "NOV WPF - NTextLedDisplayExample"
' 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)
Content = host
End Sub
#End Region
#Region "Example"
Public Function CreateExampleContent() As NWidget
Dim stack As NStackPanel = New NStackPanel()
stack.HorizontalPlacement = ENHorizontalPlacement.Left
m_TextDisplay1 = CreateTextLedDisplay()
stack.Add(m_TextDisplay1)
m_TextDisplay2 = CreateTextLedDisplay()
stack.Add(m_TextDisplay2)
m_TextDisplay3 = CreateTextLedDisplay()
stack.Add(m_TextDisplay3)
Return stack
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim propertyStack As NStackPanel = New NStackPanel()
stack.Add(New NUniSizeBoxGroup(propertyStack))
m_CellCountUpDown = New NNumericUpDown()
Me.m_CellCountUpDown.ValueChanged += AddressOf OnCellCountValueChanged
m_CellCountUpDown.Value = 20
propertyStack.Add(NPairBox.Create("Cell Count:", m_CellCountUpDown))
' init form controls
m_CellSizeComboBox = New NComboBox()
propertyStack.Add(New NPairBox("Cell Size:", m_CellSizeComboBox, True))
m_CellSizeComboBox.Items.Add(New NComboBoxItem("Small"))
m_CellSizeComboBox.Items.Add(New NComboBoxItem("Normal"))
m_CellSizeComboBox.Items.Add(New NComboBoxItem("Large"))
m_CellSizeComboBox.SelectedIndex = 1
Me.m_CellSizeComboBox.SelectedIndexChanged += AddressOf OnCellSizeComboBoxSelectedIndexChanged
m_DisplayStyleComboBox = New NComboBox()
propertyStack.Add(New NPairBox("Display Style:", m_DisplayStyleComboBox, True))
m_DisplayStyleComboBox.Items.FillFromEnum(Of ENDisplayStyle)()
Me.m_DisplayStyleComboBox.SelectedIndexChanged += AddressOf OnDisplayStyleComboBoxSelectedIndexChanged
m_DisplayStyleComboBox.SelectedIndex = CInt(ENDisplayStyle.MatrixCircle)
Dim litFillButton As NButton = New NButton("Lit Fill")
litFillButton.Click += AddressOf OnLitFillButtonClick
propertyStack.Add(litFillButton)
Dim dimFillButton As NButton = New NButton("Dim Fill")
dimFillButton.Click += AddressOf OnDimFillButtonClick
propertyStack.Add(dimFillButton)
Dim textBox1 As NTextBox = New NTextBox()
textBox1.TextChanged += AddressOf OnTextBox1TextChanged
textBox1.Text = "Custom Text 1"
propertyStack.Add(NPairBox.Create("Text 1", textBox1))
Dim textBox2 As NTextBox = New NTextBox()
textBox2.TextChanged += AddressOf OnTextBox2TextChanged
textBox2.Text = "Custom Text 2"
propertyStack.Add(NPairBox.Create("Text 2", textBox2))
Dim textBox3 As NTextBox = New NTextBox()
textBox3.TextChanged += AddressOf OnTextBox3TextChanged
textBox3.Text = "Custom Text 3"
propertyStack.Add(NPairBox.Create("Text 3", textBox3))
Return stack
End Function
Public Function GetExampleDescription() As String
Return "The example demonstrates the properties of the text led display.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Numeric LED Display", "https://www.nevron.com/docs/openvision/numeric-led-display.html"), ("Instrumentation Overview", "https://www.nevron.com/docs/openvision/instrumentation-overview.html")}
End Function
#End Region
#Region "Implementation"
Private Function CreateTextLedDisplay() As NTextLedDisplay
Dim textLedDisply As NTextLedDisplay = New NTextLedDisplay()
textLedDisply.CellCountMode = ENDisplayCellCountMode.Fixed
textLedDisply.CellCount = 7
textLedDisply.BackgroundFill = New NColorFill(NColor.Black)
textLedDisply.Border = NBorder.CreateSunken3DBorder(New NUIThemeColorMap(ENUIThemeScheme.WindowsClassic))
textLedDisply.BorderThickness = New NMargins(6)
textLedDisply.Margins = New NMargins(5)
textLedDisply.Padding = New NMargins(5)
textLedDisply.CapEffect = New NGelCapEffect()
Return textLedDisply
End Function
#End Region
#Region "Event Handlers"
Private Sub OnLitFillButtonClick(arg As NEventArgs)
Call NEditorWindow.CreateForType(CType(CType(m_TextDisplay1.LitFill.DeepClone(), NFill), NFill), Nothing, CType(m_TextDisplay1.DisplayWindow, NWindow), CBool(False), New DNFunction(Of T)(AddressOf OnLitFillEdited)).Open()
End Sub
Private Sub OnLitFillEdited(fill As NFill)
m_TextDisplay1.LitFill = CType((fill.DeepClone()), NFill)
m_TextDisplay2.LitFill = CType((fill.DeepClone()), NFill)
m_TextDisplay3.LitFill = CType((fill.DeepClone()), NFill)
End Sub
Private Sub OnDimFillButtonClick(arg As NEventArgs)
Call NEditorWindow.CreateForType(CType(CType(m_TextDisplay1.DimFill.DeepClone(), NFill), NFill), Nothing, CType(m_TextDisplay1.DisplayWindow, NWindow), CBool(False), New DNFunction(Of T)(AddressOf OnDimFillEdited)).Open()
End Sub
Private Sub OnDimFillEdited(fill As NFill)
m_TextDisplay1.DimFill = CType((fill.DeepClone()), NFill)
m_TextDisplay2.DimFill = CType((fill.DeepClone()), NFill)
m_TextDisplay3.DimFill = CType((fill.DeepClone()), NFill)
End Sub
Private Sub OnCellSizeComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs)
Dim segmentWidth = 0.0
Dim segmentGap = 0.0
Dim cellSize As NSize = New NSize(0.0, 0.0)
Select Case m_CellSizeComboBox.SelectedIndex
Case 0 ' small
segmentWidth = 2.0
segmentGap = 1.0
cellSize = New NSize(15, 30)
Case 1 ' normal
segmentWidth = 3
segmentGap = 1
cellSize = New NSize(20, 40)
Case 2 ' large
segmentWidth = 4
segmentGap = 2
cellSize = New NSize(26, 52)
End Select
Dim displays = New NTextLedDisplay() {m_TextDisplay1, m_TextDisplay2, m_TextDisplay3}
For i = 0 To displays.Length - 1
Dim display = displays(i)
display.CellSize = cellSize
display.SegmentGap = segmentGap
display.SegmentWidth = segmentWidth
Next
End Sub
Private Sub OnDisplayStyleComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs)
m_TextDisplay1.DisplayStyle = CType(m_DisplayStyleComboBox.SelectedIndex, ENDisplayStyle)
m_TextDisplay2.DisplayStyle = CType(m_DisplayStyleComboBox.SelectedIndex, ENDisplayStyle)
m_TextDisplay3.DisplayStyle = CType(m_DisplayStyleComboBox.SelectedIndex, ENDisplayStyle)
End Sub
Private Sub OnTextBox1TextChanged(arg As NValueChangeEventArgs)
m_TextDisplay1.Text = CStr(arg.NewValue)
End Sub
Private Sub OnTextBox2TextChanged(arg As NValueChangeEventArgs)
m_TextDisplay2.Text = CStr(arg.NewValue)
End Sub
Private Sub OnTextBox3TextChanged(arg As NValueChangeEventArgs)
m_TextDisplay3.Text = CStr(arg.NewValue)
End Sub
Private Sub OnCellCountValueChanged(arg As NValueChangeEventArgs)
m_TextDisplay1.CellCount = CInt(m_CellCountUpDown.Value)
m_TextDisplay2.CellCount = CInt(m_CellCountUpDown.Value)
m_TextDisplay3.CellCount = CInt(m_CellCountUpDown.Value)
End Sub
#End Region
#Region "Fields"
Private m_DisplayStyleComboBox As NComboBox
Private m_TextDisplay1 As NTextLedDisplay
Private m_TextDisplay2 As NTextLedDisplay
Private m_TextDisplay3 As NTextLedDisplay
Private m_CellSizeComboBox As NComboBox
Private m_CellCountUpDown As NNumericUpDown
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class