Beispiel #1
0
        public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
        {
            base.Draw(g, worldRect, canvasRect);

            using (var penStorage = new PenStorage())
                using (var brushStorage = new BrushesStorage())
                    foreach (var marker in data)
                    {
                        var ptScreen = Conversion.WorldToScreen(new PointD(marker.candleIndex, marker.Price),
                                                                worldRect, canvasRect);
                        marker.Draw(g, ptScreen, Chart.Font);

                        if (marker.exitPair.HasValue)
                        {
                            var pairId = marker.exitPair;
                            var pair   = data.FirstOrDefault(m => m.id == pairId);
                            if (pair != null)
                            {
                                var ptPair = Conversion.WorldToScreen(new PointD(pair.candleIndex, pair.Price),
                                                                      worldRect, canvasRect);
                                // соединить две точки
                                var pen = penStorage.GetPen(Color.DarkSlateBlue, 1,
                                                            DashStyle.Dash);
                                g.DrawLine(pen, ptScreen.ToPointF(), ptPair.ToPointF());
                            }
                        }
                        if (marker.Selected)
                        {
                            marker.DrawMarker(g, worldRect, canvasRect, penStorage, brushStorage);
                        }
                    }
        }
Beispiel #2
0
        /// <summary>
        /// нарисовать заголовочек и контрол - содержимое
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            // заголовочек
            var rectHr = new Rectangle(0, 0, Width, HeaderHeight);

            e.Graphics.FillRectangle(SystemBrushes.ButtonFace, rectHr);
            e.Graphics.DrawLine(SystemPens.ButtonShadow, 0, HeaderHeight - 1, Width - 1, HeaderHeight - 1);
            e.Graphics.DrawLine(SystemPens.ButtonShadow, Width - 1, HeaderHeight - 1, Width - 1, 0);
            e.Graphics.DrawLine(SystemPens.ButtonHighlight, 0, 0, Width - 1, 0);
            e.Graphics.DrawLine(SystemPens.ButtonHighlight, 0, 0, 0, HeaderHeight - 1);

            // текст заголовка
            var textWidth = pictograms[0].area.Left - PaddingPictogram - PaddingText;

            if (textWidth > 0)
            {
                e.Graphics.DrawString(Title, fontTitle, SystemBrushes.ControlText, PaddingText, HeaderHeight / 2,
                                      new StringFormat {
                    LineAlignment = StringAlignment.Center
                });
            }

            // пиктограммы
            using (var pens = new PenStorage())
                foreach (var pict in pictograms)
                {
                    pict.Draw(e.Graphics, pens);
                }
        }
Beispiel #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            try
            {
                using (var brushes = new BrushesStorage())
                    using (var pens = new PenStorage())
                    {
                        // подготовить фон
                        DrawBackgr(e.Graphics, brushes);

                        // нарисовать разметку
                        DrawFrame(e.Graphics, brushes, pens);

                        // кнопка отмены
                        if (CancelEnabled)
                        {
                            e.Graphics.DrawImageUnscaled(imageCancel,
                                                         Width - imageCancel.Width - padding,
                                                         (Height - imageCancel.Height) / 2);
                        }

                        if (gaps == null)
                        {
                            return;
                        }
                        DrawGaps(e.Graphics, brushes);
                    }
            }
            catch (Exception ex)
            {
                Logger.Error("QuoteHistoryFillLineControl error", ex);
            }
        }
        public Image CreateSample(Size sizeHint)
        {
            if (sizeHint.IsEmpty)
            {
                return(null);
            }
            var result       = new Bitmap(sizeHint.Width, sizeHint.Height);
            var g            = Graphics.FromImage(result);
            var brushStorage = new BrushesStorage();
            var penStorage   = new PenStorage();
            var pen          = penStorage.GetPen(Color.FromArgb(Transparency, ColorLine));
            var brush        = brushStorage.GetBrush(Color.FromArgb(Transparency, ColorFill));
            var brushText    = brushStorage.GetBrush(Color.FromArgb(Transparency, ColorText));
            var ptCenter     = new PointD(sizeHint.Width / 2.0, sizeHint.Height / 2.0);

            DrawShape(g, brush, ptCenter, pen);
            // значок
            var strFormat = new StringFormat
            {
                LineAlignment = StringAlignment.Center,
                Alignment     = StringAlignment.Center
            };

            g.DrawString(Sign, new Font(FontFamily.GenericSansSerif, 8), brushText, (float)ptCenter.X,
                         (float)ptCenter.Y, strFormat);
            return(result);
        }
