public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     base.Draw(g, worldRect, canvasRect);
     var pen = new Pen(UpLineColor, LineWidth);
     var path = new GraphicsPath();
     pen.DashStyle = (DashStyle)Enum.Parse(typeof(DashStyle), LineStyle.ToString());
     using (pen)
     {
         using (path)
         {
             for (int i = 1; i < Data.Count; i++)
             {
                 GetPriceByField(i);
                 var tf =
                     (PointF)
                     Conversion.WorldToScreen(
                         new PointD(i - 1, GetPriceByField(i - 1)), worldRect,
                         canvasRect);
                 var tf2 =
                     (PointF)
                     Conversion.WorldToScreen(new PointD(i, GetPriceByField(i)), worldRect,
                                              canvasRect);
                 path.AddLine(tf, tf2);
             }
             g.DrawPath(pen, path);
         }
     }
 }
        public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
        {
            var size = SizeD.Round(Conversion.WorldToScreen(
                new SizeD(barWidth / 100.0, 0.0), worldRect, canvasRect));
            var barWd = Math.Max(size.Width, 2);

            var left = worldRect.Left <= 0 ? 0 : (int)worldRect.Left;
            var right = worldRect.Right >= data.Count ? data.Count - 1 : (int)worldRect.Right;
            if (right <= left) return;

            for (var i = left; i <= right; i++)
            //foreach (var bar in data)
            {
                var bar = data[i];
                Point pointTop =
                    Conversion.WorldToScreen(
                        new PointD(bar.index - 0.45, bar.y),
                        worldRect,
                        canvasRect).Round();
                Point pointBottom =
                    Conversion.WorldToScreen(
                                        new PointD(bar.index - 0.45, 0),
                                        worldRect,
                                        canvasRect).Round();
                using (var brush = new SolidBrush(bar.color))
                {
                    var low = Math.Min(pointTop.Y, pointBottom.Y);
                    var height = Math.Abs(pointTop.Y - pointBottom.Y);

                    g.FillRectangle(brush, pointTop.X - (barWd / 2), low,
                                barWd, height);
                }
            }
        }
 public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     base.Draw(g, worldRect, canvasRect);
     var pen = new Pen(UpLineColor, LineWidth);
     var pen2 = new Pen(DownLineColor, LineWidth);
     pen.Alignment = PenAlignment.Center;
     pen2.Alignment = PenAlignment.Center;
     using (pen)
     {
         using (pen2)
         {
             for (int i = 0; i < Data.Count; i++)
             {
                 Pen pen3 = Data[i].open <= Data[i].close ? pen : pen2;
                 double xValue = i;
                 Point point3 =
                     Conversion.WorldToScreen(new PointD(xValue, (double)Data[i].low), worldRect,
                                                           canvasRect).Round();
                 Point point4 =
                     Conversion.WorldToScreen(new PointD(xValue, (double)Data[i].high), worldRect,
                                                           canvasRect).Round();
                 Point point =
                     Conversion.WorldToScreen(new PointD(xValue - _tickWidth, (double)Data[i].open), worldRect,
                                                           canvasRect).Round();
                 Point point2 =
                     Conversion.WorldToScreen(new PointD(xValue + _tickWidth, (double)Data[i].close),
                                                           worldRect, canvasRect).Round();
                 g.DrawLine(pen3, point3.X, point4.Y, point3.X, point3.Y);
                 g.DrawLine(pen3, point.X, point.Y, point3.X, point.Y);
                 g.DrawLine(pen3, point3.X, point2.Y, point2.X, point2.Y);
             }
         }
     }
 }
Exemple #4
0
 internal static double GetSpanLenInScreenCoords(PointD worldPtA, PointD worldPtB,
     RectangleD worldRect, RectangleD canvasRect)
 {
     var scrA = WorldToScreen(new PointD(worldPtA.X, worldPtA.Y), worldRect, canvasRect);
     var scrB = WorldToScreen(new PointD(worldPtB.X, worldPtB.Y), worldRect, canvasRect);
     return Math.Sqrt((scrA.X - scrB.X) * (scrA.X - scrB.X) +
                           (scrA.Y - scrB.Y) * (scrA.Y - scrB.Y));
 }
        private void TrendLineTypeDialogLoad(object sender, EventArgs e)
        {
            // заполнить список линий
            var w = imageListLarge.ImageSize.Width;
            var h = imageListLarge.ImageSize.Height;
            var rectWorld = new RectangleD(0, 0, w, h);
            var rectCanvas = new Rectangle(0, 0, w, h);

            var colors = new [] {Color.BlanchedAlmond, Color.GreenYellow, Color.PaleTurquoise};
            var colorIndex = 0;

            foreach (TrendLine.TrendLineStyle lineType in Enum.GetValues(typeof(TrendLine.TrendLineStyle)))
            {
                var bmp = new Bitmap(w, h);
                var line = new TrendLine();
                line.AddPoint(h * 0.23, w - 5);
                line.AddPoint(h * 0.77, 5);
                if (lineType == TrendLine.TrendLineStyle.Отрезок
                    || lineType == TrendLine.TrendLineStyle.Окружность || lineType == TrendLine.TrendLineStyle.ЛинияСМаркерами
                    || lineType == TrendLine.TrendLineStyle.ОтрезокСМаркерами)
                {
                    line.linePoints[1] = new PointD(h * 0.32, w - 16);
                    line.linePoints[0] = new PointD(h * 0.68, 16);
                }

                line.LineColor = Color.Black;
                line.ShapeFillColor = colors[colorIndex];
                line.LineStyle = lineType;
                colorIndex++;
                if (colorIndex == colors.Length)
                    colorIndex = 0;

                using (var gr = Graphics.FromImage(bmp))
                using (var brushes = new BrushesStorage())
                using (var pens = new PenStorage())
                {
                    gr.SmoothingMode = SmoothingMode.AntiAlias;
                    line.Draw(gr, rectWorld, rectCanvas, pens, brushes);
                }

                imageListLarge.Images.Add(bmp);
                var item = listView.Items.Add(lineType.ToString(),
                                              EnumFriendlyName<TrendLine.TrendLineStyle>.GetString(lineType),
                                              imageListLarge.Images.Count - 1);
                item.Tag = lineType;
                if (lineType == selectedStyle)
                    item.Selected = true;
            }

            // привязать картинки к списку
            listView.LargeImageList = imageListLarge;
            listView.SmallImageList = imageListLarge;
        }
Exemple #6
0
 internal static SizeD ScreenToWorld(SizeD screenSize, RectangleD worldRect, RectangleD screenRect)
 {
     if ((Math.Abs(screenRect.Width) > double.Epsilon) && (Math.Abs(screenRect.Height) > double.Epsilon))
     {
         var ed = new SizeD(0.0, 0.0)
                      {
                          Width = ((screenSize.Width/screenRect.Width)*worldRect.Width),
                          Height = ((screenSize.Height/screenRect.Height)*worldRect.Height)
                      };
         return ed;
     }
     return SizeD.Empty;
 }
 public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     if (data.Count == 0) return;
     base.Draw(g, worldRect, canvasRect);
     using (var pens = new PenStorage())
     using (var brushes = new BrushesStorage())
     {
         foreach (var span in data)
         {
             span.Draw(g, pens, brushes, worldRect, canvasRect, Chart.Font);
         }
     }
 }
        private void AddPoligon(Graphics g, RectangleD worldRect, Rectangle canvasRect, List<PointD> currentPoligonPointBotton,
                                       List<PointD> currentPoligonPointTop, bool currentSenkouMode)
        {
            currentPoligonPointBotton.Reverse();
            currentPoligonPointTop.AddRange(currentPoligonPointBotton);
            var pountsF = currentPoligonPointTop.Select(x => Conversion.WorldToScreen(x, worldRect, canvasRect).ToPointF()).ToArray();

            if (pountsF.Length > 0)
            {
                var brush = currentSenkouMode
                                ? new SolidBrush(Color.FromArgb(RegionAlpha, colorCloudA))
                                : new SolidBrush(Color.FromArgb(RegionAlpha, colorCloudB));
                g.FillPolygon(brush, pountsF);
            }
        }
Exemple #9
0
 internal static PointD ScreenToWorld(PointD screenPt, RectangleD worldRect, RectangleD screenRect)
 {
     if ((Math.Abs(screenRect.Width) > double.Epsilon) && (Math.Abs(screenRect.Height) > double.Epsilon))
     {
         var td = new PointD(0.0, 0.0)
                      {
                          X =
                              ((((screenPt.X - screenRect.Left)/screenRect.Width)*worldRect.Width) +
                               worldRect.Left),
                          Y =
                              ((((screenRect.Height - (screenPt.Y - screenRect.Top))/screenRect.Height)*
                                worldRect.Height) +
                               worldRect.Top)
                      };
         return td;
     }
     return PointD.Empty;
 }
        public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
        {
            base.Draw(g, worldRect, canvasRect);

            var left = worldRect.Left <= 0 ? 0 : (int) worldRect.Left;
            var right = worldRect.Right >= Data.Count ? Data.Count - 1 : (int)worldRect.Right;
            if (right <= left) return;

            using (var quotePen = new Pen(Color.Gray, 1))
                DrawLastQuote(g, worldRect, canvasRect, quotePen);

            if (BarDrawMode == CandleDrawMode.Candle)
                DrawCandles(g, worldRect, canvasRect, left, right);
            else
                if (BarDrawMode == CandleDrawMode.Bar)
                    DrawBars(g, worldRect, canvasRect, left, right);
                else
                    DrawLines(g, worldRect, canvasRect, left, right);
        }
Exemple #11
0
        /// <summary>
        /// Рисуем кораблики средних цены покупки и продажи
        /// </summary>
        private void DrawAverageOrderShip(
            StringFormat format,
            Rectangle axisRect,
            RectangleD worldRect,
            Rectangle canvasRect,
            Graphics g)
        {
            if (Orders == null)
            {
                return;
            }

            var openedOrders = Orders.Where(x => x.IsOpened && x.Symbol == Chart.Symbol);
            var priceFont    = new Font(Font.Name, Font.Size, Font.Style, Font.Unit);

            for (int i = 0; i < 2; i++)
            {
                var prices = openedOrders.Where(x => i == 0 ? x.Side == 1 : x.Side == -1).Select(x => x.PriceEnter).ToArray();
                if (prices.Length == 0)
                {
                    continue;
                }

                var averagePrice = prices.Average();
                var tf           = (PointF)Conversion.WorldToScreen(new PointD(0.0, averagePrice), worldRect, canvasRect);

                var rectOrder =
                    new Rectangle(
                        axisRect.Left + 5,
                        ((int)tf.Y) - (priceFont.Height / 2),
                        axisRect.Width - (int)priceFont.SizeInPoints,
                        priceFont.Height);

                g.FillRectangle(new SolidBrush(i == 0 ? Color.YellowGreen : Color.IndianRed), rectOrder);
                g.DrawRectangle(new Pen(Color.Black), rectOrder);
                g.DrawString(averagePrice.ToString(), priceFont, new SolidBrush(Color.Black), rectOrder, format);
            }
        }
Exemple #12
0
        internal static PointD WorldToScreen(PointD worldPt, RectangleD worldRect, RectangleD screenRect)
        {
            if ((Math.Abs(worldRect.Width) <= double.Epsilon) || (Math.Abs(worldRect.Height) <= double.Epsilon))
                return worldPt;

            if (double.IsNegativeInfinity(worldPt.Y)) worldPt.Y = worldRect.Bottom - 1;
            else if (double.IsInfinity(worldPt.Y)) worldPt.Y = worldRect.Top + 1;

            var td = new PointD
                         {
                             X = ((((worldPt.X - worldRect.Left)/worldRect.Width)*screenRect.Width) + screenRect.Left),
                             Y =
                                 ((screenRect.Height -
                                   (((worldPt.Y - worldRect.Top)/worldRect.Height)*screenRect.Height)) +
                                  screenRect.Top)
                         };
            const double maxDimx = 1048576.0;
            if (td.X > maxDimx) td.X = maxDimx;
            if (td.X < -maxDimx) td.X = -maxDimx;
            if (td.Y > maxDimx) td.Y = maxDimx;
            if (td.Y < -maxDimx) td.Y = -maxDimx;
            return td;
        }
        private void DrawPolygons(Graphics g, RectangleD worldRect, Rectangle canvasRect)
        {
            if (worldRect.Width < 2) return;

            var start = (int)worldRect.X < 0 ? 0 : (int)worldRect.X;
            var end = (int)(worldRect.Right + 0.5);

            if (end >= data.Count) end = data.Count;
            if (start >= end) return;

            var currentPoligonPointTop = new List<PointD>();
            var currentPoligonPointBotton = new List<PointD>();
            var senkouMode = data[start].yA > data[start].yB;

            for (var i = 0; i < data.Count; i++)
            {
                if (data[i].x < worldRect.Left) continue;
                if (data[i].x > worldRect.Right) break;

                var currentSenkouMode = data[i].yA > data[i].yB;

                if (senkouMode != currentSenkouMode)
                {
                    // "Собираем" предыдущий полигон
                    AddPoligon(g, worldRect, canvasRect, currentPoligonPointBotton, currentPoligonPointTop, senkouMode);

                    // Начинаем собирать точки нового полигона
                    currentPoligonPointTop = new List<PointD>();
                    currentPoligonPointBotton = new List<PointD>();

                    senkouMode = currentSenkouMode;
                }
                currentPoligonPointTop.Add(new PointD(data[i].x, data[i].yA));
                currentPoligonPointBotton.Add(new PointD(data[i].x, data[i].yB));
            }
            AddPoligon(g, worldRect, canvasRect, currentPoligonPointBotton, currentPoligonPointTop, senkouMode);
        }
