Exemple #1
0
		/// <summary>
		/// The PointPairBase copy constructor.
		/// </summary>
		/// <param name="rhs">The basis for the copy.</param>
		public PointPairBase(PointPairBase rhs)
		{
			this.X = rhs.X;
			this.Y = rhs.Y;
		}
Exemple #2
0
 /// <summary>
 /// The PointPairBase copy constructor.
 /// </summary>
 /// <param name="rhs">The basis for the copy.</param>
 public PointPairBase(PointPairBase rhs)
 {
     this.X = rhs.X;
     this.Y = rhs.Y;
 }
Exemple #3
0
        /// <summary>
        /// Compare two <see cref="PointPairBase"/> objects for equality.  To be equal, X and Y
        /// must be exactly the same between the two objects.
        /// </summary>
        /// <param name="obj">The <see cref="PointPairBase"/> object to be compared with.</param>
        /// <returns>true if the <see cref="PointPairBase"/> objects are equal, false otherwise</returns>
        public override bool Equals(object obj)
        {
            PointPairBase rhs = obj as PointPairBase;

            return(this.X == rhs.X && this.Y == rhs.Y);
        }
Exemple #4
0
        /// <summary>
        /// Draw all the <see cref="JapaneseCandleStick"/>'s to the specified <see cref="Graphics"/>
        /// device as a candlestick at each defined point.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="curve">A <see cref="JapaneseCandleStickItem"/> object representing the
        /// <see cref="JapaneseCandleStick"/>'s to be drawn.</param>
        /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent)
        /// axis for the <see cref="JapaneseCandleStick"/></param>
        /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent)
        /// axis for the <see cref="JapaneseCandleStick"/></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>
        public void Draw(
            Graphics g,
            GraphPane pane,
            JapaneseCandleStickItem curve,
            Axis baseAxis,
            Axis valueAxis,
            float scaleFactor)
        {
            //ValueHandler valueHandler = new ValueHandler( pane, false );

            if (curve.Points == null)
            {
                return;
            }
            //float halfSize = _size * scaleFactor;
            var halfSize = GetBarWidth(pane, baseAxis, scaleFactor);

            var tColor         = _color;
            var tFallingColor  = _fallingColor;
            var tPenWidth      = _width;
            var tRisingFill    = _risingFill;
            var tFallingFill   = _fallingFill;
            var tRisingBorder  = _risingBorder;
            var tFallingBorder = _fallingBorder;

            if (curve.IsSelected)
            {
                tColor         = Selection.Border.Color;
                tFallingColor  = Selection.Border.Color;
                tPenWidth      = Selection.Border.Width;
                tRisingFill    = Selection.Fill;
                tFallingFill   = Selection.Fill;
                tRisingBorder  = Selection.Border;
                tFallingBorder = Selection.Border;
            }

            using (var risingPen = new Pen(tColor, tPenWidth))
                using (var fallingPen = new Pen(tFallingColor, tPenWidth)) // Loop over each defined point
                    for (var i = 0; i < curve.Points.Count; i++)
                    {
                        var pt    = curve.Points[i];
                        var date  = pt.X;
                        var high  = pt.Y;
                        var low   = pt.Z;
                        var open  = PointPairBase.Missing;
                        var close = PointPairBase.Missing;
                        if (pt is StockPt)
                        {
                            open  = (pt as StockPt).Open;
                            close = (pt as StockPt).Close;
                        }

                        // Any value set to double max is invalid and should be skipped
                        // This is used for calculated values that are out of range, divide
                        //   by zero, etc.
                        // Also, any value <= zero on a log scale is invalid

                        if (curve.Points[i].IsInvalid3D || (date <= 0 && baseAxis._scale.IsLog) ||
                            ((high <= 0 || low <= 0) && valueAxis._scale.IsLog))
                        {
                            continue;
                        }
                        float pixBase = (int)(baseAxis.Scale.Transform(curve.IsOverrideOrdinal, i, date) + 0.5);
                        //pixBase = baseAxis.Scale.Transform( curve.IsOverrideOrdinal, i, date );
                        var pixHigh = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, high);
                        var pixLow  = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, low);
                        var pixOpen = PointPairBase.IsValueInvalid(open) ? Single.MaxValue : valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, open);

                        var pixClose = PointPairBase.IsValueInvalid(close) ? Single.MaxValue : valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, close);

                        if (!curve.IsSelected && _gradientFill.IsGradientValueType)
                        {
                            using (var tPen = GetPen(pane, scaleFactor, pt))
                                Draw(
                                    g,
                                    pane,
                                    baseAxis is XAxis || baseAxis is X2Axis,
                                    pixBase,
                                    pixHigh,
                                    pixLow,
                                    pixOpen,
                                    pixClose,
                                    halfSize,
                                    scaleFactor,
                                    (tPen),
                                    (close > open ? tRisingFill : tFallingFill),
                                    (close > open ? tRisingBorder : tFallingBorder),
                                    pt);
                        }
                        else
                        {
                            Draw(
                                g,
                                pane,
                                baseAxis is XAxis || baseAxis is X2Axis,
                                pixBase,
                                pixHigh,
                                pixLow,
                                pixOpen,
                                pixClose,
                                halfSize,
                                scaleFactor,
                                (close > open ? risingPen : fallingPen),
                                (close > open ? tRisingFill : tFallingFill),
                                (close > open ? tRisingBorder : tFallingBorder),
                                pt);
                        }
                    }
        }