Beispiel #5
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            if (Board == null)
            {
                return;
            }

            // нарисовать поле
            ArrangeCells();

            // сглаживание
            var oldMode = e.Graphics.SmoothingMode;

            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            // ячейки
            using (var brushes = new BrushStorage())
                using (var pens = new PenStorage())
                {
                    for (var i = 0; i < Board.cells.Count(); i++)
                    {
                        DrawCell(i, e.Graphics, brushes, pens);
                    }

                    // стата
                    DrawSpielerStat(e.Graphics, brushes, pens);
                }

            e.Graphics.SmoothingMode = oldMode;
        }
        public void Draw(Font font, Graphics g, RectangleD worldRect, Rectangle canvasRect,
                         PenStorage penStorage, BrushesStorage brushStorage)
        {
            var strFormat = new StringFormat {
                LineAlignment = StringAlignment.Center,
                Alignment     = StringAlignment.Center
            };

            var pen       = penStorage.GetPen(Color.FromArgb(Transparency, ColorLine), Selected ? 3f : 1f);
            var brush     = brushStorage.GetBrush(Color.FromArgb(Transparency, ColorFill));
            var brushText = brushStorage.GetBrush(Color.FromArgb(Transparency, ColorText));

            var ptCenter = Conversion.WorldToScreen(new PointD(CandleIndex, Price),
                                                    worldRect, canvasRect);

            screenX = ptCenter.X;
            screenY = ptCenter.Y;

            DrawShape(g, brush, ptCenter, pen);

            // значок
            g.DrawString(Sign, font, brushText, (float)ptCenter.X, (float)ptCenter.Y, strFormat);

            // маркеры
            if (Selected)
            {
                foreach (var marker in markers)
                {
                    marker.CalculateScreenCoords(worldRect, canvasRect);
                    marker.Draw(g, penStorage, brushStorage);
                }
            }
        }
Beispiel #7
0
        private void DrawFrame(Graphics g, BrushesStorage brushes, PenStorage pens)
        {
            var brMain = brushes.GetBrush(SystemColors.ControlText);
            var cy     = Height / 2;

            // текст (название тикера)
            var fmt = new StringFormat {
                LineAlignment = StringAlignment.Center
            };

            g.DrawString(Ticker, font, brMain, padding, cy, fmt);

            // область истории
            var barRight = Width - padding - imageCancel.Width - padding;
            var barWd    = barRight - barLeft;

            if (barWd < 0)
            {
                barWd = 0;
            }

            barBounds = new Rectangle(barLeft, cy - barHeight / 2, barWd, barHeight);
            if (barWd == 0)
            {
                return;
            }

            // рамка
            g.DrawRectangle(pens.GetPen(SystemColors.ControlText), barBounds);
        }
Beispiel #8
0
 internal virtual void Draw(Graphics g)
 {
     try
     {
         using (var brushes = new BrushesStorage())
             using (var pens = new PenStorage())
             {
                 AdjustLayout();
                 DrawBackground(g, brushes);
                 DrawFrame(g);
                 GraphicsContainer container = g.BeginContainer();
                 g.TranslateTransform(ClientRect.X, ClientRect.Y);
                 DrawYAxis(g);
                 DrawStockSeries(g);
                 DrawSeries(g);
                 if (paneIconStrip != null)
                 {
                     paneIconStrip.Draw(g);
                 }
                 DrawCursorCross(g, brushes);
                 g.EndContainer(container);
                 // нарисовать иконки - кнопочки
                 DrawButtons(g, brushes, pens);
             }
     }
     catch (Exception ex)
     {
         Logger.Error("Pane.Draw()", ex);
         throw;
     }
 }
        public Image CreateSample(Size sizeHint)
        {
            var originalPoints = new List <PointF>(points);

            points.Clear();
            var centerx = sizeHint.Width / 2;
            var centery = sizeHint.Height / 2;
            var dx      = sizeHint.Width / 2;
            var dy      = sizeHint.Height / 2;
            var left    = centerx - dx;
            var top     = centery - dy;
            var width   = sizeHint.Width;
            var height  = sizeHint.Height;

            points.Add(new PointF(left, top));
            points.Add(new PointF(left + width, top + height));
            points.Add(new PointF(left + width / 2, top + height));
            var worldRect    = new RectangleD(left - 50, top - 50, width + 100, height + 100);
            var result       = new Bitmap(sizeHint.Width, sizeHint.Height);
            var brushStorage = new BrushesStorage();
            var penStorage   = new PenStorage();

            DrawEllipse(Graphics.FromImage(result), worldRect, new Rectangle(new Point(0, 0), sizeHint), brushStorage,
                        penStorage, new Font(FontFamily.GenericSansSerif, 8));
            points.Clear();
            points.AddRange(originalPoints);
            return(result);
        }
