Gauge Axis Docking Example for WinForms

Gauge Axis Docking Example for WinForms

Nevron NOV Gauge for WinForms ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All WinForms 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.

Gauge Axis Docking Example for WinForms Description

The example demonstrates how to control the gauge axis position using gauge axis dock anchors.


Axis Docking Example

C# Gauge Axis Docking Example Code for Nevron Gauge for WinForms
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.Windows.Forms;

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

		public Form1()
		{
			InitializeComponent();

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

			// 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.Padding = new NMargins(20);
			stack.Add(controlStack);

            m_LinearGauge = new NLinearGauge();
			m_LinearGauge.Padding = new NMargins(30);
			m_LinearGauge.PreferredSize = defaultLinearHorizontalGaugeSize;
            controlStack.Add(m_LinearGauge);

			NGaugeAxis axis = new NGaugeAxis();
			m_LinearGauge.Axes.Add(axis);
            axis.Anchor = new NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, true, ENScaleOrientation.Left, 0, 100);

			axis = new NGaugeAxis();
			m_LinearGauge.Axes.Add(axis);
			axis.Anchor = new NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, true, ENScaleOrientation.Left, 0, 50);

            // create the radial gauge
			m_RadialGauge = new NRadialGauge();
			m_RadialGauge.PreferredSize = defaultRadialGaugeSize;
			m_RadialGauge.NeedleCap.Visible = false;
            controlStack.Add(m_RadialGauge);

            // create the radial gauge
            m_RadialGauge.SweepAngle = new NAngle(270, NUnit.Degree);
            m_RadialGauge.BeginAngle = new NAngle(-90, NUnit.Degree);
			m_RadialGauge.PreferredHeight = 400;

            // configure the axis
            axis = new NGaugeAxis();
			m_RadialGauge.Axes.Add(axis);
            axis.Range = new NRange(0, 100);
			axis.Anchor = new NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, true, ENScaleOrientation.Left, 0.0f, 100.0f);

			// configure the axis
			axis = new NGaugeAxis();
			m_RadialGauge.Axes.Add(axis);
			axis.Range = new NRange(0, 100);
			axis.Anchor = new NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, true, ENScaleOrientation.Left, 0.0f, 50.0f);

			NNeedleValueIndicator indicator = new NNeedleValueIndicator();
			indicator.ScaleAxis = axis;
			indicator.OffsetFromScale = 20;
			m_RadialGauge.Indicators.Add(indicator);

			NMarkerValueIndicator markerValueIndicator = new NMarkerValueIndicator(10);
			markerValueIndicator.Shape = ENScaleValueMarkerShape.Bar;
			m_RadialGauge.Indicators.Add(new NMarkerValueIndicator(10));
			m_RadialGauge.Indicators.Add(new NMarkerValueIndicator(90));


			NNeedleValueIndicator needle = new NNeedleValueIndicator();
			needle.Value = 10;
			needle.Shape = ENNeedleShape.Needle4;

			needle.Fill = new NColorFill(NColor.DarkGreen);
			needle.Stroke = new NStroke(NColor.DarkGreen);

//			radialGauge.Indicators.Add(needle);

			markerValueIndicator.Width = 20;
			markerValueIndicator.Height = 20;
			markerValueIndicator.Fill = new NColorFill(NColor.DarkGreen);
			markerValueIndicator.Stroke = new NStroke(1.0, NColor.DarkGreen); 


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

			NStackPanel propertyStack = new NStackPanel();
			stack.Add(new NUniSizeBoxGroup(propertyStack));

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

The example demonstrates how to control the gauge axis position using gauge axis dock anchors.

"; } /// /// 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"), }; } #endregion #region Implementation #endregion #region Event Handlers #endregion #region Fields NRadialGauge m_RadialGauge; NLinearGauge m_LinearGauge; #endregion #region Static Methods #endregion #region Constants private static readonly NSize defaultLinearHorizontalGaugeSize = new NSize(300, 100); private static readonly NSize defaultRadialGaugeSize = new NSize(300, 300); #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Gauge Axis Docking Example for WinForms Solution

