private NLinearGaugePanel CreateVerticalLinearGauge()
        {
            NLinearGaugePanel linearGauge = new NLinearGaugePanel();

            linearGauge.Orientation = LinearGaugeOrientation.Vertical;

            linearGauge.Location            = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(40, NRelativeUnit.ParentPercentage));
            linearGauge.Size                = new NSizeL(new NLength(60, NGraphicsUnit.Point), new NLength(50, NRelativeUnit.ParentPercentage));
            linearGauge.BorderStyle         = new NEdgeBorderStyle(BorderShape.RoundedRect);
            linearGauge.BackgroundFillStyle = new NGradientFillStyle(Color.DarkGray, Color.Black);

            // add indicators
            m_VertLinearIndicator1                   = new NRangeIndicator();
            m_VertLinearIndicator1.Value             = 10;
            m_VertLinearIndicator1.FillStyle         = new NGradientFillStyle(Color.LightBlue, Color.DarkBlue);
            m_VertLinearIndicator1.StrokeStyle.Color = Color.DarkBlue;
            linearGauge.Indicators.Add(m_VertLinearIndicator1);

            m_VertLinearIndicator2       = new NMarkerValueIndicator();
            m_VertLinearIndicator2.Value = 50;
            linearGauge.Indicators.Add(m_VertLinearIndicator2);

            NGaugeAxis axis = (NGaugeAxis)linearGauge.Axes[0];

            axis.Anchor = new NModelGaugeAxisAnchor();

            ConfigureAxis(axis);

            return(linearGauge);
        }
        private NBackgroundDecoratorPanel CreateStatusMeterPanel(string labelText, NPointL location, NRangeIndicator rangeIndicator)
        {
            NBackgroundDecoratorPanel backgroundPanel = new NBackgroundDecoratorPanel();

            backgroundPanel.Location = location;
            backgroundPanel.Size     = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage),
                                                  new NLength(20, NRelativeUnit.ParentPercentage));

            NImageFrameStyle imageFrameStyle = new NImageFrameStyle(PredefinedImageFrame.Embed);

            imageFrameStyle.BackgroundColor            = Color.Transparent;
            imageFrameStyle.ShadowStyle.Type           = ShadowType.None;
            imageFrameStyle.FillStyle                  = new NColorFillStyle(Color.Transparent);
            backgroundPanel.BackgroundStyle.FillStyle  = new NColorFillStyle(Color.White);
            backgroundPanel.BackgroundStyle.FrameStyle = imageFrameStyle;

            NDockPanel contentPanel = new NDockPanel();

            contentPanel.DockMargins = new NMarginsL(new NLength(15), new NLength(3), new NLength(15), new NLength(3));
            contentPanel.DockMode    = PanelDockMode.Fill;
            backgroundPanel.ChildPanels.Add(contentPanel);

            NLabel label = new NLabel();

            label.DockMode         = PanelDockMode.Bottom;
            label.Text             = labelText;
            label.ContentAlignment = ContentAlignment.MiddleLeft;
            label.DockMargins      = new NMarginsL(new NLength(0), new NLength(0), new NLength(0), new NLength(0));
            label.BoundsMode       = BoundsMode.Fit;
            contentPanel.ChildPanels.Add(label);

            NLinearGaugePanel linearGauge = new NLinearGaugePanel();

            linearGauge.Indicators.Add(rangeIndicator);
            linearGauge.DockMode    = PanelDockMode.Fill;
            linearGauge.DockMargins = new NMarginsL(new NLength(15), new NLength(0), new NLength(15), new NLength(0));

            NGaugeAxis axis = (NGaugeAxis)linearGauge.Axes[0];

            axis.Anchor = new NModelGaugeAxisAnchor();
            NStandardScaleConfigurator configurator = (NStandardScaleConfigurator)axis.ScaleConfigurator;

            configurator.SetPredefinedScaleStyle(PredefinedScaleStyle.Scientific);
            contentPanel.ChildPanels.Add(linearGauge);

            return(backgroundPanel);
        }
        private void CreateLinearGauge()
        {
            m_LinearGauge = new NLinearGaugePanel();
            nChartControl1.Panels.Add(m_LinearGauge);

            // create the background panel
            m_LinearGauge.BackgroundFillStyle = new NColorFillStyle(Color.Black);
            m_LinearGauge.BorderStyle         = new NEdgeBorderStyle(BorderShape.RoundedRect);

            NGaugeAxis axis = (NGaugeAxis)m_LinearGauge.Axes[0];

            axis.Anchor = new NModelGaugeAxisAnchor(new NLength(10, NGraphicsUnit.Point), VertAlign.Center, RulerOrientation.Left);
            ConfigureScale((NLinearScaleConfigurator)axis.ScaleConfigurator);

            // add some indicators
            AddRangeIndicatorToGauge(m_LinearGauge);
            m_LinearGauge.Indicators.Add(new NMarkerValueIndicator(60));
        }