Beispiel #10
0
        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;
                            }
                        }
                    }
        }
Beispiel #11
0
        private void DrawRegion(Polyline chain, Graphics g,
                                RectangleD worldRect, Rectangle canvasRect,
                                PenStorage penStor, Pen markerPen, Brush markerBrush)
        {
            var linePoints = new List <PointF>();

            for (var i = 0; i < chain.parts.Count; i++)
            {
                var p = Conversion.WorldToScreen(
                    new PointD(chain.parts[i].index - 0.5, (double)chain.parts[i].quote), worldRect, canvasRect);
                linePoints.Add(new PointF((float)p.X, (float)p.Y));
            }

            var pen = penStor.GetPen(chain.color ?? lineColor);

            g.DrawLines(pen, 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);
                }
            }
        }
Beispiel #12
0
        private void DrawSpielerStat(Graphics g, BrushStorage brushes, PenStorage pens)
        {
            var top  = Height - StatusStripHeight + 3;
            var left = 20;

            var spieler = Board.spielers[Board.currentSpielerIndex];
            var text    = "Spieler: " + spieler.Name + ", carrots: " + spieler.CarrotsSpare + ", cabbages: " +
                          spieler.CabbageSpare;

            g.DrawString(text, cellFont, brushes.GetBrush(Color.Black), left, top);

            var textSize = g.MeasureString(text, cellFont);

            top += (int)textSize.Height + 3;

            // выбор маркера
            var tokens = Board.GetSpielerTokens();

            tokenSelectors = tokens.Select((t, i) =>
                                           new Point(left + i * (TokenSelectorSpan + TokenSelectorSz) + TokenSelectorSpan / 2, top + TokenSelectorSz / 2)).ToArray();

            for (var i = 0; i < tokens.Length; i++)
            {
                var isSelected = Board.selectedTokenIndex >= 0 &&
                                 Board.tokens[Board.selectedTokenIndex] == tokens[i];
                var color  = Token.TokenColor[tokens[i].ColorIndex];
                var coords = tokenSelectors[i];

                var rect = new Rectangle(coords.X - TokenSelectorSz / 2, coords.Y - TokenSelectorSz / 2,
                                         TokenSelectorSz, TokenSelectorSz);
                g.FillEllipse(brushes.GetBrush(color), rect);
                if (isSelected)
                {
                    g.DrawEllipse(pens.GetPen(Color.Black, 3), rect);
                }
            }

            // нужно моркови / послед. ошибка
            var notes = new List <string>();

            if (carrotsNeeded != 0)
            {
                notes.Add(carrotsNeeded > 0 ? carrotsNeeded.ToString()
                    : "+" + (-carrotsNeeded).ToString());
            }
            if (!string.IsNullOrEmpty(lastError))
            {
                notes.Add(lastError);
            }

            if (notes.Count > 0)
            {
                top += TokenSelectorSz + 3;
                left = 20;
                g.DrawString(string.Join(", ", notes), Font, brushes.GetBrush(Color.Black), left, top);
            }
        }
Beispiel #13
0
 public void DrawComments(Graphics g, RectangleD worldRect, Rectangle canvasRect,
                          PenStorage penStorage, BrushesStorage brushStorage)
 {
     foreach (var marker in markers)
     {
         marker.CalculateScreenCoords(worldRect, canvasRect);
         marker.Draw(g, penStorage, brushStorage);
     }
 }
Beispiel #14
0
        public QuotePartButton(float scaleX, float scaleY, BrushesStorage brushes, PenStorage pens, bool isLeft = true)
        {
            brushesStor = brushes;
            pensStor    = pens;
            colorScheme.Add(ButtonFigureColorScheme.Normal, Color.FromArgb(255, 180, 247, 180));
            colorScheme.Add(ButtonFigureColorScheme.Pressed, Color.FromArgb(255, 200, 247, 210));
            colorScheme.Add(ButtonFigureColorScheme.Light, Color.FromArgb(255, 160, 195, 180));

            currentBrush = brushesStor.GetBrush(colorScheme[ButtonFigureColorScheme.Normal]) as SolidBrush;

            ScaleX          = scaleX;
            ScaleY          = scaleY;
            this.isLeft     = isLeft;
            translateMatrix = new Matrix();

            string buySellIndicatorHaderText;

            if (isLeft)
            {
                translateMatrix.Translate(paddingLeftRightProportion / 2, PaddingTopProportion);
                buySellIndicatorHaderText = "Bid";
            }
            else
            {
                translateMatrix.Translate(QuotePartButtonFigure.OriginalWidth * 2 + paddingLeftRightProportion / 2, PaddingTopProportion);
                translateMatrix.Scale(-1, 1);
                buySellIndicatorHaderText = "Ask";
            }

            buySellIndicator = new BuySellIndicator
            {
                ScaleX           = scaleX,
                ScaleY           = scaleY,
                OriginalLocation = isLeft
                                            ?
                                   new Point(
                    Convert.ToInt32(paddingLeftRightProportion),
                    Convert.ToInt32(PaddingTopProportion + PaddingTopBuySellIndicator))
                                            :
                                   new Point(
                    Convert.ToInt32(QuotePartButtonFigure.OriginalWidth + paddingLeftRightProportion),
                    Convert.ToInt32(PaddingTopProportion + PaddingTopBuySellIndicator)),
                HaderText = buySellIndicatorHaderText,
                Volume    = null
            };


            arrowTrend = new ArrowTrend
            {
                Sx               = ScaleX,
                Sy               = ScaleY,
                Brushes          = brushes,
                Pens             = pens,
                OriginalLocation = isLeft ? new PointF(QuotePartButtonFigure.OriginalWidth - paddingLeftRightProportion - 2, PaddingTopArrow) :
                                   new PointF(QuotePartButtonFigure.OriginalWidth * 2 - paddingLeftRightProportion - 2, PaddingTopArrow)
            };
        }
Beispiel #15
0
        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;
        }
Beispiel #16
0
 private void DrawEllipses(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     using (var brushStorage = new BrushesStorage())
         using (var penStorage = new PenStorage())
             foreach (var ellipse in data)
             {
                 ellipse.DrawEllipse(g, worldRect, canvasRect, brushStorage, penStorage, Chart.Font);
             }
 }
 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);
             }
 }
Beispiel #18
0
 private void DrawButtons(Graphics g, BrushesStorage brushes, PenStorage pens)
 {
     if (customButtons == null)
     {
         return;
     }
     foreach (var btn in customButtons)
     {
         btn.Draw(g, brushes, pens);
     }
 }
Beispiel #19
0
        public Image CreateSample(Size sizeHint)
        {
            var result    = new Bitmap(sizeHint.Width, sizeHint.Height);
            var g         = Graphics.FromImage(result);
            var pens      = new PenStorage();
            var brushes   = new BrushesStorage();
            var worldRect = new RectangleD(StartIndex - 1, Price * 0.9, EndIndex + 1, Price * 1.1);

            Draw(g, pens, brushes, worldRect, new Rectangle(new Point(0, 0), sizeHint),
                 new Font(FontFamily.GenericSansSerif, 8));
            return(result);
        }
 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);
                 }
             }
 }
Beispiel #21
0
 public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     base.Draw(g, worldRect, canvasRect);
     using (var pens = new PenStorage())
         using (var brushes = new BrushesStorage())
         {
             foreach (TrendLine line in data)
             {
                 line.Draw(g, worldRect, canvasRect, pens, brushes);
             }
         }
 }
Beispiel #22
0
        private void DrawCell(int cellIndex, Graphics g, BrushStorage brushes, PenStorage pens)
        {
            var cell = Board.cells[cellIndex];

            var ellipseRect = new Rectangle(cell.Location.X - cellShapeSz / 2, cell.Location.Y - cellShapeSz / 2,
                                            cellShapeSz, cellShapeSz);

            // залить фон
            g.FillEllipse(brushes.GetBrush(Color.White), ellipseRect);

            // граница
            g.DrawEllipse(pens.GetPen(Color.Black, cellShapeSz > 22 ? 3 : 2,
                                      cellIndex == selectedCellIndex ? DashStyle.Dot : DashStyle.Solid), ellipseRect);

            // содержимое
            int imageIndex;

            if (imageByCellType.TryGetValue(cell.CellType, out imageIndex))
            {
                var bmp = pictures[imageIndex];
                g.DrawImage(bmp, ellipseRect);
            }
            else
            {
                var textColor = cell.CellType == CellType.Cabbage
                                ? Color.DarkGreen
                                : cell.CellType == CellType.Carrot ? Color.Brown : Color.Black;
                var text = cell.CellType == CellType.Cabbage
                               ? "CB" : cell.CellType == CellType.Carrot ? "Cr" : cell.CellType == CellType.Finish
                                           ? "fin" : cell.CellType == CellType.Hare ? "H" : cell.CellType == CellType.Hedgehog
                                                       ? "Ig" : cell.CellType == CellType.Number ? cell.Points.ToString() : "St";
                g.DrawString(text, cellFont, brushes.GetBrush(textColor), cell.Location.X, cell.Location.Y,
                             new StringFormat {
                    LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center
                });
            }

            // индекс
            g.DrawString(cellIndex.ToString(), indexFont, brushes.GetBrush(Color.Black),
                         cell.NumberLocation.X, cell.NumberLocation.Y,
                         new StringFormat {
                LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center
            });

            // фишка
            var tokenOnCell = Board.tokens.FirstOrDefault(t => t.Position == cellIndex);

            if (tokenOnCell != null)
            {
                g.FillEllipse(brushes.GetBrush(Color.FromArgb(128, Token.TokenColor[tokenOnCell.ColorIndex])), ellipseRect);
            }
        }
Beispiel #23
0
 public void DrawButtons(Graphics g)
 {
     if (customButtons == null)
     {
         return;
     }
     using (var brushes = new BrushesStorage())
         using (var pens = new PenStorage())
             foreach (var btn in customButtons)
             {
                 btn.Draw(g, brushes, pens);
             }
 }
Beispiel #24
0
 private void DrawParts(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     using (var penStor = new PenStorage())
     {
         var markerPen = penStor.GetPen(lineColor);
         using (var markerBrush = new SolidBrush(Color.White))
         {
             foreach (var chain in parts)
             {
                 DrawRegion(chain, g, worldRect, canvasRect, penStor, markerPen, markerBrush);
             }
         }
     }
 }
Beispiel #25
0
            public void Draw(Graphics g, PenStorage pens)
            {
                var oldMode = g.SmoothingMode;

                g.SmoothingMode = SmoothingMode.AntiAlias;

                var pen =
                    pens.GetPen(state == DrawState.Normal
                            ? colorNormal
                            : state == DrawState.Hovered ? colorHovered : colorPressed, 0.7f);

                g.DrawPolygon(pen, figurePoints.Select(p => new Point(p.X + area.Left, p.Y + area.Top)).ToArray());

                g.SmoothingMode = oldMode;
            }
Beispiel #26
0
 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);
             }
         }
 }
Beispiel #27
0
 public void Draw(Graphics g, PenStorage penDic, float penWidth)
 {
     foreach (Polyline poly in lines)
     {
         if (poly.GetType() == typeof(Polygone))
         {
             g.FillPolygon(new SolidBrush(Color.FromArgb(alpha, ((Polygone)poly).FillColor)),
                           poly.points);
             g.DrawPolygon(penDic.GetPen(poly.LineColor, penWidth), poly.points);
         }
         else
         {
             g.DrawLines(penDic.GetPen(poly.LineColor, penWidth), poly.points);
         }
     }
 }
 public override void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect)
 {
     base.Draw(g, worldRect, canvasRect);
     using (var penDic = new PenStorage())
         using (var brushStorage = new BrushesStorage())
             foreach (var channel in data)
             {
                 try
                 {
                     channel.Draw(g, worldRect, canvasRect, Chart.Font, penDic, brushStorage);
                 }
                 catch (Exception ex)
                 {
                     logNoFlood.LogMessageFormatCheckFlood(LogEntryType.Error,
                                                           LogMsgErrorDrawChannel, "SeriesFiboChannel darawing error: {0}", ex);
                 }
             }
 }
        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);
            }
        }
        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);
        }