Car Dashboard Example for WPF

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

Car Dashboard Example for WPF Description

The example demonstrates how to use state indicators in combination with other controls. Move the accelerator scrollbar on the right to see the effect of the speed / rpm entering into the red axis range.


Car Dashboard Example

C# Car Dashboard Example Code for Nevron Gauge for WPF
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.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NCarDashboardExample";

			// 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();

            NStackPanel controlStack = new NStackPanel();
            controlStack.Direction = Layout.ENHVDirection.LeftToRight;
            controlStack.HorizontalPlacement = Layout.ENHorizontalPlacement.Left;
            controlStack.VerticalPlacement = Layout.ENVerticalPlacement.Top;

            controlStack.Add(CreateGaugePanel("km/h", new NRange(0, 260), new NRange(200, 220), out m_SpeedIndicator, out m_SpeedLedDisplay, out m_SpeedStateIndicator));
            controlStack.Add(CreateGaugePanel("rpm", new NRange(0, 7000), new NRange(5000, 7000), out m_RpmIndicator, out m_RpmLedDisplay, out m_RpmStateIndicator));

            stack.Add(controlStack);

            return stack;
        }
        /// 
        /// 
        /// 
        /// 
        public NWidget CreateExampleControls()
        {
            NStackPanel stack = new NStackPanel();

            m_AccelerationScrollBar = new NHScrollBar();
            m_AccelerationScrollBar.Minimum = -100;
            m_AccelerationScrollBar.Maximum = 100;
            m_AccelerationScrollBar.Value = 0;
            stack.Add(NPairBox.Create("Acceleration: ", m_AccelerationScrollBar));

            m_Timer = new NTimer();
            m_Timer.Tick += OnTimerTick;
            m_Timer.Start();

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

The example demonstrates how to use state indicators in combination with other controls. Move the accelerator scrollbar on the right to see the effect of the speed / rpm entering into the red axis range.

"; } /// /// 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 Overview", "https://www.nevron.com/docs/openvision/gauges-overview.html"), ("Instrumentation Overview", "https://www.nevron.com/docs/openvision/instrumentation-overview.html"), }; } #endregion #region Implementation /// /// Called when the example is unloaded /// protected void OnUnregistered() { base.OnUnregistered(); // stop the update timer m_Timer.Stop(); m_Timer = null; } /// /// /// /// /// /// /// /// private static NUserPanel CreateGaugePanel(string text, NRange axisRange, NRange redRange, out NNeedleValueIndicator needleValueIndicator, out NNumericLedDisplay numericLedDisplay, out NStateIndicator stateIndicator) { NUserPanel userPanel = new NUserPanel(); userPanel.PreferredSize = defaultRadialGaugeSize; NRadialGauge radialGauge = new NRadialGauge(); userPanel.Add(radialGauge); // create the radial gauge radialGauge.CapEffect = new NGlassCapEffect(); radialGauge.SetFx(NRadialGauge.WidthProperty, "$Parent.Width"); radialGauge.SetFx(NRadialGauge.HeightProperty, "$Parent.Height"); radialGauge.PreferredSize = defaultRadialGaugeSize; radialGauge.Dial = new NDial(ENDialShape.Circle, new NEdgeDialRim()); radialGauge.Dial.BackgroundFill = CreateAdvancedGradient(); // configure axis NGaugeAxis axis = new NGaugeAxis(); axis.Anchor = new NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, true, 0, 100); radialGauge.Axes.Add(axis); axis.Range = axisRange; NStandardScale scale = (NStandardScale)axis.Scale; ConfigureScale(scale, redRange); radialGauge.Indicators.Add(CreateRangeIndicator(redRange.Begin)); needleValueIndicator = new NNeedleValueIndicator(); needleValueIndicator.Value = 0; needleValueIndicator.Fill = new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, NColor.White, NColor.Red); needleValueIndicator.Stroke.Color = NColor.Red; needleValueIndicator.PaintOrder = ENIndicatorPaintOrder.PostPaint; radialGauge.Indicators.Add(needleValueIndicator); radialGauge.BeginAngle = new NAngle(-240, NUnit.Degree); radialGauge.SweepAngle = new NAngle(300, NUnit.Degree); NUserPanel radialGaugeContentPanel = new NUserPanel(); radialGaugeContentPanel.SetFx(NUserPanel.WidthProperty, "$Parent.Width"); radialGaugeContentPanel.SetFx(NUserPanel.HeightProperty, "$Parent.Height"); radialGauge.Content = radialGaugeContentPanel; // configure led display numericLedDisplay = new NNumericLedDisplay(); radialGaugeContentPanel.Add(numericLedDisplay); numericLedDisplay.PreferredSize = new NSize(150, 120); numericLedDisplay.Value = 0.0; numericLedDisplay.CellCountMode = ENDisplayCellCountMode.Fixed; numericLedDisplay.CellCount = 7; numericLedDisplay.BackgroundFill = new NColorFill(NColor.Black); numericLedDisplay.Border = NBorder.CreateSunken3DBorder(new NUIThemeColorMap(ENUIThemeScheme.WindowsClassic)); numericLedDisplay.BorderThickness = new NMargins(2); numericLedDisplay.Padding = new NMargins(2); numericLedDisplay.CapEffect = new NGelCapEffect(); numericLedDisplay.SetFx(NNumericLedDisplay.XProperty, "$Parent.Width / 2 - (Width / 2)"); numericLedDisplay.SetFx(NNumericLedDisplay.YProperty, "$Parent.Height / 2 + 10"); numericLedDisplay.SetFx(NNumericLedDisplay.WidthProperty, "$Parent.Width / 2"); numericLedDisplay.SetFx(NNumericLedDisplay.HeightProperty, "$Parent.Height/ 10"); // configure state indicator stateIndicator = new NStateIndicator(); radialGaugeContentPanel.Add(stateIndicator); stateIndicator.SetFx(NButton.XProperty, "$Parent.Width / 2 - (Width / 2)"); stateIndicator.SetFx(NButton.YProperty, "$Parent.Height * 3/ 4"); stateIndicator.SetFx(NStateIndicator.WidthProperty, "10"); stateIndicator.SetFx(NStateIndicator.HeightProperty, "10"); stateIndicator.States.Add(new NIndicatorState(new NRange(axisRange.Begin, redRange.Begin), ENSymbolShape.Ellipse, stateIndicatorSize, new NColorFill(NColor.LimeGreen), null)); stateIndicator.States.Add(new NIndicatorState(redRange, ENSymbolShape.Ellipse, stateIndicatorSize, new NColorFill(NColor.OrangeRed), null)); // add labels NLabel label = new NLabel(text); userPanel.Add(label); label.Font = new NFont("Times New Roman", 20, ENFontStyle.Italic); label.TextFill = new NColorFill(NColor.White); label.SetFx(NLabel.XProperty, "$Parent.Width / 2 - (Width / 2)"); label.SetFx(NLabel.YProperty, "$Parent.Height / 2 + 50"); return userPanel; } /// /// /// /// private static NFill CreateAdvancedGradient() { NAdvancedGradientFill agfs = new NAdvancedGradientFill(); agfs.BackgroundColor = NColor.FromRGB(234, 234, 234); NAdvancedGradientPoint point1 = new NAdvancedGradientPoint(); point1.PositionX = 0.5f; point1.PositionY = 0.5f; point1.Color = NColor.FromRGB(51, 51, 51); point1.Intensity = 0.7f; agfs.Points.Add(point1); NAdvancedGradientPoint point2 = new NAdvancedGradientPoint(); point2.PositionX = 0.5f; point2.PositionY = 0.5f; point2.Color = NColor.FromRGB(41, 41, 41); point2.Intensity = 0.5f; agfs.Points.Add(point2); return agfs; } /// /// /// /// /// private static void ConfigureScale(NStandardScale scale, NRange redRange) { scale.SetPredefinedScale(ENPredefinedScaleStyle.PresentationNoStroke); scale.Labels.Style.TextStyle.Font = new NFont("Arial", 11, ENFontStyle.Bold); scale.Labels.Style.TextStyle.Fill = new NColorFill(NColor.White); scale.Labels.Style.Angle = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0); scale.MinorTickCount = 1; scale.Ruler.Stroke.Width = 0; scale.Ruler.Fill = new NColorFill(NColor.FromColor(NColor.SlateGray, 125)); NScaleSection scaleSection = new NScaleSection(); scaleSection.Range = redRange; scaleSection.MajorTickFill = new NColorFill(NColor.Red); scaleSection.MinorTickFill = new NColorFill(NColor.Red); NTextStyle labelStyle = new NTextStyle(); labelStyle.Fill = new NStockGradientFill(NColor.Red, NColor.DarkRed); labelStyle.Font = new NFont("Arial", 11, ENFontStyle.Bold); scaleSection.LabelTextStyle = labelStyle; scale.Sections.Add(scaleSection); } /// /// /// /// /// private static NRangeIndicator CreateRangeIndicator(double minValue) { NRangeIndicator rangeIndicator = new NRangeIndicator(); rangeIndicator.Value = minValue; rangeIndicator.OriginMode = ENRangeIndicatorOriginMode.ScaleMax; rangeIndicator.Fill = new NColorFill(NColor.Red); rangeIndicator.Stroke.Width = 0; rangeIndicator.BeginWidth = 2; rangeIndicator.EndWidth = 10; return rangeIndicator; } /// /// /// /// private double GetSpeedFromRotation() { switch (m_Gear) { case 1: return m_Rpm * 0.005; case 2: return m_Rpm * 0.01; case 3: return m_Rpm * 0.015; case 4: return m_Rpm * 0.02; case 5: return m_Rpm * 0.034; } return 0; } private double GetRotationFromSpeed() { switch (m_Gear) { case 1: return m_Speed / 0.005; case 2: return m_Speed / 0.01; case 3: return m_Speed / 0.015; case 4: return m_Speed / 0.02; case 5: return m_Speed / 0.034; } return 0; } private void OnTimerTick() { m_Rpm += m_AccelerationScrollBar.Value; if (m_Rpm < 0) { m_Rpm = 0; } else if (m_Rpm > 7000) { m_Rpm = 7000; } m_Speed = GetSpeedFromRotation(); m_SpeedIndicator.Value = m_Speed; m_SpeedLedDisplay.Value = m_Speed; m_SpeedStateIndicator.Value = m_Speed; // change gear if (m_Rpm < 1000) { m_Gear--; } else if (m_Rpm > 3500) { m_Gear++; } if (m_Gear < 1) m_Gear = 1; if (m_Gear > 5) m_Gear = 5; m_Rpm = GetRotationFromSpeed(); m_RpmIndicator.Value = m_Rpm; m_RpmLedDisplay.Value = m_Rpm; m_RpmStateIndicator.Value = m_Rpm; } #endregion #region Event Handlers #endregion #region Fields double m_Rpm; double m_Speed; int m_Gear; NTimer m_Timer; NHScrollBar m_AccelerationScrollBar; NNeedleValueIndicator m_RpmIndicator; NNeedleValueIndicator m_SpeedIndicator; NNumericLedDisplay m_RpmLedDisplay; NNumericLedDisplay m_SpeedLedDisplay; NStateIndicator m_RpmStateIndicator; NStateIndicator m_SpeedStateIndicator; #endregion #region Static Methods #endregion #region Constants private static readonly NSize defaultRadialGaugeSize = new NSize(300, 300); private static readonly NSize stateIndicatorSize = new NSize(10, 10); #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Car Dashboard Example for WPF Solution

