Esempio n. 1
0
        internal void PaintCandle()
        {
            ChartPanel  chartPanel = _series._chartPanel;
            StockChartX chartX     = chartPanel._chartX;

            double x = chartX.GetXPixel(_index);

            Rect   rc;
            double y1;
            double y2;

            if (_rectCandle.Tag == null)
            {
                _rectCandle.Tag = _series;
            }
            if (_open > _close) //down
            {
                y1 = _series.GetY(_open);
                y2 = _series.GetY(_close);
                if (y1 + 3 > y2)
                {
                    y2 += 2;
                }
                rc = new Rect(x - _space - _halfwick, y1, 2 * (_space + _halfwick), y2 - y1);
                if (_brushMustBeChanged)
                {
                    _rectCandle.Fill    = chartX.GetBarBrush(_series.FullName, _index + chartX._startIndex, _down);
                    _brushMustBeChanged = false;
                }
                if (_candleDownOutline == null)
                {
                    _rectCandle.StrokeThickness = 0;
                }
                else
                {
                    _rectCandle.StrokeThickness = 1;
                    _rectCandle.Stroke          = _candleDownOutline;
                }

                //        Canvas.SetLeft(_rectCandle, rc.Left);
                //        Canvas.SetTop(_rectCandle, rc.Top);
            }
            else if (_open < _close) //up
            {
                y1 = _series.GetY(_close);
                y2 = _series.GetY(_open);
                if (y1 + 3 > y2)
                {
                    y2 += 2;
                }
                rc = new Rect(x - _space - _halfwick, y1, 2 * (_space + _halfwick), y2 - y1);
                if (_brushMustBeChanged)
                {
                    _rectCandle.Fill    = chartX.GetBarBrush(_series.FullName, _index + chartX._startIndex, _up);
                    _brushMustBeChanged = false;
                }
                if (_candleUpOutline == null)
                {
                    _rectCandle.StrokeThickness = 0;
                }
                else
                {
                    _rectCandle.StrokeThickness = 1;
                    _rectCandle.Stroke          = _candleUpOutline;
                }
                //        Canvas.SetLeft(_rectCandle, rc.Left);
                //        Canvas.SetTop(_rectCandle, rc.Top);
                //        _rectCandle.Width = rc.Width;
                //        _rectCandle.Height = rc.Height;
            }
            else //No change, flat bar
            {
                y1 = _series.GetY(_close);
                y2 = _series.GetY(_open);
                if (y2 == y1)
                {
                    y1 = y2 - 1;
                }
                rc = new Rect(x - _space - _halfwick, y1, 2 * (_space + _halfwick), y2 - y1);
                if (_brushMustBeChanged)
                {
                    _rectCandle.Fill    = chartX.GetBarBrush(_series.FullName, _index + chartX._startIndex, _down);
                    _brushMustBeChanged = false;
                }
                _rectCandle.StrokeThickness = 0;
                //        Canvas.SetLeft(_rectCandle, rc.Left);
                //        Canvas.SetTop(_rectCandle, rc.Top);
                //        _rectCandle.Width = rc.Width;
                //        _rectCandle.Height = rc.Height;
            }

            _rcTransform.X = rc.Left;
            _rcTransform.Y = rc.Top;
            if (_rectCandle.Width != rc.Width)
            {
                _rectCandle.Width = rc.Width;
            }
            if (_rectCandle.Height != rc.Height)
            {
                _rectCandle.Height = rc.Height;
            }
        }
Esempio n. 2
0
        internal void PaintCandle()
        {
            ChartPanel  chartPanel = _series._chartPanel;
            StockChartX chartX     = chartPanel._chartX;

            double x = chartX.GetXPixel(_index);

            Rect   rc;
            double y1;
            double y2;

            CalculateXValues();

            _rectCandle.Tag = _series;
            if (_xOpen > _xClose)
            {
                y1 = _series.GetY(_xOpen);
                y2 = _series.GetY(_xClose);
                if (y1 + 3 > y2)
                {
                    y2 += 2;
                }
                rc = new Rect(x - _space - _halfwick, y1, 2 * (_space + _halfwick), y2 - y1);
                _rectCandle.Fill = chartX.GetBarBrush(_index + chartX._startIndex, _down);
                if (_candleDownOutline == null)
                {
                    _rectCandle.StrokeThickness = 0;
                }
                else
                {
                    _rectCandle.StrokeThickness = 1;
                    _rectCandle.Stroke          = _candleDownOutline;
                }

                Canvas.SetLeft(_rectCandle, rc.Left);
                Canvas.SetTop(_rectCandle, rc.Top);
                _rectCandle.Width  = rc.Width;
                _rectCandle.Height = rc.Height;
            }
            else if (_xOpen < _xClose)
            {
                y1 = _series.GetY(_xClose);
                y2 = _series.GetY(_xOpen);
                if (y1 + 3 > y2)
                {
                    y2 += 2;
                }
                rc = new Rect(x - _space - _halfwick, y1, 2 * (_space + _halfwick), y2 - y1);
                _rectCandle.Fill = chartX.GetBarBrush(_index + chartX._startIndex, _up);
                if (_candleUpOutline == null)
                {
                    _rectCandle.StrokeThickness = 0;
                }
                else
                {
                    _rectCandle.StrokeThickness = 1;
                    _rectCandle.Stroke          = _candleUpOutline;
                }
                Canvas.SetLeft(_rectCandle, rc.Left);
                Canvas.SetTop(_rectCandle, rc.Top);
                _rectCandle.Width  = rc.Width;
                _rectCandle.Height = rc.Height;
            }
            else
            {
                y1 = _series.GetY(_xClose);
                y2 = _series.GetY(_xOpen);
                if (y2 == y1)
                {
                    y1 = y2 - 1;
                }
                rc = new Rect(x - _space - _halfwick, y1, 2 * (_space + _halfwick), y2 - y1);
                _rectCandle.Fill            = chartX.GetBarBrush(_index + chartX._startIndex, _down);
                _rectCandle.StrokeThickness = 0;
                Canvas.SetLeft(_rectCandle, rc.Left);
                Canvas.SetTop(_rectCandle, rc.Top);
                _rectCandle.Width  = rc.Width;
                _rectCandle.Height = rc.Height;
            }
        }