Example #4
0
        private void InitLinearGauge()
        {
            NLinearGaugePanel linearGauge = new NLinearGaugePanel();

            linearGauge.ContentAlignment    = ContentAlignment.TopRight;
            linearGauge.Location            = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(40, NRelativeUnit.ParentPercentage));
            linearGauge.Size                = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(55, NGraphicsUnit.Point));
            linearGauge.BackgroundFillStyle = new NGradientFillStyle(Color.DarkGray, Color.Black);
            linearGauge.BorderStyle         = new NEdgeBorderStyle(BorderShape.RoundedRect);
            linearGauge.PaintEffect         = new NGelEffectStyle();

            nChartControl1.Panels.Add(linearGauge);

            NMarkerValueIndicator indicator1 = new NMarkerValueIndicator();

            linearGauge.Indicators.Add(indicator1);

            InitSections(linearGauge);
        }
        private void CreateLinearGauge()
        {
            m_LinearGauge = new NLinearGaugePanel();
            nChartControl1.Panels.Add(m_LinearGauge);

            // create the background panel
            NAdvancedGradientFillStyle advGradient = new NAdvancedGradientFillStyle();

            advGradient.BackgroundColor = Color.Black;
            advGradient.Points.Add(new NAdvancedGradientPoint(Color.LightGray, 10, 10, 0, 100, AGPointShape.Circle));
            m_LinearGauge.BackgroundFillStyle = advGradient;
            m_LinearGauge.BorderStyle         = new NEdgeBorderStyle(BorderShape.RoundedRect);

            NGaugeAxis axis = (NGaugeAxis)m_LinearGauge.Axes[0];

            axis.Anchor = new NModelGaugeAxisAnchor(new NLength(20, NGraphicsUnit.Point), VertAlign.Center, RulerOrientation.Left);
            ConfigureScale((NLinearScaleConfigurator)axis.ScaleConfigurator);

            // add some indicators
            m_LinearGauge.Indicators.Add(new NMarkerValueIndicator(60));
        }
        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;
            }
        }
        public override void Create()
        {
            nChartControl1.Panels.Clear();

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

            header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic);
            header.ContentAlignment    = System.Drawing.ContentAlignment.BottomRight;
            header.Location            = new NPointL(new NLength(2, 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    = System.Drawing.ContentAlignment.MiddleCenter;
            m_LinearGauge.Location            = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(50, NRelativeUnit.ParentPercentage));
            m_LinearGauge.PaintEffect         = new NGelEffectStyle();
            m_LinearGauge.BorderStyle         = new NEdgeBorderStyle(BorderShape.RoundedRect);
            m_LinearGauge.BackgroundFillStyle = new NGradientFillStyle(System.Drawing.Color.Gray, System.Drawing.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(System.Drawing.Color.Red, System.Drawing.Color.Red, new NRange1DD(40, 60)));
            celsiusScale.Sections.Add(CreateSection(System.Drawing.Color.Blue, System.Drawing.Color.SkyBlue, new NRange1DD(-40, -20)));

            NLinearScaleConfigurator farenheitScale = (NLinearScaleConfigurator)farenheitAxis.ScaleConfigurator;

            ConfigureScale(farenheitScale, "°F");

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

            // now add two indicators
            m_Indicator1                   = new NRangeIndicator();
            m_Indicator1.Value             = 10;
            m_Indicator1.StrokeStyle.Color = System.Drawing.Color.DarkBlue;
            m_Indicator1.FillStyle         = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant1, System.Drawing.Color.LightBlue, System.Drawing.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, System.Drawing.Color.White, System.Drawing.Color.Red);
            m_Indicator2.Shape.StrokeStyle.Color = System.Drawing.Color.DarkRed;
            m_LinearGauge.Indicators.Add(m_Indicator2);

            // init form controls

            NExampleHelpers.BindComboToItemSource(ValueIndicatorComboBox, -20, 60, 1);
            ValueIndicatorComboBox.SelectedItem = (int)m_Indicator2.Value;

            NExampleHelpers.BindComboToItemSource(RangeIndicatorValueComboBox, -20, 60, 1);
            RangeIndicatorValueComboBox.SelectedItem = (int)m_Indicator1.Value;

            NExampleHelpers.BindComboToItemSource(MarkerWidthComboBox, 1, 40, 1);
            MarkerWidthComboBox.SelectedItem = (int)m_Indicator2.Width.Value;

            NExampleHelpers.BindComboToItemSource(MarkerHeightComboBox, 1, 40, 1);
            MarkerHeightComboBox.SelectedItem = (int)m_Indicator2.Height.Value;

            NExampleHelpers.FillComboWithEnumValues(RangeIndicatorOriginModeComboBox, typeof(OriginMode));
            RangeIndicatorOriginModeComboBox.SelectedIndex = 0;

            NExampleHelpers.BindComboToItemSource(RangeIndicatorOriginComboBox, -20, 60, 1);
            RangeIndicatorOriginComboBox.SelectedItem = (int)m_Indicator1.Origin;

            NExampleHelpers.FillComboWithEnumValues(ValueIndicatorShapeComboBox, typeof(SmartShape2D));
            ValueIndicatorShapeComboBox.SelectedIndex = (int)SmartShape2D.Triangle;

            NExampleHelpers.FillComboWithEnumValues(GaugeOrientationCombo, typeof(LinearGaugeOrientation));
            GaugeOrientationCombo.SelectedIndex = 0;
        }