VB.NET Car Dashboard Example Code for Nevron Gauge for WPF
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.Runtime.InteropServices

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 - NCarDashboardExample"

		' 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()

            Dim controlStack As NStackPanel = New NStackPanel()
            controlStack.Direction = Layout.ENHVDirection.LeftToRight
            controlStack.HorizontalPlacement = Layout.ENHorizontalPlacement.Left
            controlStack.VerticalPlacement = Layout.ENVerticalPlacement.Top

            controlStack.Add(CreateGaugePanel("km/h", New NRange(0, 260), New NRange(200, 220), m_SpeedIndicator, m_SpeedLedDisplay, m_SpeedStateIndicator))
            controlStack.Add(CreateGaugePanel("rpm", New NRange(0, 7000), New NRange(5000, 7000), m_RpmIndicator, m_RpmLedDisplay, m_RpmStateIndicator))

            stack.Add(controlStack)

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

            m_AccelerationScrollBar = New NHScrollBar()
            m_AccelerationScrollBar.Minimum = -100
            m_AccelerationScrollBar.Maximum = 100
            m_AccelerationScrollBar.Value = 0
            stack.Add(NPairBox.Create("Acceleration: ", m_AccelerationScrollBar))

            m_Timer = New NTimer()
            Me.m_Timer.Tick += AddressOf OnTimerTick
            m_Timer.Start()

            Return stack
        End Function
        ''' 
        ''' 
        ''' 
        ''' 
        Public Function GetExampleDescription() As String
            Return "

