Exemple #1
0
        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 void ValueIndicatorShapeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            N2DSmartShapeFactory factory = new N2DSmartShapeFactory(m_Indicator2.Shape.FillStyle, m_Indicator2.Shape.StrokeStyle, m_Indicator2.Shape.ShadowStyle);

            m_Indicator2.Shape = factory.CreateShape((SmartShape2D)ValueIndicatorShapeComboBox.SelectedIndex);
            nChartControl1.Refresh();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Settings.JitterMode = JitterMode.Enabled;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Series Markers");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

            // setup chart
            NChart chart = nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;

            // add interlaced stripe to the Y axis
            NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);

            stripStyle.SetShowAtWall(ChartWallType.Back, true);
            stripStyle.SetShowAtWall(ChartWallType.Left, true);
            stripStyle.Interlaced = true;
            ((NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle);

            chart.Axis(StandardAxis.Depth).Visible = false;

            NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line);

            line.LineSegmentShape = LineSegmentShape.Tape;
            line.InflateMargins   = true;
            line.DepthPercent     = 50;
            line.Legend.Mode      = SeriesLegendMode.DataPoints;
            line.Name             = "Line Series";
            line.Values.FillRandom(Random, 6);
            line.DataLabelStyle.Visible = false;
            line.ShadowStyle.Type       = ShadowType.GaussianBlur;
            line.ShadowStyle.Offset     = new NPointL(2, 2);
            line.ShadowStyle.Color      = Color.FromArgb(88, 0, 0, 0);
            line.ShadowStyle.FadeLength = new NLength(5);
            line.MarkerStyle.Visible    = true;

            NMarkerStyle marker = new NMarkerStyle();

            marker.FillStyle  = new NColorFillStyle(Color.Red);
            marker.PointShape = PointShape.Custom;

            // Create a custom shape for this marker
            N2DSmartShapeFactory factory = new N2DSmartShapeFactory(new NColorFillStyle(Color.Red), new NStrokeStyle(1.0f, Color.Black), null);

            marker.CustomShape   = factory.CreateShape(SmartShape2D.Trapezoid);
            marker.Visible       = true;
            line.MarkerStyles[3] = marker;

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, nChartControl1.Legends[0]);
        }
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Series Marker Attribute");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.ContentAlignment    = ContentAlignment.BottomCenter;
            title.Location            = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

            // setup chart
            NChart chart = nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;

            // add interlaced stripe to the Y axis
            NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);

            stripStyle.SetShowAtWall(ChartWallType.Back, true);
            stripStyle.SetShowAtWall(ChartWallType.Left, true);
            stripStyle.Interlaced = true;
            ((NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle);

            chart.Axis(StandardAxis.Depth).Visible = false;

            NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line);

            line.LineSegmentShape = LineSegmentShape.Tape;
            line.InflateMargins   = true;
            line.DepthPercent     = 50;
            line.Legend.Mode      = SeriesLegendMode.DataPoints;
            line.Name             = "Line Series";
            line.Values.FillRandom(Random, 6);
            line.DataLabelStyle.Visible = false;
            line.ShadowStyle.Type       = ShadowType.GaussianBlur;
            line.ShadowStyle.Offset     = new NPointL(2, 2);
            line.ShadowStyle.Color      = Color.FromArgb(88, 0, 0, 0);
            line.ShadowStyle.FadeLength = new NLength(5);
            line.MarkerStyle.Visible    = true;

            NMarkerStyle marker = new NMarkerStyle();

            marker.FillStyle  = new NColorFillStyle(Color.Red);
            marker.PointShape = PointShape.Custom;

            // Create a custom shape for this marker
            N2DSmartShapeFactory factory = new N2DSmartShapeFactory(new NColorFillStyle(Color.Red), new NStrokeStyle(1.0f, Color.Black), null);

            marker.CustomShape   = factory.CreateShape(SmartShape2D.Trapezoid);
            marker.Visible       = true;
            line.MarkerStyles[3] = marker;

            // apply layout
            ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]);
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel header = new NLabel("Linear Gauge Indicators");

            header.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            header.ContentAlignment           = ContentAlignment.BottomRight;
            header.Location = new NPointL(new NLength(3, NRelativeUnit.ParentPercentage),
                                          new NLength(2, NRelativeUnit.ParentPercentage));
            nChartControl1.Panels.Add(header);

            // create a linear gauge
            m_LinearGauge = new NLinearGaugePanel();
            nChartControl1.Panels.Add(m_LinearGauge);
            m_LinearGauge.ContentAlignment    = ContentAlignment.MiddleCenter;
            m_LinearGauge.BorderStyle         = new NEdgeBorderStyle(BorderShape.RoundedRect);
            m_LinearGauge.PaintEffect         = new NGelEffectStyle();
            m_LinearGauge.BackgroundFillStyle = new NGradientFillStyle(Color.Gray, Color.Black);

            m_LinearGauge.Axes.Clear();

            NRange1DD celsiusRange = new NRange1DD(-40, 60);

            // add celsius and farenheit axes
            NGaugeAxis celsiusAxis = new NGaugeAxis();

            celsiusAxis.Range  = celsiusRange;
            celsiusAxis.Anchor = new NModelGaugeAxisAnchor(new NLength(-5), VertAlign.Center, RulerOrientation.Left, 0, 100);
            m_LinearGauge.Axes.Add(celsiusAxis);

            NGaugeAxis farenheitAxis = new NGaugeAxis();

            farenheitAxis.Range  = new NRange1DD(CelsiusToFarenheit(celsiusRange.Begin), CelsiusToFarenheit(celsiusRange.End));
            farenheitAxis.Anchor = new NModelGaugeAxisAnchor(new NLength(5), VertAlign.Center, RulerOrientation.Right, 0, 100);
            m_LinearGauge.Axes.Add(farenheitAxis);

            // configure the scales
            NLinearScaleConfigurator celsiusScale = (NLinearScaleConfigurator)celsiusAxis.ScaleConfigurator;

            ConfigureScale(celsiusScale, "°C");
            celsiusScale.Sections.Add(CreateSection(Color.Red, Color.Red, new NRange1DD(40, 60)));
            celsiusScale.Sections.Add(CreateSection(Color.Blue, Color.SkyBlue, new NRange1DD(-40, -20)));

            NLinearScaleConfigurator farenheitScale = (NLinearScaleConfigurator)farenheitAxis.ScaleConfigurator;

            ConfigureScale(farenheitScale, "°F");

            farenheitScale.Sections.Add(CreateSection(Color.Red, Color.Red, new NRange1DD(CelsiusToFarenheit(40), CelsiusToFarenheit(60))));
            farenheitScale.Sections.Add(CreateSection(Color.Blue, Color.SkyBlue, new NRange1DD(CelsiusToFarenheit(-40), CelsiusToFarenheit(-20))));

            // now add two indicators
            m_Indicator1                   = new NRangeIndicator();
            m_Indicator1.Value             = 10;
            m_Indicator1.StrokeStyle.Color = Color.DarkBlue;
            m_Indicator1.FillStyle         = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant1, Color.LightBlue, Color.Blue);
            m_LinearGauge.Indicators.Add(m_Indicator1);

            m_Indicator2                         = new NMarkerValueIndicator();
            m_Indicator2.Value                   = 33;
            m_Indicator2.Shape.FillStyle         = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.Red);
            m_Indicator2.Shape.StrokeStyle.Color = Color.DarkRed;
            m_LinearGauge.Indicators.Add(m_Indicator2);

            // init form controls
            if (!Page.IsPostBack)
            {
                WebExamplesUtilities.FillComboWithEnumValues(RangeIndicatorOriginModeDropDownList, typeof(OriginMode));
                RangeIndicatorOriginModeDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithEnumValues(ValueIndicatorShapeDropDownList, typeof(SmartShape2D));
                ValueIndicatorShapeDropDownList.SelectedIndex = (int)SmartShape2D.Triangle;

                WebExamplesUtilities.FillComboWithEnumValues(GaugeOrientationDropDownList, typeof(LinearGaugeOrientation));
                GaugeOrientationDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithValues(ValueIndicatorDropDownList, -20, 60, 10);
                WebExamplesUtilities.FillComboWithValues(RangeIndicatorValueDropDownList, -20, 60, 10);
                WebExamplesUtilities.FillComboWithValues(RangeIndicatorOriginDropDownList, -20, 60, 10);
                RangeIndicatorOriginDropDownList.SelectedIndex = 5;

                RangeIndicatorValueDropDownList.SelectedValue = m_Indicator1.Value.ToString();
                ValueIndicatorDropDownList.SelectedValue      = m_Indicator2.Value.ToString();
            }

            m_LinearGauge.Orientation = (LinearGaugeOrientation)GaugeOrientationDropDownList.SelectedIndex;

            if (m_LinearGauge.Orientation == LinearGaugeOrientation.Horizontal)
            {
                m_LinearGauge.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(50, NRelativeUnit.ParentPercentage));
                m_LinearGauge.Size     = new NSizeL(new NLength(90, NRelativeUnit.ParentPercentage), new NLength(55, NRelativeUnit.ParentPercentage));
            }
            else
            {
                m_LinearGauge.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(54, NRelativeUnit.ParentPercentage));
                m_LinearGauge.Size     = new NSizeL(new NLength(37, NRelativeUnit.ParentPercentage), new NLength(85, NRelativeUnit.ParentPercentage));
            }
            m_Indicator1.OriginMode = (OriginMode)RangeIndicatorOriginModeDropDownList.SelectedIndex;
            m_Indicator1.Origin     = Convert.ToDouble(RangeIndicatorOriginDropDownList.SelectedValue);
            m_Indicator1.Value      = Convert.ToDouble(RangeIndicatorValueDropDownList.SelectedValue);

            N2DSmartShapeFactory factory = new N2DSmartShapeFactory(m_Indicator2.Shape.FillStyle, m_Indicator2.Shape.StrokeStyle, m_Indicator2.Shape.ShadowStyle);

            m_Indicator2.Shape = factory.CreateShape((SmartShape2D)ValueIndicatorShapeDropDownList.SelectedIndex);
            m_Indicator2.Value = Convert.ToDouble(ValueIndicatorDropDownList.SelectedValue);

            if (m_Indicator1.OriginMode != OriginMode.Custom)
            {
                RangeIndicatorOriginDropDownList.Enabled = false;
            }
            else
            {
                RangeIndicatorOriginDropDownList.Enabled = true;
            }
        }
Exemple #6
0
        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);
            }
        }