diff --git a/Source/Examples/Xamarin.Forms/SimpleDemo/SimpleDemo/App.xaml.cs b/Source/Examples/Xamarin.Forms/SimpleDemo/SimpleDemo/App.xaml.cs index 40fe792..28bf121 100644 --- a/Source/Examples/Xamarin.Forms/SimpleDemo/SimpleDemo/App.xaml.cs +++ b/Source/Examples/Xamarin.Forms/SimpleDemo/SimpleDemo/App.xaml.cs @@ -24,23 +24,25 @@ public App() { Model = new PlotModel { - Title = "OxyPlot in Xamarin Forms.", + Title = "OxyPlot in Xamarin.Forms", Axes = { - new CategoryAxis {Position = AxisPosition.Bottom}, - new LinearAxis {Position = AxisPosition.Left, MinimumPadding = 0} + new CategoryAxis {Position = AxisPosition.Bottom, Key = "Y" }, + new LinearAxis {Position = AxisPosition.Left, Key = "X", MinimumPadding = 0} }, Series = { - new ColumnSeries + new BarSeries { + XAxisKey = "X", + YAxisKey = "Y", Items = { - new ColumnItem {Value = 3}, - new ColumnItem {Value = 14}, - new ColumnItem {Value = 11}, - new ColumnItem {Value = 12}, - new ColumnItem {Value = 7} + new BarItem {Value = 3}, + new BarItem {Value = 14}, + new BarItem {Value = 11}, + new BarItem {Value = 12}, + new BarItem {Value = 7} } } } diff --git a/Source/Examples/Xamarin.Forms/SimpleDemo/SimpleDemo/SimpleDemo.csproj b/Source/Examples/Xamarin.Forms/SimpleDemo/SimpleDemo/SimpleDemo.csproj index 1125e9f..5ce42dc 100644 --- a/Source/Examples/Xamarin.Forms/SimpleDemo/SimpleDemo/SimpleDemo.csproj +++ b/Source/Examples/Xamarin.Forms/SimpleDemo/SimpleDemo/SimpleDemo.csproj @@ -3,7 +3,7 @@ netstandard2.0 - + diff --git a/Source/OxyPlot.Windows/OxyPlot.Windows.csproj b/Source/OxyPlot.Windows/OxyPlot.Windows.csproj index 39d0ed0..8b3ad73 100644 --- a/Source/OxyPlot.Windows/OxyPlot.Windows.csproj +++ b/Source/OxyPlot.Windows/OxyPlot.Windows.csproj @@ -16,6 +16,6 @@ - + diff --git a/Source/OxyPlot.Windows/PlotView.cs b/Source/OxyPlot.Windows/PlotView.cs index 976d110..03bae3f 100644 --- a/Source/OxyPlot.Windows/PlotView.cs +++ b/Source/OxyPlot.Windows/PlotView.cs @@ -914,7 +914,8 @@ private void UpdateVisuals() if (this.ActualModel != null) { - ((IPlotModel)this.ActualModel).Render(this.renderContext, this.canvas.ActualWidth, this.canvas.ActualHeight); + OxyRect rect = new OxyRect(0, 0, canvas.ActualWidth, canvas.ActualHeight); + ((IPlotModel)this.ActualModel).Render(this.renderContext, rect); } } diff --git a/Source/OxyPlot.Windows/RenderContext.cs b/Source/OxyPlot.Windows/RenderContext.cs index 5dc685a..1768439 100644 --- a/Source/OxyPlot.Windows/RenderContext.cs +++ b/Source/OxyPlot.Windows/RenderContext.cs @@ -29,7 +29,7 @@ namespace OxyPlot.Windows /// /// Implements for . /// - public class RenderContext : IRenderContext + public class RenderContext : ClippingRenderContext { /// /// The brush cache. @@ -102,12 +102,6 @@ public bool PaintBackground /// The width. public double Width { get; private set; } - /// - /// Gets or sets a value indicating whether the context renders to screen. - /// - /// true if the context renders to screen; otherwise, false. - public bool RendersToScreen { get; set; } - /// /// Draws an ellipse. /// @@ -185,20 +179,14 @@ public void DrawEllipses(IList rectangles, OxyColor fill, OxyColor stro /// The stroke thickness. /// The dash array. /// The line join type. - /// if set to true the shape will be aliased. - public void DrawLine( - IList points, - OxyColor stroke, - double thickness, - double[] dashArray, - LineJoin lineJoin, - bool aliased) + public override void DrawLine(IList points, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin) { var e = new Polyline { CompositeMode = ElementCompositeMode.SourceOver }; + bool aliased = this.ShouldUseAntiAliasingForLine(erm, points); this.SetStroke(e, stroke, thickness, lineJoin, dashArray, aliased); var pc = new PointCollection(); @@ -270,20 +258,14 @@ public void DrawLineSegments( /// The dash array. /// The line join type. /// if set to true the shape will be aliased. - public void DrawPolygon( - IList points, - OxyColor fill, - OxyColor stroke, - double thickness, - double[] dashArray, - LineJoin lineJoin, - bool aliased) + public override void DrawPolygon(IList points, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin) { var po = new Polygon { CompositeMode = ElementCompositeMode.SourceOver }; + bool aliased = this.ShouldUseAntiAliasingForLine(erm, points); this.SetStroke(po, stroke, thickness, lineJoin, dashArray, aliased); if (fill.IsVisible()) @@ -434,7 +416,7 @@ public void DrawRectangles(IList rectangles, OxyColor fill, OxyColor st /// The horizontal alignment. /// The vertical alignment. /// The maximum size of the text. - public void DrawText( + public override void DrawText( ScreenPoint p, string text, OxyColor fill, @@ -532,7 +514,7 @@ public void DrawText( /// Size of the font. /// The font weight. /// The text size. - public OxySize MeasureText(string text, string fontFamily, double fontSize, double fontWeight) + public override OxySize MeasureText(string text, string fontFamily, double fontSize, double fontWeight) { if (string.IsNullOrEmpty(text)) { @@ -562,7 +544,7 @@ public OxySize MeasureText(string text, string fontFamily, double fontSize, doub /// Sets the tool tip for the following items. /// /// The text in the tooltip. - public void SetToolTip(string text) + public override void SetToolTip(string text) { this.currentToolTip = text; } @@ -581,7 +563,7 @@ public void SetToolTip(string text) /// The height of the drawn image. /// The opacity. /// interpolate if set to true. - public void DrawImage( + public override void DrawImage( OxyImage source, double srcX, double srcY, @@ -633,17 +615,16 @@ public void DrawImage( /// /// The clipping rectangle. /// True if the clipping rectangle was set. - public bool SetClip(OxyRect clippingRect) + protected override void SetClip(OxyRect clippingRect) { this.clipRect = clippingRect.ToRect(false); this.clip = true; - return true; } /// /// Resets the clipping rectangle. /// - public void ResetClip() + protected override void ResetClip() { this.clip = false; } @@ -652,7 +633,7 @@ public void ResetClip() /// Cleans up resources not in use. /// /// This method is called at the end of each rendering. - public void CleanUp() + public override void CleanUp() { // Find the images in the cache that has not been used since last call to this method var imagesToRelease = this.imageCache.Keys.Where(i => !this.imagesInUse.Contains(i)).ToList(); diff --git a/Source/OxyPlot.Xamarin.Android/CanvasRenderContext.cs b/Source/OxyPlot.Xamarin.Android/CanvasRenderContext.cs index 8ebabea..a14a2d6 100644 --- a/Source/OxyPlot.Xamarin.Android/CanvasRenderContext.cs +++ b/Source/OxyPlot.Xamarin.Android/CanvasRenderContext.cs @@ -17,7 +17,7 @@ namespace OxyPlot.Xamarin.Android /// /// Provides a render context for Android.Graphics.Canvas. /// - public class CanvasRenderContext : RenderContextBase + public class CanvasRenderContext : ClippingRenderContext { /// /// The images in use @@ -96,10 +96,11 @@ public void SetTarget(Canvas c) /// The fill color. /// The stroke color. /// The thickness. - public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness) + public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm) { this.paint.Reset(); { + bool aliased = this.ShouldUseAntiAliasingForEllipse(erm); if (fill.IsVisible()) { this.SetFill(fill); @@ -108,7 +109,7 @@ public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, d if (stroke.IsVisible()) { - this.SetStroke(stroke, thickness); + this.SetStroke(stroke, thickness, aliased: aliased); this.canvas.DrawOval(this.Convert(rect), this.paint); } } @@ -122,10 +123,11 @@ public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, d /// The fill color. /// The stroke color. /// The stroke thickness. - public override void DrawEllipses(IList rectangles, OxyColor fill, OxyColor stroke, double thickness) + public override void DrawEllipses(IList rectangles, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm) { this.paint.Reset(); { + bool aliased = this.ShouldUseAntiAliasingForEllipse(erm); foreach (var rect in rectangles) { if (fill.IsVisible()) @@ -136,7 +138,7 @@ public override void DrawEllipses(IList rectangles, OxyColor fill, OxyC if (stroke.IsVisible()) { - this.SetStroke(stroke, thickness); + this.SetStroke(stroke, thickness, aliased: aliased); this.canvas.DrawOval(this.Convert(rect), this.paint); } } @@ -151,13 +153,13 @@ public override void DrawEllipses(IList rectangles, OxyColor fill, OxyC /// The stroke thickness. /// The dash array. /// The line join type. - /// if set to true the shape will be aliased. - public override void DrawLine(IList points, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased) + public override void DrawLine(IList points, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin) { this.paint.Reset(); { this.path.Reset(); { + bool aliased = this.ShouldUseAntiAliasingForLine(erm, points); this.SetPath(points, aliased); this.SetStroke(stroke, thickness, dashArray, lineJoin, aliased); this.canvas.DrawPath(this.path, this.paint); @@ -175,10 +177,11 @@ public override void DrawLine(IList points, OxyColor stroke, double /// The dash array. /// The line join type. /// If set to true the shape will be aliased. - public override void DrawLineSegments(IList points, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased) + public override void DrawLineSegments(IList points, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin) { this.paint.Reset(); { + bool aliased = this.ShouldUseAntiAliasingForLine(erm, points); this.SetStroke(stroke, thickness, dashArray, lineJoin, aliased); this.pts.Clear(); if (aliased) @@ -212,12 +215,13 @@ public override void DrawLineSegments(IList points, OxyColor stroke /// The dash array. /// The line join type. /// If set to true the shape will be aliased. - public override void DrawPolygon(IList points, OxyColor fill, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased) + public override void DrawPolygon(IList points, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin) { this.paint.Reset(); { this.path.Reset(); { + bool aliased = this.ShouldUseAntiAliasingForLine(erm, points); this.SetPath(points, aliased); this.path.Close(); @@ -243,20 +247,27 @@ public override void DrawPolygon(IList points, OxyColor fill, OxyCo /// The fill color. /// The stroke color. /// The stroke thickness. - public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness) + public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm) { this.paint.Reset(); { + bool aliased = this.ShouldUseAntiAliasingForRect(erm); if (fill.IsVisible()) { this.SetFill(fill); - this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint); + if (aliased) + this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint); + else + this.canvas.DrawRect(this.Convert(rect.Left), this.Convert(rect.Top), this.Convert(rect.Right), this.Convert(rect.Bottom), this.paint); } if (stroke.IsVisible()) { - this.SetStroke(stroke, thickness, aliased: true); - this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint); + this.SetStroke(stroke, thickness, aliased: aliased); + if (aliased) + this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint); + else + this.canvas.DrawRect(this.Convert(rect.Left), this.Convert(rect.Top), this.Convert(rect.Right), this.Convert(rect.Bottom), this.paint); } } } @@ -366,17 +377,16 @@ public override OxySize MeasureText(string text, string fontFamily, double fontS /// /// The clip rectangle. /// True if the clip rectangle was set. - public override bool SetClip(OxyRect rect) + protected override void SetClip(OxyRect rect) { this.canvas.Save(); this.canvas.ClipRect(this.Convert(rect)); - return true; } /// /// Resets the clip rectangle. /// - public override void ResetClip() + protected override void ResetClip() { this.canvas.Restore(); } diff --git a/Source/OxyPlot.Xamarin.Android/OxyPlot.Xamarin.Android.csproj b/Source/OxyPlot.Xamarin.Android/OxyPlot.Xamarin.Android.csproj index 6eaa098..e5db9e7 100644 --- a/Source/OxyPlot.Xamarin.Android/OxyPlot.Xamarin.Android.csproj +++ b/Source/OxyPlot.Xamarin.Android/OxyPlot.Xamarin.Android.csproj @@ -73,7 +73,7 @@ all - 2.0.0 + 2.1.0 4.3.0 diff --git a/Source/OxyPlot.Xamarin.Android/PlotView.cs b/Source/OxyPlot.Xamarin.Android/PlotView.cs index 68d2183..00aae6a 100644 --- a/Source/OxyPlot.Xamarin.Android/PlotView.cs +++ b/Source/OxyPlot.Xamarin.Android/PlotView.cs @@ -354,8 +354,9 @@ protected override void OnDraw(Canvas canvas) } this.rc.SetTarget(canvas); - - ((IPlotModel)actualModel).Render(this.rc, Width / Scale, Height / Scale); + + OxyRect rect = new OxyRect(0, 0, Width / Scale, Height / Scale); + ((IPlotModel)actualModel).Render(this.rc, rect); } } diff --git a/Source/OxyPlot.Xamarin.Forms.Platform.Android/OxyPlot.Xamarin.Forms.Platform.Android.csproj b/Source/OxyPlot.Xamarin.Forms.Platform.Android/OxyPlot.Xamarin.Forms.Platform.Android.csproj index 471552f..bd851e0 100644 --- a/Source/OxyPlot.Xamarin.Forms.Platform.Android/OxyPlot.Xamarin.Forms.Platform.Android.csproj +++ b/Source/OxyPlot.Xamarin.Forms.Platform.Android/OxyPlot.Xamarin.Forms.Platform.Android.csproj @@ -59,7 +59,7 @@ - + @@ -85,4 +85,4 @@ - \ No newline at end of file + diff --git a/Source/OxyPlot.Xamarin.Forms.Platform.MacOS/OxyPlot.Xamarin.Forms.Platform.MacOS.csproj b/Source/OxyPlot.Xamarin.Forms.Platform.MacOS/OxyPlot.Xamarin.Forms.Platform.MacOS.csproj index 44f93ba..b2563ab 100644 --- a/Source/OxyPlot.Xamarin.Forms.Platform.MacOS/OxyPlot.Xamarin.Forms.Platform.MacOS.csproj +++ b/Source/OxyPlot.Xamarin.Forms.Platform.MacOS/OxyPlot.Xamarin.Forms.Platform.MacOS.csproj @@ -64,6 +64,7 @@ + @@ -74,16 +75,14 @@ - + + 0.2.2 runtime; build; native; contentfiles; analyzers; buildtransitive all - - 5.0.0.2545 - @@ -100,4 +99,4 @@ - \ No newline at end of file + diff --git a/Source/OxyPlot.Xamarin.Forms.Platform.UWP/OxyPlot.Xamarin.Forms.Platform.UWP.csproj b/Source/OxyPlot.Xamarin.Forms.Platform.UWP/OxyPlot.Xamarin.Forms.Platform.UWP.csproj index 67170ec..46b7450 100644 --- a/Source/OxyPlot.Xamarin.Forms.Platform.UWP/OxyPlot.Xamarin.Forms.Platform.UWP.csproj +++ b/Source/OxyPlot.Xamarin.Forms.Platform.UWP/OxyPlot.Xamarin.Forms.Platform.UWP.csproj @@ -123,7 +123,7 @@ 6.2.12 - 2.0.0 + 2.1.0 5.0.0.2545 diff --git a/Source/OxyPlot.Xamarin.Forms.Platform.iOS/OxyPlot.Xamarin.Forms.Platform.iOS.csproj b/Source/OxyPlot.Xamarin.Forms.Platform.iOS/OxyPlot.Xamarin.Forms.Platform.iOS.csproj index f33e41c..53c14d2 100644 --- a/Source/OxyPlot.Xamarin.Forms.Platform.iOS/OxyPlot.Xamarin.Forms.Platform.iOS.csproj +++ b/Source/OxyPlot.Xamarin.Forms.Platform.iOS/OxyPlot.Xamarin.Forms.Platform.iOS.csproj @@ -63,7 +63,7 @@ - + 0.2.2 runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Source/OxyPlot.Xamarin.Forms.nuspec b/Source/OxyPlot.Xamarin.Forms.nuspec index 9010f52..f9a6b00 100644 --- a/Source/OxyPlot.Xamarin.Forms.nuspec +++ b/Source/OxyPlot.Xamarin.Forms.nuspec @@ -3,7 +3,7 @@ OxyPlot.Xamarin.Forms OxyPlot for Xamarin (Android, iOS, Mac and UWP) - 2.0.0 + 2.1.0 Oystein Bjorke, Janus Weil OxyPlot is a plotting library for .NET. This package includes a portable library for Xamarin.Forms apps and platform-specific libraries for Android, iOS, Mac and UWP. @@ -16,27 +16,27 @@ plotting plot charting chart xamarin forms android ios mac uwp - + - + - + - + - + diff --git a/Source/OxyPlot.Xamarin.Forms/OxyPlot.Xamarin.Forms.csproj b/Source/OxyPlot.Xamarin.Forms/OxyPlot.Xamarin.Forms.csproj index 1785536..3f30d89 100644 --- a/Source/OxyPlot.Xamarin.Forms/OxyPlot.Xamarin.Forms.csproj +++ b/Source/OxyPlot.Xamarin.Forms/OxyPlot.Xamarin.Forms.csproj @@ -16,7 +16,7 @@ - + diff --git a/Source/OxyPlot.Xamarin.Mac/CoreGraphicsRenderContext.cs b/Source/OxyPlot.Xamarin.Mac/CoreGraphicsRenderContext.cs index 5dab461..668957c 100644 --- a/Source/OxyPlot.Xamarin.Mac/CoreGraphicsRenderContext.cs +++ b/Source/OxyPlot.Xamarin.Mac/CoreGraphicsRenderContext.cs @@ -21,7 +21,7 @@ namespace OxyPlot.Xamarin.Mac /// /// Implements a for CoreGraphics. /// - public class CoreGraphicsRenderContext : RenderContextBase, IDisposable + public class CoreGraphicsRenderContext : ClippingRenderContext, IDisposable { /// /// The images in use. @@ -69,10 +69,11 @@ public CoreGraphicsRenderContext (CGContext context) /// The fill color. /// The stroke color. /// The thickness. - public override void DrawEllipse (OxyRect rect, OxyColor fill, OxyColor stroke, double thickness) + public override void DrawEllipse (OxyRect rect, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm) { - this.SetAlias (false); - var convertedRectangle = rect.Convert (); + bool aliased = this.ShouldUseAntiAliasingForEllipse(erm); + this.SetAlias (aliased); + var convertedRectangle = aliased ? rect.ConvertAliased() : rect.Convert (); if (fill.IsVisible ()) { this.SetFill (fill); using (var path = new CGPath ()) { @@ -150,17 +151,16 @@ public override void CleanUp () /// /// The clip rectangle. /// True if the clip rectangle was set. - public override bool SetClip (OxyRect rect) + protected override void SetClip (OxyRect rect) { this.gctx.SaveState (); this.gctx.ClipToRect (rect.Convert ()); - return true; } /// /// Resets the clip rectangle. /// - public override void ResetClip () + protected override void ResetClip () { this.gctx.RestoreState (); } @@ -173,10 +173,10 @@ public override void ResetClip () /// The stroke thickness. /// The dash array. /// The line join type. - /// if set to true the shape will be aliased. - public override void DrawLine (IList points, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased) + public override void DrawLine (IList points, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin) { if (stroke.IsVisible () && thickness > 0) { + bool aliased = this.ShouldUseAntiAliasingForLine(erm, points); this.SetAlias (aliased); this.SetStroke (stroke, thickness, dashArray, lineJoin); @@ -199,9 +199,9 @@ public override void DrawLine (IList points, OxyColor stroke, doubl /// The stroke thickness. /// The dash array. /// The line join type. - /// If set to true the shape will be aliased. - public override void DrawPolygon (IList points, OxyColor fill, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased) + public override void DrawPolygon (IList points, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin) { + bool aliased = this.ShouldUseAntiAliasingForLine(erm, points); this.SetAlias (aliased); var convertedPoints = (aliased ? points.Select (p => p.ConvertAliased ()) : points.Select (p => p.Convert ())).ToArray (); if (fill.IsVisible ()) { @@ -235,10 +235,11 @@ public override void DrawPolygon (IList points, OxyColor fill, OxyC /// The fill color. /// The stroke color. /// The stroke thickness. - public override void DrawRectangle (OxyRect rect, OxyColor fill, OxyColor stroke, double thickness) + public override void DrawRectangle (OxyRect rect, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm) { - this.SetAlias (true); - var convertedRect = rect.ConvertAliased (); + bool aliased = this.ShouldUseAntiAliasingForRect(erm); + this.SetAlias (aliased); + var convertedRect = aliased ? rect.ConvertAliased () : rect.Convert(); if (fill.IsVisible ()) { this.SetFill (fill); diff --git a/Source/OxyPlot.Xamarin.Mac/OxyPlot.Xamarin.Mac.csproj b/Source/OxyPlot.Xamarin.Mac/OxyPlot.Xamarin.Mac.csproj index 2163d5f..82c5c3c 100644 --- a/Source/OxyPlot.Xamarin.Mac/OxyPlot.Xamarin.Mac.csproj +++ b/Source/OxyPlot.Xamarin.Mac/OxyPlot.Xamarin.Mac.csproj @@ -66,6 +66,7 @@ + @@ -88,7 +89,7 @@ all - 2.0.0 + 2.1.0 4.3.0 diff --git a/Source/OxyPlot.Xamarin.Mac/PlotView.cs b/Source/OxyPlot.Xamarin.Mac/PlotView.cs index d25084f..66f1634 100644 --- a/Source/OxyPlot.Xamarin.Mac/PlotView.cs +++ b/Source/OxyPlot.Xamarin.Mac/PlotView.cs @@ -300,8 +300,9 @@ public override void DrawRect(CoreGraphics.CGRect dirtyRect) // TODO: scale font matrix?? using (var renderer = new CoreGraphicsRenderContext(context)) { - ((IPlotModel)this.model).Render(renderer, dirtyRect.Width, dirtyRect.Height); - } + OxyRect orect = new OxyRect(0, 0, dirtyRect.Width, dirtyRect.Height); + ((IPlotModel)this.model).Render(renderer, orect); + } } } diff --git a/Source/OxyPlot.Xamarin.iOS/CoreGraphicsRenderContext.cs b/Source/OxyPlot.Xamarin.iOS/CoreGraphicsRenderContext.cs index a26d239..78c5ea9 100644 --- a/Source/OxyPlot.Xamarin.iOS/CoreGraphicsRenderContext.cs +++ b/Source/OxyPlot.Xamarin.iOS/CoreGraphicsRenderContext.cs @@ -21,7 +21,7 @@ namespace OxyPlot.Xamarin.iOS /// /// Implements a for CoreGraphics. /// - public class CoreGraphicsRenderContext : RenderContextBase, IDisposable + public class CoreGraphicsRenderContext : ClippingRenderContext, IDisposable { /// /// The images in use. @@ -68,10 +68,11 @@ public CoreGraphicsRenderContext(CGContext context) /// The fill color. /// The stroke color. /// The thickness. - public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness) + public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm) { - this.SetAlias(false); - var convertedRectangle = rect.Convert(); + bool aliased = this.ShouldUseAntiAliasingForEllipse(erm); + this.SetAlias(aliased); + var convertedRectangle = aliased ? rect.ConvertAliased() : rect.Convert(); if (fill.IsVisible()) { this.SetFill(fill); @@ -155,17 +156,16 @@ public override void CleanUp() /// /// The clip rectangle. /// True if the clip rectangle was set. - public override bool SetClip(OxyRect rect) + protected override void SetClip(OxyRect rect) { this.gctx.SaveState(); this.gctx.ClipToRect(rect.Convert()); - return true; } /// /// Resets the clip rectangle. /// - public override void ResetClip() + protected override void ResetClip() { this.gctx.RestoreState(); } @@ -178,11 +178,11 @@ public override void ResetClip() /// The stroke thickness. /// The dash array. /// The line join type. - /// if set to true the shape will be aliased. - public override void DrawLine(IList points, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased) + public override void DrawLine(IList points, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin) { if (stroke.IsVisible() && thickness > 0) { + bool aliased = this.ShouldUseAntiAliasingForLine(erm, points); this.SetAlias(aliased); this.SetStroke(stroke, thickness, dashArray, lineJoin); @@ -206,9 +206,9 @@ public override void DrawLine(IList points, OxyColor stroke, double /// The stroke thickness. /// The dash array. /// The line join type. - /// If set to true the shape will be aliased. - public override void DrawPolygon(IList points, OxyColor fill, OxyColor stroke, double thickness, double[] dashArray, LineJoin lineJoin, bool aliased) + public override void DrawPolygon(IList points, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm, double[] dashArray, LineJoin lineJoin) { + bool aliased = this.ShouldUseAntiAliasingForLine(erm, points); this.SetAlias(aliased); var convertedPoints = (aliased ? points.Select(p => p.ConvertAliased()) : points.Select(p => p.Convert())).ToArray(); if (fill.IsVisible()) @@ -246,10 +246,11 @@ public override void DrawPolygon(IList points, OxyColor fill, OxyCo /// The fill color. /// The stroke color. /// The stroke thickness. - public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness) + public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode erm) { - this.SetAlias(true); - var convertedRect = rect.ConvertAliased(); + bool aliased = this.ShouldUseAntiAliasingForRect(erm); + this.SetAlias(aliased); + var convertedRect = aliased ? rect.ConvertAliased() : rect.Convert(); if (fill.IsVisible()) { diff --git a/Source/OxyPlot.Xamarin.iOS/OxyPlot.Xamarin.iOS.csproj b/Source/OxyPlot.Xamarin.iOS/OxyPlot.Xamarin.iOS.csproj index 8491c2e..de161d9 100644 --- a/Source/OxyPlot.Xamarin.iOS/OxyPlot.Xamarin.iOS.csproj +++ b/Source/OxyPlot.Xamarin.iOS/OxyPlot.Xamarin.iOS.csproj @@ -82,7 +82,7 @@ all - 2.0.0 + 2.1.0 4.3.0 diff --git a/Source/OxyPlot.Xamarin.iOS/PlotView.cs b/Source/OxyPlot.Xamarin.iOS/PlotView.cs index 2944867..0d1a325 100644 --- a/Source/OxyPlot.Xamarin.iOS/PlotView.cs +++ b/Source/OxyPlot.Xamarin.iOS/PlotView.cs @@ -313,7 +313,8 @@ public override void Draw(CoreGraphics.CGRect rect) context.FillRect (rect); } - actualModel.Render(renderer, rect.Width, rect.Height); + OxyRect orect = new OxyRect(0, 0, rect.Width, rect.Height); + actualModel.Render(renderer, orect); } } }