Exemple #14
0
        /// <summary>
        /// Расчёт и прорисовка текущей цены в рамке справа
        /// </summary>
        private void DrawSelectedPriceLabel(
            double labelPrice,
            Brush brush,
            StringFormat format, Rectangle axisRect,
            RectangleD worldRect, Rectangle canvasRect, Graphics g)
        {
            var price     = labelPrice / LabelInfo.Exponent;
            var priceFont = new Font(Font.Name, Font.Size, Font.Style, Font.Unit);
            var height    = showExtraPriceMark ? priceFont.Height + 30 : priceFont.Height;
            var rect      = new Rectangle(
                axisRect.Left + 5,
                0,
                axisRect.Width - (int)priceFont.SizeInPoints,
                height);

            var tf = (PointF)Conversion.WorldToScreen(new PointD(0.0, price), worldRect, canvasRect);

            rect.Y = ((int)tf.Y) - (priceFont.Height / 2);
            if (axisRect.Contains(rect))
            {
                var pen       = new Pen(ForeColor);
                var fillbrush = new SolidBrush(BackColor);

                using (fillbrush)
                    g.FillRectangle(fillbrush, rect);
                using (pen)
                    g.DrawRectangle(pen, rect);

                var priceMarkContent = new StringBuilder();
                priceMarkContent.AppendLine(labelPrice.ToString(PriceFormat));

                ExtraPriceMarkText(priceMarkContent);

                g.DrawString(priceMarkContent.ToString(), priceFont, brush, rect, format);
            }
        }
 public bool IsIn(int x, int y, RectangleD worldRect, Rectangle canvasRect)
 {
     CalculateScreenCoords(worldRect, canvasRect);
     return(Math.Abs(centerScreen.X - x) <= Size2 &&
            Math.Abs(centerScreen.Y - y) <= Size2);
 }
 public void RecalculateModelCoords(RectangleD worldRect, Rectangle canvasRect)
 {
     centerModel = Conversion.ScreenToWorld(centerScreen, worldRect, canvasRect);
 }
 public void CalculateScreenCoords(RectangleD worldRect, Rectangle canvasRect)
 {
     centerScreen = Conversion.WorldToScreen(centerModel, worldRect, canvasRect);
 }
 public void DrawMarkers(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     using (var penStorage = new PenStorage())
     using (var brushStorage = new BrushesStorage())
     foreach (var marker in markers)
     {
         marker.CalculateScreenCoords(worldRect, canvasRect);
         marker.Draw(g, penStorage, brushStorage);
     }
 }
        public Image CreateSample(Size sizeHint)
        {
            if (points.Count < 2)
                return null;

            // готовим данные для миниатюры
            var rangeX = (int) Math.Round(points[1].X - points[0].X);
            if (rangeX < 1)
                rangeX = 1;
            var projections = new[]
                {
                    new FiboSpanProjection
                        {
                            AckDegree = 1,
                            Index = (int) (points[1].X + 0.5) + rangeX
                        },
                    new FiboSpanProjection
                        {
                            AckDegree = 2,
                            Index = (int) (points[1].X + 0.5) + rangeX * 2
                        },
                    new FiboSpanProjection
                        {
                            AckDegree = 3,
                            Index = (int) (points[1].X + 0.5) + rangeX * 3
                        }
                };

            // рисуем
            var minX = points.Select(p => p.X).Min();
            var minY = points.Select(p => p.Y).Min();
            var maxX = points.Select(p => p.X).Max();
            var maxY = points.Select(p => p.Y).Max();
            foreach (var projection in projections)
                if (projection.Index > maxX)
                    maxX = projection.Index;
            rangeX = (int)(maxX - minX);
            var rangeY = maxY - minY;
            minX-= rangeX / 10;
            maxX += rangeX / 10;
            minY -= rangeY / 10;
            maxY += rangeY / 10;
            var worldRect = new RectangleD(minX, minY, maxX - minX, maxY - minY);
            var brushStorage = new BrushesStorage();
            var brush = brushStorage.GetBrush(Color.White);
            var penStorage = new PenStorage();
            var canvasRect = new Rectangle(new Point(0, 0), sizeHint);
            var result = new Bitmap(sizeHint.Width, sizeHint.Height);
            var g = Graphics.FromImage(result);
            ownerSeries.DrawSpan(g, worldRect, canvasRect, this, brush, penStorage);
            foreach (var projection in projections)
            {
                ownerSeries.DrawProjection(g, worldRect, canvasRect, projection, brush,
                                           new Font(FontFamily.GenericSansSerif, 8), penStorage, brushStorage);
            }
            return result;
        }
