private void UpdateKnob() { if (m_Updating) { return; } NKnobIndicator knob = m_RadialGauge.Indicators[0] as NKnobIndicator; // update the knob marker shape N2DSmartShapeFactory factory = new N2DSmartShapeFactory(knob.MarkerShape.FillStyle, knob.MarkerShape.StrokeStyle, knob.MarkerShape.ShadowStyle); knob.MarkerShape = factory.CreateShape((SmartShape2D)MarkerShapeComboBox.SelectedIndex); knob.OffsetFromScale = new NLength((int)MarkerOffsetComboBox.SelectedItem, NGraphicsUnit.Point); knob.MarkerPaintOrder = (KnobMarkerPaintOrder)MarkerPaintOrderComboBox.SelectedIndex; // update the outer rim style knob.OuterRimStyle.Pattern = (CircularRimPattern)OuterRimPatternComboBox.SelectedIndex; knob.OuterRimStyle.PatternRepeatCount = (int)OuterRimPatternRepeatCountComboBox.SelectedItem; knob.OuterRimStyle.Offset = new NLength((int)OuterRimRadiusOffsetComboBox.SelectedItem, NGraphicsUnit.Point); // update the inner rim style knob.InnerRimStyle.Pattern = (CircularRimPattern)InnerRimPatternComboBox.SelectedIndex; knob.InnerRimStyle.PatternRepeatCount = (int)InnerRimPatternRepeatCountComboBox.SelectedItem; knob.InnerRimStyle.Offset = new NLength((int)InnerRimRadiusOffsetComboBox.SelectedItem, NGraphicsUnit.Point); nChartControl1.Refresh(); }
private NRadialGaugePanel CreateRadialGauge(NKnobIndicator knobIndicator) { // create the radial gauge NRadialGaugePanel radialGauge = new NRadialGaugePanel(); radialGauge.Size = new NSizeL(new NLength(0), new NLength(50, NRelativeUnit.ParentPercentage)); radialGauge.ContentAlignment = ContentAlignment.MiddleCenter; radialGauge.DockMode = PanelDockMode.Fill; radialGauge.SweepAngle = 270; radialGauge.BeginAngle = -225; radialGauge.CapStyle.Visible = false; radialGauge.Indicators.Add(knobIndicator); // configure scale NGaugeAxis axis = (NGaugeAxis)radialGauge.Axes[0]; NStandardScaleConfigurator scale = (NStandardScaleConfigurator)axis.ScaleConfigurator; scale.SetPredefinedScaleStyle(PredefinedScaleStyle.PresentationNoStroke); scale.LabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 12, System.Drawing.FontStyle.Italic); scale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.Black); scale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0); scale.MinorTickCount = 4; scale.RulerStyle.BorderStyle.Width = new NLength(0); scale.RulerStyle.FillStyle = new NColorFillStyle(Color.DarkGray); return(radialGauge); }
public override void Create() { nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Radial Gauge Knob Indicators"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); header.ContentAlignment = ContentAlignment.BottomRight; header.DockMode = PanelDockMode.Top; header.Location = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); header.Margins = new NMarginsL(5, 5, 5, 5); nChartControl1.Panels.Add(header); NDockPanel panelContainer = new NDockPanel(); panelContainer.DockMode = PanelDockMode.Fill; // create the knob indicator NKnobIndicator knobIndicator = new NKnobIndicator(); knobIndicator.OffsetFromScale = new NLength(-5); knobIndicator.OuterRimStyle.PatternRepeatCount = 5; knobIndicator.InnerRimStyle.PatternRepeatCount = 5; //knobIndicator.InnerRimStyle.Offset = new NLength(10); // apply fill style to the marker NAdvancedGradientFillStyle advancedGradientFill = new NAdvancedGradientFillStyle(); advancedGradientFill.BackgroundColor = Color.Red; advancedGradientFill.Points.Add(new NAdvancedGradientPoint(Color.White, 20, 20, 0, 100, AGPointShape.Circle)); knobIndicator.MarkerShape.FillStyle = advancedGradientFill; knobIndicator.ValueChanged += knobIndicator_ValueChanged; m_RadialGauge = CreateRadialGauge(knobIndicator); m_NumericDisplay = CreateNumericDisplay(); panelContainer.ChildPanels.Add(m_NumericDisplay); panelContainer.ChildPanels.Add(m_RadialGauge); panelContainer.Margins = new NMarginsL(10, 10, 10, 10); nChartControl1.Panels.Add(panelContainer); nChartControl1.Controller.Tools.Add(new NSelectorTool()); nChartControl1.Controller.Tools.Add(new NIndicatorDragTool()); m_Updating = true; // Init form controls NExampleHelpers.FillComboWithEnumValues(MarkerShapeComboBox, typeof(SmartShape2D)); MarkerShapeComboBox.SelectedIndex = (int)SmartShape2D.Ellipse; NExampleHelpers.BindComboToItemSource(MarkerOffsetComboBox, -100, 100, 5); MarkerOffsetComboBox.SelectedItem = (int)knobIndicator.OffsetFromScale.Value; NExampleHelpers.FillComboWithEnumValues(MarkerPaintOrderComboBox, typeof(KnobMarkerPaintOrder)); MarkerPaintOrderComboBox.SelectedIndex = (int)knobIndicator.MarkerPaintOrder; // outer rim NExampleHelpers.FillComboWithEnumValues(OuterRimPatternComboBox, typeof(CircularRimPattern)); OuterRimPatternComboBox.SelectedIndex = (int)knobIndicator.OuterRimStyle.Pattern; NExampleHelpers.BindComboToItemSource(OuterRimPatternRepeatCountComboBox, 0, 100, 5); OuterRimPatternRepeatCountComboBox.SelectedItem = (int)knobIndicator.OuterRimStyle.PatternRepeatCount; NExampleHelpers.BindComboToItemSource(OuterRimRadiusOffsetComboBox, 0, 100, 5); OuterRimRadiusOffsetComboBox.SelectedItem = (int)knobIndicator.OuterRimStyle.Offset.Value; // inner rim NExampleHelpers.FillComboWithEnumValues(InnerRimPatternComboBox, typeof(CircularRimPattern)); InnerRimPatternComboBox.SelectedIndex = (int)knobIndicator.InnerRimStyle.Pattern; NExampleHelpers.BindComboToItemSource(InnerRimPatternRepeatCountComboBox, 0, 100, 5); InnerRimPatternRepeatCountComboBox.SelectedItem = (int)knobIndicator.InnerRimStyle.PatternRepeatCount; NExampleHelpers.BindComboToItemSource(InnerRimRadiusOffsetComboBox, 0, 100, 5); InnerRimRadiusOffsetComboBox.SelectedItem = (int)knobIndicator.InnerRimStyle.Offset.Value; m_Updating = false; OuterRimPatternRepeatCountComboBox.SelectedItem = 6; }
protected void Page_Load(object sender, System.EventArgs e) { if (!nChartControl1.Initialized) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); nChartControl1.StateId = "Gauge1"; // set a chart title NLabel header = new NLabel("Custom Commands"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.DockMode = PanelDockMode.Top; header.Location = new NPointL(new NLength(3, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); nChartControl1.Panels.Add(header); // create the radial gauge NRadialGaugePanel radialGauge = new NRadialGaugePanel(); nChartControl1.Panels.Add(radialGauge); radialGauge.DockMode = PanelDockMode.Fill; radialGauge.ContentAlignment = ContentAlignment.MiddleCenter; radialGauge.SweepAngle = 270; radialGauge.BeginAngle = -225; radialGauge.CapStyle.Visible = false; // configure the gauge scale NGaugeAxis axis = (NGaugeAxis)radialGauge.Axes[0]; NStandardScaleConfigurator scale = (NStandardScaleConfigurator)axis.ScaleConfigurator; scale.SetPredefinedScaleStyle(PredefinedScaleStyle.PresentationNoStroke); scale.LabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 12, FontStyle.Italic); scale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.Black); scale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0); scale.MinorTickCount = 4; scale.RulerStyle.BorderStyle.Width = new NLength(0); scale.RulerStyle.FillStyle = new NColorFillStyle(Color.DarkGray); // create the knob indicator NKnobIndicator knobIndicator = new NKnobIndicator(); knobIndicator.OffsetFromScale = new NLength(-3); // apply fill style to the marker NAdvancedGradientFillStyle advancedGradientFill = new NAdvancedGradientFillStyle(); advancedGradientFill.BackgroundColor = Color.Red; advancedGradientFill.Points.Add(new NAdvancedGradientPoint(Color.White, 20, 20, 0, 100, AGPointShape.Circle)); knobIndicator.MarkerShape.FillStyle = advancedGradientFill; // add the knob indicator to the indicators collection of the gauge radialGauge.Indicators.Add(knobIndicator); // update the knob marker shape N2DSmartShapeFactory factory = new N2DSmartShapeFactory(knobIndicator.MarkerShape.FillStyle, knobIndicator.MarkerShape.StrokeStyle, knobIndicator.MarkerShape.ShadowStyle); knobIndicator.MarkerShape = factory.CreateShape(SmartShape2D.Ellipse); // update the outer rim style knobIndicator.OuterRimStyle.Pattern = CircularRimPattern.RoundHandleSmall; // update the inner rim style knobIndicator.InnerRimStyle.Pattern = CircularRimPattern.Circle; NIndicatorDragTool indicatorDragTool = new NIndicatorDragTool(); indicatorDragTool.IndicatorDragCallback = new IndicatorDragCallback(); nChartControl1.Controller.Tools.Add(indicatorDragTool); } }
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); }