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

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