Exemple #20
0
        /// <summary>
        /// Рисовать по отметке под каждый бар графика.
        /// Если метка налезает на предыдущую - пропустить
        /// </summary>
        private void DrawLabels(Graphics g)
        {
            if (!ShouldDrawChart())
            {
                return;
            }
            RectangleD worldRect       = Owner.WorldRect;
            Rectangle  canvasRect      = Owner.CanvasRect;
            int        rightTextMargin = -1;
            var        fmt             = new StringFormat {
                Alignment = StringAlignment.Center
            };

            using (var brush = new SolidBrush(TextColor))
            {
                using (var pen = new Pen(ForeColor))
                {
                    for (int i = StartIndex; i < LastIndex; i++)
                    {
                        int x         = i;
                        var labelTime = GetLabelDate(ref x, worldRect, canvasRect);
                        var dateStr   = labelTime.ToString("dd/MM:HH.mm");

                        int textW = (int)g.MeasureString(dateStr, Chart.Font).Width / 2 + 1;
                        if (rightTextMargin > 0)
                        {
                            int dx = x - rightTextMargin;
                            if (dx < textW)
                            {
                                continue;
                            }
                        }
                        rightTextMargin = x + textW;

                        g.DrawString(dateStr, Chart.Font, brush, x, 3, fmt);
                        g.DrawLine(pen, x, 0, x, 3);
                    }

                    // метка для перекрестия
                    if (SelectedLabelX.HasValue)
                    {
                        var x         = (int)(SelectedLabelX.Value + 0.5);
                        var labelTime = GetLabelDate(ref x, worldRect, canvasRect);
                        var dateStr   = labelTime.ToString("dd.MM.yyyy HH:mm");

                        // нарисовать обводку
                        var sz   = g.MeasureString(dateStr, Chart.Font);
                        var rect = new Rectangle(x - (int)(sz.Width / 2),
                                                 3 /* - (int) (sz.Height/2)*/,
                                                 (int)sz.Width, (int)sz.Height);
                        rect.Inflate(4, 2);
                        using (var br = new SolidBrush(BackColor))
                            g.FillRectangle(br, rect);
                        g.DrawRectangle(pen, rect);

                        // написать текст
                        g.DrawString(dateStr, Chart.Font, brush, x, 3, fmt);
                        g.DrawLine(pen, x, 0, x, 3);
                    }
                }
            }
        }
Exemple #21
0
 public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     base.Draw(g, worldRect, canvasRect);
     DrawParts(g, worldRect, canvasRect);
 }
Exemple #22
0
 internal static SizeD WorldToScreen(SizeD worldSize, RectangleD worldRect, RectangleD screenRect)
 {
     if ((Math.Abs(worldRect.Width) > double.Epsilon) && (Math.Abs(worldRect.Height) > double.Epsilon))
     {
         var ed = new SizeD(0.0, 0.0)
                      {
                          Width = ((worldSize.Width/worldRect.Width)*screenRect.Width),
                          Height = ((worldSize.Height/worldRect.Height)*screenRect.Height)
                      };
         return ed;
     }
     return worldSize;
 }
Exemple #23
0
        private void DrawLabels(Graphics g)
        {
            RectangleD worldRect  = Owner.WorldRect;
            Rectangle  canvasRect = Owner.CanvasRect;
            var        brush      = new SolidBrush(TextColor);
            var        brush2     = new SolidBrush(BackColor);
            var        pen        = new Pen(ForeColor);

            using (brush)
            {
                using (brush2)
                {
                    using (pen)
                    {
                        Point point;
                        SizeF ef;
                        foreach (XAxisMajorLabel label in MajorLabels)
                        {
                            point =
                                PointD.Round(Conversion.WorldToScreen(new PointD(label.X, 0.0), worldRect, canvasRect));
                            ef = g.MeasureString(label.Label, Font);
                            if (label.Label != string.Empty)
                            {
                                g.FillRectangle(brush2, (point.X + 2), ((Font.Height + 6) + 1), ef.Width,
                                                (Font.Height + 6));
                            }
                            if (label.FullTick)
                            {
                                g.DrawLine(pen, point.X, 0, point.X, AxisRect.Height - 1);
                            }
                            else
                            {
                                g.DrawLine(pen, point.X, Font.Height + 6, point.X, AxisRect.Height - 1);
                            }
                            if (label.Label != string.Empty)
                            {
                                g.DrawString(label.Label, Font, brush, (point.X + 2), (Font.Height + 9));
                            }
                        }
                        foreach (XAxisMinorLabel label2 in MinorLabels)
                        {
                            point =
                                PointD.Round(Conversion.WorldToScreen(new PointD(label2.X, 0.0), worldRect, canvasRect));
                            ef = g.MeasureString(label2.Label, Font);
                            if (label2.Label != string.Empty)
                            {
                                g.FillRectangle(brush2, (point.X + 2), 0f, ef.Width, (Font.Height + 6));
                            }
                            if (label2.FullTick)
                            {
                                g.DrawLine(pen, point.X, 0, point.X, Font.Height + 6);
                            }
                            else
                            {
                                g.DrawLine(pen, point.X, 0, point.X, 2);
                            }
                            if (label2.Label != string.Empty)
                            {
                                g.DrawString(label2.Label, Font, brush, (point.X + 2), 3f);
                            }
                        }
                    }
                }
            }
        }
        public void DrawProjection(Graphics g, RectangleD worldRect, Rectangle canvasRect, FiboSpanProjection proj, 
            Brush brushWhite, Font font, PenStorage penStorage, BrushesStorage brushes)
        {
            // нижняя точка
            var projLow = Conversion.WorldToScreen(new PointD(proj.Index, 0), worldRect, canvasRect);
            projLow.Y = canvasRect.Bottom;
            // верхняя точка
            PointD projHigh = proj.UpperPrice.HasValue
                ? Conversion.WorldToScreen(new PointD(proj.Index, proj.UpperPrice.Value), worldRect, canvasRect)
                : new PointD(projLow.X, canvasRect.Top);

            var dashStyle = proj.AckDegree == 1 ? DashStyle.Dash : DashStyle.Solid;
            var pen = penStorage.GetPen(proj.Color, 1, dashStyle);

            g.DrawLine(pen, (float)projLow.X, (float)projLow.Y, (float)projHigh.X, (float)projHigh.Y);

            if (proj.AckDegree > 1)
            {// показать степень подтверждения
                const int textOffset = 37;
                const int textSize = 18, textSize2 = 9;
                g.FillEllipse(brushWhite, (float)projLow.X - textSize2, (float)projLow.Y - textOffset - textSize2,
                    textSize, textSize);
                g.DrawEllipse(pen, (float)projLow.X - textSize2, (float)projLow.Y - textOffset - textSize2,
                    textSize, textSize);
                var text = proj.AckDegree.ToString();
                var textSz = g.MeasureString(text, Chart.Font);
                var textLeft = (float) projLow.X - textSz.Width/2;
                var textTop = (float) projLow.Y - textSz.Height/2 - textOffset;

                var brush = brushes.GetBrush(proj.Color);
                g.DrawString(text, font, brush, textLeft, textTop);

                textTop += (textSize + 4);
                var timeStr = Chart.StockSeries.GetCandleOpenTimeByIndex(proj.Index).ToString("dd MMM HH:ss");
                textSz = g.MeasureString(timeStr, Chart.Font);
                textLeft = (float) projLow.X - textSz.Width/2;

                g.FillRectangle(brushWhite, textLeft - 2, textTop - 2, textSz.Width + 4, textSz.Height + 3);
                g.DrawRectangle(pen, textLeft - 2, textTop - 2, textSz.Width + 4, textSz.Height + 3);
                g.DrawString(timeStr, Chart.Font, brush, textLeft, textTop);
            }
        }
