/// <summary> /// /// </summary> /// <param name="gauge"></param> private void InitSections(NGauge gauge) { gauge.Axes.Clear(); NGaugeAxis axis = new NGaugeAxis(); gauge.Axes.Add(axis); axis.Anchor = new NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top); NStandardScale scale = (NStandardScale)axis.Scale; // init text style for regular labels scale.Labels.Style.TextStyle.Fill = new NColorFill(NColor.White); scale.Labels.Style.TextStyle.Font = new NFont("Arimo", 10, ENFontStyle.Bold); // init ticks scale.MajorGridLines.Visible = true; scale.MinTickDistance = 25; scale.MinorTickCount = 1; scale.SetPredefinedScale(ENPredefinedScaleStyle.Scientific); // create sections NScaleSection blueSection = new NScaleSection(); blueSection.Range = new NRange(0, 20); blueSection.RangeFill = new NColorFill(NColor.FromColor(NColor.Blue, 0.5f)); blueSection.MajorGridStroke = new NStroke(NColor.Blue); blueSection.MajorTickStroke = new NStroke(NColor.DarkBlue); blueSection.MinorTickStroke = new NStroke(1, NColor.Blue, ENDashStyle.Dot); NTextStyle labelStyle = new NTextStyle(); labelStyle.Fill = new NColorFill(NColor.Blue); labelStyle.Font = new NFont("Arimo", 10, ENFontStyle.Bold); blueSection.LabelTextStyle = labelStyle; scale.Sections.Add(blueSection); NScaleSection redSection = new NScaleSection(); redSection.Range = new NRange(80, 100); redSection.RangeFill = new NColorFill(NColor.FromColor(NColor.Red, 0.5f)); redSection.MajorGridStroke = new NStroke(NColor.Red); redSection.MajorTickStroke = new NStroke(NColor.DarkRed); redSection.MinorTickStroke = new NStroke(1, NColor.Red, ENDashStyle.Dot); labelStyle = new NTextStyle(); labelStyle.Fill = new NColorFill(NColor.Red); labelStyle.Font = new NFont("Arimo", 10.0, ENFontStyle.Bold); redSection.LabelTextStyle = labelStyle; scale.Sections.Add(redSection); }
private void UpdateRulerStyleForAxis(NCartesianAxis axis) { NStandardScale scale = (NStandardScale)axis.Scale; NSize capSize = new NSize(m_SizeUpDown.Value, m_SizeUpDown.Value); // apply style to begin and end caps scale.Ruler.BeginCap = new NRulerCapStyle((ENCapShape)m_BeginCapShapeComboBox.SelectedIndex, capSize, 0, new NColorFill(NColor.Black), new NStroke(NColor.Black)); scale.Ruler.EndCap = new NRulerCapStyle((ENCapShape)m_EndCapShapeComboBox.SelectedIndex, capSize, 3, new NColorFill(NColor.Black), new NStroke(NColor.Black)); scale.Ruler.ScaleBreakCap = new NRulerCapStyle((ENCapShape)m_ScaleBreakCapShapeComboBox.SelectedIndex, capSize, 0, new NColorFill(NColor.Black), new NStroke(NColor.Black)); scale.Ruler.PaintOnScaleBreaks = m_PaintOnScaleBreaksCheckBox.Checked; }
/// <summary> /// /// </summary> /// <param name="arg"></param> void UpdateSections(NValueChangeEventArgs arg) { NGauge[] gauges = new NGauge[] { m_RadialGauge, m_LinearGauge }; for (int i = 0; i < gauges.Length; i++) { NGauge gauge = gauges[i]; NGaugeAxis axis = (NGaugeAxis)gauge.Axes[0]; NStandardScale scale = (NStandardScale)axis.Scale; if (scale.Sections.Count == 2) { NScaleSection blueSection = (NScaleSection)scale.Sections[0]; blueSection.Range = new NRange(m_BlueSectionBeginUpDown.Value, m_BlueSectionEndUpDown.Value); NScaleSection redSection = (NScaleSection)scale.Sections[1]; redSection.Range = new NRange(m_RedSectionBeginUpDown.Value, m_RedSectionEndUpDown.Value); } } }
/// <summary> /// /// </summary> void OnDataFeedTimerTick() { // update linear gauge NGauge[] gauges = new NGauge[] { m_RadialGauge, m_LinearGauge }; for (int i = 0; i < gauges.Length; i++) { NGauge gauge = gauges[i]; NValueIndicator valueIndicator = (NValueIndicator)gauge.Indicators[0]; NStandardScale scale = (NStandardScale)gauge.Axes[0].Scale; NScaleSection blueSection = (NScaleSection)scale.Sections[0]; NScaleSection redSection = (NScaleSection)scale.Sections[1]; m_FirstIndicatorAngle += 0.02; valueIndicator.Value = 50.0 - Math.Cos(m_FirstIndicatorAngle) * 50.0; // FIX: Smart Shapes if (blueSection.Range.Contains(valueIndicator.Value)) { // valueIndicator.Shape.FillStyle = new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, NColor.White, NColor.Blue); // valueIndicator.Shape.StrokeStyle = new NStrokeStyle(Color.Blue); } else if (redSection.Range.Contains(valueIndicator.Value)) { // valueIndicator.Shape.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.Red); // valueIndicator.Shape.StrokeStyle = new NStrokeStyle(Color.Red); } else { // valueIndicator.Shape.FillStyle = new NColorFillStyle(Color.LightGreen); // valueIndicator.Shape.StrokeStyle = new NStrokeStyle(Color.DarkGreen); } } }
protected override NWidget CreateExampleContent() { NStackPanel stack = new NStackPanel(); NStackPanel controlStack = new NStackPanel(); stack.Add(controlStack); // create the radial gauge NRadialGauge radialGauge = new NRadialGauge(); controlStack.Add(radialGauge); radialGauge.Dial = new NDial(ENDialShape.Circle, new NEdgeDialRim()); radialGauge.PreferredSize = defaultRadialGaugeSize; radialGauge.Dial.BackgroundFill = new NStockGradientFill(NColor.DarkGray, NColor.Black); radialGauge.CapEffect = new NGlassCapEffect(); // configure the axis NGaugeAxis axis = new NGaugeAxis(); radialGauge.Axes.Add(axis); NStandardScale scale = (NStandardScale)axis.Scale; scale.SetPredefinedScale(ENPredefinedScaleStyle.Scientific); scale.Labels.Style.TextStyle.Fill = new NColorFill(NColor.White); scale.Labels.Style.TextStyle.Font = new NFont("Tinos", 10, ENFontStyle.Italic | ENFontStyle.Bold); scale.OuterMajorTicks.Stroke.Color = NColor.White; scale.OuterMajorTicks.Length = 6; scale.OuterMinorTicks.Stroke.Color = NColor.White; scale.OuterMinorTicks.Length = 4; scale.Ruler.Stroke.Color = NColor.White; scale.MinorTickCount = 4; // add some indicators m_RangeIndicator = new NRangeIndicator(); m_RangeIndicator.Value = 50; m_RangeIndicator.Palette = new NTwoColorPalette(NColor.DarkBlue, NColor.LightBlue); m_RangeIndicator.Stroke = null; m_RangeIndicator.EndWidth = 20; m_RangeIndicator.AllowDragging = true; radialGauge.Indicators.Add(m_RangeIndicator); m_NeedleIndicator = new NNeedleValueIndicator(); m_NeedleIndicator.Value = 79; m_NeedleIndicator.AllowDragging = true; radialGauge.Indicators.Add(m_NeedleIndicator); radialGauge.SweepAngle = new NAngle(270, NUnit.Degree); m_MarkerIndicator = new NMarkerValueIndicator(); m_MarkerIndicator.Value = 90; m_MarkerIndicator.AllowDragging = true; m_MarkerIndicator.OffsetOriginMode = ENIndicatorOffsetOriginMode.ScaleEnd; m_MarkerIndicator.OffsetFromScale = 0.0; radialGauge.Indicators.Add(m_MarkerIndicator); return(stack); }
/// <summary> /// /// </summary> /// <returns></returns> protected override NWidget CreateExampleContent() { NStackPanel stack = new NStackPanel(); NStackPanel controlStack = new NStackPanel(); controlStack.Direction = ENHVDirection.LeftToRight; stack.Add(controlStack); m_LinearGauge = new NLinearGauge(); m_LinearGauge.Orientation = ENLinearGaugeOrientation.Vertical; m_LinearGauge.PreferredSize = defaultLinearVerticalGaugeSize; m_LinearGauge.CapEffect = new NGelCapEffect(); m_LinearGauge.Border = base.CreateBorder(); m_LinearGauge.Padding = new NMargins(20); m_LinearGauge.BorderThickness = new NMargins(6); controlStack.Add(m_LinearGauge); // create the background panel NAdvancedGradientFill advGradient = new NAdvancedGradientFill(); advGradient.BackgroundColor = NColor.Black; advGradient.Points.Add(new NAdvancedGradientPoint(NColor.LightGray, new NAngle(10, NUnit.Degree), 0.1f, 0, 1.0f, ENAdvancedGradientPointShape.Circle)); m_LinearGauge.BackgroundFill = advGradient; m_LinearGauge.Axes.Clear(); NGaugeAxis axis = new NGaugeAxis(); m_LinearGauge.Axes.Add(axis); axis.Anchor = new NModelGaugeAxisAnchor(24.0, ENVerticalAlignment.Center, ENScaleOrientation.Left); ConfigureScale((NLinearScale)axis.Scale); // add some indicators m_LinearGauge.Indicators.Add(new NMarkerValueIndicator(60)); // create the radial gauge m_RadialGauge = new NRadialGauge(); controlStack.Add(m_RadialGauge); m_RadialGauge.CapEffect = new NGlassCapEffect(); m_RadialGauge.Dial = new NDial(ENDialShape.Circle, new NEdgeDialRim()); // set some background advGradient = new NAdvancedGradientFill(); advGradient.BackgroundColor = NColor.Black; advGradient.Points.Add(new NAdvancedGradientPoint(NColor.LightGray, new NAngle(10, NUnit.Degree), 0.1f, 0, 1.0f, ENAdvancedGradientPointShape.Circle)); m_RadialGauge.Dial.BackgroundFill = advGradient; m_RadialGauge.CapEffect = new NGlassCapEffect(ENCapEffectShape.Ellipse); // create the radial gauge m_RadialGauge.SweepAngle = new NAngle(270, NUnit.Degree); m_RadialGauge.BeginAngle = new NAngle(-90, NUnit.Degree); // FIX remove axis.Scale.Title.Text = "Axis Title"; NStandardScale scale = axis.Scale as NStandardScale; scale.MajorTickMode = ENMajorTickMode.AutoMinDistance; scale.MinTickDistance = 50; // configure the axis m_RadialGauge.Axes.Clear(); axis = new NGaugeAxis(); axis.Range = new NRange(0, 100); axis.Anchor.ScaleOrientation = ENScaleOrientation.Right; axis.Anchor = new NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, true, ENScaleOrientation.Right, 0, 100); m_RadialGauge.Axes.Add(axis); ConfigureScale((NLinearScale)axis.Scale); // add some indicators NNeedleValueIndicator needle = new NNeedleValueIndicator(60); needle.OffsetOriginMode = ENIndicatorOffsetOriginMode.ScaleMiddle; needle.OffsetFromScale = 15; m_RadialGauge.Indicators.Add(needle); return(stack); }
protected override NWidget CreateExampleContent() { NStackPanel stack = new NStackPanel(); stack.HorizontalPlacement = Layout.ENHorizontalPlacement.Left; NStackPanel controlStack = new NStackPanel(); stack.Add(controlStack); // create the radial gauge m_RadialGauge = new NRadialGauge(); // radialGauge.PreferredSize = new NSize(0, 50); // radialGauge.ContentAlignment = ContentAlignment.MiddleCenter; m_RadialGauge.SweepAngle = new NAngle(270, NUnit.Degree); m_RadialGauge.BeginAngle = new NAngle(-225, NUnit.Degree); m_RadialGauge.NeedleCap.Visible = false; m_RadialGauge.PreferredSize = defaultRadialGaugeSize; // configure scale NGaugeAxis axis = new NGaugeAxis(); m_RadialGauge.Axes.Add(axis); NStandardScale scale = (NStandardScale)axis.Scale; scale.SetPredefinedScale(ENPredefinedScaleStyle.PresentationNoStroke); scale.Labels.Style.TextStyle.Font = new NFont("Arimo", 12.0, ENFontStyle.Italic); scale.Labels.Style.TextStyle.Fill = new NColorFill(NColor.Black); scale.Labels.Style.Angle = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0.0); scale.MinorTickCount = 4; scale.Ruler.Stroke.Width = 0; scale.Ruler.Fill = new NColorFill(NColor.DarkGray); // create the knob indicator m_KnobIndicator = new NKnobIndicator(); m_KnobIndicator.OffsetFromScale = -3; m_KnobIndicator.AllowDragging = true; // apply fill style to the marker NAdvancedGradientFill advancedGradientFill = new NAdvancedGradientFill(); advancedGradientFill.BackgroundColor = NColor.Red; advancedGradientFill.Points.Add(new NAdvancedGradientPoint(NColor.White, new NAngle(20, NUnit.Degree), 20, 0, 100, ENAdvancedGradientPointShape.Circle)); m_KnobIndicator.Fill = advancedGradientFill; m_KnobIndicator.ValueChanged += new Function <NValueChangeEventArgs>(OnKnobValueChanged); m_RadialGauge.Indicators.Add(m_KnobIndicator); // create the numeric display m_NumericDisplay = new NNumericLedDisplay(); m_NumericDisplay.PreferredSize = new NSize(0, 60); m_NumericDisplay.BackgroundFill = new NColorFill(NColor.Black); m_NumericDisplay.Border = NBorder.CreateSunken3DBorder(new NUIThemeColorMap(ENUIThemeScheme.WindowsClassic)); m_NumericDisplay.BorderThickness = new NMargins(6); m_NumericDisplay.ContentAlignment = ENContentAlignment.MiddleCenter; m_NumericDisplay.Margins = new NMargins(5); m_NumericDisplay.Padding = new NMargins(5); m_NumericDisplay.CapEffect = new NGelCapEffect(); controlStack.Add(m_RadialGauge); controlStack.Add(m_NumericDisplay); return(stack); }
/// <summary> /// /// </summary> /// <returns></returns> protected override NWidget CreateExampleContent() { NStackPanel stack = new NStackPanel(); NStackPanel controlStack = new NStackPanel(); stack.Add(controlStack); // create the radial gauge m_RadialGauge = new NRadialGauge(); m_RadialGauge.PreferredSize = defaultRadialGaugeSize; controlStack.Add(m_RadialGauge); m_RadialGauge.Dial = new NDial(ENDialShape.CutCircle, new NEdgeDialRim()); m_RadialGauge.Dial.BackgroundFill = new NStockGradientFill(NColor.DarkGray, NColor.Black); NGelCapEffect gelEffect = new NGelCapEffect(ENCapEffectShape.Ellipse); gelEffect.Margins = new NMargins(0, 0, 0, 0.5); m_RadialGauge.Axes.Clear(); // create the first axis NGaugeAxis axis1 = new NGaugeAxis(); axis1.Anchor = new NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, true, 0, 70); NStandardScale scale1 = (NStandardScale)axis1.Scale; scale1.SetPredefinedScale(ENPredefinedScaleStyle.PresentationNoStroke); scale1.MinorTickCount = 3; scale1.Ruler.Fill = new NColorFill(NColor.FromColor(NColor.White, 0.4f)); scale1.OuterMajorTicks.Fill = new NColorFill(NColor.Orange); scale1.Labels.Style.TextStyle.Font = new NFont("Arimo", 12, ENFontStyle.Bold); scale1.Labels.Style.TextStyle.Fill = new NColorFill(NColor.White); scale1.Labels.Style.Angle = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0); m_RadialGauge.Axes.Add(axis1); // create the second axis NGaugeAxis axis2 = new NGaugeAxis(); axis2.Anchor = new NDockGaugeAxisAnchor(ENGaugeAxisDockZone.Top, false, 75, 95); NStandardScale scale2 = (NStandardScale)axis2.Scale; scale2.SetPredefinedScale(ENPredefinedScaleStyle.PresentationNoStroke); scale2.MinorTickCount = 3; scale2.Ruler.Fill = new NColorFill(NColor.FromColor(NColor.White, 0.4f)); scale2.OuterMajorTicks.Fill = new NColorFill(NColor.Blue); scale2.Labels.Style.TextStyle.Font = new NFont("Arimo", 12, ENFontStyle.Bold); scale2.Labels.Style.TextStyle.Fill = new NColorFill(NColor.White); scale2.Labels.Style.Angle = new NScaleLabelAngle(ENScaleLabelAngleMode.Scale, 0); m_RadialGauge.Axes.Add(axis2); // add indicators NRangeIndicator rangeIndicator = new NRangeIndicator(); rangeIndicator.Value = 50; rangeIndicator.Fill = new NStockGradientFill(NColor.Orange, NColor.Red); rangeIndicator.Stroke.Width = 0; rangeIndicator.OffsetFromScale = 3; rangeIndicator.BeginWidth = 6; rangeIndicator.EndWidth = 12; m_RadialGauge.Indicators.Add(rangeIndicator); NNeedleValueIndicator needleValueIndicator1 = new NNeedleValueIndicator(); needleValueIndicator1.Value = 79; // needleValueIndicator1.Shape.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant2, Color.White, Color.Red); // needleValueIndicator1.Shape.StrokeStyle.Color = Color.Red; needleValueIndicator1.ScaleAxis = axis1; needleValueIndicator1.OffsetFromScale = 2; m_RadialGauge.Indicators.Add(needleValueIndicator1); m_RadialGauge.SweepAngle = new NAngle(360, NUnit.Degree); NNeedleValueIndicator needleValueIndicator2 = new NNeedleValueIndicator(); needleValueIndicator2.Value = 79; // needleValueIndicator2.Shape.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant2, Color.White, Color.Blue); // needleValueIndicator2.Shape.StrokeStyle.Color = Color.Blue; needleValueIndicator2.ScaleAxis = axis2; needleValueIndicator2.OffsetFromScale = 2; m_RadialGauge.Indicators.Add(needleValueIndicator2); return(stack); }