Skip to content

Commit

Permalink
Stylecop pass
Browse files Browse the repository at this point in the history
  • Loading branch information
VisualMelon committed May 14, 2020
1 parent 552c8a0 commit 1927d3d
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 149 deletions.
10 changes: 5 additions & 5 deletions Source/OxyPlot.ImageSharp/ImageRenderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ namespace OxyPlot.ImageSharp
/// </summary>
public class ImageRenderContext : RenderContextBase, IDisposable, ITextMeasurer
{
/// <summary>
/// Gets or sets the <see cref="TextArranger"/> used by this instance.
/// </summary>
public TextArranger TextArranger { get; set; }

/// <summary>
/// The default font to use when a request font cannot be found.
/// </summary>
Expand Down Expand Up @@ -91,6 +86,11 @@ public ImageRenderContext(int width, int height, OxyColor background, double dpi
this.TextArranger = new TextArranger(this);
}

/// <summary>
/// Gets or sets the <see cref="TextArranger"/> used by this instance.
/// </summary>
public TextArranger TextArranger { get; set; }

/// <summary>
/// Gets the DPI scaling factor. A value of 1 corresponds to 96 DPI (dots per inch).
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion Source/OxyPlot.ImageSharp/SvgExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ public class SvgExporter : OxyPlot.SvgExporter, IDisposable
/// <summary>
/// Initializes a new instance of the <see cref="SvgExporter" /> class.
/// </summary>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="resolution">The resolution in dots per inch.</param>
public SvgExporter(double width, double height, double resolution = 96)
{
this.Width = width;
this.Height = height;
this.irc = new ImageRenderContext(1, 1, OxyColors.Undefined, resolution);
this.TextMeasurer = irc;
this.TextMeasurer = this.irc;
}

/// <summary>
Expand Down
32 changes: 15 additions & 17 deletions Source/OxyPlot.SkiaSharp/SkiaRenderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@

namespace OxyPlot.SkiaSharp
{
using global::SkiaSharp;
using global::SkiaSharp.HarfBuzz;
using HarfBuzzSharp;
using OxyPlot.Rendering;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using global::SkiaSharp;
using global::SkiaSharp.HarfBuzz;
using OxyPlot.Rendering;

/// <summary>
/// Implements <see cref="IRenderContext" /> based on SkiaSharp.
Expand All @@ -30,7 +28,7 @@ public class SkiaRenderContext : IRenderContext, IDisposable, ITextMeasurer
/// </summary>
public SkiaRenderContext()
{
TextArranger = new TextArranger(this);
this.TextArranger = new TextArranger(this);
}

/// <summary>
Expand Down Expand Up @@ -243,7 +241,7 @@ public void DrawEllipses(IList<OxyRect> extents, OxyColor fill, OxyColor stroke,
double[] dashArray = null,
LineJoin lineJoin = LineJoin.Miter)
{
if (!fill.IsVisible() && !(stroke.IsVisible() || thickness <= 0) || points.Count < 2)
if ((!fill.IsVisible() && !(stroke.IsVisible() || thickness <= 0)) || points.Count < 2)
{
return;
}
Expand Down Expand Up @@ -276,7 +274,7 @@ public void DrawEllipses(IList<OxyRect> extents, OxyColor fill, OxyColor stroke,
double[] dashArray = null,
LineJoin lineJoin = LineJoin.Miter)
{
if (!fill.IsVisible() && !(stroke.IsVisible() || thickness <= 0) || polygons.Count == 0)
if ((!fill.IsVisible() && !(stroke.IsVisible() || thickness <= 0)) || polygons.Count == 0)
{
return;
}
Expand Down Expand Up @@ -333,7 +331,7 @@ public void DrawRectangle(OxyRect rectangle, OxyColor fill, OxyColor stroke, dou
/// <inheritdoc/>
public void DrawRectangles(IList<OxyRect> rectangles, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode edgeRenderingMode)
{
if (!fill.IsVisible() && !(stroke.IsVisible() || thickness <= 0) || rectangles.Count == 0)
if ((!fill.IsVisible() && !(stroke.IsVisible() || thickness <= 0)) || rectangles.Count == 0)
{
return;
}
Expand Down Expand Up @@ -381,7 +379,7 @@ public void DrawRectangles(IList<OxyRect> rectangles, OxyColor fill, OxyColor st
var x = this.Convert(p.X);
var y = this.Convert(p.Y);

using var _ = new SKAutoCanvasRestore(this.SkCanvas);
using var canvasRestore = new SKAutoCanvasRestore(this.SkCanvas);
this.SkCanvas.Translate(x, y);
this.SkCanvas.RotateDegrees((float)rotation);

Expand All @@ -398,7 +396,7 @@ public void DrawRectangles(IList<OxyRect> rectangles, OxyColor fill, OxyColor st
HorizontalAlignment.Left => SKTextAlign.Left,
HorizontalAlignment.Center => SKTextAlign.Center,
HorizontalAlignment.Right => SKTextAlign.Right,
_ => throw new ArgumentOutOfRangeException(nameof(horizontalAlignment))
_ => throw new ArgumentOutOfRangeException(nameof(horizontalAlignment)),
};
}

Expand Down Expand Up @@ -455,7 +453,7 @@ public void SetToolTip(string text)
/// <inheritdoc/>
public FontMetrics GetFontMetrics(string fontFamily, double fontSize, double fontWeight)
{
var lineSpacing = paint.GetFontMetrics(out var metrics);
var lineSpacing = this.paint.GetFontMetrics(out var metrics);
var ascender = this.ConvertBack(Math.Abs(metrics.Ascent));
var descender = this.ConvertBack(Math.Abs(metrics.Descent));
var leading = this.ConvertBack(Math.Abs(metrics.Leading));
Expand Down Expand Up @@ -791,7 +789,7 @@ private SKPaint GetLinePaint(OxyColor strokeColor, double strokeThickness, EdgeR
LineJoin.Miter => SKStrokeJoin.Miter,
LineJoin.Round => SKStrokeJoin.Round,
LineJoin.Bevel => SKStrokeJoin.Bevel,
_ => throw new ArgumentOutOfRangeException(nameof(lineJoin))
_ => throw new ArgumentOutOfRangeException(nameof(lineJoin)),
};

return paint;
Expand Down Expand Up @@ -952,12 +950,12 @@ public FontDescriptor(string fontFamily, double fontWeight)
}

/// <summary>
/// The font family.
/// Gets the font family.
/// </summary>
public string FontFamily { get; }

/// <summary>
/// The font weight.
/// Gets the font weight.
/// </summary>
public double FontWeight { get; }

Expand All @@ -971,8 +969,8 @@ public override bool Equals(object obj)
public override int GetHashCode()
{
var hashCode = -1030903623;
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(this.FontFamily);
hashCode = hashCode * -1521134295 + this.FontWeight.GetHashCode();
hashCode = (hashCode * -1521134295) + EqualityComparer<string>.Default.GetHashCode(this.FontFamily);
hashCode = (hashCode * -1521134295) + this.FontWeight.GetHashCode();
return hashCode;
}
}
Expand Down
13 changes: 6 additions & 7 deletions Source/OxyPlot.WindowsForms/GraphicsRenderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ namespace OxyPlot.WindowsForms
/// </summary>
public class GraphicsRenderContext : RenderContextBase, IDisposable, ITextMeasurer
{
/// <summary>
/// Gets or sets the <see cref="TextArranger"/> for this instance.
/// </summary>
public TextArranger TextArranger { get; set; }

/// <summary>
/// The font size factor.
/// </summary>
Expand Down Expand Up @@ -87,6 +82,11 @@ public GraphicsRenderContext(Graphics graphics = null)
this.TextArranger = new TextArranger(this);
}

/// <summary>
/// Gets or sets the <see cref="TextArranger"/> for this instance.
/// </summary>
public TextArranger TextArranger { get; set; }

/// <summary>
/// Sets the graphics target.
/// </summary>
Expand All @@ -113,7 +113,7 @@ public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, d
{
return;
}

var pen = this.GetCachedPen(stroke, thickness);
this.g.DrawEllipse(pen, (float)rect.Left, (float)rect.Top, (float)rect.Width, (float)rect.Height);
}
Expand Down Expand Up @@ -231,7 +231,6 @@ public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke,

this.g.TranslateTransform((float)p.X, (float)p.Y);

//var layoutRectangle = new RectangleF(0, 0, size.Width, size.Height);
if (Math.Abs(rotation) > double.Epsilon)
{
this.g.RotateTransform((float)rotation);
Expand Down
2 changes: 1 addition & 1 deletion Source/OxyPlot.WindowsForms/OxyPlot.WindowsForms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<ProjectReference Include="..\OxyPlot\OxyPlot.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\Icons\OxyPlot_128.png" Pack="true" PackagePath="\"/>
<None Include="..\..\Icons\OxyPlot_128.png" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<None Include="OxyPlot.WindowsForms.snk" />
Expand Down
10 changes: 8 additions & 2 deletions Source/OxyPlot.Wpf/OxyPlot.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@
<Reference Include="System.Printing" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OxyPlot.Wpf.Shared\OxyPlot.Wpf.Shared.csproj"/>
<ProjectReference Include="..\OxyPlot\OxyPlot.csproj"/>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OxyPlot.Wpf.Shared\OxyPlot.Wpf.Shared.csproj" />
<ProjectReference Include="..\OxyPlot\OxyPlot.csproj" />
</ItemGroup>
</Project>
12 changes: 6 additions & 6 deletions Source/OxyPlot/Pdf/PdfRenderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,17 @@

namespace OxyPlot
{
using OxyPlot.Rendering;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using OxyPlot.Rendering;

/// <summary>
/// Implements an <see cref="IRenderContext" /> producing PDF documents by <see cref="PortableDocument" />.
/// </summary>
public class PdfRenderContext : RenderContextBase, ITextMeasurer
{
/// <summary>
/// Gets or sets the <see cref="TextArranger"/> for this instance.
/// </summary>
public TextArranger TextArranger { get; set; }

/// <summary>
/// The current document.
/// </summary>
Expand Down Expand Up @@ -56,6 +51,11 @@ public PdfRenderContext(double width, double height, OxyColor background)
this.TextArranger = new TextArranger(this);
}

/// <summary>
/// Gets or sets the <see cref="TextArranger"/> for this instance.
/// </summary>
public TextArranger TextArranger { get; set; }

/// <summary>
/// Saves the output to the specified stream.
/// </summary>
Expand Down

0 comments on commit 1927d3d

Please sign in to comment.