Exemple #25
0
 public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     base.Draw(g, worldRect, canvasRect);
     var pen = new Pen(ForeColor, LineWidth);
     var brush = new SolidBrush(BackColor);
     pen.Alignment = PenAlignment.Center;
     var pen2 = new Pen(Chart.StockSeries.UpLineColor, LineWidth);
     var pen3 = new Pen(Chart.StockSeries.DownLineColor, LineWidth);
     var brush2 = new SolidBrush(Chart.StockSeries.UpFillColor);
     var brush3 = new SolidBrush(Chart.StockSeries.DownFillColor);
     pen2.Alignment = PenAlignment.Center;
     pen3.Alignment = PenAlignment.Center;
     using (pen)
     {
         using (brush)
         {
             using (pen2)
             {
                 using (pen3)
                 {
                     using (brush2)
                     {
                         using (brush3)
                         {
                             Pen pen4;
                             double xValue;
                             PointF tf;
                             PointF tf2;
                             if (PercentBarWidth < float.Epsilon)
                             {
                                 for (int i = Data.StartIndex; i <= Data.LastIndex; i++)
                                 {
                                     xValue = i;
                                     tf =
                                         (PointF)
                                         Conversion.WorldToScreen(new PointD(xValue, 0.0), worldRect, canvasRect);
                                     tf2 =
                                         (PointF)
                                         Conversion.WorldToScreen(new PointD(xValue, Data[i]), worldRect,
                                                                  canvasRect);
                                     if (UseUpDownColor)
                                     {
                                         if (((i >= Chart.StockSeries.Data.StartIndex) &&
                                              (i <= Chart.StockSeries.Data.LastIndex)) &&
                                             (Chart.StockSeries.Data[i].open <=
                                              Chart.StockSeries.Data[i].close))
                                         {
                                             pen4 = pen2;
                                         }
                                         else
                                         {
                                             pen4 = pen3;
                                         }
                                     }
                                     else
                                     {
                                         pen4 = pen;
                                     }
                                     g.DrawLine(pen4, tf, tf2);
                                 }
                             }
                             else
                             {
                                 for (int j = Data.StartIndex; j <= Data.LastIndex; j++)
                                 {
                                     SolidBrush brush4;
                                     xValue = j;
                                     double barLeftEdge = Chart.StockSeries.GetBarLeftEdge(j);
                                     double num5 = ((Chart.StockSeries.GetBarRightEdge(j) - barLeftEdge)*
                                                    PercentBarWidth)/200.0;
                                     tf =
                                         (PointF)
                                         Conversion.WorldToScreen(new PointD(xValue - num5, Data[j]), worldRect,
                                                                  canvasRect);
                                     tf2 =
                                         (PointF)
                                         Conversion.WorldToScreen(new PointD(xValue + num5, 0.0), worldRect,
                                                                  canvasRect);
                                     if (UseUpDownColor)
                                     {
                                         if (((j >= Chart.StockSeries.Data.StartIndex) &&
                                              (j <= Chart.StockSeries.Data.LastIndex)) &&
                                             (Chart.StockSeries.Data[j].open <=
                                              Chart.StockSeries.Data[j].close))
                                         {
                                             pen4 = pen2;
                                             brush4 = brush2;
                                         }
                                         else
                                         {
                                             pen4 = pen3;
                                             brush4 = brush3;
                                         }
                                     }
                                     else
                                     {
                                         pen4 = pen;
                                         brush4 = brush;
                                     }
                                     g.FillRectangle(brush4, tf.X, tf.Y, tf2.X - tf.X, tf2.Y - tf.Y);
                                     g.DrawRectangle(pen4, tf.X, tf.Y, tf2.X - tf.X, tf2.Y - tf.Y);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        private void DrawComments(Graphics g, RectangleD worldRect, Rectangle canvasRect)
        {
            List<Rectangle> areasDrawn = null;
            // контроль перекрывающихся комментов
            if (hideSpannedComments)
                areasDrawn = new List<Rectangle>();

            using (var fonts = new FontStorage(new Font(Chart.Font.FontFamily, fontSize,
                FontBold ? FontStyle.Bold : FontStyle.Regular)))
            using (var penStorage = new PenStorage())
            using (var brushStorage = new BrushesStorage())
            {

                for (var i = data.Count - 1; i >= 0; i--)
                {
                    data[i].DrawComment(g, fonts, worldRect, canvasRect, penStorage, brushStorage, areasDrawn);
                    if (!hideSpannedComments) continue;
                }
            }
        }
 private void DrawPairs(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     using (var brush = new SolidBrush(Color.White))
     using (var fnt = new Font(Chart.Font.FontFamily, fontSize))
     using (var penStorage = new PenStorage())
     {
         foreach (var pair in data)
         {
             pair.Draw(g, worldRect, canvasRect, brush, fnt, penStorage, DrawText);
         }
     }
 }
Exemple #28
0
 private void DrawParts(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     using (var linePen = new Pen(LineColor, LineThickness))
     {
         using (var markerPen = new Pen(LineColor, 1))
         {
             using (var markerBrush = new SolidBrush(Color.White))
             {
                 foreach (var chain in parts)
                 {
                     DrawRegion(chain, g, worldRect, canvasRect, linePen, markerPen, markerBrush);
                 }
             }
         }
     }
 }
Exemple #29
0
 private void DrawRegion(List<PartSeriesPoint> chain, Graphics g, 
     RectangleD worldRect, Rectangle canvasRect, 
     Pen linePen, Pen markerPen, Brush markerBrush)
 {
     var linePoints = new List<PointF>();
     for (var i = 0; i < chain.Count; i++)
     {
         var p = Conversion.WorldToScreen(
             new PointD(chain[i].index - 0.5, (double) chain[i].quote), worldRect, canvasRect);
         linePoints.Add(new PointF((float)p.X, (float)p.Y));
     }
     g.DrawLines(linePen, linePoints.ToArray());
     if (MarkerRadius > 0)
     {
         foreach (var point in linePoints)
         {
             var ellipseRect = new RectangleF(
                 point.X - MarkerRadius, point.Y - MarkerRadius,
                 MarkerRadius*2, MarkerRadius*2);
             g.FillEllipse(markerBrush, ellipseRect);
             g.DrawEllipse(markerPen, ellipseRect);
         }
     }
 }
 public int GetCandleCoordX(int index, RectangleD worldRect, Rectangle canvasRect)
 {
     return PointD.Round(Conversion.WorldToScreen(
         new PointD(index, 0), worldRect, canvasRect)).X;
 }
        private void DrawLines(Graphics g, RectangleD worldRect, Rectangle canvasRect,
            int left, int right)
        {
            var prev = Data[left].close;
            using (var penNeutral = new Pen(BarNeutralColor, BarLineWidth)
                                        {
                                            Alignment = PenAlignment.Center,
                                            DashCap = DashCap.Flat,
                                            StartCap = LineCap.Flat,
                                            EndCap = LineCap.Flat
                                        })
            {
                using (var quotePen = new Pen(Color.Gray, 1))
                    DrawLastQuote(g, worldRect, canvasRect, quotePen);
                for (var i = left + 1; i <= right; i++)
                {
                    var close = Data[i].close;
                    var ptB = PointD.Round(Conversion.WorldToScreen(new PointD(
                                   i, close), worldRect, canvasRect));
                    var ptA = PointD.Round(Conversion.WorldToScreen(new PointD(
                        i - 1, prev), worldRect, canvasRect));
                    prev = close;

                    DrawLine(g, penNeutral, ptA, ptB);
                }
            }
        }
        private void DrawCandles(Graphics g, RectangleD worldRect, Rectangle canvasRect,
            int left, int right)
        {
            var barWidth = (int)(Conversion.WorldToScreen(new SizeD(BarWidthPercent / 100.0, 0.0),
                                                 worldRect, canvasRect).Width);
            if (barWidth < 3) barWidth = 1;

            using (var brushStorage = new BrushesStorage())
            using (var brushUp = new SolidBrush(UpFillColor))
            using (var brushDown = new SolidBrush(DownFillColor))
            using (var penBarUp = new Pen(UpLineColor, BarLineWidth)
            {
                Alignment = PenAlignment.Center,
                DashCap = DashCap.Flat,
                StartCap = LineCap.Flat,
                EndCap = LineCap.Flat
            })
            using (var penBarDown = new Pen(DownLineColor, BarLineWidth)
            {
                Alignment = PenAlignment.Center,
                DashCap = DashCap.Flat,
                StartCap = LineCap.Flat,
                EndCap = LineCap.Flat
            })
            {
                for (var i = left; i <= right; i++)
                {
                    double close;
                    double open;
                    Brush brush;
                    var candle = Data[i];
                    var isGrowing = candle.close >= candle.open;

                    if (isGrowing)
                    {
                        close = candle.close;
                        open = candle.open;
                        brush = brushUp;
                    }
                    else
                    {
                        close = candle.open;
                        open = candle.close;
                        brush = brushDown;
                    }
                    double xValue = i;
                    if (candle.customColor.HasValue)
                        brush = brushStorage.GetBrush(candle.customColor.Value);

                    // рисовать отрезочек
                    if (barWidth == 1)
                    {
                        var pointA = PointD.Round(Conversion.WorldToScreen(
                                         new PointD(xValue, close), worldRect, canvasRect));

                        var pointB = PointD.Round(Conversion.WorldToScreen(
                                    new PointD(xValue, open), worldRect, canvasRect));

                        DrawLine(g, isGrowing ? penBarUp : penBarDown, pointA, pointB);
                        continue;
                    }

                    var point1 = PointD.Round(Conversion.WorldToScreen(
                                         new PointD(xValue - 0.45, close), worldRect, canvasRect));

                    var point2 = PointD.Round(Conversion.WorldToScreen(
                                new PointD(xValue + 0.45, open), worldRect, canvasRect));

                    var point3 = PointD.Round(Conversion.WorldToScreen(
                                new PointD(xValue, Data[i].low), worldRect, canvasRect));

                    var point4 = PointD.Round(Conversion.WorldToScreen(
                                new PointD(xValue, Data[i].high), worldRect, canvasRect));

                    // свеча...
                    DrawCandle(g, barWidth, close, open, isGrowing ? penBarUp : penBarDown,
                                       point3, point1, point4, point2, brush);
                }
            }
        }
Exemple #33
0
        public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
        {
            if (Hidden) return;
            base.Draw(g, worldRect, canvasRect);
            var pen = new Pen(LineColor ?? ForeColor, LineWidth);
            var brush = new SolidBrush(BackColor);
            var path = new GraphicsPath();
            var path2 = new GraphicsPath();
            pen.Alignment = PenAlignment.Center;
            if (LineDashStyle.HasValue)
                pen.DashStyle = LineDashStyle.Value;
            else
                pen.DashStyle = (DashStyle)Enum.Parse(typeof(DashStyle), LineStyle.ToString());
            if (pen.DashStyle == DashStyle.Custom)
                pen.DashPattern = dashPattern;

            var markerPen = new Pen(ColorMarker);

            // измерить расстояние между маркерами в пикселях
            var markerSpanPointsView = MarkerSpanPoints;
            if (MinPixelsBetweenMarkers > 0)
            {
                for (var i = 0; i < 10; i++)
                {
                    var sizeUnit = Conversion.WorldToScreen(new SizeD(markerSpanPointsView, 0), worldRect, canvasRect);
                    if (sizeUnit.Width >= MinPixelsBetweenMarkers) break;
                    markerSpanPointsView *= markerSpanPointsMultiplier;
                }
            }

            using (pen)
            {
                using (brush)
                {
                    using (path)
                    {
                        using (path2)
                        {
                            using (markerPen)
                            {
                                PointF tf;
                                PointF tf2;
                                if (Data.BarCount > 0)
                                {
                                    tf =
                                        (PointF)
                                        Conversion.WorldToScreen(
                                            new PointD(Data.StartIndex,
                                                       Data[Data.StartIndex]), worldRect, canvasRect);

                                    path2.AddLine(tf.X, canvasRect.Bottom, tf.X, tf.Y);
                                }
                                // разлиновать
                                if (Data.StartIndex < Data.LastIndex && markerSpanPointsView > 0)
                                {
                                    for (var i = Data.StartIndex; i <= Data.LastIndex; i += markerSpanPointsView)
                                    {
                                        var pointTop = (PointF) Conversion.WorldToScreen(
                                                                    new PointD(
                                                                        i + ShiftX,
                                                                        0),
                                                                    worldRect, canvasRect);
                                        pointTop.Y = canvasRect.Top;
                                        var pointBottom = new PointF(pointTop.X, canvasRect.Bottom);
                                        g.DrawLine(markerPen, pointTop, pointBottom);
                                    }
                                }

                                // построить график
                                var startIndex = Math.Max(Data.StartIndex, (int)Chart.StockPane.WorldRect.Left);
                                var endIndex = Math.Min(Data.LastIndex, (int) Chart.StockPane.WorldRect.Right);

                                for (var i = startIndex + 1; i <= endIndex; i++)
                                {
                                    if (double.IsNaN(Data[i - 1]) || double.IsNaN(Data[i]))
                                    {
                                        g.DrawPath(pen, path);
                                        path.Reset();
                                        continue;
                                    }
                                    tf =
                                        (PointF)
                                        Conversion.WorldToScreen(
                                            new PointD((i - 1 - 1) + ShiftX,
                                                       Data[i - 1]),
                                            worldRect,
                                            canvasRect);
                                    tf2 =
                                        (PointF)
                                        Conversion.WorldToScreen(new PointD(i - 1 + ShiftX,
                                                                            Data[i]), worldRect, canvasRect);

                                    path2.AddLine(tf, tf2);
                                    path.AddLine(tf, tf2);
                                }
                                if (Data.BarCount > 0)
                                {
                                    if (Data[Data.LastIndex] != double.NaN)
                                    {
                                       tf2 =
                                            (PointF)
                                            Conversion.WorldToScreen(
                                                new PointD(Data.LastIndex,
                                                           Data[Data.LastIndex]), worldRect, canvasRect);
                                        path2.AddLine(tf2.X, tf2.Y, tf2.X, canvasRect.Bottom);
                                    }
                                }
                                try
                                {
                                    if (!Transparent)
                                        g.FillPath(brush, path2);
                                    if (DrawShadow)
                                        DrawShadowPath(path, g);
                                    g.DrawPath(pen, path);
                                }
                                catch
                                {
                                }
                            }
                        }
                    }
                }
            }
        }
        private void DrawBars(Graphics g, RectangleD worldRect, Rectangle canvasRect,
            int left, int right)
        {
            var barWidth = (int)(Conversion.WorldToScreen(new SizeD(BarWidthPercent / 100.0, 0.0),
                                                 worldRect, canvasRect).Width);
            if (barWidth < 3) barWidth = 1;

            using (var penNeutral = new Pen(BarNeutralColor, BarLineWidth)
                                        {
                                            Alignment = PenAlignment.Center,
                                            DashCap = DashCap.Flat,
                                            StartCap = LineCap.Flat,
                                            EndCap = LineCap.Flat
                                        })
            {
                using (var quotePen = new Pen(Color.Gray, 1))
                    DrawLastQuote(g, worldRect, canvasRect, quotePen);
                for (var i = left; i <= right; i++)
                {
                    double close;
                    double open;
                    var candle = Data[i];
                    var isGrowing = candle.close >= candle.open;

                    if (isGrowing)
                    {
                        close = candle.close;
                        open = candle.open;
                    }
                    else
                    {
                        close = candle.open;
                        open = candle.close;
                    }
                    double xValue = i;

                    var point1 = PointD.Round(Conversion.WorldToScreen(
                                         new PointD(xValue - 0.45, close), worldRect, canvasRect));

                    var point2 = PointD.Round(Conversion.WorldToScreen(
                                new PointD(xValue + 0.45, open), worldRect, canvasRect));

                    var point3 = PointD.Round(Conversion.WorldToScreen(
                                new PointD(xValue, Data[i].low), worldRect, canvasRect));

                    var point4 = PointD.Round(Conversion.WorldToScreen(
                                new PointD(xValue, Data[i].high), worldRect, canvasRect));

                    // бар...
                    DrawBar(g, barWidth, penNeutral, point1, point2, point3,
                                    point4, Data[i].close > Data[i].open);
                }
            }
        }
        public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
        {
            base.Draw(g, worldRect, canvasRect);

            using (var font = new Font(Chart.Font.FontFamily, fontSize))
            using (var penStorage = new PenStorage())
            using (var brushStorage = new BrushesStorage())
            {
                var brush = brushStorage.GetBrush(Color.White);

                foreach (var span in data)
                {
                    DrawSpan(g, worldRect, canvasRect, span, brush, penStorage);
                }

                foreach (var proj in projections)
                {
                    DrawProjection(g, worldRect, canvasRect, proj, brush, font,
                        penStorage, brushStorage);
                }
            }
        }
        public void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect,
            Brush brush, Font fnt, PenStorage penStorage, 
            bool doDrawText)
        {
            spansProjScreenCoords.Clear();
            rectanglesTextScreenCoords.Clear();

            var pen = penStorage.GetPen(Color, Selected ? 2f : 1f, DashStyle.Dot);
            var screenPoints = points.Select(point =>
                Conversion.WorldToScreen(new PointD(point.a, point.b), worldRect, canvasRect)).ToList();

            // сохранить координаты начального отрезка (для проверки попадания)
            if (screenPoints.Count > 1)
                spanBaseScreenCoords = new Cortege2<Point, Point>(screenPoints[0].ToPoint(), screenPoints[1].ToPoint());

            // соединить
            if (Completed && HideLine == false)
                g.DrawLine(pen, (float)screenPoints[0].X, (float)screenPoints[0].Y,
                            (float)screenPoints[1].X, (float)screenPoints[1].Y);
            // нарисовать кружки
            foreach (var point in screenPoints)
            {
                g.FillEllipse(brush, (float)point.X - 3, (float)point.Y - 3, 6, 6);
                g.DrawEllipse(pen, (float)point.X - 3, (float)point.Y - 3, 6, 6);
            }

            // нарисовать проекции
            if (points.Count < 2 || points[0].b == points[1].b || pricesProj == null) return;

            visibleParts = new List<ProjectionLinePart>();
            if (IsExtension)
            {
                foreach (var price in pricesProj)
                {
                    visibleParts.Add(new ProjectionLinePart(StartIndex,
                                                            EndIndex, price));
                }
            }
            if (IsCorrection)
            {
                foreach (var price in pricesCorr)
                {
                    visibleParts.Add(new ProjectionLinePart(StartIndex,
                                                            EndIndex, price));
                }
            }

            // скрыть "лишние" кусочки
            if (HideFarParts) DoHideFarParts(visibleParts);

            foreach (var part in visibleParts)
            {
                var ptScrLeft = Conversion.WorldToScreen(new PointD(part.left,
                                                                part.price), worldRect, canvasRect);
                var ptScrRight = Conversion.WorldToScreen(new PointD(part.right,
                                                                part.price), worldRect, canvasRect);
                part.x1 = (float)ptScrLeft.X;
                part.y1 = (float)ptScrLeft.Y;
                part.x2 = (float)ptScrRight.X;
                part.y2 = (float)ptScrRight.Y;
                g.DrawLine(pen, (float)ptScrLeft.X, (float)ptScrLeft.Y, (float)ptScrRight.X, (float)ptScrRight.Y);
                // сохранить координаты
                spansProjScreenCoords.Add(new Cortege2<Point, Point>(
                    new Point((int)ptScrLeft.X, (int)ptScrLeft.Y),
                    new Point((int)ptScrRight.X, (int)ptScrRight.Y)));
            }

            if (doDrawText)
            {
                using (var fontBrush = new SolidBrush(Color))
                {
                    var strFormat = new StringFormat { LineAlignment = StringAlignment.Center };
                    foreach (var part in visibleParts)
                    {
                        if (part.left == part.right) continue;
                        var priceStr = part.price.ToStringUniformPriceFormat(false);
                        var textSz = g.MeasureString(priceStr, fnt);
                        if (Markers == MarkerPlacement.Слева ||
                            Markers == MarkerPlacement.ДвеМетки)
                        {
                            g.DrawString(priceStr, fnt, fontBrush, part.x1 - textSz.Width - 2, part.y1, strFormat);
                            rectanglesTextScreenCoords.Add(new Rectangle((int)(part.x1 - textSz.Width - 2), (int)(part.y1 - textSz.Height / 2),
                                (int)textSz.Width, (int)textSz.Height));
                        }
                        if (Markers == MarkerPlacement.Справа ||
                            Markers == MarkerPlacement.ДвеМетки)
                        {
                            g.DrawString(priceStr, fnt, fontBrush, part.x2 + 2, part.y2, strFormat);
                            rectanglesTextScreenCoords.Add(new Rectangle((int)(part.x2 + 2), (int)(part.y2 - textSz.Height / 2),
                                (int)textSz.Width, (int)textSz.Height));
                        }
                    }
                }
            }
            if (Selected)
                DrawMarkers(g, worldRect, canvasRect);
        }
 public void DrawSpan(Graphics g, RectangleD worldRect, Rectangle canvasRect, 
     FiboSpan span, Brush brushWhite, PenStorage penStorage)
 {
     if (span.points.Count == 0) return;
     var pen = penStorage.GetPen(span.Color);
     var ptA = Conversion.WorldToScreen(new PointD(span.points[0].X, span.points[0].Y),
                                                         worldRect, canvasRect);
     if (span.points.Count == 2)
     {
         var ptB = Conversion.WorldToScreen(new PointD(span.points[1].X, span.points[1].Y),
                                                         worldRect, canvasRect);
         g.DrawLine(pen, ptA.ToPointF(), ptB.ToPointF());
         DrawMarker(g, pen, brushWhite, ptB);
     }
     DrawMarker(g, pen, brushWhite, ptA);
 }
Exemple #38
0
        private void DetermineLabelStrategy(Graphics g)
        {
            LabelStrategy.ShowDayLabel = true;
            int  num   = 0;
            int  num2  = 7;
            int  num3  = 0;
            int  num4  = 0x1f;
            int  num5  = 0;
            int  num6  = 270;
            bool flag  = false;
            bool flag2 = false;
            bool flag3 = false;

            foreach (XAxisLabelInfo info in Dates)
            {
                num++;
                num3++;
                num5++;
                if (info.StartWeek)
                {
                    if (flag)
                    {
                        num2 = (num < num2) ? num : num2;
                    }
                    flag = true;
                    num  = 0;
                }
                if (info.StartMonth)
                {
                    if (flag2)
                    {
                        num4 = (num3 < num4) ? num3 : num4;
                    }
                    flag2 = true;
                    num3  = 0;
                    if (!info.StartYear)
                    {
                        continue;
                    }
                    if (flag3)
                    {
                        num6 = (num5 < num6) ? num5 : num6;
                    }
                    flag3 = true;
                    num5  = 0;
                }
            }
            RectangleD worldRect  = Owner.WorldRect;
            Rectangle  canvasRect = Owner.CanvasRect;
            SizeF      ef         = g.MeasureString("00.", Font);
            SizeF      ef2        = g.MeasureString("00.", Font);
            SizeF      ef3        = g.MeasureString("September.", Font);
            SizeF      ef4        = g.MeasureString("Sep.", Font);
            SizeF      ef5        = g.MeasureString("S.", Font);
            SizeF      ef6        = g.MeasureString("2005.", Font);
            SizeD      ed2        = Conversion.WorldToScreen(new SizeD(StockSeries.MinimumXDelta, 0.0), worldRect,
                                                             canvasRect);

            LabelStrategy.ShowDayTick      = ed2.Width > 8.0;
            LabelStrategy.ShowWeekTick     = (ed2.Width * num2) > 8.0;
            LabelStrategy.ShowMonthTick    = (ed2.Width * num4) > 8.0;
            LabelStrategy.ShowQuarterTick  = ((ed2.Width * num4) * 3.0) > 8.0;
            LabelStrategy.ShowDayLabel     = ed2.Width > ef.Width;
            LabelStrategy.ShowWeekLabel    = (ed2.Width * num2) > ef2.Width;
            LabelStrategy.ShowMonthLabel   = (ed2.Width * num4) > ef5.Width;
            LabelStrategy.ShowQuarterLabel = ((ed2.Width * num4) * 3.0) > ef5.Width;
            LabelStrategy.Show1YearLabel   = (ed2.Width * num6) > ef6.Width;
            LabelStrategy.Show5YearLabel   = ((ed2.Width * num6) * 5.0) > ef6.Width;
            if (LabelStrategy.ShowMonthLabel)
            {
                LabelStrategy.ShowLongMonth  = (ed2.Width * num4) > ef3.Width;
                LabelStrategy.ShowShortMonth = ((ed2.Width * num4) > ef4.Width) && ((ed2.Width * num4) <= ef3.Width);
                LabelStrategy.ShowCharMonth  = ((ed2.Width * num4) > ef5.Width) && ((ed2.Width * num4) <= ef4.Width);
            }
            else
            {
                LabelStrategy.ShowLongMonth  = ((ed2.Width * num4) * 3.0) > ef3.Width;
                LabelStrategy.ShowShortMonth = (((ed2.Width * num4) * 3.0) > ef4.Width) &&
                                               (((ed2.Width * num4) * 3.0) <= ef3.Width);
                LabelStrategy.ShowCharMonth = (((ed2.Width * num4) * 3.0) > ef5.Width) &&
                                              (((ed2.Width * num4) * 3.0) <= ef4.Width);
            }
        }