public void Draw(Graphics g, PenStorage penStorage, BrushesStorage brushStorage) { var pen = penStorage.GetPen(Color.Black); var brush = brushStorage.GetBrush(Color.White); if (action == MarkerAction.Move) { var points = new[] { new Point((int) centerScreen.X - Size2, (int) centerScreen.Y), new Point((int) centerScreen.X, (int) centerScreen.Y - Size2), new Point((int) centerScreen.X + Size2, (int) centerScreen.Y), new Point((int) centerScreen.X, (int) centerScreen.Y + Size2) }; g.FillPolygon(brush, points); g.DrawPolygon(pen, points); return; } g.FillRectangle(brush, (float)centerScreen.X - Size2, (float)centerScreen.Y - Size2, Size, Size); g.DrawRectangle(pen, (float) centerScreen.X - Size2, (float) centerScreen.Y - Size2, Size, Size); }
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); }
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 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; }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); using (var pens = new PenStorage()) using (var brushes = new BrushesStorage()) { var str = MakeDisplayedString(); // залить прямоугольник и отрисовать границу var outerRectColor = Selected ? clOutlineSel[blinkCounter] : clOutline; var pen = pens.GetPen(outerRectColor, BookmarkDrawState == DrawState.Pressed || DragState != DragDropState.Normal ? 2 : 1); var brColor = brushColor[BookmarkDrawState]; if (IsBlinking) brColor = brushColor[(DrawState)blinkCounter]; var brush = brushes.GetBrush(brColor); var area = new Rectangle(new Point(0, 0), new Size(Width - 1, Height - 1)); e.Graphics.FillRectangle(brush, area); e.Graphics.DrawRectangle(pen, area); // нарисовать "тень" if (Selected || DragState == DragDropState.InFrame) { var penSelected = pens.GetPen(clOutlineSel[blinkCounter]); e.Graphics.DrawLine(penSelected, 1, 1, Width - 1, 1); e.Graphics.DrawLine(penSelected, 1, 1, 1, Bottom - 1); } // нарисовать крестик контрастным if (modeEdit) { var brushCross = brushes.GetBrush(closeBtnVisible ? clOutline : MakeContrastColor(brColor, 26)); var points = pointsCross.Select(p => new PointF(p.X + areaCross.Left, p.Y + areaCross.Top)).ToArray(); e.Graphics.FillPolygon(brushCross, points); } // нарисовать картинку var left = TilePad; if (Bookmark.ShouldDrawImage && ImageList.Images.Count > Bookmark.ImageIndex && Bookmark.ImageIndex >= 0) { e.Graphics.DrawImage(ImageList.Images[Bookmark.ImageIndex], left, (TileH - ImageSize) / 2); left += (ImageSize + TilePad); } // нарисовать текст if (Bookmark.ShouldDrawText && str.Length > 0) e.Graphics.DrawString(str, Selected ? fontSelected : Font, brushes.GetBrush(clOutline), left, TileH/2, new StringFormat { LineAlignment = StringAlignment.Center }); } }
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 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 void Draw(Graphics g, RectangleD worldRect, Rectangle canvasRect, Font font, PenStorage penDic, BrushesStorage brushStorage) { spansInScreenCoords.Clear(); Draw(g, worldRect, canvasRect, penDic, brushStorage); if (linePoints.Count == 2) {// сохранить экранные координаты задающего отрезка spansInScreenCoords.Add(new Cortege2<Point, Point>( new Point((int) screenPointA.X, (int) screenPointA.Y), new Point((int) screenPointB.X, (int) screenPointB.Y))); } if (!Point3.HasValue) return; PointD oldPoint0 = linePoints[0], oldPoint1 = linePoints[1]; // параллельно перенести прямую по уровням var pointC = ProjectDotOnSpan(worldRect, canvasRect); var vector = new PointD(Point3.Value.X - pointC.X, Point3.Value.Y - pointC.Y); // начальная прямая linePoints[0] = oldPoint0 + vector; linePoints[1] = oldPoint1 + vector; Draw(g, worldRect, canvasRect, penDic, brushStorage); spansInScreenCoords.Add(new Cortege2<Point, Point>( new Point((int)screenPointA.X, (int)screenPointA.Y), new Point((int)screenPointB.X, (int)screenPointB.Y))); // нормаль var vectorScale = series.Count == 0 ? 1.0 : series[series.Count - 1] + 1; var pointC2 = pointC + vector * vectorScale; var pointArrow = Conversion.WorldToScreen(pointC + vector, worldRect, canvasRect); var screenC = Conversion.WorldToScreen(pointC, worldRect, canvasRect); var screenC2 = Conversion.WorldToScreen(pointC2, worldRect, canvasRect); using (var pen = new Pen(LineColor) { DashStyle = DashStyle.Dot }) { g.DrawLine(pen, screenC.ToPointF(), screenC2.ToPointF()); g.DrawPolygon(pen, GetArrowPoints(screenC, pointArrow)); // сохранить экранные координаты нормали spanNormalScreenCoords = new Cortege2<Point, Point>(screenC.ToPoint(), screenC2.ToPoint()); } // ряд прямых var rectPen = penDic.GetPen(LineColor); foreach (var level in series) { var vectorScaled = vector * (1 + level); linePoints[0] = oldPoint0 + vectorScaled; linePoints[1] = oldPoint1 + vectorScaled; Draw(g, worldRect, canvasRect, penDic, brushStorage); // сохранить координаты (для проверки попадания) spansInScreenCoords.Add(new Cortege2<Point, Point>( new Point((int)screenPointA.X, (int)screenPointA.Y), new Point((int)screenPointB.X, (int)screenPointB.Y))); // вывести подпись в рамке if (DrawText) { var whiteBrush = brushStorage.GetBrush(Color.White); var brush = brushStorage.GetBrush(LineColor); var ptText = pointC + vectorScaled; ptText = Conversion.WorldToScreen(ptText, worldRect, canvasRect); var textSz = g.MeasureString(level.ToString(), font); var textRect = new Rectangle((int) (ptText.X - textSz.Width/2 - 2), (int) (ptText.Y - textSz.Height/2 - 2), (int) textSz.Width + 4, (int) textSz.Height + 4); g.FillRectangle(whiteBrush, textRect); g.DrawRectangle(rectPen, textRect); g.DrawString(level.ToString(), font, brush, (float) ptText.X, (float) ptText.Y, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } } // восстановить начальные точки linePoints[0] = oldPoint0; linePoints[1] = oldPoint1; }
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); } }
private void DrawTangent(List<PointD> screenPoints, Rectangle canvasRect, Graphics g, PenStorage penStorage, BrushesStorage brushStorage, Font font) { var ptLeft = points[0].X < points[1].X ? points[0] : points[1]; var ptRight = points[0].X < points[1].X ? points[1] : points[0]; var m1 = new PointD(cx + b * Math.Sin(angle), cy + b * Math.Cos(angle)); var m2 = new PointD(cx + b * Math.Sin(angle + Math.PI), cy + b * Math.Cos(angle + Math.PI)); var m = ptLeft.Y > ptRight.Y ? m1.Y < m2.Y ? m1 : m2 // нижняя касательная для растущего эллипса : m1.Y < m2.Y ? m2 : m1; // верхняя для падающего var o = new PointD(cx, cy); var r = new PointD(m.X - o.X, m.Y - o.Y); var pen = penStorage.GetPen(TangentColor); foreach (var level in tangentFiboLevels) { // нарисовать касательную или параллельную ей линию var A = new PointD(screenPoints[0].X + r.X * (level + 1), screenPoints[0].Y + r.Y * (level + 1)); var B = new PointD(screenPoints[1].X + r.X * (level + 1), screenPoints[1].Y + r.Y * (level + 1)); if (TangentType == EllipseTangentType.Прямая) StretchSpanToScreen(ref A, ref B, canvasRect); g.DrawLine(pen, A.ToPointF(), B.ToPointF()); if (level == 0) continue; // нарисовать текстовую отметку var ptText = new PointD(o.X + r.X * (level + 1), o.Y + r.Y * (level + 1)); var textSz = g.MeasureString(level.ToString(), font); var textRect = new Rectangle((int) (ptText.X - textSz.Width / 2 - 2), (int) (ptText.Y - textSz.Height / 2 - 2), (int) textSz.Width + 4, (int) textSz.Height + 4); var brushWhite = brushStorage.GetBrush(Color.FromArgb(60, pen.Color)); g.FillRectangle(brushWhite, textRect); g.DrawRectangle(pen, textRect); var brushText = brushStorage.GetBrush(pen.Color); g.DrawString(level.ToString(), font, brushText, (float) ptText.X, (float) ptText.Y, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } }
public void DrawEllipse(Graphics g, RectangleD worldRect, Rectangle canvasRect, BrushesStorage brushStorage, PenStorage penStorage, Font font) { const int markerSize = 3; var pen = penStorage.GetPen(Color, Selected ? 3f : 1f); var screenPoints = new List<PointD>(); foreach (var pt in points) { screenPoints.Add(Conversion.WorldToScreen(new PointD(pt.X, pt.Y), worldRect, canvasRect)); } foreach (var pt in screenPoints) { g.DrawRectangle(pen, (float)pt.X - markerSize, (float)pt.Y - markerSize, markerSize * 2F, markerSize * 2F); } if (screenPoints.Count == 2) { g.DrawLine(pen, screenPoints[0].ToPointF(), screenPoints[1].ToPointF()); } if (screenPoints.Count == 3) { // нарисовать собственно эллипс double newAngle; float newCx, newCy, newA, newB; correctEllipse = Geometry.GetEllipseParams(screenPoints[0].ToPointF(), screenPoints[1].ToPointF(), screenPoints[2].ToPointF(), out newAngle, out newA, out newB, out newCx, out newCy); if (correctEllipse) // можно построить эллипс - рисуем его { a = newA; b = newB; angle = newAngle; cx = newCx; cy = newCy; var ellipseBezierPoints = Geometry.GetEllipseBezierPoints(newAngle, newA, newB, newCx, newCy); g.DrawBeziers(pen, ellipseBezierPoints); if (BrushAlpha > 0) { var brush = brushStorage.GetBrush(Color.FromArgb(BrushAlpha, BrushColor)); g.FillClosedCurve(brush, ellipseBezierPoints); } // строить касательную if (BuildTangent) DrawTangent(screenPoints, canvasRect, g, penStorage, brushStorage, font); } else // построить эллипс по указанным координатам невозможно { g.DrawLine(pen, screenPoints[1].ToPointF(), screenPoints[2].ToPointF()); g.DrawLine(pen, screenPoints[0].ToPointF(), screenPoints[2].ToPointF()); } } // маркеры if (Selected) DrawComments(g, worldRect, canvasRect, penStorage, brushStorage); }
public virtual void Draw(Graphics g, BrushesStorage brushes, PenStorage pens) { var images = buttonImage[key]; // нарисовать подложку и обводку if (State == ImageState.Pressed) { var brush = brushes.GetBrush(Color.FromArgb(128, ColorThemeIndex == 0 ? Color.Black : Color.White)); g.FillRectangle(brush, Position.X, Position.Y, Size.Width - 1, Size.Height - 1); } if (State == ImageState.Highlighted || State == ImageState.Pressed) { var pen = pens.GetPen(ColorThemeIndex == 0 ? Color.Black : Color.White); g.DrawRectangle(pen, Position.X, Position.Y, Size.Width - 1, Size.Height - 1); } // нарисовать картинку var img = images.images[ColorThemeIndex, imageIndex]; var padding = (Size.Width - img.Width) / 2; g.DrawImage(img, Position.X + padding, Position.Y + padding, img.Width, img.Height); }
public void Draw(Graphics g, PenStorage pens, BrushesStorage brushes, RectangleD worldRect, Rectangle canvasRect, Font font) { var ptA = Conversion.WorldToScreen(new PointD(StartIndex, Price), worldRect, canvasRect); var ptB = Conversion.WorldToScreen(new PointD(EndIndex, Price), worldRect, canvasRect); // линия var pen = pens.GetPen(LineColor, LineWidth); g.DrawLine(pen, (float)ptA.X, (float)ptA.Y, (float)ptB.X, (float)ptB.Y); // текст if (string.IsNullOrEmpty(TextLeft) && string.IsNullOrEmpty(TextRight)) return; const int textOffsetPx = 2; var brush = brushes.GetBrush(LineColor); var fmt = new StringFormat { Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Center }; if (!string.IsNullOrEmpty(TextLeft)) g.DrawString(TextLeft, font, brush, (float) ptA.X - textOffsetPx, (float) ptA.Y, fmt); if (!string.IsNullOrEmpty(TextRight)) { fmt.Alignment = StringAlignment.Near; g.DrawString(TextRight, font, brush, (float) ptB.X + textOffsetPx, (float) ptB.Y, fmt); } }
public void DrawObjectOnly(Graphics g, RectangleD worldRect, Rectangle canvasRect, PenStorage dicPen, BrushesStorage brushes) { var pen = dicPen.GetPen(LineColor, Selected ? PenWidth + 2 : PenWidth, penDashStyle); if (linePoints.Count == 2) { if (LineStyle == TrendLineStyle.Линия || LineStyle == TrendLineStyle.Отрезок || LineStyle == TrendLineStyle.ОтрезокСМаркерами || LineStyle == TrendLineStyle.ЛинияСМаркерами) { DrawLine(worldRect, canvasRect, g, pen, brushes, false); return; } if (LineStyle == TrendLineStyle.Стрелка) { DrawLine(worldRect, canvasRect, g, pen, brushes, true); return; } // пэкмен (анимация) if (LineStyle == TrendLineStyle.Пэкмен) { packmanCurrentFrame++; if (packmanCurrentFrame >= packmanFrames.Length) packmanCurrentFrame = 0; DrawObject(worldRect, canvasRect, g, pen, packmanFrames[packmanCurrentFrame], dicPen); return; } // спец символ if (styleSymbol.ContainsKey(LineStyle)) { DrawObject(worldRect, canvasRect, g, pen, styleSymbol[LineStyle], dicPen); return; } if (LineStyle == TrendLineStyle.Прямоугольник) { DrawRectangle(worldRect, canvasRect, g, pen); return; } if (LineStyle == TrendLineStyle.СвечнаяСтрелка) { DrawBarSizedArrow(worldRect, canvasRect, g, pen, symbolSmoothArrow); return; } } else {// нарисовать крестиком первую и единственную точку линии PointD pt = Conversion.WorldToScreen(linePoints[0], worldRect, canvasRect); const int cruaSz = 8, cruaGap = 3; g.DrawLine(pen, (float)pt.X, (float)pt.Y - cruaGap, (float)pt.X, (float)pt.Y - cruaSz); g.DrawLine(pen, (float)pt.X, (float)pt.Y + cruaGap, (float)pt.X, (float)pt.Y + cruaSz); g.DrawLine(pen, (float)pt.X - cruaGap, (float)pt.Y, (float)pt.X - cruaSz, (float)pt.Y); g.DrawLine(pen, (float)pt.X + cruaGap, (float)pt.Y, (float)pt.X + cruaSz, (float)pt.Y); } }
public void DrawComment( Graphics g, FontStorage fonts, RectangleD worldRect, Rectangle canvasRect, PenStorage penStorage, BrushesStorage brushStorage, List<Rectangle> areasToCheck) { var oldMode = g.SmoothingMode; g.SmoothingMode = /*SmoothingMode.AntiAlias : */SmoothingMode.None; try { var brush = brushStorage.GetBrush(Color.FromArgb(FillTransparency, ColorFill)); // нормализовать угол стрелки var arrowAngle = GetNormalizedArrowAngle(); while (arrowAngle < 0) arrowAngle = Math.PI * 2 + arrowAngle; // точка привязки PointD ptPivot = Conversion.WorldToScreen(new PointD(PivotIndex, PivotPrice), worldRect, canvasRect); // вторая точка стрелки var ptEnd = new PointD(ptPivot.X + ArrowLength * Math.Cos(arrowAngle), ptPivot.Y + ArrowLength * Math.Sin(arrowAngle)); var commentText = string.IsNullOrEmpty(Text) ? "" : Text; var color = Color; commentText = GetColorByComment(commentText, ref color); ReplaceTextPatterns(); var dashStyle = IsBeingCreated ? DashStyle.Dash : DashStyle.Solid; var pen = penStorage.GetPen(color, Selected ? 3f : 1f, dashStyle); // посчитать координаты текста float top, left, width, height; GetTextAreaLeftTop(g, fonts, commentText, arrowAngle, ptEnd, out left, out top, out width, out height); // проверить пересечение с комментом if (areasToCheck != null) { var rectOwn = new Rectangle((int)top, (int)left, (int)width, (int)height); if (areasToCheck.Any(a => a.IntersectsWith(rectOwn))) return; areasToCheck.Add(rectOwn); } // нарисовать область с текстом if (!HideBox) DrawTextArea(pen, g, brush, left, top, width, height); // .. и сам текст DrawTextOrSymbol(commentText, brushStorage, fonts, ColorText, g, left, top, width, height); TextArea = new Rectangle((int)left + canvasRect.Left, (int)top, (int)width, (int)height); // нарисовать стрелку if (!HideArrow) { PointD pointArrowEnd; List<PointF> arrowPoints = GetArrowPoints(arrowAngle, ptPivot, out pointArrowEnd); // нарисовать палку g.DrawLine(pen, (float)pointArrowEnd.X, (float)pointArrowEnd.Y, (float)ptEnd.X, (float)ptEnd.Y); // нарисовать стрелочку g.FillPolygon(brush, arrowPoints.ToArray()); g.DrawPolygon(pen, arrowPoints.ToArray()); } // маркеры if (Selected) DrawMarkers(g, worldRect, canvasRect); } finally { g.SmoothingMode = oldMode; } }
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); }