Ejemplo n.º 1
0
        private NScaleBreakStyle CreateScaleBreakStyle(Color color)
        {
            NWaveScaleBreakStyle style = new NWaveScaleBreakStyle();

            style.VertStep  = new NLength(20);
            style.FillStyle = new NColorFillStyle(color);
            return(style);
        }
Ejemplo n.º 2
0
        protected void UpdateScaleBreaks()
        {
            // read the form control values
            float horzStep;

            if (!float.TryParse(horzStepTextBox.Text, out horzStep) || horzStep < 0 || horzStep > 50)
            {
                horzStep             = 20f;
                horzStepTextBox.Text = horzStep.ToString();
            }

            float vertStep;

            if (!float.TryParse(vertStepTextBox.Text, out vertStep) || vertStep < 0 || vertStep > 50)
            {
                vertStep             = 3f;
                vertStepTextBox.Text = vertStep.ToString();
            }

            float length;

            if (!float.TryParse(lengthTextBox.Text, out length) || length < 0 || length > 50)
            {
                length             = 0;
                lengthTextBox.Text = length.ToString();
            }

            // update scale breaks
            NChart chart = nChartControl1.Charts[0];
            NLinearScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
            NScaleBreakStyle         oldScaleBreakStyle = null;

            if (scale.ScaleBreaks.Count > 0)
            {
                oldScaleBreakStyle = ((NScaleBreak)scale.ScaleBreaks[0]).Style;
            }
            scale.ScaleBreaks.Clear();

            NScaleBreakStyle newScaleBreakStyle = null;

            switch (styleDropDownList.SelectedIndex)
            {
            case 0:                     // Line
                newScaleBreakStyle = new NLineScaleBreakStyle();
                break;

            case 1:                     // Waves
                newScaleBreakStyle = new NWaveScaleBreakStyle();
                break;

            case 2:                     // ZigZag
                newScaleBreakStyle = new NZigZagScaleBreakStyle();
                break;
            }

            // try to preserve fill and stroke settings
            if (newScaleBreakStyle != null)
            {
                if (oldScaleBreakStyle != null)
                {
                    newScaleBreakStyle.InitFrom(oldScaleBreakStyle);
                }

                // update the length of the scale break
                newScaleBreakStyle.Length = new NLength(length, NGraphicsUnit.Point);

                // update paramers relevant to pattern scale break appearance
                NPatternScaleBreakStyle patternScaleBreakStyle = newScaleBreakStyle as NPatternScaleBreakStyle;
                bool enablePatternControls = patternScaleBreakStyle != null;
                if (patternScaleBreakStyle != null)
                {
                    patternScaleBreakStyle.HorzStep = new NLength(horzStep);
                    patternScaleBreakStyle.VertStep = new NLength(vertStep);
                    patternScaleBreakStyle.Pattern  = (ScaleBreakPattern)Enum.Parse(typeof(ScaleBreakPattern), patternDropDownList.SelectedItem.Text);
                }

                scale.ScaleBreaks.Add(new NAutoScaleBreak(newScaleBreakStyle, 0.4f));
            }
        }
Ejemplo n.º 3
0
        private void UpdateScaleBreak()
        {
            NChart chart = nChartControl1.Charts[0];
            NLinearScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
            NScaleBreakStyle         oldScaleBreakStyle = null;

            if (scale.ScaleBreaks.Count > 0)
            {
                oldScaleBreakStyle = ((NScaleBreak)scale.ScaleBreaks[0]).Style;
            }
            scale.ScaleBreaks.Clear();

            NScaleBreakStyle newScaleBreakStyle = null;

            switch (ScaleBreakStyleComboBox.SelectedIndex)
            {
            case 0:     // Line
                newScaleBreakStyle = new NLineScaleBreakStyle();
                break;

            case 1:     // Waves
                newScaleBreakStyle = new NWaveScaleBreakStyle();
                break;

            case 2:     // ZigZag
                newScaleBreakStyle = new NZigZagScaleBreakStyle();
                break;
            }

            // try to preserve fill and stroke settings
            if (newScaleBreakStyle != null)
            {
                if (oldScaleBreakStyle != null)
                {
                    newScaleBreakStyle.InitFrom(oldScaleBreakStyle);
                }
                else
                {
                    newScaleBreakStyle.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant2, Color.LightGray, Color.White);
                }

                // update the length of the scale break
                newScaleBreakStyle.Length = new NLength((float)LengthUpDown.Value, NGraphicsUnit.Point);

                // update paramers relevant to pattern scale break appearance
                NPatternScaleBreakStyle patternScaleBreakStyle = newScaleBreakStyle as NPatternScaleBreakStyle;
                bool enablePatternControls = patternScaleBreakStyle != null;
                if (patternScaleBreakStyle != null)
                {
                    patternScaleBreakStyle.HorzStep = new NLength((float)HorzStepNumericUpDown.Value);
                    patternScaleBreakStyle.VertStep = new NLength((float)VertStepNumericUpDown.Value);
                    patternScaleBreakStyle.Pattern  = (ScaleBreakPattern)PatternComboBox.SelectedIndex;
                }

                HorzStepNumericUpDown.Enabled = enablePatternControls;
                VertStepNumericUpDown.Enabled = enablePatternControls;
                PatternComboBox.Enabled       = enablePatternControls;

                scale.ScaleBreaks.Add(new NAutoScaleBreak(newScaleBreakStyle, 0.4f));
            }

            nChartControl1.Refresh();
        }