public bool DrawString( System.Windows.Media.DrawingContext graphics, System.Windows.Media.FontFamily fontFamily, System.Windows.FontStyle fontStyle, System.Windows.FontWeight fontWeight, double fontSize, string strText, System.Windows.Point ptDraw, System.Globalization.CultureInfo ci) { Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci); if (m_bClrText) { SolidColorBrush brush = new SolidColorBrush(m_clrText); Pen pen = new Pen(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), 1.0); graphics.DrawGeometry(brush, pen, path); } else { Pen pen = new Pen(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), 1.0); graphics.DrawGeometry(m_brushText, pen, path); } return true; }
public bool DrawString( System.Windows.Media.DrawingContext graphics, System.Windows.Media.FontFamily fontFamily, System.Windows.FontStyle fontStyle, System.Windows.FontWeight fontWeight, double fontSize, string strText, System.Windows.Point ptDraw, System.Globalization.CultureInfo ci) { Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci); SolidColorBrush solidbrush = new SolidColorBrush(m_clrOutline); Pen pen = new Pen(solidbrush, m_nThickness); pen.LineJoin = PenLineJoin.Round; SolidColorBrush transbrush = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)); graphics.DrawGeometry(transbrush, pen, path); return true; }
public static void UserDrawRasterWPFScreenCoordinate(System.Windows.Media.DrawingContext dc, System.Windows.Media.ImageSource ImageSource, int PixelX, int PixelY, int Width, int Height, double angle = 0.0, System.Windows.Media.ImageBrush pImageBrush = null) { System.Windows.Size sz = new System.Windows.Size(Width, Height); System.Windows.Point pnt = new System.Windows.Point(PixelX - sz.Width / 2, PixelY - sz.Height / 2); System.Windows.Rect rectBack = new System.Windows.Rect(pnt, sz); //if (angle == 0.0) //{ // dc.DrawImage(ImageSource, rectBack); //} //else //{ System.Windows.Media.RotateTransform rotRect = new System.Windows.Media.RotateTransform(angle, PixelX, PixelY); System.Windows.Media.RectangleGeometry RectGeo = new System.Windows.Media.RectangleGeometry(rectBack); RectGeo.Transform = rotRect; System.Windows.Media.ImageBrush imbrush = null; if (pImageBrush != null) { imbrush = pImageBrush; } else if (ImageSource != null) { imbrush = new System.Windows.Media.ImageBrush(ImageSource); } // imbrush.Viewport = imbrush.Viewport = new Rect(0, 0, 16, 16); //dc.DrawImage(_ImageSource, rectBack); if (imbrush != null) { imbrush.Transform = rotRect; dc.DrawGeometry(imbrush, null, RectGeo); } // } }
public bool DrawString( System.Windows.Media.DrawingContext graphics, System.Windows.Media.FontFamily fontFamily, System.Windows.FontStyle fontStyle, System.Windows.FontWeight fontWeight, double fontSize, string strText, System.Windows.Point ptDraw, System.Globalization.CultureInfo ci) { Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, ptDraw, ci); for (int i = 1; i <= m_nThickness; ++i) { SolidColorBrush solidbrush = new SolidColorBrush(m_clrOutline); Pen pen = new Pen(solidbrush, i); pen.LineJoin = PenLineJoin.Round; if (m_bClrText) { SolidColorBrush brush = new SolidColorBrush(m_clrText); graphics.DrawGeometry(brush, pen, path); } else graphics.DrawGeometry(m_brushText, pen, path); } return true; }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { drawingContext.DrawGeometry(null, new Pen(Stroke, StrokeThickness), GetArcGeometry()); }
public void Draw(TextView textView, System.Windows.Media.DrawingContext drawingContext) { if (markers == null || !textView.VisualLinesValid) { return; } var visualLines = textView.VisualLines; if (visualLines.Count == 0) { return; } int viewStart = visualLines.First().FirstDocumentLine.Offset; int viewEnd = visualLines.Last().LastDocumentLine.EndOffset; foreach (TextMarker marker in markers.FindOverlappingSegments(viewStart, viewEnd - viewStart)) { if (marker.BackgroundColor != null) { var geoBuilder = new BackgroundGeometryBuilder { AlignToWholePixels = true, CornerRadius = 3 }; geoBuilder.AddSegment(textView, marker); System.Windows.Media.Geometry geometry = geoBuilder.CreateGeometry(); if (geometry != null) { System.Windows.Media.Color color = marker.BackgroundColor.Value; var brush = new System.Windows.Media.SolidColorBrush(color); brush.Freeze(); drawingContext.DrawGeometry(brush, null, geometry); } } foreach (System.Windows.Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, marker)) { var startPoint = r.BottomLeft; var endPoint = r.BottomRight; var usedPen = new System.Windows.Media.Pen(new System.Windows.Media.SolidColorBrush(marker.MarkerColor), 1); usedPen.Freeze(); const double offset = 2.5; int count = Math.Max((int)((endPoint.X - startPoint.X) / offset) + 1, 4); var geometry = new System.Windows.Media.StreamGeometry(); using (System.Windows.Media.StreamGeometryContext ctx = geometry.Open()) { ctx.BeginFigure(startPoint, false, false); ctx.PolyLineTo(CreatePoints(startPoint, endPoint, offset, count).ToArray(), true, false); } geometry.Freeze(); drawingContext.DrawGeometry(System.Windows.Media.Brushes.Transparent, usedPen, geometry); break; } } }
public void Draw(TextView textView, System.Windows.Media.DrawingContext drawingContext) { ISegment s = element.Segment; if (s != null) { BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder(); geoBuilder.AlignToMiddleOfPixels = true; if (Layer == KnownLayer.Background) { geoBuilder.AddSegment(textView, s); drawingContext.DrawGeometry(backgroundBrush, null, geoBuilder.CreateGeometry()); } else { // draw foreground only if active if (element.isCaretInside) { geoBuilder.AddSegment(textView, s); foreach (BoundActiveElement boundElement in element.context.ActiveElements.OfType<BoundActiveElement>()) { if (boundElement.targetElement == element) { geoBuilder.AddSegment(textView, boundElement.Segment); geoBuilder.CloseFigure(); } } drawingContext.DrawGeometry(null, activeBorderPen, geoBuilder.CreateGeometry()); } } } }
public override void Drawing(System.Windows.Media.DrawingContext drawingContext, Rect area) { drawingContext.DrawLine(DrawPen, Start, End); DrawLine(drawingContext, Start, End); drawingContext.DrawGeometry(ShapeBrush, null, MakeArrowGeometry(Start, End)); }
public bool DrawString( System.Windows.Media.DrawingContext graphics, System.Windows.Media.FontFamily fontFamily, System.Windows.FontStyle fontStyle, System.Windows.FontWeight fontWeight, double fontSize, string strText, System.Windows.Point ptDraw, System.Globalization.CultureInfo ci) { int nOffset = Math.Abs(m_nOffsetX); if (Math.Abs(m_nOffsetX) == Math.Abs(m_nOffsetY)) { nOffset = Math.Abs(m_nOffsetX); } else if (Math.Abs(m_nOffsetX) > Math.Abs(m_nOffsetY)) { nOffset = Math.Abs(m_nOffsetY); } else if (Math.Abs(m_nOffsetX) < Math.Abs(m_nOffsetY)) { nOffset = Math.Abs(m_nOffsetX); } for (int i = 0; i < nOffset; ++i) { Geometry path = GDIPath.CreateTextGeometry(strText, fontFamily, fontStyle, fontWeight, fontSize, new Point(ptDraw.X + ((i * (-m_nOffsetX)) / nOffset), ptDraw.Y + ((i * (-m_nOffsetY)) / nOffset)), ci); SolidColorBrush solidbrush = new SolidColorBrush(m_clrOutline); Pen pen = new Pen(solidbrush, m_nThickness); pen.LineJoin = PenLineJoin.Round; if (m_bClrText) { SolidColorBrush brush = new SolidColorBrush(m_clrText); graphics.DrawGeometry(brush, pen, path); } else { graphics.DrawGeometry(m_brushText, pen, path); } } return true; }
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext) { base.OnRender(drawingContext); var childRect = GetChildRect(); double childMiddleY = childRect.Top + (childRect.Height / 2); double childMiddleX = childRect.Left + (childRect.Width / 2); var strokePen = new Pen(BorderBrush, BorderStrokeThickness); drawingContext.DrawGeometry(Background, strokePen, GetCombinedSides(childMiddleX, childMiddleY)); }
protected override void OnRender (System.Windows.Media.DrawingContext drawingContext) { if (m_CurrentAOI != null) { Point startPoint = PointToWindowCoordinates(m_CurrentAOI.StartPoint); Point endPoint = PointToWindowCoordinates(m_CurrentAOI.EndPoint); RectangleGeometry rectGeo = new RectangleGeometry(new Rect(startPoint, endPoint), m_CurrentAOI.Marking.RadiusX, m_CurrentAOI.Marking.RadiusY); Brush fill = (Enabled) ? Brushes.Transparent : null; drawingContext.DrawGeometry(fill, m_CurrentAOI.Pen, rectGeo); } base.OnRender(drawingContext); }