VB.NET Gauge Axis Docking Example Code for Nevron Gauge for WinForms
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

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

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

            Dim controlStack As NStackPanel = New NStackPanel()
            controlStack.Padding = New NMargins(20)
            stack.Add(controlStack)

            m_LinearGauge = New NLinearGauge()
            m_LinearGauge.Padding = New NMargins(30)
            m_LinearGauge.PreferredSize = defaultLinearHorizontalGaugeSize
            controlStack.Add(m_LinearGauge)

            Dim axis As NGaugeAxis = New NGaugeAxis()
            m_LinearGauge.Axes.Add(axis)
            axis.Anchor = New NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, True, ENScaleOrientation.Left, 0, 100)

            axis = New NGaugeAxis()
            m_LinearGauge.Axes.Add(axis)
            axis.Anchor = New NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, True, ENScaleOrientation.Left, 0, 50)

            ' create the radial gauge
            m_RadialGauge = New NRadialGauge()
            m_RadialGauge.PreferredSize = defaultRadialGaugeSize
            m_RadialGauge.NeedleCap.Visible = False
            controlStack.Add(m_RadialGauge)

            ' create the radial gauge
            m_RadialGauge.SweepAngle = New NAngle(270, NUnit.Degree)
            m_RadialGauge.BeginAngle = New NAngle(-90, NUnit.Degree)
            m_RadialGauge.PreferredHeight = 400

            ' configure the axis
            axis = New NGaugeAxis()
            m_RadialGauge.Axes.Add(axis)
            axis.Range = New NRange(0, 100)
            axis.Anchor = New NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, True, ENScaleOrientation.Left, 0.0F, 100.0F)

            ' configure the axis
            axis = New NGaugeAxis()
            m_RadialGauge.Axes.Add(axis)
            axis.Range = New NRange(0, 100)
            axis.Anchor = New NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, True, ENScaleOrientation.Left, 0.0F, 50.0F)

            Dim indicator As NNeedleValueIndicator = New NNeedleValueIndicator()
            indicator.ScaleAxis = axis
            indicator.OffsetFromScale = 20
            m_RadialGauge.Indicators.Add(indicator)

            Dim markerValueIndicator As NMarkerValueIndicator = New NMarkerValueIndicator(10)
            markerValueIndicator.Shape = ENScaleValueMarkerShape.Bar
            m_RadialGauge.Indicators.Add(New NMarkerValueIndicator(10))
            m_RadialGauge.Indicators.Add(New NMarkerValueIndicator(90))


            Dim needle As NNeedleValueIndicator = New NNeedleValueIndicator()
            needle.Value = 10
            needle.Shape = ENNeedleShape.Needle4

            needle.Fill = New NColorFill(NColor.DarkGreen)
            needle.Stroke = New NStroke(NColor.DarkGreen)

            '			radialGauge.Indicators.Add(needle);

            markerValueIndicator.Width = 20
            markerValueIndicator.Height = 20
            markerValueIndicator.Fill = New NColorFill(NColor.DarkGreen)
            markerValueIndicator.Stroke = New NStroke(1.0, NColor.DarkGreen)


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

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

The example demonstrates how to control the gauge axis position using gauge axis dock anchors.

" 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")} End Function #End Region #Region "Implementation" #End Region #Region "Event Handlers" #End Region #Region "Fields" Private m_RadialGauge As NRadialGauge Private m_LinearGauge As NLinearGauge #End Region #Region "Static Methods" #End Region #Region "Constants" Private Shared ReadOnly defaultLinearHorizontalGaugeSize As NSize = New NSize(300, 100) Private Shared ReadOnly defaultRadialGaugeSize As NSize = New NSize(300, 300) #End Region #Region "Nested Types" #End Region End Class

Download a fully functional VB.NET (.vb) Gauge Axis Docking Example for WinForms Solution