Example #1
0
        /// <summary>
        /// Create a <see cref="Pen" /> object based on the properties of this
        /// <see cref="LineBase" />.
        /// </summary>
        /// <param name="pane">The owner <see cref="GraphPane" /> of this
        /// <see cref="LineBase" />.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="dataValue">The data value to be used for a value-based
        /// color gradient.  This is only applicable if <see cref="Fill.Type">GradientFill.Type</see>
        /// is one of <see cref="FillType.GradientByX"/>,
        /// <see cref="FillType.GradientByY"/>, <see cref="FillType.GradientByZ"/>,
        /// or <see cref="FillType.GradientByColorValue" />.
        /// </param>
        /// <returns>A <see cref="Pen" /> object with the properties of this <see cref="LineBase" />
        /// </returns>
        public Pen GetPen(PaneBase pane, float scaleFactor, PointPair dataValue)
        {
            Color color = _color;

            if (_gradientFill.IsGradientValueType)
            {
                color = _gradientFill.GetGradientColor(dataValue);
            }

            Pen pen = new Pen(color,
                              pane.ScaledPenWidth(_width, scaleFactor));

            pen.DashStyle = _style;

            if (_style == DashStyle.Custom)
            {
                if (_dashOff > 1e-10 && _dashOn > 1e-10)
                {
                    pen.DashStyle = DashStyle.Custom;
                    float[] pattern = new float[2];
                    pattern[0]      = _dashOn;
                    pattern[1]      = _dashOff;
                    pen.DashPattern = pattern;
                }
                else
                {
                    pen.DashStyle = DashStyle.Solid;
                }
            }

            return(pen);
        }
Example #2
0
        /// <summary>
        /// Create a <see cref="Pen" /> object based on the properties of this
        /// <see cref="LineBase" />.
        /// </summary>
        /// <param name="pane">The owner <see cref="GraphPane" /> of this
        /// <see cref="LineBase" />.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="dataValue">The data value to be used for a value-based
        /// color gradient.  This is only applicable if <see cref="Fill.Type">GradientFill.Type</see>
        /// is one of <see cref="FillType.GradientByX"/>,
        /// <see cref="FillType.GradientByY"/>, <see cref="FillType.GradientByZ"/>,
        /// or <see cref="FillType.GradientByColorValue" />.
        /// </param>
        /// <returns>A <see cref="Pen" /> object with the properties of this <see cref="LineBase" />
        /// </returns>
        public Pen GetPen(PaneBase pane, float scaleFactor, PointPair dataValue)
        {
            Color color = _color;

            if (_gradientFill.IsGradientValueType)
            {
                color = _gradientFill.GetGradientColor(dataValue);
            }

            Pen pen = new Pen(color,
                              pane.ScaledPenWidth(_width, scaleFactor));

            pen.DashStyle = _style;

            if (_style == DashStyle.Custom)
            {
                CustomDashes.SetupPen(pen, this, dataValue);
            }

            return(pen);
        }