Exemple #5
0
        /// <summary>
        /// Draw all the <see cref="OHLCBar"/>'s to the specified <see cref="Graphics"/>
        /// device as a candlestick at each defined point.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="curve">A <see cref="OHLCBarItem"/> object representing the
        /// <see cref="OHLCBar"/>'s to be drawn.</param>
        /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent)
        /// axis for the <see cref="OHLCBar"/></param>
        /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent)
        /// axis for the <see cref="OHLCBar"/></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>
        public virtual void Draw(Graphics g, GraphPane pane, OHLCBarItem curve,
                                 Axis baseAxis, Axis valueAxis, float scaleFactor)
        {
            //ValueHandler valueHandler = new ValueHandler( pane, false );

            if (curve.Points == null)
            {
                return;
            }

            //float halfSize = _size * scaleFactor;
            var halfSize    = GetBarWidth(pane, baseAxis, scaleFactor);
            var dotHalfSize = Math.Max(curve.DotHalfSize, IsAutoSize ? Math.Max(2, halfSize / 4) : curve.DotHalfSize)
                              * scaleFactor;

            using (var pen = curve.IsSelected
                         ? new Pen(Selection.Border.Color, Selection.Border.Width)
                         : new Pen(Color, Width))
                using (var fallingPen = curve.IsSelected
                         ? new Pen(Selection.Border.Color, Selection.Border.Width)
                         : new Pen(FallingColor, Width))
                {
                    // Loop over each defined point
                    for (int i = 0; i < curve.Points.Count; i++)
                    {
                        var    pt = curve.Points[i];
                        double date;
                        double open;
                        double high;
                        double low;
                        double close;
                        GetOHLC(pt, out date, out open, out high, out low, out close);

                        // Any value set to double max is invalid and should be skipped
                        // This is used for calculated values that are out of range, divide
                        //   by zero, etc.
                        // Also, any value <= zero on a log scale is invalid

                        if (curve.Points[i].IsInvalid || (!(date > 0) && baseAxis.Scale.IsLog) ||
                            ((!(high > 0) || !(low > 0)) && valueAxis.Scale.IsLog))
                        {
                            continue;
                        }

                        var pixBase =
                            (int)(baseAxis.Scale.Transform(curve.IsOverrideOrdinal, i, date) + 0.5);
                        //pixBase = baseAxis.Scale.Transform( curve.IsOverrideOrdinal, i, date );
                        var pixHigh = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, high);
                        var pixLow  = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, low);
                        var pixOpen = PointPairBase.IsValueInvalid(open)
                          ? float.MaxValue
                          : valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, open);

                        var pixClose = PointPair.IsValueInvalid(close)
                          ? float.MaxValue
                          : valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, close);

                        var rising = close > open;

                        if (pixBase == PointPair.Missing)
                        {
                            continue;
                        }

                        BeforeDraw(g, pane, valueAxis, curve, pt, pixBase, pixHigh, pixLow, halfSize);

                        var gradient = !curve.IsSelected && this.GradientFill.IsGradientValueType;

                        if (gradient)
                        {
                            using (var tPen = GetPen(pane, scaleFactor, pt))
                                Draw(g, pane, baseAxis is IXAxis,
                                     pixBase, pixHigh, pixLow, pixOpen,
                                     pixClose, halfSize, tPen, dotHalfSize);
                        }
                        else
                        {
                            Draw(g, pane, baseAxis is IXAxis,
                                 pixBase, pixHigh, pixLow, pixOpen,
                                 pixClose, halfSize, rising ? pen : fallingPen, dotHalfSize);
                        }
                    }
                }
        }
Exemple #6
0
 /// <summary>
 /// The PointPairBase copy constructor.
 /// </summary>
 /// <param name="rhs">The basis for the copy.</param>
 public PointPairBase(PointPairBase rhs)
 {
     X = rhs.X;
     Y = rhs.Y;
 }