public bool NextDraw(Point pt, IDrawingContext dc, bool isFinal) { if (iPoint == pointCount) { return(true); } Points[iPoint] = pt; var p0 = PointSnapper.SnapPoint(Points[0]); var p1 = PointSnapper.SnapPoint(Points[1]); dc.DrawLine(Pen, p0, p1); if (iPoint == 2) { var p2 = PointSnapper.SnapPoint(Points[2]); var diffX = p1.X - p2.X; var diffY = p1.Y - p2.Y; Point pt00 = new Point(p0.X - diffX, p0.Y - diffY); dc.DrawLine(Pen, pt00, p2); } if (isFinal) { iPoint++; } return(iPoint == PointCount); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView) { if ((canvasView.ScaleRatio >= 2.0) && GetIsPixelGridEnabled(canvasView)) { SizeDouble canvasSize = base.Owner.CanvasSize; RectDouble b = new RectDouble(PointDouble.Zero, canvasSize); RectInt32 rect = RectDouble.Intersect(clipRect, b).Int32Bound; Matrix3x2Double transform = dc.Transform; double num6 = 1.0 / canvasView.CanvasHairWidth; RectDouble num7 = transform.Transform(rect); double num9 = DoubleUtil.Clamp((canvasView.ScaleRatio - 2.0) / 4.0, 0.0, 1.0) / 2.0; this.stippleBitmapBrush.Opacity = num9; using (dc.UseAntialiasMode(AntialiasMode.Aliased)) { using (dc.UseTransform(Matrix3x2Float.Identity)) { using (dc.UseAxisAlignedClip((RectFloat)num7, AntialiasMode.Aliased)) { for (int i = -(rect.Width & 1); i <= rect.Width; i++) { dc.DrawLine(num7.X + (i * num6), num7.Y, num7.X + (i * num6), num7.Y + num7.Height, this.stippleBitmapBrush, 1.0); } for (int j = -(rect.Height & 1); j <= rect.Height; j++) { dc.DrawLine(num7.X, num7.Y + (j * num6), num7.X + num7.Width, num7.Y + (j * num6), this.stippleBitmapBrush, 1.0); } } } } } base.OnRender(dc, clipRect, canvasView); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect) { dc.Clear(new ColorRgba128Float?(this.BackColor)); using (dc.UseTranslateTransform(0.5f, 0.5f, MatrixMultiplyOrder.Append)) { RectDouble num = RectDouble.Inflate(base.ClientRectangle.ToRectInt32(), -1.0, -1.0); double num3 = Math.Min(num.Width, num.Height) / 2.0; PointDouble center = new PointDouble(num.X + num3, num.Y + num3); double d = MathUtil.DegreesToRadians(this.value); EllipseDouble ellipse = new EllipseDouble(center, num3 - 0.5, num3 - 0.5); double thickness = this.hover ? 2.0 : 1.0; double num8 = this.maxValue - this.minValue; if (num8 >= 360.0) { dc.FillEllipse(ellipse, validAnglesFillBrush); dc.DrawEllipse(ellipse, outlineBrush, thickness); } else { dc.FillEllipse(ellipse, invalidAnglesFillBrush); double width = num3; PointDouble num14 = new PointDouble(center.X + (width * Math.Cos(MathUtil.DegreesToRadians(this.minValue))), center.Y - (width * Math.Sin(MathUtil.DegreesToRadians(this.minValue)))); PointDouble num15 = new PointDouble(center.X + (width * Math.Cos(MathUtil.DegreesToRadians(this.maxValue))), center.Y - (width * Math.Sin(MathUtil.DegreesToRadians(this.maxValue)))); SizeDouble num16 = new SizeDouble(width, width); if (this.validRangeGeometry == null) { this.validRangeGeometry = new PathGeometry(); this.validRangeFigure = new PathFigure(); this.validRangeFigure.IsFilled = true; this.validRangeFigure.IsClosed = true; this.validRangeGeometry.Figures.Add(this.validRangeFigure); this.validRangeLineSegment1 = new LineSegment(); this.validRangeFigure.Segments.Add(this.validRangeLineSegment1); this.validRangeArcSegment = new ArcSegment(); this.validRangeArcSegment.SweepDirection = SweepDirection.Counterclockwise; this.validRangeFigure.Segments.Add(this.validRangeArcSegment); this.validRangeLineSegment2 = new LineSegment(); this.validRangeFigure.Segments.Add(this.validRangeLineSegment2); } this.validRangeFigure.StartPoint = center; this.validRangeLineSegment1.Point = num14; this.validRangeArcSegment.Point = num15; this.validRangeArcSegment.IsLargeArc = num8 >= 180.0; this.validRangeArcSegment.Size = num16; this.validRangeLineSegment2.Point = num15; dc.FillGeometry(this.validRangeGeometry, validAnglesFillBrush, null); dc.DrawEllipse(ellipse, outlineBrush, thickness); dc.DrawLine(center, num14, outlineBrush, 0.5); dc.DrawLine(center, num15, outlineBrush, 0.5); } double num9 = num3 - 2.0; PointDouble num10 = new PointDouble(center.X + (num9 * Math.Cos(d)), center.Y - (num9 * Math.Sin(d))); double radius = 2.5; EllipseDouble num12 = new EllipseDouble(center, radius); dc.FillEllipse(num12, gripFillBrush); dc.DrawLine(center, num10, gripBrush, this.hover ? 2.0 : 1.5); } base.OnRender(dc, clipRect); }
public void Render(LayoutInformation layout, ILayoutContext layoutContext, IDrawingContext drawingContext) { var start = Start.Resolve(layout, layoutContext.Options); var end = End.Resolve(layout, layoutContext.Options); if (layoutContext.Options.Absolute) { drawingContext.DrawLine(Point.Add(start, layout.Location), Point.Add(end, layout.Location), Thickness); } else { drawingContext.DrawLine(start, end, Thickness); } }
public override void Render(IDrawingContext context) { var selectionStart = this.SelectionStart; var selectionEnd = this.SelectionEnd; if (selectionStart != selectionEnd) { var start = Math.Min(selectionStart, selectionEnd); var length = Math.Max(selectionStart, selectionEnd) - start; var rects = this.FormattedText.HitTestTextRange(start, length); var brush = new SolidColorBrush(0xff086f9e); foreach (var rect in rects) { context.FillRectange(brush, rect); } } base.Render(context); if (this.IsFocused && selectionStart == selectionEnd) { var charPos = this.FormattedText.HitTestTextPosition(this.CaretIndex); Brush caretBrush = Brushes.Black; if (this.caretBlink) { context.DrawLine(new Pen(caretBrush, 1), charPos.TopLeft, charPos.BottomLeft); } } }
public override void Render(IDrawingContext context) { Rect rect = new Rect(this.ActualSize); context.DrawText(Brushes.Black, rect, this.FormattedText); if (this.parent.IsFocused) { ITextService textService = Locator.Current.GetService <ITextService>(); Point caretPos = textService.GetCaretPosition( this.formattedText, this.parent.CaretIndex, this.ActualSize); double[] lineHeights = textService.GetLineHeights(this.formattedText, this.ActualSize); Brush caretBrush = Brushes.Black; if (this.caretBlink) { context.DrawLine( new Pen(caretBrush, 1), caretPos, new Point(caretPos.X, caretPos.Y + lineHeights[0])); } } }
public virtual void RenderWire(Wire wire, IDrawingContext drawingContext) { var size = wire.Layout.Orientation == Orientation.Horizontal ? new Point(wire.Layout.Size, 0.0) : new Point(0.0, wire.Layout.Size); drawingContext.DrawLine(wire.Layout.Location, Point.Add(wire.Layout.Location, size), 2.0); }
private void DrawSnapIndicators(IDrawingContext dc, double radius) { for (int i = 0; i < 360; i += 15) { double d = i * 0.017453292519943295; if (this.lockRadius) { double centerX = (this.wheelRadius * radius) * Math.Cos(d); double centerY = (this.wheelRadius * radius) * Math.Sin(d); dc.FillCircle(centerX, centerY, 2.0, this.snapMarkBrush); } else { double num5 = this.wheelRadius * Math.Cos(d); double num6 = this.wheelRadius * Math.Sin(d); dc.FillCircle(num5, num6, 2.0, this.snapMarkBrush); } } if (!this.lockRadius) { for (int j = 0; j < 360; j += 15) { double num8 = j * 0.017453292519943295; PointDouble num9 = new PointDouble(3.0 * Math.Cos(num8), 3.0 * Math.Sin(num8)); PointDouble num10 = new PointDouble(this.wheelRadius * Math.Cos(num8), this.wheelRadius * Math.Sin(num8)); dc.DrawLine(num9, num10, this.snapLineBrush, 1.0); } } }
private void RenderBorder(IDrawingContext drawingContext, Measurement measurement) { var borderThickness = Style.Get(StyleKeys.Border); var size = measurement.Size; var color = Style.Get(StyleKeys.BorderColor); if (borderThickness.Top > 0) { var y1 = -borderThickness.Top / 2; var x1 = 0; var y2 = y1; var x2 = size.Width; var s = new Position(x1, y1); var e = new Position(x2, y2); drawingContext.DrawLine(s, e, new Pen(color, borderThickness.Top)); } if (borderThickness.Left > 0) { var y1 = -borderThickness.Top; var x1 = -borderThickness.Left / 2; var y2 = size.Height + borderThickness.Bottom; var x2 = x1; var s = new Position(x1, y1); var e = new Position(x2, y2); drawingContext.DrawLine(s, e, new Pen(color, borderThickness.Left)); } if (borderThickness.Bottom > 0) { var y1 = size.Height + borderThickness.Bottom / 2; var x1 = 0; var y2 = y1; var x2 = size.Width; var s = new Position(x1, y1); var e = new Position(x2, y2); drawingContext.DrawLine(s, e, new Pen(color, borderThickness.Bottom)); } if (borderThickness.Right > 0) { var y1 = -borderThickness.Top; var x1 = size.Width + borderThickness.Right / 2; var y2 = size.Height + borderThickness.Bottom; var x2 = x1; var s = new Position(x1, y1); var e = new Position(x2, y2); drawingContext.DrawLine(s, e, new Pen(color, borderThickness.Right)); } }
public void DrawExtraData(ChartControl chartSource, IDrawingContext dc) { var dataSource = chartSource.MainCollection; if (dataSource == null) { return; } var items = dataSource.Items; int iStart = dataSource.FirstVisibleItemIndex; int count = dataSource.VisiableItemCount; IPen pen = DrawingObjectFactory.CreatePen(Forground, 1); var xMid = dataSource.ItemXDistance / 2; startY = -1; internalIndex = -1; XRItems = null; for (int i = iStart; i < iStart + count; i++) { var item = dataSource.Items[i]; if (item.ExtraData == null) { continue; } var xhHistory = item.ExtraData.Get(ExtraDataNames.XRName) as ExitRight; if (xhHistory != null) { var x = dataSource.GetItemPositionX(i, ChartItemCollection.ValueName); if (startY == -1) { startY = dataSource.ChartRegion.Bottom - height; XRItems = new List <XRItem>(); } XRItems.Add(new XRItem() { X = x, Index = i, toolTip = xhHistory.ToString() }); x = PointSnapper.SnapValue(x + xMid); var point1 = new Point(x, dataSource.ChartRegion.Bottom); var point2 = new Point(x, dataSource.ChartRegion.Bottom - 2); dc.DrawLine(pen, point1, point2); point1 = new Point(x, dataSource.ChartRegion.Bottom - 5); dc.DrawEllipse(Forground, null, point1, radius, radius); } } }
private void DrawHueGuide(IDrawingContext dc, double theta) { double x = this.wheelRadius * Math.Cos(theta); double y = this.wheelRadius * Math.Sin(theta); PointDouble num3 = new PointDouble(x, y); dc.DrawLine(PointDouble.Zero, this.lockHue ? num3 : this.lastHueGuidePoint, this.lockHueGuideBrush, 1.0); if (this.lockHue) { this.lastHueGuidePoint = num3; } }
public void Draw(IDrawingContext dc) { if (iPoint != pointCount) { return; } var pts = new Point[pointCount]; for (int i = 0; i < pointCount; i++) { pts[i] = PointSnapper.SnapPoint(Points[i]); } dc.DrawLine(Pen, pts[0], pts[1]); var diffX = pts[1].X - pts[2].X; var diffY = pts[1].Y - pts[2].Y; Point pt00 = new Point(pts[0].X - diffX, pts[0].Y - diffY); dc.DrawLine(Pen, pt00, pts[2]); if (IsSelected) { selectionGeoList = new List <RectangleGeometry>(); for (int i = 0; i < PointCount; i++) { var selectionGeo = new RectangleGeometry(new Rect(PointSnapper.RoundValue(pts[i].X - 3), PointSnapper.RoundValue(pts[i].Y - 3), 6, 6)); dc.DrawGeometry(Pen.Brush, null, selectionGeo); selectionGeoList.Add(selectionGeo); } } CreateRegion(pts); }
protected override void OnRender(IDrawingContext context, Rect bounds, double opacity) { base.OnRender(context, bounds, opacity); Line line = WpfElement as Line; DrawingStyle style = DrawingStyle.FromElement(this); style.Stroke = line.Stroke; style.StrokeThickness = new Thickness(line.StrokeThickness); style.Opacity = opacity; context.DrawLine(bounds, new Point(line.X1, line.Y1), new Point(line.X2, line.Y2), style); }
public bool NextDraw(Point pt, IDrawingContext dc, bool isFinal) { Points[1] = pt; var p0 = PointSnapper.SnapPoint(Points[0]); var p1 = PointSnapper.SnapPoint(Points[1]); dc.DrawLine(Pen, p0, p1); if (isFinal) { CreateRegion(); } return(isFinal); }
/// <summary> /// Renders the <see cref="AccessText"/> to a drawing context. /// </summary> /// <param name="context">The drawing context.</param> public override void Render(IDrawingContext context) { base.Render(context); int underscore = Text?.IndexOf('_') ?? -1; if (underscore != -1 && ShowAccessKey) { var rect = FormattedText.HitTestTextPosition(underscore); var offset = new Vector(0, -0.5); context.DrawLine( new Pen(Foreground, 1), rect.BottomLeft + offset, rect.BottomRight + offset); } }
private void Draw3DLine(IDrawingContext dc, double rx, double ry, double scale, double xs, double ys, double zs, double xe, double ye, double ze, PaintDotNet.UI.Media.Brush brush, double thickness) { double sinAmount = Math.Sqrt((rx * rx) + (ry * ry)); if (sinAmount != 0.0) { double a = Math.Atan2(ry, rx); double sinAngle = Math.Sin(a); double cosAngle = Math.Cos(a); this.Transform(sinAngle, cosAngle, sinAmount, Math.Cos(Math.Asin(sinAmount)), ref xs, ref ys, ref zs); this.Transform(sinAngle, cosAngle, sinAmount, Math.Cos(Math.Asin(sinAmount)), ref xe, ref ye, ref ze); } xs *= scale; xe *= scale; ys *= scale; ye *= scale; if ((ze < 0.03) && (zs < 0.03)) { dc.DrawLine(xs, ys, xe, ye, brush, thickness); } }
public void Draw(IDrawingContext dc) { var p0 = PointSnapper.SnapPoint(Points[0]); var p1 = PointSnapper.SnapPoint(Points[1]); dc.DrawLine(Pen, p0, p1); if (IsSelected) { selectionGeo1 = new RectangleGeometry(new Rect(PointSnapper.RoundValue(p0.X - 3), PointSnapper.RoundValue(p0.Y - 3), 6, 6)); selectionGeo2 = new RectangleGeometry(new Rect(PointSnapper.RoundValue(p1.X - 3), PointSnapper.RoundValue(p1.Y - 3), 6, 6)); dc.DrawGeometry(Pen.Brush, null, selectionGeo1); dc.DrawGeometry(Pen.Brush, null, selectionGeo2); } CreateRegion(); }
public override void DrawLine(RPen pen, double x1, double y1, double x2, double y2) { x1 = (int)x1; x2 = (int)x2; y1 = (int)y1; y2 = (int)y2; var adj = pen.Width; if (Math.Abs(x1 - x2) < .1 && Math.Abs(adj % 2 - 1) < .1) { x1 += .5; x2 += .5; } if (Math.Abs(y1 - y2) < .1 && Math.Abs(adj % 2 - 1) < .1) { y1 += .5; y2 += .5; } _g.DrawLine(((PenAdapter)pen).CreatePen(), new Point(x1, y1), new Point(x2, y2)); }
public override void Render(IDrawingContext context) { var selectionStart = SelectionStart; var selectionEnd = SelectionEnd; if (selectionStart != selectionEnd) { var start = Math.Min(selectionStart, selectionEnd); var length = Math.Max(selectionStart, selectionEnd) - start; var rects = FormattedText.HitTestTextRange(start, length); var brush = new SolidColorBrush(0xff086f9e); foreach (var rect in rects) { context.FillRectange(brush, rect); } } base.Render(context); if (selectionStart == selectionEnd) { var charPos = FormattedText.HitTestTextPosition(CaretIndex); Brush caretBrush = Brushes.Black; if (_caretBlink) { var x = Math.Floor(charPos.X) + 0.5; var y = Math.Floor(charPos.Y) + 0.5; var b = Math.Ceiling(charPos.Bottom) - 0.5; context.DrawLine( new Pen(caretBrush, 1), new Point(x, y), new Point(x, b)); } } }
public override void Render(IDrawingContext context) { var selectionStart = SelectionStart; var selectionEnd = SelectionEnd; if (selectionStart != selectionEnd) { var start = Math.Min(selectionStart, selectionEnd); var length = Math.Max(selectionStart, selectionEnd) - start; var rects = FormattedText.HitTestTextRange(start, length); var brush = new SolidColorBrush(0xff086f9e); foreach (var rect in rects) { context.FillRectange(brush, rect); } } base.Render(context); if (selectionStart == selectionEnd) { var charPos = FormattedText.HitTestTextPosition(CaretIndex); var backgroundColor = (((Control)TemplatedParent).GetValue(BackgroundProperty) as SolidColorBrush)?.Color; var caretBrush = Brushes.Black; if(backgroundColor.HasValue) { byte red = (byte)~(backgroundColor.Value.R); byte green = (byte)~(backgroundColor.Value.G); byte blue = (byte)~(backgroundColor.Value.B); caretBrush = new SolidColorBrush(Color.FromRgb(red, green, blue)); } if (_caretBlink) { var x = Math.Floor(charPos.X) + 0.5; var y = Math.Floor(charPos.Y) + 0.5; var b = Math.Ceiling(charPos.Bottom) - 0.5; context.DrawLine( new Pen(caretBrush, 1), new Point(x, y), new Point(x, b)); } } }
public void DrawLine(Point start, Point end, double thickness) { Expand(new Rect(start, end)); underlying?.DrawLine(start, end, thickness); }
public bool NextDraw(Point pt, IDrawingContext dc, bool isFinal) { Points[1] = pt; double radius = Math.Atan((Points[1].X - Points[0].X) / (Points[0].Y - Points[1].Y)); double degree = radius * 180 / Math.PI; if (degree < 0) { if (Points[1].X > Points[0].X) { degree = 180 + degree; } } else { if (Points[1].X < Points[0].X) { degree = 180 + degree; } } IPen pen = DrawingObjectFactory.CreatePen(MeasureColor, MeasureThickness); if (MeasureDashes != null) { pen.Dashes = MeasureDashes; } //Trace.WriteLine(radius + "," + degree); RotateTransform transferm = new RotateTransform() { Angle = degree, CenterX = Points[0].X, CenterY = Points[0].Y }; dc.PushTransform(transferm); Point pt1 = new Point(Points[0].X + 3, Points[0].Y); Point pt2 = new Point(Points[0].X - 3, Points[0].Y); dc.DrawLine(pen, pt1, pt2); double value = -Math.Sqrt(Math.Abs(Points[0].X - Points[1].X) * Math.Abs(Points[0].X - Points[1].X) + Math.Abs(Points[0].Y - Points[1].Y) * Math.Abs(Points[0].Y - Points[1].Y)); Point pt3 = new Point(Points[0].X, Points[0].Y + value); dc.DrawLine(pen, Points[0], pt3); pt1 = new Point(Points[0].X + 3, Points[0].Y + value); pt2 = new Point(Points[0].X - 3, Points[0].Y + value); dc.DrawLine(pen, pt1, pt2); dc.Pop(); ITextFormat format = DrawingObjectFactory.CreateTextFormat(measureValue.ToString("P2"), FlowDirection, FontFamily, FontStyle, FontWeight, FontStretch, FontSize, Foreground); Point ptText = Points[1]; ptText.Y -= format.Height; dc.DrawText(format, ptText); return(false); }
public void DrawLine(Point start, Point end, double thickness) { Expand(new Rect(new Point(Math.Min(start.X, end.X), Math.Min(start.Y, end.Y)), new Point(Math.Max(start.X, end.X), Math.Max(start.Y, end.Y)))); underlying?.DrawLine(start, end, thickness); }
public static bool RenderFromXml(Stream xmlStream, IDrawingContext drawingContext, out Size imageSize) { var doc = XDocument.Load(xmlStream); var previewNode = doc.Elements().First(x => x.Name == PreviewNamespace + "preview"); imageSize = new Size(double.Parse(previewNode.Attribute("width").Value), double.Parse(previewNode.Attribute("height").Value)); var renderElements = previewNode.Elements(); foreach (var renderElement in renderElements) { if (renderElement.Name == "line") { Point start = Point.Parse(renderElement.Attribute("start").Value); Point end = Point.Parse(renderElement.Attribute("end").Value); double thickness = double.Parse(renderElement.Attribute("thickness").Value); drawingContext.DrawLine(start, end, thickness); } else if (renderElement.Name == "rect") { Point start = Point.Parse(renderElement.Attribute("start").Value); Size size = Size.Parse(renderElement.Attribute("size").Value); double thickness = double.Parse(renderElement.Attribute("thickness").Value); bool fill = bool.Parse(renderElement.Attribute("fill").Value); drawingContext.DrawRectangle(start, size, thickness, fill); } else if (renderElement.Name == "ellipse") { Point centre = Point.Parse(renderElement.Attribute("centre").Value); double radiusx = double.Parse(renderElement.Attribute("rx").Value); double radiusy = double.Parse(renderElement.Attribute("ry").Value); double thickness = double.Parse(renderElement.Attribute("thickness").Value); bool fill = bool.Parse(renderElement.Attribute("fill").Value); drawingContext.DrawEllipse(centre, radiusx, radiusy, thickness, fill); } else if (renderElement.Name == "path") { Point start = Point.Parse(renderElement.Attribute("start").Value); double thickness = double.Parse(renderElement.Attribute("thickness").Value); bool fill = bool.Parse(renderElement.Attribute("fill").Value); string data = renderElement.Value; List <IPathCommand> pathCommands = new List <IPathCommand>(); using (MemoryStream dataStream = new MemoryStream(Convert.FromBase64String(data))) { BinaryReader reader = new BinaryReader(dataStream); int numCommands = reader.ReadInt32(); for (int l = 0; l < numCommands; l++) { CommandType pType = (CommandType)reader.ReadInt32(); IPathCommand theCommand = null; switch (pType) { case CommandType.MoveTo: theCommand = new MoveTo(); break; case CommandType.LineTo: theCommand = new LineTo(); break; case CommandType.CurveTo: theCommand = new CurveTo(); break; case CommandType.EllipticalArcTo: theCommand = new EllipticalArcTo(); break; case CommandType.QuadraticBeizerCurveTo: theCommand = new QuadraticBeizerCurveTo(); break; case CommandType.SmoothCurveTo: theCommand = new SmoothCurveTo(); break; case CommandType.SmoothQuadraticBeizerCurveTo: theCommand = new SmoothQuadraticBeizerCurveTo(); break; default: theCommand = new ClosePath(); break; } theCommand.Read(reader); pathCommands.Add(theCommand); } } drawingContext.DrawPath(start, pathCommands, thickness, fill); } else if (renderElement.Name == "text") { Point anchor = Point.Parse(renderElement.Attribute("anchor").Value); TextAlignment alignment = (TextAlignment)Enum.Parse(typeof(TextAlignment), renderElement.Attribute("alignment").Value); List <TextRun> runs = new List <TextRun>(); foreach (var runNode in renderElement.Elements()) { if (runNode.Name != "run") { continue; } double size = double.Parse(runNode.Attribute("size").Value); TextRunFormattingType formattingType = (TextRunFormattingType)Enum.Parse(typeof(TextRunFormattingType), runNode.Attribute("formatting").Value); string text = runNode.Value; runs.Add(new TextRun(text, new TextRunFormatting(formattingType, size))); } drawingContext.DrawText(anchor, alignment, runs); } } return(true); }
public void DrawLine(Point start, Point end, double thickness) { underlying.DrawLine(start.Add(offset), end.Add(offset), thickness); }
protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView) { double canvasHairWidth = canvasView.CanvasHairWidth; if (this.handleDiameter > 2.0) { double rotationAngle = this.handleTransform.GetRotationAngle(); PointDouble location = this.handleTransform.Transform(this.handleLocation) + ((PointDouble)(this.handleLocationScreenOffset * canvasHairWidth)); VectorDouble[] vecs = new VectorDouble[] { new VectorDouble(-1.0, -1.0), new VectorDouble(1.0, -1.0), new VectorDouble(1.0, 1.0), new VectorDouble(-1.0, 1.0), new VectorDouble(-1.0, 0.0), new VectorDouble(1.0, 0.0), new VectorDouble(0.0, -1.0), new VectorDouble(0.0, 1.0) }; vecs.RotateInPlace(rotationAngle); vecs.NormalizeInPlace(); double num5 = ((double)this.handleAlpha) / 255.0; this.whiteBrush.Opacity = num5; this.blackBrush.Opacity = num5; if (this.handleShape != MoveHandleShape.Circle) { PointDouble[] numArray2 = new PointDouble[] { location + (vecs[0] * (this.handleDiameter * canvasHairWidth)), location + (vecs[1] * (this.handleDiameter * canvasHairWidth)), location + (vecs[2] * (this.handleDiameter * canvasHairWidth)), location + (vecs[3] * (this.handleDiameter * canvasHairWidth)) }; PointDouble[] numArray3 = new PointDouble[] { location + (vecs[0] * ((this.handleDiameter - 1.0) * canvasHairWidth)), location + (vecs[1] * ((this.handleDiameter - 1.0) * canvasHairWidth)), location + (vecs[2] * ((this.handleDiameter - 1.0) * canvasHairWidth)), location + (vecs[3] * ((this.handleDiameter - 1.0) * canvasHairWidth)) }; PointDouble[] numArray4 = new PointDouble[] { location + (vecs[0] * ((this.handleDiameter - 2.0) * canvasHairWidth)), location + (vecs[1] * ((this.handleDiameter - 2.0) * canvasHairWidth)), location + (vecs[2] * ((this.handleDiameter - 2.0) * canvasHairWidth)), location + (vecs[3] * ((this.handleDiameter - 2.0) * canvasHairWidth)) }; dc.DrawLine(numArray2[0], numArray2[1], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray2[1], numArray2[2], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray2[2], numArray2[3], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray2[3], numArray2[0], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray3[0], numArray3[1], this.blackBrush, canvasHairWidth); dc.DrawLine(numArray3[1], numArray3[2], this.blackBrush, canvasHairWidth); dc.DrawLine(numArray3[2], numArray3[3], this.blackBrush, canvasHairWidth); dc.DrawLine(numArray3[3], numArray3[0], this.blackBrush, canvasHairWidth); dc.DrawLine(numArray4[0], numArray4[1], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray4[1], numArray4[2], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray4[2], numArray4[3], this.whiteBrush, canvasHairWidth); dc.DrawLine(numArray4[3], numArray4[0], this.whiteBrush, canvasHairWidth); } else if (this.handleShape == MoveHandleShape.Circle) { RectDouble rect = new RectDouble(location, SizeDouble.Zero); rect.Inflate((double)((this.handleDiameter - 1.0) * canvasHairWidth), (double)((this.handleDiameter - 1.0) * canvasHairWidth)); dc.DrawEllipse(EllipseDouble.FromRect(rect), this.whiteBrush, canvasHairWidth); rect.Inflate(-canvasHairWidth, -canvasHairWidth); dc.DrawEllipse(EllipseDouble.FromRect(rect), this.blackBrush, canvasHairWidth); rect.Inflate(-canvasHairWidth, -canvasHairWidth); dc.DrawEllipse(EllipseDouble.FromRect(rect), this.whiteBrush, canvasHairWidth); } if (this.handleShape == MoveHandleShape.Compass) { PointDouble num7 = location + ((PointDouble)(vecs[0] * ((this.handleDiameter - 1.0) * canvasHairWidth))); PointDouble point = location + ((PointDouble)(vecs[1] * ((this.handleDiameter - 1.0) * canvasHairWidth))); PointDouble num9 = location + ((PointDouble)(vecs[2] * ((this.handleDiameter - 1.0) * canvasHairWidth))); PointDouble num10 = location + ((PointDouble)(vecs[3] * ((this.handleDiameter - 1.0) * canvasHairWidth))); PointDouble num11 = new PointDouble(num7.X, (num7.Y + num10.Y) / 2.0); PointDouble num12 = new PointDouble((num7.X + point.X) / 2.0, num7.Y); PointDouble num13 = new PointDouble(point.X, (point.Y + num9.Y) / 2.0); PointDouble num14 = new PointDouble((num10.X + num9.X) / 2.0, num9.Y); PointDouble num15 = new PointDouble(num12.X, num11.Y); PathGeometry geometry = new PathGeometry(); PathFigure item = new PathFigure { IsClosed = true, IsFilled = true, StartPoint = num7 }; item.Segments.Add(new LineSegment(point)); item.Segments.Add(new LineSegment(num9)); item.Segments.Add(new LineSegment(num10)); geometry.Figures.Add(item); dc.FillGeometry(geometry, this.whiteBrush, null); PathGeometry geometry2 = new PathGeometry(); double num16 = canvasHairWidth; double num17 = 1.35 * canvasHairWidth; double num18 = (num17 * 3.0) / 2.0; double num19 = num16 / 2.0; double num20 = (num17 * Math.Sqrt(27.0)) / 2.0; PathFigure figure2 = new PathFigure { IsFilled = true, IsClosed = true, StartPoint = num11 }; figure2.Segments.Add(new LineSegment(new PointDouble(num11.X + num20, num11.Y + num18))); figure2.Segments.Add(new LineSegment(new PointDouble(num11.X + num20, num11.Y + num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num15.X - num19, num15.Y + num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num14.X - num19, num14.Y - num20))); figure2.Segments.Add(new LineSegment(new PointDouble(num14.X - num18, num14.Y - num20))); figure2.Segments.Add(new LineSegment(num14)); figure2.Segments.Add(new LineSegment(new PointDouble(num14.X + num18, num14.Y - num20))); figure2.Segments.Add(new LineSegment(new PointDouble(num14.X + num19, num14.Y - num20))); figure2.Segments.Add(new LineSegment(new PointDouble(num15.X + num19, num15.Y + num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num13.X - num20, num13.Y + num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num13.X - num20, num13.Y + num18))); figure2.Segments.Add(new LineSegment(num13)); figure2.Segments.Add(new LineSegment(new PointDouble(num13.X - num20, num13.Y - num18))); figure2.Segments.Add(new LineSegment(new PointDouble(num13.X - num20, num13.Y - num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num15.X + num19, num15.Y - num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num12.X + num19, num12.Y + num20))); figure2.Segments.Add(new LineSegment(new PointDouble(num12.X + num18, num12.Y + num20))); figure2.Segments.Add(new LineSegment(num12)); figure2.Segments.Add(new LineSegment(new PointDouble(num12.X - num18, num12.Y + num20))); figure2.Segments.Add(new LineSegment(new PointDouble(num12.X - num19, num12.Y + num20))); figure2.Segments.Add(new LineSegment(new PointDouble(num15.X - num19, num15.Y - num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num11.X + num20, num11.Y - num19))); figure2.Segments.Add(new LineSegment(new PointDouble(num11.X + num20, num11.Y - num18))); geometry2.Figures.Add(figure2); dc.FillGeometry(geometry2, this.blackBrush, null); } } base.OnRender(dc, clipRect, canvasView); }
private void DrawToDrawingContext(IDrawingContext dc) { RectInt32 rect = base.ClientRectangle.ToRectInt32(); dc.Clear(new ColorRgba128Float?(this.BackColor)); using (dc.UseTranslateTransform(0.5f, 0.5f, MatrixMultiplyOrder.Append)) { using (dc.UseAntialiasMode(AntialiasMode.PerPrimitive)) { RectInt32 num2 = RectInt32.Inflate(rect, -2, -2); int num3 = Math.Min(num2.Width, num2.Height); PointInt32 center = new PointInt32(num2.X + (num3 / 2), num2.Y + (num3 / 2)); double radius = ((double)num3) / 2.0; double scale = ((double)num3) / 3.0; double num7 = ((double)num3) / 2.0; double d = -MathUtil.DegreesToRadians(this.angle); double num9 = Math.Cos(d); double num10 = Math.Sin(d); double rx = (this.rollAmount * Math.Cos(MathUtil.DegreesToRadians(this.rollDirection))) / 90.0; double num12 = (this.rollAmount * Math.Sin(MathUtil.DegreesToRadians(this.rollDirection))) / 90.0; double num13 = rx / (((num12 * num12) < 0.99) ? Math.Sqrt(1.0 - (num12 * num12)) : 1.0); double num14 = num12 / (((rx * rx) < 0.99) ? Math.Sqrt(1.0 - (rx * rx)) : 1.0); double thickness = (this.mouseEntered && !this.onSphere) ? 2.0 : 1.0; if (this.ringOuterEllipseGeometry == null) { this.ringOuterEllipseGeometry = new EllipseGeometry(); } if (this.ringInnerEllipseGeometry == null) { this.ringInnerEllipseGeometry = new EllipseGeometry(); } if (this.ringFillGeometry == null) { this.ringFillGeometry = new CombinedGeometry(GeometryCombineMode.Exclude, this.ringOuterEllipseGeometry, this.ringInnerEllipseGeometry); } this.ringOuterEllipseGeometry.Center = center; this.ringOuterEllipseGeometry.RadiusX = radius - 0.5; this.ringOuterEllipseGeometry.RadiusY = radius - 0.5; this.ringInnerEllipseGeometry.Center = center; this.ringInnerEllipseGeometry.RadiusX = radius; this.ringInnerEllipseGeometry.RadiusY = radius; dc.FillGeometry(this.ringFillGeometry, ringFillBrush, null); if (this.ringOutlinePen == null) { this.ringOutlinePen = new PaintDotNet.UI.Media.Pen(); } this.ringOutlinePen.Brush = ringOutlineBrush; this.ringOutlinePen.Thickness = thickness; dc.DrawCircle(center, radius, this.ringOutlinePen); double num16 = (this.mouseEntered && !this.onSphere) ? ((double)2) : ((double)1); dc.DrawLine(center.X + (scale * num9), center.Y + (scale * num10), center.X + (num7 * num9), center.Y + (num7 * num10), thetaLineBrush, num16); using (dc.UseTranslateTransform((float)center.X, (float)center.Y, MatrixMultiplyOrder.Prepend)) { double num17 = (this.angle * 3.1415926535897931) / 180.0; float num18 = (this.mouseEntered && this.onSphere) ? 1.5f : 1f; int num19 = 0x18; for (int i = 0; i >= (-num19 / 2); i--) { double num22 = (i * 3.1415926535897931) / ((double)num19); double num23 = -num17 - 3.1415926535897931; double xs = Math.Cos(num23) * Math.Cos(num22); double ys = Math.Sin(num23) * Math.Cos(num22); double zs = Math.Sin(num22); double num30 = ((double)(i + (num19 / 2))) / ((double)(num19 / 2)); byte index = Int32Util.ClampToByte((int)(num30 * 255.0)); if (this.latBrushCache[index] == null) { ColorBgra bgra = ColorBgra.Blend(latGradStart, latGradEnd, index); this.latBrushCache[index] = SolidColorBrushCache.Get((ColorRgba128Float)bgra); } SolidColorBrush brush = this.latBrushCache[index]; for (int k = -num19 * 6; k <= (num19 * 6); k++) { num23 = -num17 + ((k * 3.1415926535897931) / ((double)(num19 * 6))); double num33 = Math.Cos(num22); double num34 = Math.Sin(num22); double xe = Math.Cos(num23) * Math.Cos(num22); double ye = Math.Sin(num23) * Math.Cos(num22); double ze = Math.Sin(num22); double num35 = (this.mouseEntered && this.onSphere) ? 1.5 : 1.0; this.Draw3DLine(dc, rx, -num12, scale, xs, ys, zs, xe, ye, ze, brush, num35); xs = xe; ys = ye; zs = ze; } } int num20 = 4; for (int j = -num20; j < num20; j++) { double num37 = -num17 + ((j * 3.1415926535897931) / ((double)num20)); double num38 = -1.5707963267948966; double num39 = Math.Cos(num37) * Math.Cos(num38); double num40 = Math.Sin(num37) * Math.Cos(num38); double num41 = Math.Sin(num38); for (int m = -num20 * 4; m <= 0; m++) { num38 = (m * 3.1415926535897931) / ((double)(num20 * 8)); double num42 = Math.Cos(num37) * Math.Cos(num38); double num43 = Math.Sin(num37) * Math.Cos(num38); double num44 = Math.Sin(num38); double num46 = (this.mouseEntered && this.onSphere) ? 2.0 : 1.0; this.Draw3DLine(dc, rx, -num12, scale, num39, num40, num41, num42, num43, num44, lightBrush, num46); num39 = num42; num40 = num43; num41 = num44; } } } dc.DrawCircle(center, scale, ringInlineBrush, thickness); } } }
public override void Render(IDrawingContext context) { var selectionStart = this.SelectionStart; var selectionEnd = this.SelectionEnd; if (selectionStart != selectionEnd) { var start = Math.Min(selectionStart, selectionEnd); var length = Math.Max(selectionStart, selectionEnd) - start; var rects = this.FormattedText.HitTestTextRange(start, length); var brush = new SolidColorBrush(0xff086f9e); foreach (var rect in rects) { context.FillRectange(brush, rect); } } base.Render(context); if (selectionStart == selectionEnd) { var charPos = this.FormattedText.HitTestTextPosition(this.CaretIndex); Brush caretBrush = Brushes.Black; if (this.caretBlink) { var x = Math.Floor(charPos.X) + 0.5; var y = Math.Floor(charPos.Y) + 0.5; var b = Math.Ceiling(charPos.Bottom) - 0.5; context.DrawLine( new Pen(caretBrush, 1), new Point(x, y), new Point(x, b)); } } }
public void Draw(IDrawingContext context) { context.DrawLine(_startPoint, _endPoint); }
/// <summary> /// /// </summary> /// <param name="dc"></param> /// <param name="pen"></param> /// <param name="isStroked"></param> /// <param name="p0"></param> /// <param name="p1"></param> private static void DrawLineInternal( IDrawingContext dc, Pen pen, bool isStroked, ref Point p0, ref Point p1) { if (isStroked) { dc.DrawLine(pen, p0, p1); } }