private Paint GetPaint(Primitives.Pen pen) { var paint = new Paint(PaintFlags.AntiAlias); paint.Color = new global::Android.Graphics.Color(pen.Color.R, pen.Color.G, pen.Color.B, pen.Color.A); return(paint); }
private Pen ConvertPen(Primitives.Pen pen) { Pen gdiPen; if (_penCache.ContainsKey(pen)) { gdiPen = _penCache[pen]; } else { gdiPen = new Pen(new SolidBrush(ConvertColor(pen.Color)), (float)pen.Thickness); _penCache.Add(pen, gdiPen); } return(gdiPen); }
private Pen ConvertPen(Primitives.Pen pen) { Pen wpfPen; if (_penCache.ContainsKey(pen)) { wpfPen = _penCache[pen]; } else { wpfPen = new Pen(new SolidColorBrush(ConvertColor(pen.Color)), pen.Thickness); _penCache.Add(pen, wpfPen); } return(wpfPen); }
public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, MusicalSymbol owner) { }
public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, Model.MusicalSymbol owner) { using (var paint = GetPaint(pen)) { Canvas.DrawLine((float)startPoint.X, (float)startPoint.Y, (float)endPoint.X, (float)endPoint.Y, paint); } }
public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, MusicalSymbol owner) { renderingQueue.Enqueue(() => base.DrawBezier(p1, p2, p3, p4, pen, owner)); if (renderingQueue.Count > BufferSize) { FlushBuffer(); } }
public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama) { p1 = p1.Translate(CurrentScore.DefaultPageSettings); p2 = p2.Translate(CurrentScore.DefaultPageSettings); p3 = p3.Translate(CurrentScore.DefaultPageSettings); p4 = p4.Translate(CurrentScore.DefaultPageSettings); } Canvas.DrawBezier(ConvertPen(pen), new PointF((float)p1.X, (float)p1.Y), new PointF((float)p2.X, (float)p2.Y), new PointF((float)p3.X, (float)p3.Y), new PointF((float)p4.X, (float)p4.Y)); }
public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama) { p1 = p1.Translate(CurrentScore.DefaultPageSettings); p2 = p2.Translate(CurrentScore.DefaultPageSettings); p3 = p3.Translate(CurrentScore.DefaultPageSettings); p4 = p4.Translate(CurrentScore.DefaultPageSettings); } var bezierCurve = new BezierCurve(); bezierCurve.Thickness = pen.Thickness; bezierCurve.Color = pen.Color; bezierCurve.TranslationX = p1.X; bezierCurve.TranslationY = p1.Y; bezierCurve.X2 = p2.X; bezierCurve.Y2 = p2.Y; bezierCurve.X3 = p3.X; bezierCurve.Y3 = p3.Y; bezierCurve.X4 = p4.X; bezierCurve.Y4 = p4.Y; Canvas.Children.Add(bezierCurve); OwnershipDictionary.Add(bezierCurve, owner); }
public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner) { if (Settings.RenderingMode != ScoreRenderingModes.Panorama) { startPoint = startPoint.Translate(CurrentScore.DefaultPageSettings); endPoint = endPoint.Translate(CurrentScore.DefaultPageSettings); } var line = new Line(); line.TranslationX = startPoint.X; line.TranslationY = startPoint.Y; line.EndX = endPoint.X; line.EndY = endPoint.Y; line.Color = pen.Color; line.Thickness = pen.Thickness; Canvas.Children.Add(line); OwnershipDictionary.Add(line, owner); }
/// <summary> /// Adds a bezier curve to HTML canvas /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <param name="p3"></param> /// <param name="p4"></param> /// <param name="pen"></param> /// <param name="owner"></param> public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, Model.MusicalSymbol owner) { Canvas.AppendLine("context.beginPath();"); Canvas.AppendLine(string.Format("context.moveTo({0}, {1});", p1.X.ToStringInvariant(), p1.Y.ToStringInvariant())); Canvas.AppendLine(string.Format("context.bezierCurveTo({0},{1},{2},{3},{4},{5});", p2.X.ToStringInvariant(), p2.Y.ToStringInvariant(), p3.X.ToStringInvariant(), p3.Y.ToStringInvariant(), p4.X.ToStringInvariant(), p4.Y.ToStringInvariant())); Canvas.AppendLine("context.stroke();"); if (p4.X > ActualWidth) { ActualWidth = p4.X; } if (p1.Y > ActualHeight) { ActualHeight = p1.Y; } }
/// <summary> /// Ads arc to HTML canvas /// </summary> /// <param name="rect"></param> /// <param name="startAngle"></param> /// <param name="sweepAngle"></param> /// <param name="pen"></param> /// <param name="owner"></param> public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, Model.MusicalSymbol owner) { Canvas.AppendLine("context.beginPath();"); Canvas.AppendLine(string.Format("context.arc({0},{1},{2},{3},{4});", rect.X.ToStringInvariant(), rect.Y.ToStringInvariant(), rect.Height.ToStringInvariant(), UsefulMath.GradToRadians(startAngle).ToStringInvariant(), UsefulMath.GradToRadians(sweepAngle).ToStringInvariant())); Canvas.AppendLine("context.stroke();"); if (rect.X + rect.Width > ActualWidth) { ActualWidth = rect.X + rect.Width; } if (rect.Y + rect.Height > ActualHeight) { ActualHeight = rect.Y + rect.Height; } }
/// <summary> /// Adds a line to HTML canvas /// </summary> /// <param name="startPoint"></param> /// <param name="endPoint"></param> /// <param name="pen"></param> /// <param name="owner"></param> public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, Model.MusicalSymbol owner) { Canvas.AppendLine("context.beginPath();"); Canvas.AppendLine(string.Format("context.moveTo({0}, {1});", startPoint.X.ToStringInvariant(), startPoint.Y.ToStringInvariant())); Canvas.AppendLine(string.Format("context.lineTo({0}, {1});", endPoint.X.ToStringInvariant(), endPoint.Y.ToStringInvariant())); Canvas.AppendLine("context.stroke();"); if (startPoint.X > ActualWidth) { ActualWidth = startPoint.X; } if (endPoint.X > ActualWidth) { ActualWidth = endPoint.X; } if (startPoint.Y > ActualHeight) { ActualHeight = startPoint.Y; } if (endPoint.Y > ActualHeight) { ActualHeight = endPoint.Y; } }
public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner) { var line = new Line(); line.Stroke = new SolidColorBrush(ConvertColor(pen.Color)); line.UseLayoutRounding = true; line.X1 = startPoint.X; line.X2 = endPoint.X; line.Y1 = startPoint.Y; line.Y2 = endPoint.Y; System.Windows.Controls.Canvas.SetZIndex(line, (int)pen.ZIndex); line.StrokeThickness = pen.Thickness; line.Visibility = BoolToVisibility(owner.IsVisible); Canvas.Children.Add(line); OwnershipDictionary.Add(line, owner); }
public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, MusicalSymbol owner) { PathGeometry pathGeom = new PathGeometry(); PathFigure pf = new PathFigure(); pf.StartPoint = new Point(p1.X, p1.Y); BezierSegment bezierSegment = new BezierSegment(); bezierSegment.Point1 = ConvertPoint(p2); bezierSegment.Point2 = ConvertPoint(p3); bezierSegment.Point3 = ConvertPoint(p4); pf.Segments.Add(bezierSegment); pathGeom.Figures.Add(pf); Path path = new Path(); path.Stroke = new SolidColorBrush(ConvertColor(pen.Color)); path.StrokeThickness = pen.Thickness; path.Data = pathGeom; path.Visibility = BoolToVisibility(owner.IsVisible); System.Windows.Controls.Canvas.SetZIndex(path, (int)pen.ZIndex); Canvas.Children.Add(path); OwnershipDictionary.Add(path, owner); }
public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner) { Canvas.DrawLine(ConvertPen(pen), ConvertPoint(startPoint), ConvertPoint(endPoint)); }
public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner) { startPoint = startPoint.Translate(CurrentScore.DefaultPageSettings); endPoint = endPoint.Translate(CurrentScore.DefaultPageSettings); var line = new Line(); line.Stroke = new SolidColorBrush(ConvertColor(pen.Color)); line.UseLayoutRounding = true; line.X1 = startPoint.X; line.X2 = endPoint.X; line.Y1 = startPoint.Y; line.Y2 = endPoint.Y; Canvas.SetZIndex(line, (int)pen.ZIndex); line.StrokeThickness = pen.Thickness; line.Visibility = BoolToVisibility(owner.IsVisible); Canvas.Children.Add(line); OwnershipDictionary.Add(line, owner); }
public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, MusicalSymbol owner) { rect = rect.Translate(CurrentScore.DefaultPageSettings); PathGeometry pathGeom = new PathGeometry(); PathFigure pf = new PathFigure(); pf.StartPoint = new Point(rect.X, rect.Y); ArcSegment arcSeg = new ArcSegment(); arcSeg.Point = new Point(rect.X + rect.Width, rect.Y); arcSeg.RotationAngle = startAngle; arcSeg.Size = new Size(rect.Width, rect.Height); arcSeg.SweepDirection = sweepAngle < 180 ? SweepDirection.Counterclockwise : SweepDirection.Clockwise; arcSeg.IsLargeArc = sweepAngle > 180; pf.Segments.Add(arcSeg); pathGeom.Figures.Add(pf); Path path = new Path(); path.Stroke = new SolidColorBrush(ConvertColor(pen.Color)); path.StrokeThickness = pen.Thickness; path.Data = pathGeom; path.Visibility = BoolToVisibility(owner.IsVisible); Windows.UI.Xaml.Controls.Canvas.SetZIndex(path, (int)pen.ZIndex); Canvas.Children.Add(path); OwnershipDictionary.Add(path, owner); }
public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama) { rect = rect.Translate(CurrentScore.DefaultPageSettings); } var arc = new Arc(); arc.TranslationX = rect.X; arc.TranslationY = rect.Y; arc.RX = rect.Width; arc.RY = rect.Height; arc.Thickness = pen.Thickness; arc.StartAngle = startAngle; arc.SweepAngle = sweepAngle; arc.Color = pen.Color; Canvas.Children.Add(arc); OwnershipDictionary.Add(arc, owner); }
public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama) { p1 = p1.Translate(CurrentScore.DefaultPageSettings); p2 = p2.Translate(CurrentScore.DefaultPageSettings); p3 = p3.Translate(CurrentScore.DefaultPageSettings); p4 = p4.Translate(CurrentScore.DefaultPageSettings); } PathGeometry pathGeom = new PathGeometry(); PathFigure pf = new PathFigure(); pf.StartPoint = new Point(p1.X, p1.Y); BezierSegment bezierSegment = new BezierSegment(); bezierSegment.Point1 = ConvertPoint(p2); bezierSegment.Point2 = ConvertPoint(p3); bezierSegment.Point3 = ConvertPoint(p4); pf.Segments.Add(bezierSegment); pathGeom.Figures.Add(pf); Path path = new Path(); path.Stroke = new SolidColorBrush(ConvertColor(pen.Color)); path.StrokeThickness = pen.Thickness; path.Data = pathGeom; path.Visibility = BoolToVisibility(owner.IsVisible); Canvas.Children.Add(path); OwnershipDictionary.Add(path, owner); }
public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama) { startPoint = startPoint.Translate(CurrentScore.DefaultPageSettings); endPoint = endPoint.Translate(CurrentScore.DefaultPageSettings); } Canvas.DrawLine(ConvertPen(pen), new PointF((float)startPoint.X, (float)startPoint.Y), new PointF((float)endPoint.X, (float)endPoint.Y)); }
public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama) { startPoint = startPoint.Translate(CurrentScore.DefaultPageSettings); endPoint = endPoint.Translate(CurrentScore.DefaultPageSettings); } var line = new Line(); line.Stroke = new SolidColorBrush(ConvertColor(pen.Color)); line.X1 = startPoint.X; line.X2 = endPoint.X; line.Y1 = startPoint.Y; line.Y2 = endPoint.Y; line.StrokeThickness = pen.Thickness; line.Visibility = BoolToVisibility(owner.IsVisible); Canvas.Children.Add(line); OwnershipDictionary.Add(line, owner); }
public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama) { rect = rect.Translate(CurrentScore.DefaultPageSettings); } Canvas.DrawArc(ConvertPen(pen), new RectangleF((float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height), (float)startAngle, (float)sweepAngle); }
public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama) { rect = rect.Translate(CurrentScore.DefaultPageSettings); } if (rect.Width < 0 || rect.Height < 0) { return; //TODO: Sprawdzić czemu tak się dzieje, poprawić } PathGeometry pathGeom = new PathGeometry(); PathFigure pf = new PathFigure(); pf.StartPoint = new Point(rect.X, rect.Y); ArcSegment arcSeg = new ArcSegment(); arcSeg.Point = new Point(rect.X + rect.Width, rect.Y); arcSeg.RotationAngle = startAngle; arcSeg.Size = new Size(rect.Width, rect.Height); arcSeg.SweepDirection = sweepAngle < 180 ? SweepDirection.Counterclockwise : SweepDirection.Clockwise; arcSeg.IsLargeArc = sweepAngle > 180; pf.Segments.Add(arcSeg); pathGeom.Figures.Add(pf); Path path = new Path(); path.Stroke = new SolidColorBrush(ConvertColor(pen.Color)); path.StrokeThickness = pen.Thickness; path.Data = pathGeom; path.Visibility = BoolToVisibility(owner.IsVisible); Canvas.Children.Add(path); OwnershipDictionary.Add(path, owner); }
public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, MusicalSymbol owner) { renderingQueue.Enqueue(() => base.DrawArc(rect, startAngle, sweepAngle, pen, owner)); if (renderingQueue.Count > BufferSize) { FlushBuffer(); } }
public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, MusicalSymbol owner) { PathGeometry pathGeom = new PathGeometry(); PathFigure pf = new PathFigure(); pf.StartPoint = new Point(rect.X, rect.Y); ArcSegment arcSeg = new ArcSegment(new Point(rect.X, rect.Y), new Size(rect.Width, rect.Height), startAngle, false, SweepDirection.Clockwise, true); pf.Segments.Add(arcSeg); pathGeom.Figures.Add(pf); Canvas.DrawGeometry(null, ConvertPen(pen), pathGeom); }
public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, MusicalSymbol owner) { renderingQueue.Enqueue(() => base.DrawLine(startPoint, endPoint, pen, owner)); if (renderingQueue.Count > BufferSize) { FlushBuffer(); } }
public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, Model.MusicalSymbol owner) { }