diff --git a/samples/Microcharts/ChartEntry.cs b/samples/Microcharts/ChartEntry.cs
index 7e43a24..79a58c4 100644
--- a/samples/Microcharts/ChartEntry.cs
+++ b/samples/Microcharts/ChartEntry.cs
@@ -3,15 +3,13 @@
namespace Microcharts
{
- using SkiaSharp;
+ using Microsoft.StandardUI;
///
/// A data entry for a chart.
///
public class ChartEntry
{
- #region Constructors
-
///
/// Initializes a new instance of the class.
///
@@ -21,10 +19,6 @@ namespace Microcharts
this.Value = value;
}
- #endregion
-
- #region Properties
-
///
/// Gets the value.
///
@@ -47,14 +41,12 @@ namespace Microcharts
/// Gets or sets the color of the fill.
///
/// The color of the fill.
- public SKColor Color { get; set; } = SKColors.Black;
+ public Color Color { get; set; } = Colors.Black;
///
/// Gets or sets the color of the text (for the caption label).
///
/// The color of the text.
- public SKColor TextColor { get; set; } = SKColors.Gray;
-
- #endregion
+ public Color TextColor { get; set; } = Colors.Gray;
}
}
diff --git a/samples/Microcharts/Charts/BarChart.cs b/samples/Microcharts/Charts/BarChart.cs
index b398c17..6831591 100644
--- a/samples/Microcharts/Charts/BarChart.cs
+++ b/samples/Microcharts/Charts/BarChart.cs
@@ -7,7 +7,7 @@ using Microsoft.StandardUI;
using Microsoft.StandardUI.Controls;
using Microsoft.StandardUI.Media;
using Microsoft.StandardUI.Shapes;
-using static Microsoft.StandardUI.FactoryExtensions;
+using static Microsoft.StandardUI.FactoryStatics;
using SkiaSharp;
namespace Microcharts
@@ -19,8 +19,6 @@ namespace Microcharts
///
public class BarChart : PointChart
{
- #region Constructors
-
///
/// Initializes a new instance of the class.
///
@@ -29,27 +27,19 @@ namespace Microcharts
PointSize = 0;
}
- #endregion
-
- #region Properties
-
///
/// Gets or sets the bar background area alpha.
///
/// The bar area alpha.
public byte BarAreaAlpha { get; set; } = 32;
- #endregion
-
- #region Methods
-
///
/// Draws the content of the chart onto the specified canvas.
///
/// The output canvas.
/// The width of the chart.
/// The height of the chart.
- public override void DrawContent(SKCanvas canvas, int width, int height)
+ public override void DrawContent(ICanvas canvas, int width, int height)
{
if (Entries != null)
{
@@ -62,7 +52,7 @@ namespace Microcharts
var headerHeight = CalculateFooterHeaderHeight(valueLabelSizes, ValueLabelOrientation);
var itemSize = CalculateItemSize(width, height, footerHeight, headerHeight);
- var origin = CalculateYOrigin(itemSize.Height, headerHeight);
+ var origin = CalculateYOrigin((float) itemSize.Height, headerHeight);
var points = CalculatePoints(itemSize, origin, headerHeight);
DrawBarAreas(canvas, points, itemSize, headerHeight);
@@ -81,7 +71,7 @@ namespace Microcharts
/// The item size.
/// The origin.
/// The Header height.
- protected void DrawBars(ICanvas canvas, Point[] points, Size itemSize, float origin, float headerHeight)
+ protected void DrawBars(ICanvas canvas, Point[] points, Size itemSize, double origin, double headerHeight)
{
const float MinBarHeight = 4;
if (points.Length > 0)
@@ -91,27 +81,19 @@ namespace Microcharts
var entry = Entries.ElementAt(i);
var point = points[i];
- using (var paint = new SKPaint
+ var x = point.X - (itemSize.Width / 2);
+ var y = Math.Min(origin, point.Y);
+ var height = Math.Max(MinBarHeight, Math.Abs(origin - point.Y));
+ if (height < MinBarHeight)
{
- Style = SKPaintStyle.Fill,
- Color = entry.Color,
- })
- {
- var x = point.X - (itemSize.Width / 2);
- var y = Math.Min(origin, point.Y);
- var height = Math.Max(MinBarHeight, Math.Abs(origin - point.Y));
- if (height < MinBarHeight)
+ height = MinBarHeight;
+ if (y + height > Margin + itemSize.Height)
{
- height = MinBarHeight;
- if (y + height > Margin + itemSize.Height)
- {
- y = headerHeight + itemSize.Height - height;
- }
+ y = headerHeight + itemSize.Height - height;
}
-
- var rect = SKRect.Create(x, y, itemSize.Width, height);
- canvas.DrawRect(rect, paint);
}
+
+ canvas.Add(x, y, Rectangle() .Width(itemSize.Width) .Height(height) .Fill(SolidColorBrush().Color(entry.Color)));
}
}
}
@@ -123,7 +105,7 @@ namespace Microcharts
/// The entry points.
/// The item size.
/// The header height.
- protected void DrawBarAreas(ICanvas canvas, Point[] points, Size itemSize, float headerHeight)
+ protected void DrawBarAreas(ICanvas canvas, Point[] points, Size itemSize, double headerHeight)
{
if (points.Length > 0 && PointAreaAlpha > 0)
{
@@ -132,28 +114,18 @@ namespace Microcharts
var entry = Entries.ElementAt(i);
var point = points[i];
- using (var paint = new SKPaint
- {
- Style = SKPaintStyle.Fill,
- Color = entry.Color.WithAlpha((byte)(this.BarAreaAlpha * this.AnimationProgress)),
- })
- {
- var max = entry.Value > 0 ? headerHeight : headerHeight + itemSize.Height;
- var height = Math.Abs(max - point.Y);
- var y = Math.Min(max, point.Y);
- canvas.DrawRect(SKRect.Create(point.X - (itemSize.Width / 2), y, itemSize.Width, height), paint);
+ var color = entry.Color.WithA((byte)(this.BarAreaAlpha * this.AnimationProgress));
+ var brush = SolidColorBrush();
+ brush.Color = color;
- var rect = Rectangle();
- rect.Width = itemSize.Width;
- rect.Height = height;
+ var max = entry.Value > 0 ? headerHeight : headerHeight + itemSize.Height;
+ var height = Math.Abs(max - point.Y);
+ var y = Math.Min(max, point.Y);
- canvas.Children.Add(rect);
- }
+ canvas.Add(point.X - (itemSize.Width / 2), y, Rectangle().Width(itemSize.Width).Height(height).Fill(brush));
}
}
}
-
- #endregion
}
}
diff --git a/samples/Microcharts/Charts/Chart.cs b/samples/Microcharts/Charts/Chart.cs
index 9cc44de..2e2a6b5 100644
--- a/samples/Microcharts/Charts/Chart.cs
+++ b/samples/Microcharts/Charts/Chart.cs
@@ -9,41 +9,30 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.StandardUI;
+using Microsoft.StandardUI.Controls;
using SkiaSharp;
+using static Microsoft.StandardUI.FactoryStatics;
namespace Microcharts
{
///
/// A chart.
///
- public abstract class Chart : INotifyPropertyChanged
+ public abstract class Chart : StandardUIUserControl, INotifyPropertyChanged
{
- #region Fields
-
private IEnumerable entries;
-
- private float animationProgress, margin = 20, labelTextSize = 16;
-
- private SKColor backgroundColor = SKColors.White;
-
- private SKColor labelColor = SKColors.Gray;
-
+ private float animationProgress;
+ private double margin = 20, labelTextSize = 16;
+ private Color backgroundColor = Colors.White;
+ private Color labelColor = Colors.Gray;
private SKTypeface typeface;
-
- private float? internalMinValue, internalMaxValue;
-
+ private double? internalMinValue, internalMaxValue;
private bool isAnimated = true, isAnimating = false;
-
private TimeSpan animationDuration = TimeSpan.FromSeconds(1.5f);
-
private Task invalidationPlanification;
-
private CancellationTokenSource animationCancellation;
- #endregion
-
- #region Constructors
-
///
/// Initializes a new instance of the class.
///
@@ -52,10 +41,6 @@ namespace Microcharts
PropertyChanged += OnPropertyChanged;
}
- #endregion
-
- #region Events
-
///
/// Occurs when property changed.
///
@@ -66,8 +51,6 @@ namespace Microcharts
///
public event EventHandler Invalidated;
- #endregion
-
#region Properties
///
@@ -124,7 +107,7 @@ namespace Microcharts
/// Gets or sets the global margin.
///
/// The margin.
- public float Margin
+ public double Margin
{
get => margin;
set => Set(ref margin, value);
@@ -148,7 +131,7 @@ namespace Microcharts
/// Gets or sets the text size of the labels.
///
/// The size of the label text.
- public float LabelTextSize
+ public double LabelTextSize
{
get => labelTextSize;
set => Set(ref labelTextSize, value);
@@ -164,7 +147,7 @@ namespace Microcharts
/// Gets or sets the color of the chart background.
///
/// The color of the background.
- public SKColor BackgroundColor
+ public Color BackgroundColor
{
get => backgroundColor;
set => Set(ref backgroundColor, value);
@@ -174,7 +157,7 @@ namespace Microcharts
/// Gets or sets the color of the labels.
///
/// The color of the labels.
- public SKColor LabelColor
+ public Color LabelColor
{
get => labelColor;
set => Set(ref labelColor, value);
@@ -195,7 +178,7 @@ namespace Microcharts
/// minimal entry value.
///
/// The minimum value.
- public float MinValue
+ public double MinValue
{
get
{
@@ -220,7 +203,7 @@ namespace Microcharts
/// maximum entry value.
///
/// The minimum value.
- public float MaxValue
+ public double MaxValue
{
get
{
@@ -249,7 +232,7 @@ namespace Microcharts
/// Gets or sets the internal minimum value (that can be null).
///
/// The internal minimum value.
- protected float? InternalMinValue
+ protected double? InternalMinValue
{
get => internalMinValue;
set
@@ -265,7 +248,7 @@ namespace Microcharts
/// Gets or sets the internal max value (that can be null).
///
/// The internal max value.
- protected float? InternalMaxValue
+ protected double? InternalMaxValue
{
get => internalMaxValue;
set
@@ -287,15 +270,23 @@ namespace Microcharts
#region Methods
+ public void Build()
+ {
+ ICanvas canvas = Canvas() .Width(Width) .Height(Height);
+ Draw(canvas, (int) Width, (int) Height);
+
+ Content = canvas;
+ }
+
///
/// Draw the graph onto the specified canvas.
///
/// The canvas.
/// The width.
/// The height.
- public void Draw(SKCanvas canvas, int width, int height)
+ public void Draw(ICanvas canvas, int width, int height)
{
- canvas.Clear(BackgroundColor);
+ //canvas.Clear(BackgroundColor);
DrawableChartArea = new SKRect(0, 0, width, height);
@@ -308,7 +299,7 @@ namespace Microcharts
/// The canvas.
/// The width.
/// The height.
- public abstract void DrawContent(SKCanvas canvas, int width, int height);
+ public abstract void DrawContent(ICanvas canvas, int width, int height);
///
/// Draws caption elements on the right or left side of the chart.
@@ -319,8 +310,9 @@ namespace Microcharts
/// The entries.
/// If set to true is left.
/// Should the chart in the center always?
- protected void DrawCaptionElements(SKCanvas canvas, int width, int height, List entries, bool isLeft, bool isGraphCentered)
+ protected void DrawCaptionElements(ICanvas canvas, int width, int height, List entries, bool isLeft, bool isGraphCentered)
{
+#if LATER
var totalMargin = 2 * Margin;
var availableHeight = height - (2 * totalMargin);
var x = isLeft ? Margin : (width - Margin - LabelTextSize);
@@ -342,9 +334,9 @@ namespace Microcharts
{
var captionMargin = LabelTextSize * 0.60f;
var captionX = isLeft ? Margin : width - Margin - LabelTextSize;
- var valueColor = entry.Color.WithAlpha((byte)(entry.Color.Alpha * AnimationProgress));
- var lblColor = entry.TextColor.WithAlpha((byte)(entry.TextColor.Alpha * AnimationProgress));
- var rect = SKRect.Create(captionX, y, LabelTextSize, LabelTextSize);
+ var valueColor = entry.Color.WithA((byte)(entry.Color.A * AnimationProgress));
+ var lblColor = entry.TextColor.WithA((byte)(entry.TextColor.A * AnimationProgress));
+ var rect = new Rect(captionX, y, LabelTextSize, LabelTextSize);
using (var paint = new SKPaint
{
@@ -396,6 +388,7 @@ namespace Microcharts
}
}
}
+#endif
}
///
@@ -444,9 +437,6 @@ namespace Microcharts
}
}
-
- #region Weak event handlers
-
///
/// Adds a weak event handler to observe invalidate changes.
///
@@ -461,8 +451,6 @@ namespace Microcharts
return weakHandler;
}
- #endregion
-
///
/// Animates the view.
///
@@ -565,8 +553,6 @@ namespace Microcharts
}
}
- #region INotifyPropertyChanged
-
///
/// Raises the property change.
///
@@ -596,8 +582,6 @@ namespace Microcharts
return false;
}
- #endregion
-
- #endregion
+#endregion
}
}
diff --git a/samples/Microcharts/Charts/DonutChart.cs b/samples/Microcharts/Charts/DonutChart.cs
index d870283..389bbed 100644
--- a/samples/Microcharts/Charts/DonutChart.cs
+++ b/samples/Microcharts/Charts/DonutChart.cs
@@ -8,6 +8,7 @@ using SkiaSharp;
namespace Microcharts
{
+#if LATER
///
/// ![chart](../images/Donut.png)
///
@@ -15,7 +16,7 @@ namespace Microcharts
///
public class DonutChart : Chart
{
- #region Properties
+#region Properties
///
/// Gets or sets the radius of the hole in the center of the chart.
@@ -33,9 +34,9 @@ namespace Microcharts
///
public GraphPosition GraphPosition { get; set; } = GraphPosition.AutoFill;
- #endregion
+#endregion
- #region Methods
+#region Methods
public override void DrawContent(SKCanvas canvas, int width, int height)
{
@@ -134,6 +135,7 @@ namespace Microcharts
DrawCaptionElements(canvas, width, height, leftValues, true, isGraphCentered);
}
- #endregion
+#endregion
}
+#endif
}
diff --git a/samples/Microcharts/Charts/LineChart.cs b/samples/Microcharts/Charts/LineChart.cs
index 463f447..9359358 100644
--- a/samples/Microcharts/Charts/LineChart.cs
+++ b/samples/Microcharts/Charts/LineChart.cs
@@ -1,7 +1,11 @@
// Copyright (c) Aloïs DENIEL. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
+#if LATER
+
using System.Linq;
+using Microsoft.StandardUI;
+using Microsoft.StandardUI.Controls;
using SkiaSharp;
namespace Microcharts
@@ -13,8 +17,6 @@ namespace Microcharts
///
public class LineChart : PointChart
{
- #region Constructors
-
///
/// Initializes a new instance of the class.
///
@@ -23,10 +25,6 @@ namespace Microcharts
this.PointSize = 10;
}
- #endregion
-
- #region Properties
-
///
/// Gets or sets the size of the line.
///
@@ -51,11 +49,7 @@ namespace Microcharts
/// The state of the fadeout gradient.
public bool EnableYFadeOutGradient { get; set; } = false;
- #endregion
-
- #region Methods
-
- public override void DrawContent(SKCanvas canvas, int width, int height)
+ public override void DrawContent(ICanvas canvas, int width, int height)
{
if (this.Entries != null)
{
@@ -79,7 +73,7 @@ namespace Microcharts
}
}
- protected void DrawLine(SKCanvas canvas, SKPoint[] points, SKSize itemSize)
+ protected void DrawLine(ICanvas canvas, Point[] points, Size itemSize)
{
if (points.Length > 1 && this.LineMode != LineMode.None)
{
@@ -121,7 +115,7 @@ namespace Microcharts
}
}
- protected void DrawArea(SKCanvas canvas, SKPoint[] points, SKSize itemSize, float origin)
+ protected void DrawArea(ICanvas canvas, Point[] points, Size itemSize, double origin)
{
if (this.LineAreaAlpha > 0 && points.Length > 1)
{
@@ -178,7 +172,7 @@ namespace Microcharts
return (point, currentControl, nextPoint, nextControl);
}
- private SKShader CreateXGradient(SKPoint[] points, byte alpha = 255)
+ private SKShader CreateXGradient(Point[] points, byte alpha = 255)
{
var startX = points.First().X;
var endX = points.Last().X;
@@ -187,12 +181,12 @@ namespace Microcharts
return SKShader.CreateLinearGradient(
new SKPoint(startX, 0),
new SKPoint(endX, 0),
- this.Entries.Select(x => x.Color.WithAlpha(alpha)).ToArray(),
+ this.Entries.Select(x => x.Color.WithA(alpha)).ToArray(),
null,
SKShaderTileMode.Clamp);
}
- private SKShader CreateYGradient(SKPoint[] points, byte alpha = 255)
+ private SKShader CreateYGradient(Point[] points, byte alpha = 255)
{
var startY = points.Max(i => i.Y);
var endY = 0;
@@ -204,7 +198,7 @@ namespace Microcharts
null,
SKShaderTileMode.Clamp);
}
-
- #endregion
}
}
+
+#endif
\ No newline at end of file
diff --git a/samples/Microcharts/Charts/PieChart.cs b/samples/Microcharts/Charts/PieChart.cs
index 54be16e..0ea787d 100644
--- a/samples/Microcharts/Charts/PieChart.cs
+++ b/samples/Microcharts/Charts/PieChart.cs
@@ -3,6 +3,7 @@
namespace Microcharts
{
+#if LATER
///
/// ![chart](../images/Donut.png)
///
@@ -10,7 +11,7 @@ namespace Microcharts
///
public class PieChart : DonutChart
{
- #region Constructors
+#region Constructors
///
/// Initializes a new instance of the class.
@@ -20,6 +21,7 @@ namespace Microcharts
this.HoleRadius = 0;
}
- #endregion
+#endregion
}
+#endif
}
diff --git a/samples/Microcharts/Charts/PointChart.cs b/samples/Microcharts/Charts/PointChart.cs
index 814370c..76424ec 100644
--- a/samples/Microcharts/Charts/PointChart.cs
+++ b/samples/Microcharts/Charts/PointChart.cs
@@ -5,6 +5,8 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
+using Microsoft.StandardUI;
+using Microsoft.StandardUI.Controls;
using SkiaSharp;
using SkiaSharp.HarfBuzz;
@@ -17,8 +19,6 @@ namespace Microcharts
///
public class PointChart : Chart
{
- #region Constructors
-
///
/// Initializes a new instance of the class.
///
@@ -28,16 +28,8 @@ namespace Microcharts
ValueLabelOrientation = Orientation.Default;
}
- #endregion
-
- #region Fields
-
private Orientation labelOrientation, valueLabelOrientation;
- #endregion
-
- #region Properties
-
///
/// Gets or sets the size of the point.
///
@@ -76,13 +68,9 @@ namespace Microcharts
set => valueLabelOrientation = (value == Orientation.Default) ? Orientation.Vertical : value;
}
- private float ValueRange => MaxValue - MinValue;
+ private double ValueRange => MaxValue - MinValue;
- #endregion
-
- #region Methods
-
- public override void DrawContent(SKCanvas canvas, int width, int height)
+ public override void DrawContent(ICanvas canvas, int width, int height)
{
if (Entries != null)
{
@@ -105,7 +93,7 @@ namespace Microcharts
}
}
- protected float CalculateYOrigin(float itemHeight, float headerHeight)
+ protected double CalculateYOrigin(double itemHeight, double headerHeight)
{
if (MaxValue <= 0)
{
@@ -120,17 +108,17 @@ namespace Microcharts
return headerHeight + ((MaxValue / ValueRange) * itemHeight);
}
- protected SKSize CalculateItemSize(int width, int height, float footerHeight, float headerHeight)
+ protected Size CalculateItemSize(int width, int height, double footerHeight, double headerHeight)
{
var total = Entries.Count();
var w = (width - ((total + 1) * Margin)) / total;
var h = height - Margin - footerHeight - headerHeight;
- return new SKSize(w, h);
+ return new Size(w, h);
}
- protected SKPoint[] CalculatePoints(SKSize itemSize, float origin, float headerHeight)
+ protected Point[] CalculatePoints(Size itemSize, double origin, double headerHeight)
{
- var result = new List();
+ var result = new List();
for (int i = 0; i < Entries.Count(); i++)
{
@@ -139,31 +127,31 @@ namespace Microcharts
var x = Margin + (itemSize.Width / 2) + (i * (itemSize.Width + Margin));
var y = headerHeight + ((1 - AnimationProgress) * (origin - headerHeight) + (((MaxValue - value) / ValueRange) * itemSize.Height) * AnimationProgress);
- var point = new SKPoint(x, y);
+ var point = new Point(x, y);
result.Add(point);
}
return result.ToArray();
}
- protected void DrawHeader(SKCanvas canvas, string[] labels, SKRect[] labelSizes, SKPoint[] points, SKSize itemSize, int height, float headerHeight)
+ protected void DrawHeader(ICanvas canvas, string[] labels, Rect[] labelSizes, Point[] points, Size itemSize, int height, double headerHeight)
{
DrawLabels(canvas,
labels,
- points.Select(p => new SKPoint(p.X, headerHeight - Margin)).ToArray(),
+ points.Select(p => new Point(p.X, headerHeight - Margin)).ToArray(),
labelSizes,
- Entries.Select(x => x.Color.WithAlpha((byte)(255 * AnimationProgress))).ToArray(),
+ Entries.Select(x => x.Color.WithA((byte)(255 * AnimationProgress))).ToArray(),
ValueLabelOrientation,
true,
itemSize,
height);
}
- protected void DrawFooter(SKCanvas canvas, string[] labels, SKRect[] labelSizes, SKPoint[] points, SKSize itemSize, int height, float footerHeight)
+ protected void DrawFooter(ICanvas canvas, string[] labels, Rect[] labelSizes, Point[] points, Size itemSize, int height, double footerHeight)
{
DrawLabels(canvas,
labels,
- points.Select(p => new SKPoint(p.X, height - footerHeight + Margin)).ToArray(),
+ points.Select(p => new Point(p.X, height - footerHeight + Margin)).ToArray(),
labelSizes,
Entries.Select(x => LabelColor).ToArray(),
LabelOrientation,
@@ -172,7 +160,7 @@ namespace Microcharts
height);
}
- protected void DrawPoints(SKCanvas canvas, SKPoint[] points)
+ protected void DrawPoints(ICanvas canvas, Point[] points)
{
if (points.Length > 0 && PointMode != PointMode.None)
{
@@ -185,8 +173,9 @@ namespace Microcharts
}
}
- protected void DrawPointAreas(SKCanvas canvas, SKPoint[] points, float origin)
+ protected void DrawPointAreas(ICanvas canvas, Point[] points, double origin)
{
+#if LATER
if (points.Length > 0 && PointAreaAlpha > 0)
{
for (int i = 0; i < points.Length; i++)
@@ -195,11 +184,11 @@ namespace Microcharts
var point = points[i];
var y = Math.Min(origin, point.Y);
- using (var shader = SKShader.CreateLinearGradient(new SKPoint(0, origin), new SKPoint(0, point.Y), new[] { entry.Color.WithAlpha(PointAreaAlpha), entry.Color.WithAlpha((byte)(PointAreaAlpha / 3)) }, null, SKShaderTileMode.Clamp))
+ using (var shader = SKShader.CreateLinearGradient(new SKPoint(0, origin), new SKPoint(0, point.Y), new[] { entry.Color.WithA(PointAreaAlpha), entry.Color.WithA((byte)(PointAreaAlpha / 3)) }, null, SKShaderTileMode.Clamp))
using (var paint = new SKPaint
{
Style = SKPaintStyle.Fill,
- Color = entry.Color.WithAlpha(PointAreaAlpha),
+ Color = entry.Color.WithA(PointAreaAlpha),
})
{
paint.Shader = shader;
@@ -208,6 +197,7 @@ namespace Microcharts
}
}
}
+#endif
}
///
@@ -222,8 +212,9 @@ namespace Microcharts
///
///
///
- protected void DrawLabels(SKCanvas canvas,string[] texts, SKPoint[] points, SKRect[] sizes, SKColor[] colors, Orientation orientation, bool isTop, SKSize itemSize, float height)
+ protected void DrawLabels(ICanvas canvas,string[] texts, Point[] points, Rect[] sizes, Color[] colors, Orientation orientation, bool isTop, Size itemSize, float height)
{
+#if LATER
if (points.Length > 0)
{
var maxWidth = sizes.Max(x => x.Width);
@@ -300,6 +291,7 @@ namespace Microcharts
}
}
}
+#endif
}
///
@@ -307,7 +299,7 @@ namespace Microcharts
///
/// The footer height.
/// Value label sizes.
- protected float CalculateFooterHeaderHeight(SKRect[] valueLabelSizes, Orientation orientation)
+ protected double CalculateFooterHeaderHeight(Rect[] valueLabelSizes, Orientation orientation)
{
var result = Margin;
@@ -334,8 +326,9 @@ namespace Microcharts
/// Measures the value labels.
///
/// The value labels.
- protected SKRect[] MeasureLabels(string[] labels)
+ protected Rect[] MeasureLabels(string[] labels)
{
+#if LATER
using (var paint = new SKPaint())
{
paint.TextSize = LabelTextSize;
@@ -351,8 +344,8 @@ namespace Microcharts
return bounds;
}).ToArray();
}
+#endif
+ return labels.Select(text => new Rect(0, 0, 50, 50)).ToArray();
}
-
- #endregion
}
}
diff --git a/samples/Microcharts/Charts/RadarChart.cs b/samples/Microcharts/Charts/RadarChart.cs
index a1767fa..66e6644 100644
--- a/samples/Microcharts/Charts/RadarChart.cs
+++ b/samples/Microcharts/Charts/RadarChart.cs
@@ -7,6 +7,7 @@ using SkiaSharp;
namespace Microcharts
{
+#if LATER
///
/// ![chart](../images/Radar.png)
///
@@ -14,13 +15,13 @@ namespace Microcharts
///
public class RadarChart : Chart
{
- #region Constants
+#region Constants
private const float Epsilon = 0.01f;
- #endregion
+#endregion
- #region Properties
+#region Properties
///
/// Gets or sets the size of the line.
@@ -58,9 +59,9 @@ namespace Microcharts
private float ValueRange => this.AbsoluteMaximum - this.AbsoluteMinimum;
- #endregion
+#endregion
- #region Methods
+#region Methods
public override void DrawContent(SKCanvas canvas, int width, int height)
{
@@ -207,6 +208,7 @@ namespace Microcharts
}
}
- #endregion
+#endregion
}
+#endif
}
diff --git a/samples/Microcharts/Charts/RadialGaugeChart.cs b/samples/Microcharts/Charts/RadialGaugeChart.cs
index 0d601e4..af258bd 100644
--- a/samples/Microcharts/Charts/RadialGaugeChart.cs
+++ b/samples/Microcharts/Charts/RadialGaugeChart.cs
@@ -7,6 +7,7 @@ using SkiaSharp;
namespace Microcharts
{
+#if LATER
///
/// ![chart](../images/RadialGauge.png)
///
@@ -14,7 +15,7 @@ namespace Microcharts
///
public class RadialGaugeChart : Chart
{
- #region Properties
+#region Properties
///
/// Gets or sets the size of each gauge. If negative, then its will be calculated from the available space.
@@ -40,9 +41,9 @@ namespace Microcharts
private float ValueRange => AbsoluteMaximum - AbsoluteMinimum;
- #endregion
+#endregion
- #region Methods
+#region Methods
public void DrawGaugeArea(SKCanvas canvas, ChartEntry entry, float radius, int cx, int cy, float strokeWidth)
{
@@ -112,6 +113,7 @@ namespace Microcharts
DrawCaptionElements(canvas, width, height, leftValues, true, false);
}
- #endregion
+#endregion
}
+#endif
}
diff --git a/samples/Microcharts/Extensions/CanvasExtensions.cs b/samples/Microcharts/Extensions/CanvasExtensions.cs
index dc82c36..1a26a4f 100644
--- a/samples/Microcharts/Extensions/CanvasExtensions.cs
+++ b/samples/Microcharts/Extensions/CanvasExtensions.cs
@@ -1,8 +1,13 @@
// Copyright (c) Aloïs DENIEL. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
+using Microsoft.StandardUI;
+using Microsoft.StandardUI.Controls;
+using Microsoft.StandardUI.Media;
+using Microsoft.StandardUI.Shapes;
using SkiaSharp;
using SkiaSharp.HarfBuzz;
+using static Microsoft.StandardUI.FactoryStatics;
namespace Microcharts
{
@@ -101,27 +106,16 @@ namespace Microcharts
/// The fill color.
/// The point size.
/// The point mode.
- public static void DrawPoint(this SKCanvas canvas, SKPoint point, SKColor color, float size, PointMode mode)
+ public static void DrawPoint(this ICanvas canvas, Point point, Color color, float size, PointMode mode)
{
- using (var paint = new SKPaint
- {
- Style = SKPaintStyle.Fill,
- IsAntialias = true,
- Color = color,
- })
- {
- switch (mode)
- {
- case PointMode.Square:
- canvas.DrawRect(SKRect.Create(point.X - (size / 2), point.Y - (size / 2), size, size), paint);
- break;
+ IShape shape;
+ if (mode == PointMode.Square)
+ shape = Rectangle();
+ else if (mode == PointMode.Circle)
+ shape = Ellipse();
+ else return;
- case PointMode.Circle:
- paint.IsAntialias = true;
- canvas.DrawCircle(point.X, point.Y, size / 2, paint);
- break;
- }
- }
+ canvas.Add(point.X - (size / 2), point.Y - (size / 2), shape.Width(size).Height(size).Fill(SolidColorBrush().Color(color)));
}
///
diff --git a/samples/Microcharts/Helpers/RadialHelpers.cs b/samples/Microcharts/Helpers/RadialHelpers.cs
index 0c023b2..708f5db 100644
--- a/samples/Microcharts/Helpers/RadialHelpers.cs
+++ b/samples/Microcharts/Helpers/RadialHelpers.cs
@@ -8,18 +8,10 @@ namespace Microcharts
internal static class RadialHelpers
{
- #region Constants
-
public const float PI = (float)Math.PI;
-
private const float UprightAngle = PI / 2f;
-
private const float TotalAngle = 2f * PI;
- #endregion
-
- #region Sectors
-
public static SKPoint GetCirclePoint(float r, float angle)
{
return new SKPoint(r * (float)Math.Cos(angle), r * (float)Math.Sin(angle));
@@ -82,7 +74,5 @@ namespace Microcharts
return path;
}
-
- #endregion
}
}