This example demonstrates how to control the paint order of gauge indicators.

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.Chart;
using Nevron.Nov.Dom;
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 - NIndicatorPaintOrderExample";
// 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;
NStackPanel controlStack = new NStackPanel();
stack.Add(controlStack);
// create the radial gauge
m_RadialGauge = new NRadialGauge();
m_RadialGauge.SweepAngle = new NAngle(270, NUnit.Degree);
m_RadialGauge.BeginAngle = new NAngle(-225, NUnit.Degree);
m_RadialGauge.PreferredSize = defaultRadialGaugeSize;
m_RadialGauge.CapEffect = new NGlassCapEffect();
m_RadialGauge.Dial = new NDial(ENDialShape.RoundedOutline, new NEdgeDialRim());
m_RadialGauge.Dial.BackgroundFill = new NStockGradientFill(NColor.DarkGray, NColor.Black);
// configure scale
NGaugeAxis axis = new NGaugeAxis();
m_RadialGauge.Axes.Add(axis);
NLinearScale scale = (NLinearScale)axis.Scale;
scale.SetPredefinedScale(ENPredefinedScaleStyle.Presentation);
scale.Labels.Style.TextStyle.Font = new NFont("Arimo", 10, ENFontStyle.Bold);
scale.Labels.Style.TextStyle.Fill = new NColorFill(NColor.White);
scale.Labels.Style.Angle = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 90.0);
scale.MinorTickCount = 4;
scale.Ruler.Stroke.Width = 0;
scale.Ruler.Fill = new NColorFill(NColor.DarkGray);
// add radial gauge indicators
m_ValueIndicator = new NNeedleValueIndicator();
m_ValueIndicator.Fill = new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, NColor.White, NColor.Red);
m_ValueIndicator.Stroke.Color = NColor.Red;
m_ValueIndicator.Width = 15;
m_ValueIndicator.OffsetFromScale = -10;
m_RadialGauge.Indicators.Add(m_ValueIndicator);
NStackPanel verticalStack = new NStackPanel();
verticalStack.Direction = Layout.ENHVDirection.TopToBottom;
verticalStack.Padding = new NMargins(80, 200, 80, 0);
m_NumericLedDisplay = new NNumericLedDisplay();
m_NumericLedDisplay.Value = 0.0;
m_NumericLedDisplay.CellCountMode = ENDisplayCellCountMode.Fixed;
m_NumericLedDisplay.CellCount = 7;
m_NumericLedDisplay.BackgroundFill = new NColorFill(NColor.Black);
m_NumericLedDisplay.Border = NBorder.CreateSunken3DBorder(new NUIThemeColorMap(ENUIThemeScheme.WindowsClassic));
m_NumericLedDisplay.BorderThickness = new NMargins(6);
m_NumericLedDisplay.Margins = new NMargins(5);
m_NumericLedDisplay.Padding = new NMargins(5);
NGelCapEffect gelCap = new NGelCapEffect();
gelCap.Shape = ENCapEffectShape.RoundedRect;
m_NumericLedDisplay.CapEffect = gelCap;
m_NumericLedDisplay.PreferredHeight = 60;
verticalStack.Add(m_NumericLedDisplay);
m_RadialGauge.Content = verticalStack;
// add radial gauge
controlStack.Add(m_RadialGauge);
m_DataFeedTimer = new NTimer();
m_DataFeedTimer.Tick += OnDataFeedTimerTick;
m_DataFeedTimer.Start();
return stack;
}
///
///
///
protected void OnUnregistered()
{
base.OnUnregistered();
m_DataFeedTimer.Stop();
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
NStackPanel propertyStack = new NStackPanel();
stack.Add(new NUniSizeBoxGroup(propertyStack));
propertyStack.Add(new NLabel("Paint Order:"));
m_PaintOrderComboBox = new NComboBox();
propertyStack.Add(m_PaintOrderComboBox);
m_PaintOrderComboBox.Items.FillFromEnum();
m_PaintOrderComboBox.SelectedIndexChanged += OnPaintOrderComboBoxSelectedIndexChanged;
m_PaintOrderComboBox.SelectedIndex = (int)ENIndicatorPaintOrder.AfterScale;
return stack;
}
public string GetExampleDescription()
{
return @"This example demonstrates how to control the paint order of gauge indicators.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Gauges Indicators Overview", "https://www.nevron.com/docs/openvision/gauges-indicators-overview.html"),
("Gauges Needle Indicator", "https://www.nevron.com/docs/openvision/gauges-needle-indicator.html"),
("Gauges Range Indicator", "https://www.nevron.com/docs/openvision/gauges-range-indicator.html"),
("Gauges Marker Indicator", "https://www.nevron.com/docs/openvision/gauges-marker-indicator.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
///
///
///
///
void OnPaintOrderComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
{
// set the paint order
m_ValueIndicator.PaintOrder = (ENIndicatorPaintOrder)m_PaintOrderComboBox.SelectedIndex;
}
///
///
///
void OnDataFeedTimerTick()
{
// update the indicator and the numeric led display
m_FirstIndicatorAngle += 0.02;
double value = 50.0 - Math.Cos(m_FirstIndicatorAngle) * 50.0;
m_ValueIndicator.Value = value;
m_NumericLedDisplay.Value = value;
}
#endregion
#region Fields
NRadialGauge m_RadialGauge;
NNeedleValueIndicator m_ValueIndicator;
NNumericLedDisplay m_NumericLedDisplay;
NTimer m_DataFeedTimer;
double m_FirstIndicatorAngle;
NComboBox m_PaintOrderComboBox;
#endregion
#region Static Methods
#endregion
#region Constants
private static readonly NSize defaultRadialGaugeSize = new NSize(300, 300);
#endregion
#region Nested Types
#endregion
}
} | Language: VB.NET |
Imports Nevron.Nov
Imports Nevron.Nov.Chart
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Wpf
Imports System
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 - NIndicatorPaintOrderExample"
' 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
Dim controlStack As NStackPanel = New NStackPanel()
stack.Add(controlStack)
' create the radial gauge
m_RadialGauge = New NRadialGauge()
m_RadialGauge.SweepAngle = New NAngle(270, NUnit.Degree)
m_RadialGauge.BeginAngle = New NAngle(-225, NUnit.Degree)
m_RadialGauge.PreferredSize = defaultRadialGaugeSize
m_RadialGauge.CapEffect = New NGlassCapEffect()
m_RadialGauge.Dial = New NDial(ENDialShape.RoundedOutline, New NEdgeDialRim())
m_RadialGauge.Dial.BackgroundFill = New NStockGradientFill(NColor.DarkGray, NColor.Black)
' configure scale
Dim axis As NGaugeAxis = New NGaugeAxis()
m_RadialGauge.Axes.Add(axis)
Dim scale = CType(axis.Scale, NLinearScale)
scale.SetPredefinedScale(ENPredefinedScaleStyle.Presentation)
scale.Labels.Style.TextStyle.Font = New NFont("Arimo", 10, ENFontStyle.Bold)
scale.Labels.Style.TextStyle.Fill = New NColorFill(NColor.White)
scale.Labels.Style.Angle = New NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 90.0)
scale.MinorTickCount = 4
scale.Ruler.Stroke.Width = 0
scale.Ruler.Fill = New NColorFill(NColor.DarkGray)
' add radial gauge indicators
m_ValueIndicator = New NNeedleValueIndicator()
m_ValueIndicator.Fill = New NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, NColor.White, NColor.Red)
m_ValueIndicator.Stroke.Color = NColor.Red
m_ValueIndicator.Width = 15
m_ValueIndicator.OffsetFromScale = -10
m_RadialGauge.Indicators.Add(m_ValueIndicator)
Dim verticalStack As NStackPanel = New NStackPanel()
verticalStack.Direction = ENHVDirection.TopToBottom
verticalStack.Padding = New NMargins(80, 200, 80, 0)
m_NumericLedDisplay = New NNumericLedDisplay()
m_NumericLedDisplay.Value = 0.0
m_NumericLedDisplay.CellCountMode = ENDisplayCellCountMode.Fixed
m_NumericLedDisplay.CellCount = 7
m_NumericLedDisplay.BackgroundFill = New NColorFill(NColor.Black)
m_NumericLedDisplay.Border = NBorder.CreateSunken3DBorder(New NUIThemeColorMap(ENUIThemeScheme.WindowsClassic))
m_NumericLedDisplay.BorderThickness = New NMargins(6)
m_NumericLedDisplay.Margins = New NMargins(5)
m_NumericLedDisplay.Padding = New NMargins(5)
Dim gelCap As NGelCapEffect = New NGelCapEffect()
gelCap.Shape = ENCapEffectShape.RoundedRect
m_NumericLedDisplay.CapEffect = gelCap
m_NumericLedDisplay.PreferredHeight = 60
verticalStack.Add(m_NumericLedDisplay)
m_RadialGauge.Content = verticalStack
' add radial gauge
controlStack.Add(m_RadialGauge)
m_DataFeedTimer = New NTimer()
Me.m_DataFeedTimer.Tick += AddressOf OnDataFeedTimerTick
m_DataFeedTimer.Start()
Return stack
End Function
'''
'''
'''
Protected Sub OnUnregistered()
MyBase.OnUnregistered()
m_DataFeedTimer.Stop()
End Sub
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
Dim propertyStack As NStackPanel = New NStackPanel()
stack.Add(New NUniSizeBoxGroup(propertyStack))
propertyStack.Add(New NLabel("Paint Order:"))
m_PaintOrderComboBox = New NComboBox()
propertyStack.Add(m_PaintOrderComboBox)
m_PaintOrderComboBox.Items.FillFromEnum(Of ENIndicatorPaintOrder)()
Me.m_PaintOrderComboBox.SelectedIndexChanged += AddressOf OnPaintOrderComboBoxSelectedIndexChanged
m_PaintOrderComboBox.SelectedIndex = CInt(ENIndicatorPaintOrder.AfterScale)
Return stack
End Function
Public Function GetExampleDescription() As String
Return "This example demonstrates how to control the paint order of gauge indicators.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Gauges Indicators Overview", "https://www.nevron.com/docs/openvision/gauges-indicators-overview.html"), ("Gauges Needle Indicator", "https://www.nevron.com/docs/openvision/gauges-needle-indicator.html"), ("Gauges Range Indicator", "https://www.nevron.com/docs/openvision/gauges-range-indicator.html"), ("Gauges Marker Indicator", "https://www.nevron.com/docs/openvision/gauges-marker-indicator.html")}
End Function
#End Region
#Region "Implementation"
#End Region
#Region "Event Handlers"
'''
'''
'''
'''
Private Sub OnPaintOrderComboBoxSelectedIndexChanged(arg As NValueChangeEventArgs)
' set the paint order
m_ValueIndicator.PaintOrder = CType(m_PaintOrderComboBox.SelectedIndex, ENIndicatorPaintOrder)
End Sub
'''
'''
'''
Private Sub OnDataFeedTimerTick()
' update the indicator and the numeric led display
m_FirstIndicatorAngle += 0.02
Dim value = 50.0 - Math.Cos(m_FirstIndicatorAngle) * 50.0
m_ValueIndicator.Value = value
m_NumericLedDisplay.Value = value
End Sub
#End Region
#Region "Fields"
Private m_RadialGauge As NRadialGauge
Private m_ValueIndicator As NNeedleValueIndicator
Private m_NumericLedDisplay As NNumericLedDisplay
Private m_DataFeedTimer As NTimer
Private m_FirstIndicatorAngle As Double
Private m_PaintOrderComboBox As NComboBox
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
Private Shared ReadOnly defaultRadialGaugeSize As NSize = New NSize(300, 300)
#End Region
#Region "Nested Types"
#End Region
End Class