Profile Picture

Nevron Chart - RadialGaugeIndicator

Posted By moh aziz 14 Years Ago
Author
Message
moh aziz
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 4, Visits: 1
NRadialGaugeIndicatorsUC.     WinForms App - using Visual Studio.

I want to use the above component in my application. I have the examples solution part of the .NET vision which provides the code however that code seems to long just to display the indicator.

my question is I want to update the indicator every 5 secs with a new reading. the reading will be read from a sql datasource - is this possible and how to do this without using all this code below?

thanks 

code copied from your examples solution for RadialGaugeIndicator:

using System;
2using System.Collections;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Windows.Forms;
7using Nevron.Editors;
8using Nevron.SmartShapes;
9using Nevron.GraphicsCore;
10using Nevron.Chart;
11
12namespace Nevron.Examples.Chart.WinForm
13{
14 /// <summary>
15 /// Summary description for NRadialGaugeIndicatorsUC.
16 /// </summary>
17 public class NRadialGaugeIndicatorsUC : NExampleBaseUC
18 {
19 /// <summary>
20 /// Required designer variable.
21 /// </summary>
22 private System.ComponentModel.Container components = null;
23
24 private Nevron.UI.WinForm.Controls.NGroupBox groupBox2;
25 private Nevron.UI.WinForm.Controls.NComboBox RangeIndicatorOriginModeComboBox;
26 private Nevron.UI.WinForm.Controls.NNumericUpDown RangeIndicatorOriginUpDown;
27 private System.Windows.Forms.Label label3;
28 private System.Windows.Forms.Label label2;
29 private System.Windows.Forms.Label label1;
30 private Nevron.UI.WinForm.Controls.NNumericUpDown RangeIndicatorValueUpDown;
31 private Nevron.UI.WinForm.Controls.NGroupBox groupBox1;
32 private Nevron.UI.WinForm.Controls.NNumericUpDown ValueIndicatorUpDown;
33 private System.Windows.Forms.Label label5;
34 private System.Windows.Forms.Label label4;
35 private Nevron.UI.WinForm.Controls.NComboBox ValueIndicatorShapeComboBox;
36 private System.Windows.Forms.Label label6;
37 private System.Windows.Forms.Label label7;
38 private Nevron.UI.WinForm.Controls.NNumericUpDown BeginAngleUpDown;
39 private Nevron.UI.WinForm.Controls.NNumericUpDown SweepAngleUpDown;
40
41 NRadialGaugePanel m_RadialGauge;
42 NRangeIndicator m_Indicator1;
43 NNeedleValueIndicator m_Indicator2;
44 private System.Windows.Forms.Label label8;
45 private Nevron.UI.WinForm.Controls.NButton ShowNeedleEditorButton;
46 private Nevron.UI.WinForm.Controls.NNumericUpDown NeedleWidthUpDown;
47 NNumericDisplayPanel m_NumericDisplay;
48
49 public NRadialGaugeIndicatorsUC()
50 {
51 // This call is required by the Windows.Forms Form Designer.
52 InitializeComponent();
53 }
54
55 /// <summary>
56 /// Clean up any resources being used.
57 /// </summary>
58 protected override void Dispose( bool disposing )
59 {
60 if( disposing )
61 {
62 if(components != null)
63 {
64 components.Dispose();
65 }
66 }
67 base.Dispose( disposing );
68 }
69
70 public override void Initialize()
71 {
72 nChartControl1.Panels.Clear();
73
74 // add a header label
75 NLabel header = new NLabel("Radial Gauge Indicators");
76            header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
77            header.ContentAlignment = ContentAlignment.BottomRight;
78            header.Location = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));
79           
80            nChartControl1.Panels.Add(header);
81
82 // create the radial gauge
83 m_RadialGauge = new NRadialGaugePanel();
84            m_RadialGauge.PaintEffect = new NGlassEffectStyle();
85            m_RadialGauge.BorderStyle = new NEdgeBorderStyle(BorderShape.Auto);
86 m_RadialGauge.ContentAlignment = ContentAlignment.MiddleCenter;
87 m_RadialGauge.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(55, NRelativeUnit.ParentPercentage));
88 m_RadialGauge.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage));
89            m_RadialGauge.BackgroundFillStyle = new NGradientFillStyle(Color.DarkGray, Color.Black);
90
91            // configure scale
92            NGaugeAxis axis = (NGaugeAxis)m_RadialGauge.Axes[0];
93            NStandardScaleConfigurator scale = (NStandardScaleConfigurator)axis.ScaleConfigurator;
94
95            scale.SetPredefinedScaleStyle(PredefinedScaleStyle.Presentation);
96            scale.LabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 12, FontStyle.Bold);
97            scale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.White);
98            scale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 90);
99            scale.MinorTickCount = 4;
100            scale.RulerStyle.BorderStyle.Width = new NLength(0);
101            scale.RulerStyle.FillStyle = new NColorFillStyle(Color.DarkGray);
102
103            // add radial gauge indicators
104            m_Indicator1 = new NRangeIndicator();
105            m_Indicator1.Value = 20;
106            m_Indicator1.FillStyle = new NGradientFillStyle(Color.Yellow, Color.Red);
107            m_Indicator1.StrokeStyle.Color = Color.DarkBlue;
108            m_Indicator1.EndWidth = new NLength(-20);
109            m_RadialGauge.Indicators.Add(m_Indicator1);
110
111            m_Indicator2 = new NNeedleValueIndicator();
112            m_Indicator2.Value = 79;
113            m_Indicator2.Shape.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.Red);
114            m_Indicator2.Shape.StrokeStyle.Color = Color.Red;
115            m_RadialGauge.Indicators.Add(m_Indicator2);
116            m_RadialGauge.SweepAngle = 270;
117
118            // add radial gauge
119            nChartControl1.Panels.Add(m_RadialGauge);
120
121            // create and configure a numeric display attached to the radial gauge
122 m_NumericDisplay = new NNumericDisplayPanel();
123 m_NumericDisplay.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage));
124 m_NumericDisplay.ContentAlignment = ContentAlignment.TopCenter;
125 m_NumericDisplay.SegmentWidth = new NLength(2, NGraphicsUnit.Point);
126 m_NumericDisplay.SegmentGap = new NLength(1, NGraphicsUnit.Point);
127 m_NumericDisplay.CellSize = new NSizeL(new NLength(15, NGraphicsUnit.Point), new NLength(30, NGraphicsUnit.Point));
128 m_NumericDisplay.DecimalCellSize = new NSizeL(new NLength(10, NGraphicsUnit.Point), new NLength(20, NGraphicsUnit.Point));
129 m_NumericDisplay.ShowDecimalSeparator = false;
130 m_NumericDisplay.CellAlignment = VertAlign.Top;
131            m_NumericDisplay.BackgroundFillStyle = new NColorFillStyle(Color.DimGray);
132            m_NumericDisplay.LitFillStyle = new NGradientFillStyle(Color.Lime, Color.Green);
133            m_NumericDisplay.CellCountMode = DisplayCellCountMode.Fixed;
134            m_NumericDisplay.CellCount = 6;
135            m_NumericDisplay.Padding = new NMarginsL(6, 3, 6, 3);
136            m_RadialGauge.ChildPanels.Add(m_NumericDisplay);
137
138            // create a sunken border around the display
139            NEdgeBorderStyle borderStyle = new NEdgeBorderStyle(BorderShape.RoundedRect);
140            borderStyle.OuterBevelWidth = new NLength(0);
141            borderStyle.MiddleBevelWidth = new NLength(0);
142            m_NumericDisplay.BorderStyle = borderStyle;
143
144 // init form controls
145 SweepAngleUpDown.Value = (decimal)m_RadialGauge.SweepAngle;
146 BeginAngleUpDown.Value = (decimal)m_RadialGauge.BeginAngle;
147
148 ValueIndicatorShapeComboBox.FillFromEnum(typeof(SmartShape1D));
149 ValueIndicatorShapeComboBox.SelectedIndex = (int)SmartShape1D.Arrow2;
150
151 ValueIndicatorUpDown.Value = (decimal)m_Indicator2.Value;
152 RangeIndicatorValueUpDown.Value = (decimal)m_Indicator1.Value;
153
154 RangeIndicatorOriginModeComboBox.FillFromEnum(typeof(OriginMode));
155 RangeIndicatorOriginModeComboBox.SelectedIndex = 0;
156
157 NeedleWidthUpDown.Value = (decimal)m_Indicator2.Width.Value;
158 }
159 #region Component Designer generated code   ... #endregion
428
429 private void RangeIndicatorOriginModeComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
430 {
431 m_Indicator1.OriginMode = (OriginMode)RangeIndicatorOriginModeComboBox.SelectedIndex;
432 if (m_Indicator1.OriginMode != OriginMode.Custom)
433 {
434 RangeIndicatorOriginUpDown.Enabled = false;
435 }
436 else
437 {
438 RangeIndicatorOriginUpDown.Enabled = true;
439 }
440
441 nChartControl1.Refresh();
442 }
443
444 private void ValueIndicatorUpDown_ValueChanged(object sender, System.EventArgs e)
445 {
446 m_Indicator2.Value = (double)ValueIndicatorUpDown.Value;
447 m_NumericDisplay.Value = m_Indicator2.Value;
448 nChartControl1.Refresh();
449 }
450
451 private void RangeIndicatorValueUpDown_ValueChanged(object sender, System.EventArgs e)
452 {
453 m_Indicator1.Value = (double)RangeIndicatorValueUpDown.Value;
454 nChartControl1.Refresh();
455 }
456
457 private void RangeIndicatorOriginUpDown_ValueChanged(object sender, System.EventArgs e)
458 {
459 m_Indicator1.Origin = (double)RangeIndicatorOriginUpDown.Value;
460 nChartControl1.Refresh();
461 }
462
463 private void BeginAngleUpDown_ValueChanged(object sender, System.EventArgs e)
464 {
465 m_RadialGauge.BeginAngle = (float)BeginAngleUpDown.Value;
466 nChartControl1.Refresh();
467 }
468
469 private void SweepAngleUpDown_ValueChanged(object sender, System.EventArgs e)
470 {
471 m_RadialGauge.SweepAngle = (float)SweepAngleUpDown.Value;
472 nChartControl1.Refresh();
473 }
474
475 private void ValueIndicatorShapeComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
476 {
477 N1DSmartShapeFactory factory = new N1DSmartShapeFactory(m_Indicator2.Shape.FillStyle, m_Indicator2.Shape.StrokeStyle, m_Indicator2.Shape.ShadowStyle);
478 m_Indicator2.Shape = factory.CreateShape((SmartShape1D)ValueIndicatorShapeComboBox.SelectedIndex);
479 nChartControl1.Refresh();
480 }
481
482 private void ShowNeedleEditorButton_Click(object sender, System.EventArgs e)
483 {
484 NSmartShapeEditorUC editor2 = new NSmartShapeEditorUC();
485
486 NSmartShapesCategory cat = new NSmartShapesCategory("Needle Shapes");
487 N1DSmartShapeFactory factory = new N1DSmartShapeFactory(m_Indicator2.Shape.FillStyle, m_Indicator2.Shape.StrokeStyle, m_Indicator2.Shape.ShadowStyle);
488
489 NSmartShape[] shapes = factory.CreateShapes();
490
491 for (int i = 0; i < shapes.Length; i++)
492 {
493 cat.Add(shapes[i]);
494 }
495
496 editor2.PredefinedShapes = new NSmartShapesCategory[]{cat};
497 editor2.Shape = (NSmartShape)(((ICloneable)m_Indicator2.Shape).Clone());
498
499 if (editor2.ShowInHostForm() == DialogResult.OK)
500 {
501 m_Indicator2.Shape = editor2.Shape;
502 nChartControl1.Refresh();
503 }
504
505 editor2.Dispose();
506 }
507
508 private void NeedleWidthUpDown_ValueChanged(object sender, System.EventArgs e)
509 {
510 m_Indicator2.Width = new NLength((float)NeedleWidthUpDown.Value);
511 nChartControl1.Refresh();
512 }
513 }
514}
515
 
 

    



Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009
Hello,

Most of this code is related to form controls, only the Initialize function configures the gauge appearance.

The code in ValueIndicatorUpDown_ValueChanged updates the gauge needle, so you may take a look at this function. You can update the indicator Value property with the reading from the SQL database.

The other event handlers demonstrate how different aspects of the gauge are changed in response to user input. In your case most of them won't be necessary.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic