An RPM gauge is displayed using a mlutiplier, which allows for the increase or decrease in scale labels.

| 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 - NScaleMultiplierExample";
// 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.PreferredSize = defaultRadialGaugeSize;
m_RadialGauge.Dial = new NDial(ENDialShape.Circle, new NEdgeDialRim());
m_RadialGauge.SweepAngle = new NAngle(270, NUnit.Degree);
m_RadialGauge.BeginAngle = new NAngle(-225, NUnit.Degree);
NAdvancedGradientFill advancedGradient = new NAdvancedGradientFill();
advancedGradient.BackgroundColor = NColor.Black;
advancedGradient.Points.Add(new NAdvancedGradientPoint(NColor.CadetBlue, new NAngle(10, NUnit.Degree), 0.1f, 0, 1.0f, ENAdvancedGradientPointShape.Circle));
m_RadialGauge.Dial.BackgroundFill = advancedGradient;
m_RadialGauge.CapEffect = new NGlassCapEffect(ENCapEffectShape.Ellipse);
controlStack.Add(m_RadialGauge);
// configure scale
NGaugeAxis axis = new NGaugeAxis();
m_RadialGauge.Axes.Add(axis);
axis.Range = new NRange(0, 10000);
// add Scale
m_Scale = (NLinearScale)axis.Scale;
m_Scale.SetPredefinedScale(ENPredefinedScaleStyle.Presentation);
m_Scale.Labels.Style.TextStyle.Font = new NFont("Arimo", 10, ENFontStyle.Bold);
m_Scale.Labels.Style.TextStyle.Fill = new NColorFill(NColor.White);
m_Scale.MajorTickMode = ENMajorTickMode.CustomStep;
m_Scale.CustomStep = 1000;
m_Scale.MinorTickCount = 10;
m_Scale.Ruler.Fill = new NColorFill(NColor.Gray);
// add radial gauge indicators
m_ValueIndicator = new NNeedleValueIndicator();
m_ValueIndicator.Fill = new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, NColor.White, NColor.Red);
m_ValueIndicator.Width = 7;
m_ValueIndicator.OffsetFromScale = -10;
m_RadialGauge.Indicators.Add(m_ValueIndicator);
NStackPanel verticalStack = new NStackPanel();
verticalStack.Direction = Layout.ENHVDirection.TopToBottom;
verticalStack.Padding = new NMargins(80, 230, 80, 0);
// add Numeric Led dusplay
m_NumericLedDisplay = new NNumericLedDisplay();
m_NumericLedDisplay.CellCountMode = ENDisplayCellCountMode.Fixed;
m_NumericLedDisplay.CellCount = 7;
m_NumericLedDisplay.BackgroundFill = new NColorFill(NColor.Black);
m_NumericLedDisplay.Border = NBorder.CreateSunken3DBorder(new NUIThemeColorMap(ENUIThemeScheme.Brick));
m_NumericLedDisplay.BorderThickness = new NMargins(6);
m_NumericLedDisplay.Margins = new NMargins(5);
m_NumericLedDisplay.VerticalPlacement = ENVerticalPlacement.Bottom;
m_NumericLedDisplay.PreferredSize = new NSize(30, 50);
verticalStack.Add(m_NumericLedDisplay);
m_RadialGauge.Content = verticalStack;
// timer
m_DataFeedTimer = new NTimer();
m_DataFeedTimer.Tick += OnDataFeedTimerTick;
m_DataFeedTimer.Start();
return stack;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
m_MultiplierRadioGroup = new NRadioButtonGroup();
m_MultiplierRadioGroup.SelectedIndexChanged += OnMultiplierRadioGroupIndexChanged;
NStackPanel radioStack = new NStackPanel();
m_MultiplierRadioGroup.Content = radioStack;
radioStack.Add(new NRadioButton("10"));
radioStack.Add(new NRadioButton("1"));
radioStack.Add(new NRadioButton("0.1"));
radioStack.Add(new NRadioButton("0.01"));
radioStack.Add(new NRadioButton("0.001"));
((NRadioButton)radioStack[1]).Checked = true;
stack.Add(new NGroupBox("Multiplier Value: ", m_MultiplierRadioGroup));
return stack;
}
public string GetExampleDescription()
{
return @" An RPM gauge is displayed using a mlutiplier, which allows for the increase or decrease in scale labels.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Gauges Axes", "https://www.nevron.com/docs/openvision/gauges-axes.html"),
("Scales Overview", "https://www.nevron.com/docs/openvision/scales-overview.html"),
("Gauges Overview", "https://www.nevron.com/docs/openvision/gauges-overview.html"),
("Scale Labels Formatting", "https://www.nevron.com/docs/openvision/scale-labels-formatting.html"),
};
}
#endregion
#region Implementation
#endregion
#region Event Handlers
private void OnMultiplierRadioGroupIndexChanged(NValueChangeEventArgs arg)
{
int selectedIndex = m_MultiplierRadioGroup.SelectedIndex;
switch (selectedIndex)
{
case 0:
// handle "10" radio button
m_RadialGauge.Axes[0].Range = new NRange(0, 100000);
m_Scale.CustomStep = 10000;
// create a scale title - RPM X 10
m_RadialGauge.Axes[0].Scale.Title.Text = "RPM X 10";
m_RadialGauge.Axes[0].Scale.Title.TextStyle = new NTextStyle(NColor.Red);
break;
case 1:
// handle "1" radio button
m_RadialGauge.Axes[0].Range = new NRange(0, 10000);
m_Scale.CustomStep = 1000;
// create a scale title - RPM
m_RadialGauge.Axes[0].Scale.Title.Text = "RPM";
m_RadialGauge.Axes[0].Scale.Title.TextStyle = new NTextStyle(NColor.Red);
break;
case 2:
// handle "0.1" radio button
m_RadialGauge.Axes[0].Range = new NRange(0, 1000);
m_Scale.CustomStep = 100;
// create a scale title - RPM X 0.1
m_RadialGauge.Axes[0].Scale.Title.Text = "RPM X 0.1";
m_RadialGauge.Axes[0].Scale.Title.TextStyle = new NTextStyle(NColor.Red);
break;
case 3:
// handle "0.01" radio button
m_RadialGauge.Axes[0].Range = new NRange(0, 100);
m_Scale.CustomStep = 10;
// create a scale title - RPM X 0.01
m_RadialGauge.Axes[0].Scale.Title.Text = "RPM X 0.01";
m_RadialGauge.Axes[0].Scale.Title.TextStyle = new NTextStyle(NColor.Red);
break;
case 4:
// handle "0.001" radio button
m_RadialGauge.Axes[0].Range = new NRange(0, 10);
m_Scale.CustomStep = 1;
// create a scale title - RPM X 0.001
m_RadialGauge.Axes[0].Scale.Title.Text = "RPM X 0.001";
m_RadialGauge.Axes[0].Scale.Title.TextStyle = new NTextStyle(NColor.Red);
break;
}
}
private void OnDataFeedTimerTick()
{
int selectedIndex = m_MultiplierRadioGroup.SelectedIndex;
// update the indicator
m_FirstIndicatorAngle += 0.02;
double value = 50.0 - Math.Cos(m_FirstIndicatorAngle) * 50.0;
m_ValueIndicator.Value = value;
switch (selectedIndex)
{
case 0:
// handle "10" radio button
m_ValueIndicator.Value = value * 1000;
m_NumericLedDisplay.Value = m_ValueIndicator.Value;
break;
case 1:
// handle "1" radio button
m_ValueIndicator.Value = value * 100;
m_NumericLedDisplay.Value = m_ValueIndicator.Value;
break;
case 2:
// handle "0.1" radio button
m_ValueIndicator.Value = value * 10;
m_NumericLedDisplay.Value = m_ValueIndicator.Value;
break;
case 3:
// handle "0.01" radio button
m_ValueIndicator.Value = value;
m_NumericLedDisplay.Value = m_ValueIndicator.Value;
break;
case 4:
// handle "0.001" radio button
m_ValueIndicator.Value = value * 0.1;
m_NumericLedDisplay.Value = m_ValueIndicator.Value;
break;
}
}
#endregion
#region Fields
NRadialGauge m_RadialGauge;
NLinearScale m_Scale;
NNeedleValueIndicator m_ValueIndicator;
NNumericLedDisplay m_NumericLedDisplay;
NRadioButtonGroup m_MultiplierRadioGroup;
NTimer m_DataFeedTimer;
double m_FirstIndicatorAngle;
#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.Forms
Imports System
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 - NScaleMultiplierExample"
' 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 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.PreferredSize = defaultRadialGaugeSize
m_RadialGauge.Dial = New NDial(ENDialShape.Circle, New NEdgeDialRim())
m_RadialGauge.SweepAngle = New NAngle(270, NUnit.Degree)
m_RadialGauge.BeginAngle = New NAngle(-225, NUnit.Degree)
Dim advancedGradient As NAdvancedGradientFill = New NAdvancedGradientFill()
advancedGradient.BackgroundColor = NColor.Black
advancedGradient.Points.Add(New NAdvancedGradientPoint(NColor.CadetBlue, New NAngle(10, NUnit.Degree), 0.1F, 0, 1.0F, ENAdvancedGradientPointShape.Circle))
m_RadialGauge.Dial.BackgroundFill = advancedGradient
m_RadialGauge.CapEffect = New NGlassCapEffect(ENCapEffectShape.Ellipse)
controlStack.Add(m_RadialGauge)
' configure scale
Dim axis As NGaugeAxis = New NGaugeAxis()
m_RadialGauge.Axes.Add(axis)
axis.Range = New NRange(0, 10000)
' add Scale
m_Scale = CType(axis.Scale, NLinearScale)
m_Scale.SetPredefinedScale(ENPredefinedScaleStyle.Presentation)
m_Scale.Labels.Style.TextStyle.Font = New NFont("Arimo", 10, ENFontStyle.Bold)
m_Scale.Labels.Style.TextStyle.Fill = New NColorFill(NColor.White)
m_Scale.MajorTickMode = ENMajorTickMode.CustomStep
m_Scale.CustomStep = 1000
m_Scale.MinorTickCount = 10
m_Scale.Ruler.Fill = New NColorFill(NColor.Gray)
' add radial gauge indicators
m_ValueIndicator = New NNeedleValueIndicator()
m_ValueIndicator.Fill = New NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, NColor.White, NColor.Red)
m_ValueIndicator.Width = 7
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, 230, 80, 0)
' add Numeric Led dusplay
m_NumericLedDisplay = New NNumericLedDisplay()
m_NumericLedDisplay.CellCountMode = ENDisplayCellCountMode.Fixed
m_NumericLedDisplay.CellCount = 7
m_NumericLedDisplay.BackgroundFill = New NColorFill(NColor.Black)
m_NumericLedDisplay.Border = NBorder.CreateSunken3DBorder(New NUIThemeColorMap(ENUIThemeScheme.Brick))
m_NumericLedDisplay.BorderThickness = New NMargins(6)
m_NumericLedDisplay.Margins = New NMargins(5)
m_NumericLedDisplay.VerticalPlacement = ENVerticalPlacement.Bottom
m_NumericLedDisplay.PreferredSize = New NSize(30, 50)
verticalStack.Add(m_NumericLedDisplay)
m_RadialGauge.Content = verticalStack
' timer
m_DataFeedTimer = New NTimer()
Me.m_DataFeedTimer.Tick += AddressOf OnDataFeedTimerTick
m_DataFeedTimer.Start()
Return stack
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
m_MultiplierRadioGroup = New NRadioButtonGroup()
Me.m_MultiplierRadioGroup.SelectedIndexChanged += AddressOf OnMultiplierRadioGroupIndexChanged
Dim radioStack As NStackPanel = New NStackPanel()
m_MultiplierRadioGroup.Content = radioStack
radioStack.Add(New NRadioButton("10"))
radioStack.Add(New NRadioButton("1"))
radioStack.Add(New NRadioButton("0.1"))
radioStack.Add(New NRadioButton("0.01"))
radioStack.Add(New NRadioButton("0.001"))
CType(radioStack(1), NRadioButton).Checked = True
stack.Add(New NGroupBox("Multiplier Value: ", m_MultiplierRadioGroup))
Return stack
End Function
Public Function GetExampleDescription() As String
Return " An RPM gauge is displayed using a mlutiplier, which allows for the increase or decrease in scale labels.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Gauges Axes", "https://www.nevron.com/docs/openvision/gauges-axes.html"), ("Scales Overview", "https://www.nevron.com/docs/openvision/scales-overview.html"), ("Gauges Overview", "https://www.nevron.com/docs/openvision/gauges-overview.html"), ("Scale Labels Formatting", "https://www.nevron.com/docs/openvision/scale-labels-formatting.html")}
End Function
#End Region
#Region "Implementation"
#End Region
#Region "Event Handlers"
Private Sub OnMultiplierRadioGroupIndexChanged(arg As NValueChangeEventArgs)
Dim selectedIndex = m_MultiplierRadioGroup.SelectedIndex
Select Case selectedIndex
Case 0
' handle "10" radio button
m_RadialGauge.Axes(0).Range = New NRange(0, 100000)
m_Scale.CustomStep = 10000
' create a scale title - RPM X 10
m_RadialGauge.Axes(0).Scale.Title.Text = "RPM X 10"
m_RadialGauge.Axes(0).Scale.Title.TextStyle = New NTextStyle(NColor.Red)
Case 1
' handle "1" radio button
m_RadialGauge.Axes(0).Range = New NRange(0, 10000)
m_Scale.CustomStep = 1000
' create a scale title - RPM
m_RadialGauge.Axes(0).Scale.Title.Text = "RPM"
m_RadialGauge.Axes(0).Scale.Title.TextStyle = New NTextStyle(NColor.Red)
Case 2
' handle "0.1" radio button
m_RadialGauge.Axes(0).Range = New NRange(0, 1000)
m_Scale.CustomStep = 100
' create a scale title - RPM X 0.1
m_RadialGauge.Axes(0).Scale.Title.Text = "RPM X 0.1"
m_RadialGauge.Axes(0).Scale.Title.TextStyle = New NTextStyle(NColor.Red)
Case 3
' handle "0.01" radio button
m_RadialGauge.Axes(0).Range = New NRange(0, 100)
m_Scale.CustomStep = 10
' create a scale title - RPM X 0.01
m_RadialGauge.Axes(0).Scale.Title.Text = "RPM X 0.01"
m_RadialGauge.Axes(0).Scale.Title.TextStyle = New NTextStyle(NColor.Red)
Case 4
' handle "0.001" radio button
m_RadialGauge.Axes(0).Range = New NRange(0, 10)
m_Scale.CustomStep = 1
' create a scale title - RPM X 0.001
m_RadialGauge.Axes(0).Scale.Title.Text = "RPM X 0.001"
m_RadialGauge.Axes(0).Scale.Title.TextStyle = New NTextStyle(NColor.Red)
End Select
End Sub
Private Sub OnDataFeedTimerTick()
Dim selectedIndex = m_MultiplierRadioGroup.SelectedIndex
' update the indicator
m_FirstIndicatorAngle += 0.02
Dim value = 50.0 - Math.Cos(m_FirstIndicatorAngle) * 50.0
m_ValueIndicator.Value = value
Select Case selectedIndex
Case 0
' handle "10" radio button
m_ValueIndicator.Value = value * 1000
m_NumericLedDisplay.Value = m_ValueIndicator.Value
Case 1
' handle "1" radio button
m_ValueIndicator.Value = value * 100
m_NumericLedDisplay.Value = m_ValueIndicator.Value
Case 2
' handle "0.1" radio button
m_ValueIndicator.Value = value * 10
m_NumericLedDisplay.Value = m_ValueIndicator.Value
Case 3
' handle "0.01" radio button
m_ValueIndicator.Value = value
m_NumericLedDisplay.Value = m_ValueIndicator.Value
Case 4
' handle "0.001" radio button
m_ValueIndicator.Value = value * 0.1
m_NumericLedDisplay.Value = m_ValueIndicator.Value
End Select
End Sub
#End Region
#Region "Fields"
Private m_RadialGauge As NRadialGauge
Private m_Scale As NLinearScale
Private m_ValueIndicator As NNeedleValueIndicator
Private m_NumericLedDisplay As NNumericLedDisplay
Private m_MultiplierRadioGroup As NRadioButtonGroup
Private m_DataFeedTimer As NTimer
Private m_FirstIndicatorAngle As Double
#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