The example demonstrates how to use state indicators in combination with other controls. Move the accelerator scrollbar on the right to see the effect of the speed / rpm entering into the red axis range.

" 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 Overview", "https://www.nevron.com/docs/openvision/gauges-overview.html"), ("Instrumentation Overview", "https://www.nevron.com/docs/openvision/instrumentation-overview.html")} End Function #End Region #Region "Implementation" ''' ''' Called when the example is unloaded ''' Protected Sub OnUnregistered() MyBase.OnUnregistered() ' stop the update timer m_Timer.Stop() m_Timer = Nothing End Sub ''' ''' ''' ''' ''' ''' ''' ''' Private Shared Function CreateGaugePanel(text As String, axisRange As NRange, redRange As NRange, ByRef needleValueIndicator As NNeedleValueIndicator, ByRef numericLedDisplay As NNumericLedDisplay, ByRef stateIndicator As NStateIndicator) As NUserPanel Dim userPanel As NUserPanel = New NUserPanel() userPanel.PreferredSize = defaultRadialGaugeSize Dim radialGauge As NRadialGauge = New NRadialGauge() userPanel.Add(radialGauge) ' create the radial gauge radialGauge.CapEffect = New NGlassCapEffect() radialGauge.SetFx(NBoxElement.WidthProperty, "$Parent.Width") radialGauge.SetFx(NBoxElement.HeightProperty, "$Parent.Height") radialGauge.PreferredSize = defaultRadialGaugeSize radialGauge.Dial = New NDial(ENDialShape.Circle, New NEdgeDialRim()) radialGauge.Dial.BackgroundFill = CreateAdvancedGradient() ' configure axis Dim axis As NGaugeAxis = New NGaugeAxis() axis.Anchor = New NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, True, 0, 100) radialGauge.Axes.Add(axis) axis.Range = axisRange Dim scale = CType(axis.Scale, NStandardScale) ConfigureScale(scale, redRange) radialGauge.Indicators.Add(CreateRangeIndicator(redRange.Begin)) needleValueIndicator = New NNeedleValueIndicator() needleValueIndicator.Value = 0 needleValueIndicator.Fill = New NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, NColor.White, NColor.Red) needleValueIndicator.Stroke.Color = NColor.Red needleValueIndicator.PaintOrder = ENIndicatorPaintOrder.PostPaint radialGauge.Indicators.Add(needleValueIndicator) radialGauge.BeginAngle = New NAngle(-240, NUnit.Degree) radialGauge.SweepAngle = New NAngle(300, NUnit.Degree) Dim radialGaugeContentPanel As NUserPanel = New NUserPanel() radialGaugeContentPanel.SetFx(NBoxElement.WidthProperty, "$Parent.Width") radialGaugeContentPanel.SetFx(NBoxElement.HeightProperty, "$Parent.Height") radialGauge.Content = radialGaugeContentPanel ' configure led display numericLedDisplay = New NNumericLedDisplay() radialGaugeContentPanel.Add(numericLedDisplay) numericLedDisplay.PreferredSize = New NSize(150, 120) numericLedDisplay.Value = 0.0 numericLedDisplay.CellCountMode = ENDisplayCellCountMode.Fixed numericLedDisplay.CellCount = 7 numericLedDisplay.BackgroundFill = New NColorFill(NColor.Black) numericLedDisplay.Border = NBorder.CreateSunken3DBorder(New NUIThemeColorMap(ENUIThemeScheme.WindowsClassic)) numericLedDisplay.BorderThickness = New NMargins(2) numericLedDisplay.Padding = New NMargins(2) numericLedDisplay.CapEffect = New NGelCapEffect() numericLedDisplay.SetFx(NBoxElement.XProperty, "$Parent.Width / 2 - (Width / 2)") numericLedDisplay.SetFx(NBoxElement.YProperty, "$Parent.Height / 2 + 10") numericLedDisplay.SetFx(NBoxElement.WidthProperty, "$Parent.Width / 2") numericLedDisplay.SetFx(NBoxElement.HeightProperty, "$Parent.Height/ 10") ' configure state indicator stateIndicator = New NStateIndicator() radialGaugeContentPanel.Add(stateIndicator) stateIndicator.SetFx(NBoxElement.XProperty, "$Parent.Width / 2 - (Width / 2)") stateIndicator.SetFx(NBoxElement.YProperty, "$Parent.Height * 3/ 4") stateIndicator.SetFx(NBoxElement.WidthProperty, "10") stateIndicator.SetFx(NBoxElement.HeightProperty, "10") stateIndicator.States.Add(New NIndicatorState(New NRange(axisRange.Begin, redRange.Begin), ENSymbolShape.Ellipse, stateIndicatorSize, New NColorFill(NColor.LimeGreen), Nothing)) stateIndicator.States.Add(New NIndicatorState(redRange, ENSymbolShape.Ellipse, stateIndicatorSize, New NColorFill(NColor.OrangeRed), Nothing)) ' add labels Dim label As NLabel = New NLabel(text) userPanel.Add(label) label.Font = New NFont("Times New Roman", 20, ENFontStyle.Italic) label.TextFill = New NColorFill(NColor.White) label.SetFx(NBoxElement.XProperty, "$Parent.Width / 2 - (Width / 2)") label.SetFx(NBoxElement.YProperty, "$Parent.Height / 2 + 50") Return userPanel End Function ''' ''' ''' ''' Private Shared Function CreateAdvancedGradient() As NFill Dim agfs As NAdvancedGradientFill = New NAdvancedGradientFill() agfs.BackgroundColor = NColor.FromRGB(234, 234, 234) Dim point1 As NAdvancedGradientPoint = New NAdvancedGradientPoint() point1.PositionX = 0.5F point1.PositionY = 0.5F point1.Color = NColor.FromRGB(51, 51, 51) point1.Intensity = 0.7F agfs.Points.Add(point1) Dim point2 As NAdvancedGradientPoint = New NAdvancedGradientPoint() point2.PositionX = 0.5F point2.PositionY = 0.5F point2.Color = NColor.FromRGB(41, 41, 41) point2.Intensity = 0.5F agfs.Points.Add(point2) Return agfs End Function ''' ''' ''' ''' ''' Private Shared Sub ConfigureScale(scale As NStandardScale, redRange As NRange) scale.SetPredefinedScale(ENPredefinedScaleStyle.PresentationNoStroke) scale.Labels.Style.TextStyle.Font = New NFont("Arial", 11, ENFontStyle.Bold) scale.Labels.Style.TextStyle.Fill = New NColorFill(NColor.White) scale.Labels.Style.Angle = New NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0) scale.MinorTickCount = 1 scale.Ruler.Stroke.Width = 0 scale.Ruler.Fill = New NColorFill(NColor.FromColor(NColor.SlateGray, 125)) Dim scaleSection As NScaleSection = New NScaleSection() scaleSection.Range = redRange scaleSection.MajorTickFill = New NColorFill(NColor.Red) scaleSection.MinorTickFill = New NColorFill(NColor.Red) Dim labelStyle As NTextStyle = New NTextStyle() labelStyle.Fill = New NStockGradientFill(NColor.Red, NColor.DarkRed) labelStyle.Font = New NFont("Arial", 11, ENFontStyle.Bold) scaleSection.LabelTextStyle = labelStyle scale.Sections.Add(scaleSection) End Sub ''' ''' ''' ''' ''' Private Shared Function CreateRangeIndicator(minValue As Double) As NRangeIndicator Dim rangeIndicator As NRangeIndicator = New NRangeIndicator() rangeIndicator.Value = minValue rangeIndicator.OriginMode = ENRangeIndicatorOriginMode.ScaleMax rangeIndicator.Fill = New NColorFill(NColor.Red) rangeIndicator.Stroke.Width = 0 rangeIndicator.BeginWidth = 2 rangeIndicator.EndWidth = 10 Return rangeIndicator End Function ''' ''' ''' ''' Private Function GetSpeedFromRotation() As Double Select Case m_Gear Case 1 Return m_Rpm * 0.005 Case 2 Return m_Rpm * 0.01 Case 3 Return m_Rpm * 0.015 Case 4 Return m_Rpm * 0.02 Case 5 Return m_Rpm * 0.034 End Select Return 0 End Function Private Function GetRotationFromSpeed() As Double Select Case m_Gear Case 1 Return m_Speed / 0.005 Case 2 Return m_Speed / 0.01 Case 3 Return m_Speed / 0.015 Case 4 Return m_Speed / 0.02 Case 5 Return m_Speed / 0.034 End Select Return 0 End Function Private Sub OnTimerTick() m_Rpm += m_AccelerationScrollBar.Value If m_Rpm < 0 Then m_Rpm = 0 ElseIf m_Rpm > 7000 Then m_Rpm = 7000 End If m_Speed = GetSpeedFromRotation() m_SpeedIndicator.Value = m_Speed m_SpeedLedDisplay.Value = m_Speed m_SpeedStateIndicator.Value = m_Speed ' change gear If m_Rpm < 1000 Then m_Gear -= 1 ElseIf m_Rpm > 3500 Then m_Gear += 1 End If If m_Gear < 1 Then m_Gear = 1 If m_Gear > 5 Then m_Gear = 5 m_Rpm = GetRotationFromSpeed() m_RpmIndicator.Value = m_Rpm m_RpmLedDisplay.Value = m_Rpm m_RpmStateIndicator.Value = m_Rpm End Sub #End Region #Region "Event Handlers" #End Region #Region "Fields" Private m_Rpm As Double Private m_Speed As Double Private m_Gear As Integer Private m_Timer As NTimer Private m_AccelerationScrollBar As NHScrollBar Private m_RpmIndicator As NNeedleValueIndicator Private m_SpeedIndicator As NNeedleValueIndicator Private m_RpmLedDisplay As NNumericLedDisplay Private m_SpeedLedDisplay As NNumericLedDisplay Private m_RpmStateIndicator As NStateIndicator Private m_SpeedStateIndicator As NStateIndicator #End Region #Region "Static Methods" #End Region #Region "Constants" Private Shared ReadOnly defaultRadialGaugeSize As NSize = New NSize(300, 300) Private Shared ReadOnly stateIndicatorSize As NSize = New NSize(10, 10) #End Region #Region "Nested Types" #End Region End Class

Download a fully functional VB.NET (.vb) Car Dashboard Example for WPF Solution