From 987bfe464a43035b9155dcda0dbb96a176bd30dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Fri, 17 Nov 2023 17:48:45 -0600 Subject: [PATCH 01/23] use Collection expressions --- samples/MauiSample/AppShell.xaml.cs | 2 +- .../Bars/AutoUpdate/ViewModel.cs | 12 ++--- .../Bars/DelayedAnimation/ViewModel.cs | 2 +- .../General/ConditionalDraw/ViewModel.cs | 8 ++-- .../General/RealTime/ViewModel.cs | 8 ++-- .../General/Scrollable/ViewModel.cs | 2 +- .../Lines/AutoUpdate/ViewModel.cs | 12 ++--- .../Pies/AutoUpdate/ViewModel.cs | 6 +-- .../Scatter/AutoUpdate/ViewModel.cs | 12 ++--- .../StepLines/AutoUpdate/ViewModel.cs | 12 ++--- .../XamarinSample/AppShell.xaml.cs | 2 +- src/LiveChartsCore/CartesianChart.cs | 4 +- src/LiveChartsCore/Chart.cs | 10 ++-- src/LiveChartsCore/CoreAxis.cs | 4 +- src/LiveChartsCore/CoreHeatLandSeries.cs | 4 +- src/LiveChartsCore/CoreHeatSeries.cs | 2 +- src/LiveChartsCore/CoreLineSeries.cs | 8 ++-- src/LiveChartsCore/CorePolarAxis.cs | 4 +- src/LiveChartsCore/CorePolarLineSeries.cs | 8 ++-- src/LiveChartsCore/CoreStepLineSeries.cs | 8 ++-- src/LiveChartsCore/Drawing/Animatable.cs | 2 +- src/LiveChartsCore/Geo/CoreMap.cs | 2 +- src/LiveChartsCore/Geo/MapLayer.cs | 2 +- src/LiveChartsCore/GeoMap.cs | 2 +- src/LiveChartsCore/Kernel/ChartElement.cs | 4 +- .../Kernel/ChartEntityMetaData.cs | 2 +- .../Kernel/CollectionDeepObserver.cs | 2 +- src/LiveChartsCore/Kernel/Drawing/Sketch.cs | 2 +- .../Kernel/LiveChartsSettings.cs | 2 +- .../Kernel/Providers/DataFactory.cs | 4 +- src/LiveChartsCore/Kernel/SeriesContext.cs | 12 ++--- src/LiveChartsCore/Kernel/Stacker.cs | 6 +-- src/LiveChartsCore/Motion/MotionCanvas.cs | 6 +-- src/LiveChartsCore/Series.cs | 28 ++--------- src/LiveChartsCore/Themes/Theme.cs | 48 +++++++++---------- .../VisualElements/AngularTicksVisual.cs | 2 +- .../VisualElements/RelativePanel.cs | 2 +- .../VisualElements/StackPanel.cs | 6 +-- .../VisualElements/TableLayout.cs | 4 +- .../MotionCanvas.cs | 2 +- .../Drawing/Geometries/SVGPathGeometry.cs | 2 +- .../Extensions/GaugeGenerator.cs | 4 +- .../Extensions/PieChartExtensions.cs | 4 +- .../LiveChartsCore.SkiaSharp/GaugeBuilder.cs | 4 +- .../LiveChartsCore.SkiaSharp/MapFactory.cs | 6 +-- .../Painting/Paint.cs | 6 +-- .../SKCharts/Helpers/DoubleDict.cs | 4 +- .../JsInterop/DomJsInterop.cs | 4 +- .../MotionCanvas.razor.cs | 2 +- .../MotionCanvas.cs | 2 +- 50 files changed, 143 insertions(+), 165 deletions(-) diff --git a/samples/MauiSample/AppShell.xaml.cs b/samples/MauiSample/AppShell.xaml.cs index 8c6cb7a92..094925761 100644 --- a/samples/MauiSample/AppShell.xaml.cs +++ b/samples/MauiSample/AppShell.xaml.cs @@ -3,7 +3,7 @@ public partial class AppShell : Shell { private bool _isLoaded = false; - private readonly Dictionary _routesSamples = new(); + private readonly Dictionary _routesSamples = []; public AppShell() { diff --git a/samples/ViewModelsSamples/Bars/AutoUpdate/ViewModel.cs b/samples/ViewModelsSamples/Bars/AutoUpdate/ViewModel.cs index 0c6a9c7d7..e588efa21 100644 --- a/samples/ViewModelsSamples/Bars/AutoUpdate/ViewModel.cs +++ b/samples/ViewModelsSamples/Bars/AutoUpdate/ViewModel.cs @@ -18,8 +18,8 @@ public partial class ViewModel : ObservableObject public ViewModel() { // Use ObservableCollections to let the chart listen for changes (or any INotifyCollectionChanged). // mark - _observableValues = new ObservableCollection - { + _observableValues = + [ // Use the ObservableValue or ObservablePoint types to let the chart listen for property changes // mark // or use any INotifyPropertyChanged implementation // mark new ObservablePoint(_index++, 2), @@ -35,15 +35,15 @@ public ViewModel() new(_index++, 3), new(_index++, 8), new(_index++, 3) - }; + ]; - Series = new ObservableCollection - { + Series = + [ new ColumnSeries { Values = _observableValues } - }; + ]; // in the following sample notice that the type int does not implement INotifyPropertyChanged // and our Series.Values property is of type List diff --git a/samples/ViewModelsSamples/Bars/DelayedAnimation/ViewModel.cs b/samples/ViewModelsSamples/Bars/DelayedAnimation/ViewModel.cs index 9696f92c9..2fa32acd7 100644 --- a/samples/ViewModelsSamples/Bars/DelayedAnimation/ViewModel.cs +++ b/samples/ViewModelsSamples/Bars/DelayedAnimation/ViewModel.cs @@ -43,7 +43,7 @@ public ViewModel() columnSeries1.PointMeasured += OnPointMeasured; columnSeries2.PointMeasured += OnPointMeasured; - Series = new List { columnSeries1, columnSeries2 }; + Series = [columnSeries1, columnSeries2]; } private void OnPointMeasured(ChartPoint point) diff --git a/samples/ViewModelsSamples/General/ConditionalDraw/ViewModel.cs b/samples/ViewModelsSamples/General/ConditionalDraw/ViewModel.cs index bad676fa7..b8cd03d99 100644 --- a/samples/ViewModelsSamples/General/ConditionalDraw/ViewModel.cs +++ b/samples/ViewModelsSamples/General/ConditionalDraw/ViewModel.cs @@ -13,16 +13,16 @@ namespace ViewModelsSamples.General.ConditionalDraw; public partial class ViewModel : ObservableObject { - private readonly ObservableCollection _values = new(); + private readonly ObservableCollection _values = []; public ViewModel() { var dangerPaint = new SolidColorPaint(SKColors.Red); - _values = new ObservableCollection - { + _values = + [ new(2), new(5), new(4), new(6), new(8), new(3), new(2), new(4), new(6) - }; + ]; var series = new ColumnSeries { diff --git a/samples/ViewModelsSamples/General/RealTime/ViewModel.cs b/samples/ViewModelsSamples/General/RealTime/ViewModel.cs index bec4a2ef0..3f411faf4 100644 --- a/samples/ViewModelsSamples/General/RealTime/ViewModel.cs +++ b/samples/ViewModelsSamples/General/RealTime/ViewModel.cs @@ -14,13 +14,13 @@ namespace ViewModelsSamples.General.RealTime; public partial class ViewModel : ObservableObject { private readonly Random _random = new(); - private readonly List _values = new(); + private readonly List _values = []; private readonly DateTimeAxis _customAxis; public ViewModel() { - Series = new ObservableCollection - { + Series = + [ new LineSeries { Values = _values, @@ -28,7 +28,7 @@ public ViewModel() GeometryFill = null, GeometryStroke = null } - }; + ]; _customAxis = new DateTimeAxis(TimeSpan.FromSeconds(1), Formatter) { diff --git a/samples/ViewModelsSamples/General/Scrollable/ViewModel.cs b/samples/ViewModelsSamples/General/Scrollable/ViewModel.cs index 341f8f4ea..e48552f83 100644 --- a/samples/ViewModelsSamples/General/Scrollable/ViewModel.cs +++ b/samples/ViewModelsSamples/General/Scrollable/ViewModel.cs @@ -16,7 +16,7 @@ namespace ViewModelsSamples.General.Scrollable; public partial class ViewModel { private bool _isDown = false; - private readonly ObservableCollection _values = new(); + private readonly ObservableCollection _values = []; public ViewModel() { diff --git a/samples/ViewModelsSamples/Lines/AutoUpdate/ViewModel.cs b/samples/ViewModelsSamples/Lines/AutoUpdate/ViewModel.cs index 67398a217..3bb7e5786 100644 --- a/samples/ViewModelsSamples/Lines/AutoUpdate/ViewModel.cs +++ b/samples/ViewModelsSamples/Lines/AutoUpdate/ViewModel.cs @@ -18,8 +18,8 @@ public partial class ViewModel : ObservableObject public ViewModel() { // Use ObservableCollections to let the chart listen for changes (or any INotifyCollectionChanged). // mark - _observableValues = new ObservableCollection - { + _observableValues = + [ // Use the ObservableValue or ObservablePoint types to let the chart listen for property changes // mark // or use any INotifyPropertyChanged implementation // mark new ObservableValue(2), @@ -35,16 +35,16 @@ public ViewModel() new(3), new(4), new(3) - }; + ]; - Series = new ObservableCollection - { + Series = + [ new LineSeries { Values = _observableValues, Fill = null } - }; + ]; // in the following sample notice that the type int does not implement INotifyPropertyChanged // and our Series.Values property is of type List diff --git a/samples/ViewModelsSamples/Pies/AutoUpdate/ViewModel.cs b/samples/ViewModelsSamples/Pies/AutoUpdate/ViewModel.cs index d7bb498d1..5ccd9e9c0 100644 --- a/samples/ViewModelsSamples/Pies/AutoUpdate/ViewModel.cs +++ b/samples/ViewModelsSamples/Pies/AutoUpdate/ViewModel.cs @@ -15,8 +15,8 @@ public partial class ViewModel : ObservableObject public ViewModel() { // Use ObservableCollections to let the chart listen for changes (or any INotifyCollectionChanged). // mark - Series = new ObservableCollection - { + Series = + [ // Use the ObservableValue or ObservablePoint types to let the chart listen for property changes // mark // or use any INotifyPropertyChanged implementation // mark new PieSeries { Values = new[] { new ObservableValue(2) } }, @@ -25,7 +25,7 @@ public ViewModel() new PieSeries { Values = new[] { new ObservableValue(7) } }, new PieSeries { Values = new[] { new ObservableValue(4) } }, new PieSeries { Values = new[] { new ObservableValue(3) } } - }; + ]; } public ObservableCollection Series { get; set; } diff --git a/samples/ViewModelsSamples/Scatter/AutoUpdate/ViewModel.cs b/samples/ViewModelsSamples/Scatter/AutoUpdate/ViewModel.cs index ba675fa62..174917151 100644 --- a/samples/ViewModelsSamples/Scatter/AutoUpdate/ViewModel.cs +++ b/samples/ViewModelsSamples/Scatter/AutoUpdate/ViewModel.cs @@ -18,8 +18,8 @@ public partial class ViewModel : ObservableObject public ViewModel() { // Use ObservableCollections to let the chart listen for changes (or any INotifyCollectionChanged). // mark - _observableValues = new ObservableCollection - { + _observableValues = + [ // Use the WeightedPoint, ObservableValue or ObservablePoint types to let the chart listen for property changes // mark // or use any INotifyPropertyChanged implementation // mark new WeightedPoint(_index++, 2, 6), @@ -35,12 +35,12 @@ public ViewModel() new(_index++, 3, 8), new(_index++, 8, 9), new(_index++, 3, 4) - }; + ]; - Series = new ObservableCollection - { + Series = + [ new ScatterSeries { Values = _observableValues, GeometrySize = 50 } - }; + ]; // in the following series notice that the type int does not implement INotifyPropertyChanged // and our Series.Values collection is of type List diff --git a/samples/ViewModelsSamples/StepLines/AutoUpdate/ViewModel.cs b/samples/ViewModelsSamples/StepLines/AutoUpdate/ViewModel.cs index 549d038a3..05dc04353 100644 --- a/samples/ViewModelsSamples/StepLines/AutoUpdate/ViewModel.cs +++ b/samples/ViewModelsSamples/StepLines/AutoUpdate/ViewModel.cs @@ -18,8 +18,8 @@ public partial class ViewModel : ObservableObject public ViewModel() { // Use ObservableCollections to let the chart listen for changes (or any INotifyCollectionChanged). // mark - _observableValues = new ObservableCollection - { + _observableValues = + [ // Use the ObservableValue or ObservablePoint types to let the chart listen for property changes // mark // or use any INotifyPropertyChanged implementation // mark new ObservablePoint(_index++, 2), @@ -35,16 +35,16 @@ public ViewModel() new(_index++, 3), new(_index++, 4), new(_index++, 3) - }; + ]; - Series = new ObservableCollection - { + Series = + [ new StepLineSeries { Values = _observableValues, // Fill = null } - }; + ]; // in the following series notice that the type int does not implement INotifyPropertyChanged // and our Series.Values collection is of type List diff --git a/samples/XamarinSample/XamarinSample/XamarinSample/AppShell.xaml.cs b/samples/XamarinSample/XamarinSample/XamarinSample/AppShell.xaml.cs index f8d15b40c..90dfaa014 100644 --- a/samples/XamarinSample/XamarinSample/XamarinSample/AppShell.xaml.cs +++ b/samples/XamarinSample/XamarinSample/XamarinSample/AppShell.xaml.cs @@ -8,7 +8,7 @@ namespace XamarinSample; public partial class AppShell : Shell { private bool _isLoaded = false; - private readonly Dictionary _routesSamples = new(); + private readonly Dictionary _routesSamples = []; public AppShell() { diff --git a/src/LiveChartsCore/CartesianChart.cs b/src/LiveChartsCore/CartesianChart.cs index 94abc5d20..29387eac8 100644 --- a/src/LiveChartsCore/CartesianChart.cs +++ b/src/LiveChartsCore/CartesianChart.cs @@ -48,7 +48,7 @@ public class CartesianChart : Chart private DrawMarginFrame? _previousDrawMarginFrame; private const double MaxAxisBound = 0.05; private const double MaxAxisActiveBound = 0.15; - private HashSet> _crosshair = new(); + private HashSet> _crosshair = []; /// /// Initializes a new instance of the class. @@ -851,7 +851,7 @@ protected internal override void Measure() public override void Unload() { base.Unload(); - _crosshair = new(); + _crosshair = []; _isFirstDraw = true; } diff --git a/src/LiveChartsCore/Chart.cs b/src/LiveChartsCore/Chart.cs index 8f1223bd0..f4149a2bf 100644 --- a/src/LiveChartsCore/Chart.cs +++ b/src/LiveChartsCore/Chart.cs @@ -44,15 +44,15 @@ public abstract class Chart : IChart { #region fields - internal readonly HashSet> _everMeasuredElements = new(); - internal HashSet> _toDeleteElements = new(); + internal readonly HashSet> _everMeasuredElements = []; + internal HashSet> _toDeleteElements = []; internal bool _isToolTipOpen = false; internal bool _isPointerIn; internal LvcPoint _pointerPosition = new(-10, -10); internal float _titleHeight = 0f; internal LvcSize _legendSize; internal bool _preserveFirstDraw = false; - internal readonly HashSet _drawnSeries = new(); + internal readonly HashSet _drawnSeries = []; internal bool _isFirstDraw = true; private readonly ActionThrottler _updateThrottler; private readonly ActionThrottler _tooltipThrottler; @@ -62,7 +62,7 @@ public abstract class Chart : IChart private LvcPoint _pointerPanningPosition = new(-10, -10); private LvcPoint _pointerPreviousPanningPosition = new(-10, -10); private bool _isPanning = false; - private readonly Dictionary _activePoints = new(); + private readonly Dictionary _activePoints = []; private LvcSize _previousSize = new(); private readonly bool _isMobile; @@ -578,7 +578,7 @@ protected void CollectVisuals() _ = _everMeasuredElements.Remove(visual); } - _toDeleteElements = new HashSet>(); + _toDeleteElements = []; } /// diff --git a/src/LiveChartsCore/CoreAxis.cs b/src/LiveChartsCore/CoreAxis.cs index 848d59fd8..10a14170e 100644 --- a/src/LiveChartsCore/CoreAxis.cs +++ b/src/LiveChartsCore/CoreAxis.cs @@ -52,7 +52,7 @@ public abstract class CoreAxis /// /// The active separators /// - protected internal readonly Dictionary>> activeSeparators = new(); + protected internal readonly Dictionary>> activeSeparators = []; internal float _xo = 0f, _yo = 0f; internal LvcSize _size; @@ -405,7 +405,7 @@ public override void Invalidate(Chart chart) if (!activeSeparators.TryGetValue(cartesianChart, out var separators)) { - separators = new Dictionary>(); + separators = []; activeSeparators[cartesianChart] = separators; } diff --git a/src/LiveChartsCore/CoreHeatLandSeries.cs b/src/LiveChartsCore/CoreHeatLandSeries.cs index 594536afc..4c084d996 100644 --- a/src/LiveChartsCore/CoreHeatLandSeries.cs +++ b/src/LiveChartsCore/CoreHeatLandSeries.cs @@ -45,9 +45,9 @@ public class CoreHeatLandSeries : IGeoSeries, private double[]? _colorStops; private IEnumerable? _lands; private bool _isVisible; - private readonly HashSet> _subscribedTo = new(); + private readonly HashSet> _subscribedTo = []; private readonly CollectionDeepObserver _observer; - private readonly HashSet _everUsed = new(); + private readonly HashSet _everUsed = []; /// /// Initializes a new instance of the class. diff --git a/src/LiveChartsCore/CoreHeatSeries.cs b/src/LiveChartsCore/CoreHeatSeries.cs index 751c2a12e..1cf2fb270 100644 --- a/src/LiveChartsCore/CoreHeatSeries.cs +++ b/src/LiveChartsCore/CoreHeatSeries.cs @@ -46,7 +46,7 @@ public abstract class CoreHeatSeries private IPaint? _paintTaks; private Bounds _weightBounds = new(); private int _heatKnownLength = 0; - private List> _heatStops = new(); + private List> _heatStops = []; private LvcColor[] _heatMap = { LvcColor.FromArgb(255, 87, 103, 222), // cold (min value) diff --git a/src/LiveChartsCore/CoreLineSeries.cs b/src/LiveChartsCore/CoreLineSeries.cs index 1a74fd5ca..0236a83f7 100644 --- a/src/LiveChartsCore/CoreLineSeries.cs +++ b/src/LiveChartsCore/CoreLineSeries.cs @@ -49,8 +49,8 @@ public class CoreLineSeries, new() where TDrawingContext : DrawingContext { - internal readonly Dictionary> _fillPathHelperDictionary = new(); - internal readonly Dictionary> _strokePathHelperDictionary = new(); + internal readonly Dictionary> _fillPathHelperDictionary = []; + internal readonly Dictionary> _strokePathHelperDictionary = []; private float _lineSmoothness = 0.65f; private float _geometrySize = 14f; private bool _enableNullSplitting = true; @@ -162,13 +162,13 @@ public override void Invalidate(Chart chart) if (!_strokePathHelperDictionary.TryGetValue(chart.Canvas.Sync, out var strokePathHelperContainer)) { - strokePathHelperContainer = new List(); + strokePathHelperContainer = []; _strokePathHelperDictionary[chart.Canvas.Sync] = strokePathHelperContainer; } if (!_fillPathHelperDictionary.TryGetValue(chart.Canvas.Sync, out var fillPathHelperContainer)) { - fillPathHelperContainer = new List(); + fillPathHelperContainer = []; _fillPathHelperDictionary[chart.Canvas.Sync] = fillPathHelperContainer; } diff --git a/src/LiveChartsCore/CorePolarAxis.cs b/src/LiveChartsCore/CorePolarAxis.cs index 832d5f306..735129594 100644 --- a/src/LiveChartsCore/CorePolarAxis.cs +++ b/src/LiveChartsCore/CorePolarAxis.cs @@ -52,7 +52,7 @@ public abstract class CorePolarAxis /// The active separators /// - protected readonly Dictionary>> activeSeparators = new(); + protected readonly Dictionary>> activeSeparators = []; internal PolarAxisOrientation _orientation; private double _minStep = 0; @@ -279,7 +279,7 @@ public override void Invalidate(Chart chart) if (!activeSeparators.TryGetValue(polarChart, out var separators)) { - separators = new Dictionary>(); + separators = []; activeSeparators[polarChart] = separators; } diff --git a/src/LiveChartsCore/CorePolarLineSeries.cs b/src/LiveChartsCore/CorePolarLineSeries.cs index 874799fe3..6913365c5 100644 --- a/src/LiveChartsCore/CorePolarLineSeries.cs +++ b/src/LiveChartsCore/CorePolarLineSeries.cs @@ -47,8 +47,8 @@ public class CorePolarLineSeries, new() where TDrawingContext : DrawingContext { - private readonly Dictionary> _fillPathHelperDictionary = new(); - private readonly Dictionary> _strokePathHelperDictionary = new(); + private readonly Dictionary> _fillPathHelperDictionary = []; + private readonly Dictionary> _strokePathHelperDictionary = []; private float _lineSmoothness = 0.65f; private float _geometrySize = 14f; private bool _enableNullSplitting = true; @@ -218,13 +218,13 @@ public override void Invalidate(Chart chart) if (!_strokePathHelperDictionary.TryGetValue(chart.Canvas.Sync, out var strokePathHelperContainer)) { - strokePathHelperContainer = new List(); + strokePathHelperContainer = []; _strokePathHelperDictionary[chart.Canvas.Sync] = strokePathHelperContainer; } if (!_fillPathHelperDictionary.TryGetValue(chart.Canvas.Sync, out var fillPathHelperContainer)) { - fillPathHelperContainer = new List(); + fillPathHelperContainer = []; _fillPathHelperDictionary[chart.Canvas.Sync] = fillPathHelperContainer; } diff --git a/src/LiveChartsCore/CoreStepLineSeries.cs b/src/LiveChartsCore/CoreStepLineSeries.cs index 96af5eaff..916efae43 100644 --- a/src/LiveChartsCore/CoreStepLineSeries.cs +++ b/src/LiveChartsCore/CoreStepLineSeries.cs @@ -48,8 +48,8 @@ public class CoreStepLineSeries, new() where TDrawingContext : DrawingContext { - private readonly Dictionary> _fillPathHelperDictionary = new(); - private readonly Dictionary> _strokePathHelperDictionary = new(); + private readonly Dictionary> _fillPathHelperDictionary = []; + private readonly Dictionary> _strokePathHelperDictionary = []; private float _geometrySize = 14f; private IPaint? _geometryFill; private IPaint? _geometryStroke; @@ -133,13 +133,13 @@ public override void Invalidate(Chart chart) if (!_strokePathHelperDictionary.TryGetValue(chart.Canvas.Sync, out var strokePathHelperContainer)) { - strokePathHelperContainer = new List(); + strokePathHelperContainer = []; _strokePathHelperDictionary[chart.Canvas.Sync] = strokePathHelperContainer; } if (!_fillPathHelperDictionary.TryGetValue(chart.Canvas.Sync, out var fillPathHelperContainer)) { - fillPathHelperContainer = new List(); + fillPathHelperContainer = []; _fillPathHelperDictionary[chart.Canvas.Sync] = fillPathHelperContainer; } diff --git a/src/LiveChartsCore/Drawing/Animatable.cs b/src/LiveChartsCore/Drawing/Animatable.cs index 62de9f6d0..5a4b6f23e 100644 --- a/src/LiveChartsCore/Drawing/Animatable.cs +++ b/src/LiveChartsCore/Drawing/Animatable.cs @@ -45,7 +45,7 @@ protected Animatable() { } public bool RemoveOnCompleted { get; set; } /// - public Dictionary MotionProperties { get; } = new(); + public Dictionary MotionProperties { get; } = []; /// public void SetTransition(Animation? animation, params string[]? propertyName) diff --git a/src/LiveChartsCore/Geo/CoreMap.cs b/src/LiveChartsCore/Geo/CoreMap.cs index 8e6a834bb..fdd83def2 100644 --- a/src/LiveChartsCore/Geo/CoreMap.cs +++ b/src/LiveChartsCore/Geo/CoreMap.cs @@ -62,7 +62,7 @@ public CoreMap(StreamReader streamReader, string layerName = "default") /// /// Gets the map layers dictionary. /// - public Dictionary> Layers { get; protected set; } = new(); + public Dictionary> Layers { get; protected set; } = []; /// /// Finds a land by short name. diff --git a/src/LiveChartsCore/Geo/MapLayer.cs b/src/LiveChartsCore/Geo/MapLayer.cs index 1423c9652..029d3404d 100644 --- a/src/LiveChartsCore/Geo/MapLayer.cs +++ b/src/LiveChartsCore/Geo/MapLayer.cs @@ -87,7 +87,7 @@ public MapLayer(string layerName, IPaint stroke, IPaint /// Gets the lands. /// - public Dictionary Lands { get; private set; } = new(); + public Dictionary Lands { get; private set; } = []; /// /// Gets or sets the land condition, it must return true if the land is required. diff --git a/src/LiveChartsCore/GeoMap.cs b/src/LiveChartsCore/GeoMap.cs index 7b141cc2c..5c7612990 100644 --- a/src/LiveChartsCore/GeoMap.cs +++ b/src/LiveChartsCore/GeoMap.cs @@ -38,7 +38,7 @@ namespace LiveChartsCore; public class GeoMap where TDrawingContext : DrawingContext { - private readonly HashSet> _everMeasuredSeries = new(); + private readonly HashSet> _everMeasuredSeries = []; private readonly ActionThrottler _updateThrottler; private readonly ActionThrottler _panningThrottler; private bool _isHeatInCanvas = false; diff --git a/src/LiveChartsCore/Kernel/ChartElement.cs b/src/LiveChartsCore/Kernel/ChartElement.cs index 29dd9ed00..5f8ab9cde 100644 --- a/src/LiveChartsCore/Kernel/ChartElement.cs +++ b/src/LiveChartsCore/Kernel/ChartElement.cs @@ -37,8 +37,8 @@ public abstract class ChartElement : IChartElement _userSets = new(); - private readonly List> _deletingTasks = new(); + internal readonly HashSet _userSets = []; + private readonly List> _deletingTasks = []; /// /// Occurs when a property value changes. diff --git a/src/LiveChartsCore/Kernel/ChartEntityMetaData.cs b/src/LiveChartsCore/Kernel/ChartEntityMetaData.cs index e397e19c9..6bc98a98b 100644 --- a/src/LiveChartsCore/Kernel/ChartEntityMetaData.cs +++ b/src/LiveChartsCore/Kernel/ChartEntityMetaData.cs @@ -60,5 +60,5 @@ public int EntityIndex /// /// Gets the chart points dictionary. /// - public Dictionary ChartPoints { get; set; } = new(); + public Dictionary ChartPoints { get; set; } = []; } diff --git a/src/LiveChartsCore/Kernel/CollectionDeepObserver.cs b/src/LiveChartsCore/Kernel/CollectionDeepObserver.cs index 70bccadef..94f711715 100644 --- a/src/LiveChartsCore/Kernel/CollectionDeepObserver.cs +++ b/src/LiveChartsCore/Kernel/CollectionDeepObserver.cs @@ -36,7 +36,7 @@ public class CollectionDeepObserver { private readonly NotifyCollectionChangedEventHandler _onCollectionChanged; private readonly PropertyChangedEventHandler _onItemPropertyChanged; - private readonly HashSet _itemsListening = new(); + private readonly HashSet _itemsListening = []; /// /// The check i notify property changed diff --git a/src/LiveChartsCore/Kernel/Drawing/Sketch.cs b/src/LiveChartsCore/Kernel/Drawing/Sketch.cs index ba3967562..7cf7b81e7 100644 --- a/src/LiveChartsCore/Kernel/Drawing/Sketch.cs +++ b/src/LiveChartsCore/Kernel/Drawing/Sketch.cs @@ -72,5 +72,5 @@ public Sketch(double width, double height, string? svg) /// /// The paint tasks schedule. /// - public List> PaintSchedules { get; set; } = new(); + public List> PaintSchedules { get; set; } = []; } diff --git a/src/LiveChartsCore/Kernel/LiveChartsSettings.cs b/src/LiveChartsCore/Kernel/LiveChartsSettings.cs index 91d8bcbd7..d70782269 100644 --- a/src/LiveChartsCore/Kernel/LiveChartsSettings.cs +++ b/src/LiveChartsCore/Kernel/LiveChartsSettings.cs @@ -38,7 +38,7 @@ namespace LiveChartsCore.Kernel; public class LiveChartsSettings { private object? _currentProvider; - private readonly Dictionary _mappers = new(); + private readonly Dictionary _mappers = []; private object _theme = new(); /// diff --git a/src/LiveChartsCore/Kernel/Providers/DataFactory.cs b/src/LiveChartsCore/Kernel/Providers/DataFactory.cs index 173a358f2..f7a0d45a0 100644 --- a/src/LiveChartsCore/Kernel/Providers/DataFactory.cs +++ b/src/LiveChartsCore/Kernel/Providers/DataFactory.cs @@ -40,7 +40,7 @@ public class DataFactory where TDrawingContext : DrawingContext { private readonly bool _isTModelChartEntity = false; - private readonly Dictionary> _chartIndexEntityMap = new(); + private readonly Dictionary> _chartIndexEntityMap = []; private ISeries? _series; /// @@ -380,7 +380,7 @@ private IEnumerable EnumerateChartEntities(ISeries series, _ = _chartIndexEntityMap.TryGetValue(canvas.Sync, out var d); if (d is null) { - d = new Dictionary(); + d = []; _chartIndexEntityMap[canvas.Sync] = d; } var IndexEntityMap = d; diff --git a/src/LiveChartsCore/Kernel/SeriesContext.cs b/src/LiveChartsCore/Kernel/SeriesContext.cs index 2123f6ee4..385361ee5 100644 --- a/src/LiveChartsCore/Kernel/SeriesContext.cs +++ b/src/LiveChartsCore/Kernel/SeriesContext.cs @@ -47,13 +47,13 @@ public class SeriesContext private bool _arePieLabeleMeasured = false; private float _pieLabelsSize = 0f; - private readonly Dictionary, int> _columnPositions = new(); - private readonly Dictionary, int> _rowPositions = new(); - private readonly Dictionary, int> _boxPositions = new(); - private readonly Dictionary _stackColumnPositions = new(); - private readonly Dictionary _stackRowsPositions = new(); + private readonly Dictionary, int> _columnPositions = []; + private readonly Dictionary, int> _rowPositions = []; + private readonly Dictionary, int> _boxPositions = []; + private readonly Dictionary _stackColumnPositions = []; + private readonly Dictionary _stackRowsPositions = []; - private readonly Dictionary> _stackers = new(); + private readonly Dictionary> _stackers = []; private readonly IChart _chart; diff --git a/src/LiveChartsCore/Kernel/Stacker.cs b/src/LiveChartsCore/Kernel/Stacker.cs index 56d5f2472..9389e5120 100644 --- a/src/LiveChartsCore/Kernel/Stacker.cs +++ b/src/LiveChartsCore/Kernel/Stacker.cs @@ -33,9 +33,9 @@ namespace LiveChartsCore.Kernel; public class Stacker where TDrawingContext : DrawingContext { - private readonly Dictionary, int> _stackPositions = new(); - private readonly List> _stack = new(); - private readonly Dictionary _totals = new(); + private readonly Dictionary, int> _stackPositions = []; + private readonly List> _stack = []; + private readonly Dictionary _totals = []; private int _stackCount = 0; private int _knownMaxLenght = 0; diff --git a/src/LiveChartsCore/Motion/MotionCanvas.cs b/src/LiveChartsCore/Motion/MotionCanvas.cs index 0a29dc940..0939df793 100644 --- a/src/LiveChartsCore/Motion/MotionCanvas.cs +++ b/src/LiveChartsCore/Motion/MotionCanvas.cs @@ -35,9 +35,9 @@ namespace LiveChartsCore.Motion; public class MotionCanvas : IDisposable where TDrawingContext : DrawingContext { - internal HashSet> _paintTasks = new(); + internal HashSet> _paintTasks = []; private readonly Stopwatch _stopwatch = new(); - private readonly List _fpsStack = new(); + private readonly List _fpsStack = []; private long _previousFrameTime; private long _previousLogTime; private object _sync = new(); @@ -81,7 +81,7 @@ public MotionCanvas() /// /// Gets the animatables collection. /// - public HashSet Trackers { get; } = new HashSet(); + public HashSet Trackers { get; } = []; /// /// Draws the frame. diff --git a/src/LiveChartsCore/Series.cs b/src/LiveChartsCore/Series.cs index 705b2184d..4c029fecc 100644 --- a/src/LiveChartsCore/Series.cs +++ b/src/LiveChartsCore/Series.cs @@ -56,7 +56,7 @@ public abstract class Series /// /// The subscribed to /// - protected readonly HashSet subscribedTo = new(); + protected readonly HashSet subscribedTo = []; /// /// The implements icp @@ -76,7 +76,7 @@ public abstract class Series /// /// The ever fetched points. /// - protected internal HashSet everFetched = new(); + protected internal HashSet everFetched = []; /// /// Indicates whether the custom measure handler was requested already. @@ -93,12 +93,6 @@ public abstract class Series /// protected bool _geometrySvgChanged = false; - /// - /// Will be deleted on future versions - /// - [Obsolete] - protected Func, string>? _obsolete_formatter = null; - private readonly CollectionDeepObserver _observer; private IEnumerable? _values; private string? _name; @@ -233,22 +227,6 @@ public string? GeometrySvg /// public int ZIndex { get => _zIndex; set => SetProperty(ref _zIndex, value); } - /// - /// Gets or sets the tool tip label formatter, this function will build the label when a point in this series - /// is shown inside a tool tip. - /// - /// - /// The tool tip label formatter. - /// - [Obsolete( - $"You must now use {nameof(CartesianSeries.XToolTipLabelFormatter)} or " + - $"{nameof(CartesianSeries.YToolTipLabelFormatter)} instead.")] - public Func, string>? TooltipLabelFormatter - { - get => _obsolete_formatter; - set => _obsolete_formatter = value; - } - /// /// Gets or sets the data label formatter, this function will build the label when a point in this series /// is shown as data label. @@ -428,7 +406,7 @@ public override void RemoveFromUI(Chart chart) base.RemoveFromUI(chart); DataFactory?.Dispose(chart); _dataFactory = null; - everFetched = new HashSet(); + everFetched = []; } /// diff --git a/src/LiveChartsCore/Themes/Theme.cs b/src/LiveChartsCore/Themes/Theme.cs index a2e3edbe6..e425a3ec1 100644 --- a/src/LiveChartsCore/Themes/Theme.cs +++ b/src/LiveChartsCore/Themes/Theme.cs @@ -48,7 +48,7 @@ public class Theme /// /// The axis builder. /// - public List>> AxisBuilder { get; set; } = new(); + public List>> AxisBuilder { get; set; } = []; /// /// Gets or sets the draw margin frame builder. @@ -56,7 +56,7 @@ public class Theme /// /// The draw margin frame builder. /// - public List>> DrawMarginFrameBuilder { get; set; } = new(); + public List>> DrawMarginFrameBuilder { get; set; } = []; /// /// Gets or sets the series builder. @@ -64,7 +64,7 @@ public class Theme /// /// The pie series builder. /// - public List>> SeriesBuilder { get; set; } = new(); + public List>> SeriesBuilder { get; set; } = []; /// /// Gets or sets the pie series builder. @@ -72,7 +72,7 @@ public class Theme /// /// The pie series builder. /// - public List>> PieSeriesBuilder { get; set; } = new(); + public List>> PieSeriesBuilder { get; set; } = []; /// /// Gets or sets the gauge series builder. @@ -80,7 +80,7 @@ public class Theme /// /// The pie series builder. /// - public List>> GaugeSeriesBuilder { get; set; } = new(); + public List>> GaugeSeriesBuilder { get; set; } = []; /// /// Gets or sets the gauge fill series builder. @@ -88,7 +88,7 @@ public class Theme /// /// The pie series builder. /// - public List>> GaugeFillSeriesBuilder { get; set; } = new(); + public List>> GaugeFillSeriesBuilder { get; set; } = []; /// /// Gets or sets the Cartesian series builder. @@ -96,7 +96,7 @@ public class Theme /// /// The pie series builder. /// - public List>> CartesianSeriesBuilder { get; set; } = new(); + public List>> CartesianSeriesBuilder { get; set; } = []; /// /// Gets or sets the stepline series builder. @@ -104,7 +104,7 @@ public class Theme /// /// The pie series builder. /// - public List>> StepLineSeriesBuilder { get; set; } = new(); + public List>> StepLineSeriesBuilder { get; set; } = []; /// /// Gets or sets the stacked stepline series builder. @@ -112,7 +112,7 @@ public class Theme /// /// The pie series builder. /// - public List>> StackedStepLineSeriesBuilder { get; set; } = new(); + public List>> StackedStepLineSeriesBuilder { get; set; } = []; /// /// Gets or sets the line series builder. @@ -120,7 +120,7 @@ public class Theme /// /// The pie series builder. /// - public List>> LineSeriesBuilder { get; set; } = new(); + public List>> LineSeriesBuilder { get; set; } = []; /// /// Gets or sets the line series builder. @@ -128,7 +128,7 @@ public class Theme /// /// The polar series builder. /// - public List>> PolarSeriesBuilder { get; set; } = new(); + public List>> PolarSeriesBuilder { get; set; } = []; /// /// Gets or sets the line series builder. @@ -136,7 +136,7 @@ public class Theme /// /// The polar series builder. /// - public List>> PolarLineSeriesBuilder { get; set; } = new(); + public List>> PolarLineSeriesBuilder { get; set; } = []; /// /// Gets or sets the line series builder. @@ -144,7 +144,7 @@ public class Theme /// /// The polar series builder. /// - public List>> StackedPolarSeriesBuilder { get; set; } = new(); + public List>> StackedPolarSeriesBuilder { get; set; } = []; /// /// Gets or sets the line series builder. @@ -152,7 +152,7 @@ public class Theme /// /// The pie series builder. /// - public List>> HeatSeriesBuilder { get; set; } = new(); + public List>> HeatSeriesBuilder { get; set; } = []; /// /// Gets or sets the financial series builder. @@ -160,7 +160,7 @@ public class Theme /// /// The pie series builder. /// - public List>> FinancialSeriesBuilder { get; set; } = new(); + public List>> FinancialSeriesBuilder { get; set; } = []; /// /// Gets or sets the stacked line series builder. @@ -168,7 +168,7 @@ public class Theme /// /// The pie series builder. /// - public List>> StackedLineSeriesBuilder { get; set; } = new(); + public List>> StackedLineSeriesBuilder { get; set; } = []; /// /// Gets or sets the bar series builder. @@ -176,7 +176,7 @@ public class Theme /// /// The pie series builder. /// - public List>> BarSeriesBuilder { get; set; } = new(); + public List>> BarSeriesBuilder { get; set; } = []; /// /// Gets or sets the column series builder. @@ -184,7 +184,7 @@ public class Theme /// /// The pie series builder. /// - public List>> ColumnSeriesBuilder { get; set; } = new(); + public List>> ColumnSeriesBuilder { get; set; } = []; /// /// Gets or sets the row series builder. @@ -192,7 +192,7 @@ public class Theme /// /// The pie series builder. /// - public List>> RowSeriesBuilder { get; set; } = new(); + public List>> RowSeriesBuilder { get; set; } = []; /// /// Gets or sets the stacked bar series builder. @@ -200,7 +200,7 @@ public class Theme /// /// The pie series builder. /// - public List>> StackedBarSeriesBuilder { get; set; } = new(); + public List>> StackedBarSeriesBuilder { get; set; } = []; /// /// Gets or sets the stacked column series builder. @@ -208,7 +208,7 @@ public class Theme /// /// The pie series builder. /// - public List>> StackedColumnSeriesBuilder { get; set; } = new(); + public List>> StackedColumnSeriesBuilder { get; set; } = []; /// /// Gets or sets the stacked row series builder. @@ -216,7 +216,7 @@ public class Theme /// /// The pie series builder. /// - public List>> StackedRowSeriesBuilder { get; set; } = new(); + public List>> StackedRowSeriesBuilder { get; set; } = []; /// /// Gets or sets the scatter series builder. @@ -224,7 +224,7 @@ public class Theme /// /// The pie series builder. /// - public List>> ScatterSeriesBuilder { get; set; } = new(); + public List>> ScatterSeriesBuilder { get; set; } = []; /// /// Gets or sets the error series builder. @@ -232,7 +232,7 @@ public class Theme /// /// The pie series builder. /// - public List>> BoxSeriesBuilder { get; set; } = new(); + public List>> BoxSeriesBuilder { get; set; } = []; /// /// Applies the theme to an axis. diff --git a/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs b/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs index 6f840fcfe..a9a3218e9 100644 --- a/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs +++ b/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs @@ -50,7 +50,7 @@ public class AngularTicksVisual _visuals = new(); + private readonly Dictionary _visuals = []; /// /// Gets or sets the labels paint. diff --git a/src/LiveChartsCore/VisualElements/RelativePanel.cs b/src/LiveChartsCore/VisualElements/RelativePanel.cs index cb9c4c301..58b2a80bd 100644 --- a/src/LiveChartsCore/VisualElements/RelativePanel.cs +++ b/src/LiveChartsCore/VisualElements/RelativePanel.cs @@ -52,7 +52,7 @@ public RelativePanel() /// /// Gets the children collection. /// - public HashSet> Children { get; } = new(); + public HashSet> Children { get; } = []; /// /// Gets or sets the background paint. diff --git a/src/LiveChartsCore/VisualElements/StackPanel.cs b/src/LiveChartsCore/VisualElements/StackPanel.cs index a32f7c3e5..7189be31f 100644 --- a/src/LiveChartsCore/VisualElements/StackPanel.cs +++ b/src/LiveChartsCore/VisualElements/StackPanel.cs @@ -55,7 +55,7 @@ public StackPanel() /// /// Gets the children collection. /// - public List> Children { get; } = new(); + public List> Children { get; } = []; /// /// Gets or sets the panel orientation. @@ -176,7 +176,7 @@ public override LvcSize Measure(Chart chart) var mx = 0f; var my = 0f; - List line = new(); + List line = []; LvcSize alignCurrentLine() { @@ -212,7 +212,7 @@ LvcSize alignCurrentLine() if (child.Size.Height > my) my = child.Size.Height; } - line = new(); + line = []; return new LvcSize(mx, my); } diff --git a/src/LiveChartsCore/VisualElements/TableLayout.cs b/src/LiveChartsCore/VisualElements/TableLayout.cs index 2c32bc074..436e5b4af 100644 --- a/src/LiveChartsCore/VisualElements/TableLayout.cs +++ b/src/LiveChartsCore/VisualElements/TableLayout.cs @@ -37,7 +37,7 @@ public class TableLayout : VisualElement, new() { private IPaint? _backgroundPaint; - private readonly Dictionary> _positions = new(); + private readonly Dictionary> _positions = []; private LvcSize[,] _measuredSizes = new LvcSize[0, 0]; private int _maxRow = 0; private int _maxColumn = 0; @@ -149,7 +149,7 @@ public void AddChild( Align? verticalAlign = null) { if (!_positions.TryGetValue(row, out var r)) - _positions.Add(row, r = new Dictionary()); + _positions.Add(row, r = []); r[column] = new(row, column, child, verticalAlign, horizontalAlign); if (row > _maxRow) _maxRow = row; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/MotionCanvas.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/MotionCanvas.cs index f2126d156..aa6afda3a 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/MotionCanvas.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/MotionCanvas.cs @@ -40,7 +40,7 @@ namespace LiveChartsCore.SkiaSharpView.WinForms; public partial class MotionCanvas : UserControl { private bool _isDrawingLoopRunning = false; - private List> _paintTasksSchedule = new(); + private List> _paintTasksSchedule = []; /// /// Initializes a new instance of the class. diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/SVGPathGeometry.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/SVGPathGeometry.cs index a4b38d051..7ea5ccc6e 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/SVGPathGeometry.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/SVGPathGeometry.cs @@ -69,7 +69,7 @@ public SVGPathGeometry(Func pathSource) /// memory, this has no secondary effects in most of the cases, but if you are parsing a lot of paths /// (maybe over 500) then you must consider cleaning the cache when you no longer need a path. /// - public static readonly Dictionary Cache = new(); + public static readonly Dictionary Cache = []; /// /// Gets or sets the path. diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/GaugeGenerator.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/GaugeGenerator.cs index 8a9e486ef..5407587ed 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/GaugeGenerator.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/GaugeGenerator.cs @@ -70,8 +70,8 @@ public static ObservableCollection> BuildAngularGauge private static ObservableCollection> Build( GaugeOptions options, params GaugeItem[] items) { - List seriesRules = new(); - List backgroundRules = new(); + List seriesRules = []; + List backgroundRules = []; foreach (var item in items) { diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/PieChartExtensions.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/PieChartExtensions.cs index bcec47d26..2860fd626 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/PieChartExtensions.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/PieChartExtensions.cs @@ -132,14 +132,14 @@ internal static TSeries AsSeries( ObservableCollection values; if (gaugeOptions == GaugeOptions.Solid) { - values = new ObservableCollection(); + values = []; while (values.Count < count - 1) values.Add(default!); values.Insert(i, instance); } else { - values = new ObservableCollection { instance }; + values = [instance]; if (gaugeOptions == GaugeOptions.Angular) { series.HoverPushout = 0; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/GaugeBuilder.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/GaugeBuilder.cs index d428b05b7..2b3105bfd 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/GaugeBuilder.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/GaugeBuilder.cs @@ -39,8 +39,8 @@ namespace LiveChartsCore.SkiaSharpView; [Obsolete($"Use {nameof(GaugeGenerator)}.{nameof(GaugeGenerator.BuildSolidGauge)} instead.")] public class GaugeBuilder : IGaugeBuilder { - private readonly Dictionary?, IPaint?>> _keyValuePairs = new(); - private readonly List?, IPaint?>> _tuples = new(); + private readonly Dictionary?, IPaint?>> _keyValuePairs = []; + private readonly List?, IPaint?>> _tuples = []; private List>? _builtSeries; private RadialAlignment? _radialAlign = null; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/MapFactory.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/MapFactory.cs index 1d959e706..e8400c70d 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/MapFactory.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/MapFactory.cs @@ -37,9 +37,9 @@ namespace LiveChartsCore.SkiaSharpView; /// public class MapFactory : IMapFactory { - private readonly HashSet _usedPathShapes = new(); - private readonly HashSet> _usedPaints = new(); - private readonly HashSet _usedLayers = new(); + private readonly HashSet _usedPathShapes = []; + private readonly HashSet> _usedPaints = []; + private readonly HashSet _usedLayers = []; private IGeoMapView? _mapView; /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/Paint.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/Paint.cs index 65f466798..35189b4e9 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/Paint.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/Paint.cs @@ -36,8 +36,8 @@ namespace LiveChartsCore.SkiaSharpView.Painting; public abstract class Paint : Animatable, IDisposable, IPaint { private readonly FloatMotionProperty _strokeMiterTransition; - private readonly Dictionary, HashSet>> _geometriesByCanvas = new(); - private readonly Dictionary, LvcRectangle> _clipRectangles = new(); + private readonly Dictionary, HashSet>> _geometriesByCanvas = []; + private readonly Dictionary, LvcRectangle> _clipRectangles = []; private char? _matchesChar = null; internal SKPaint? _skiaPaint; internal FloatMotionProperty _strokeWidthTransition; @@ -205,7 +205,7 @@ public void AddGeometryToPaintTask(MotionCanvas canvas, var g = GetGeometriesByCanvas(canvas); if (g is null) { - g = new HashSet>(); + g = []; _geometriesByCanvas[canvas] = g; } _ = g.Add(geometry); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/Helpers/DoubleDict.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/Helpers/DoubleDict.cs index 2e3a740bb..cca9254c9 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/Helpers/DoubleDict.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/Helpers/DoubleDict.cs @@ -29,8 +29,8 @@ internal class DoubleDict where T1 : notnull where T2 : notnull { - private readonly Dictionary _keys = new(); - private readonly Dictionary _values = new(); + private readonly Dictionary _keys = []; + private readonly Dictionary _values = []; public void Add(T1 key, T2 value) { diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/JsInterop/DomJsInterop.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/JsInterop/DomJsInterop.cs index 1488fbc8c..4abb8e974 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/JsInterop/DomJsInterop.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/JsInterop/DomJsInterop.cs @@ -32,7 +32,7 @@ namespace LiveChartsCore.SkiaSharpView.Blazor; public class DomJsInterop : IAsyncDisposable { private readonly Lazy> _moduleTask; - private static readonly Dictionary>> s_resizeEvent = new(); + private static readonly Dictionary>> s_resizeEvent = []; /// /// Initialized a new instance of the class. @@ -86,7 +86,7 @@ public async ValueTask OnResize(ElementReference element, string elementId, Acti { if (!s_resizeEvent.TryGetValue(elementId, out var actions)) { - actions = new List>(); + actions = []; s_resizeEvent.Add(elementId, actions); var module = await _moduleTask.Value; await module.InvokeVoidAsync("DOMInterop.registerResizeListener", element, elementId); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/MotionCanvas.razor.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/MotionCanvas.razor.cs index 316ca51d9..0d5d74989 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/MotionCanvas.razor.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/MotionCanvas.razor.cs @@ -37,7 +37,7 @@ public partial class MotionCanvas : IDisposable private SKCanvasView? _canvas; private bool _disposing = false; private bool _isDrawingLoopRunning = false; - private List> _paintTasksSchedule = new(); + private List> _paintTasksSchedule = []; /// /// Called when the control is initialized. diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/MotionCanvas.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/MotionCanvas.cs index 9e124831d..8e64618c8 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/MotionCanvas.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/MotionCanvas.cs @@ -38,7 +38,7 @@ namespace LiveChartsCore.SkiaSharpView.Eto; public class MotionCanvas : SkiaDrawable { private bool _isDrawingLoopRunning = false; - private List> _paintTasksSchedule = new(); + private List> _paintTasksSchedule = []; /// /// Initializes a new instance of the class. From 4b062047e2b39d24f7ec0ef48b2ecc58ef3d7086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Fri, 17 Nov 2023 17:51:08 -0600 Subject: [PATCH 02/23] remove obsolete formatter --- src/LiveChartsCore/CartesianSeries.cs | 2 +- src/LiveChartsCore/CorePieSeries.cs | 2 +- src/LiveChartsCore/CorePolarLineSeries.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/LiveChartsCore/CartesianSeries.cs b/src/LiveChartsCore/CartesianSeries.cs index eb9797059..2f1f08d8b 100644 --- a/src/LiveChartsCore/CartesianSeries.cs +++ b/src/LiveChartsCore/CartesianSeries.cs @@ -94,7 +94,7 @@ public Func, string>? XToolTipLabelFormatter public Func, string>? YToolTipLabelFormatter { get => _yTooltipLabelFormatter; - set { SetProperty(ref _yTooltipLabelFormatter, value); _obsolete_formatter = value; } + set => SetProperty(ref _yTooltipLabelFormatter, value); } /// diff --git a/src/LiveChartsCore/CorePieSeries.cs b/src/LiveChartsCore/CorePieSeries.cs index 5f0c0c931..12cc3fe47 100644 --- a/src/LiveChartsCore/CorePieSeries.cs +++ b/src/LiveChartsCore/CorePieSeries.cs @@ -151,7 +151,7 @@ public IPaint? Fill public Func, string>? ToolTipLabelFormatter { get => _tooltipLabelFormatter; - set { SetProperty(ref _tooltipLabelFormatter, value); _obsolete_formatter = value; } + set => SetProperty(ref _tooltipLabelFormatter, value); } /// diff --git a/src/LiveChartsCore/CorePolarLineSeries.cs b/src/LiveChartsCore/CorePolarLineSeries.cs index 6913365c5..3c441c568 100644 --- a/src/LiveChartsCore/CorePolarLineSeries.cs +++ b/src/LiveChartsCore/CorePolarLineSeries.cs @@ -167,7 +167,7 @@ public Func, string>? AngleToolTipLabelForma public Func, string>? RadiusToolTipLabelFormatter { get => _radiusTooltipLabelFormatter; - set { SetProperty(ref _radiusTooltipLabelFormatter, value); _obsolete_formatter = value; } + set => SetProperty(ref _radiusTooltipLabelFormatter, value); } /// From 06b418f3efc874ceb6dc4c2f8f88c1e89c3e06f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Fri, 17 Nov 2023 17:55:28 -0600 Subject: [PATCH 03/23] clean core assembly warnings --- src/LiveChartsCore/Chart.cs | 10 +++++++++- src/LiveChartsCore/CorePieSeries.cs | 5 +---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/LiveChartsCore/Chart.cs b/src/LiveChartsCore/Chart.cs index f4149a2bf..702b7f118 100644 --- a/src/LiveChartsCore/Chart.cs +++ b/src/LiveChartsCore/Chart.cs @@ -57,14 +57,16 @@ public abstract class Chart : IChart private readonly ActionThrottler _updateThrottler; private readonly ActionThrottler _tooltipThrottler; private readonly ActionThrottler _panningThrottler; - private bool _isTooltipCanceled; private LvcPoint _pointerPanningStartPosition = new(-10, -10); private LvcPoint _pointerPanningPosition = new(-10, -10); private LvcPoint _pointerPreviousPanningPosition = new(-10, -10); private bool _isPanning = false; private readonly Dictionary _activePoints = []; private LvcSize _previousSize = new(); +#if NET5_0_OR_GREATER private readonly bool _isMobile; + private bool _isTooltipCanceled; +#endif #endregion @@ -328,7 +330,9 @@ internal virtual void InvokePointerDown(LvcPoint point, bool isSecondaryAction) lock (Canvas.Sync) { +#if NET5_0_OR_GREATER if (_isMobile) _isTooltipCanceled = false; +#endif var strategy = VisibleSeries.GetTooltipFindingStrategy(); @@ -373,6 +377,7 @@ internal virtual void InvokePointerMove(LvcPoint point) internal virtual void InvokePointerUp(LvcPoint point, bool isSecondaryAction) { +#if NET5_0_OR_GREATER if (_isMobile) { lock (Canvas.Sync) @@ -382,6 +387,7 @@ internal virtual void InvokePointerUp(LvcPoint point, bool isSecondaryAction) View.InvokeOnUIThread(CloseTooltip); } +#endif if (!_isPanning) return; _isPanning = false; @@ -661,7 +667,9 @@ private Task TooltipThrottlerUnlocked() { lock (Canvas.Sync) { +#if NET5_0_OR_GREATER if (_isTooltipCanceled) return; +#endif DrawToolTip(); Canvas.Invalidate(); } diff --git a/src/LiveChartsCore/CorePieSeries.cs b/src/LiveChartsCore/CorePieSeries.cs index 12cc3fe47..9cf72db1f 100644 --- a/src/LiveChartsCore/CorePieSeries.cs +++ b/src/LiveChartsCore/CorePieSeries.cs @@ -169,9 +169,6 @@ public override void Invalidate(Chart chart) minDimension = minDimension - (Stroke?.StrokeThickness ?? 0) * 2 - maxPushout * 2; - var maxOuterRadius = (float)MaxOuterRadius; - minDimension *= maxOuterRadius; - var pieLabelsCorrection = chart.SeriesContext.GetPieOuterLabelsSpace(); minDimension -= pieLabelsCorrection; @@ -505,7 +502,7 @@ public override int GetStackGroup() /// internal override IPaint?[] GetPaintTasks() { - return new[] { _fill, _stroke, DataLabelsPaint }; + return [_fill, _stroke, DataLabelsPaint]; } /// From f2aa359e814aaefb82f51aba3054d62aad514521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Fri, 17 Nov 2023 18:08:55 -0600 Subject: [PATCH 04/23] use Primary constructors --- .../Platforms/Android/MainApplication.cs | 7 +- .../Financial/BasicCandlesticks/ViewModel.cs | 21 ++-- .../General/ConditionalDraw/City.cs | 9 +- .../General/Legends/AvailablePosition.cs | 12 +-- .../General/Tooltips/AvailablePositions.cs | 12 +-- samples/WPFSample/Command.cs | 8 +- .../ChartBehaviour.Android.cs | 11 +-- .../Events/EventArgs.cs | 16 ++-- .../Events/PinchEventArgs.cs | 24 ++--- .../Events/PressedEventArgs.cs | 21 ++-- .../Events/ScreenEventArgs.cs | 19 ++-- .../Events/ScrollEventArgs.cs | 21 ++-- .../ConditionalDraw/ConditionalDrawBuilder.cs | 38 +++----- src/LiveChartsCore/CoreLineSeries.cs | 30 ++---- src/LiveChartsCore/Drawing/LvcSize.cs | 21 ++-- src/LiveChartsCore/Geo/LandDefinition.cs | 26 ++--- src/LiveChartsCore/Geo/MapContext.cs | 31 +++--- src/LiveChartsCore/Geo/MapLayer.cs | 26 ++--- src/LiveChartsCore/Geo/MapShapeContext.cs | 39 ++++---- src/LiveChartsCore/Geo/ZoomOnPointerView.cs | 21 ++-- src/LiveChartsCore/Kernel/ActionThrottler.cs | 25 ++--- .../Kernel/ChartEntityMetaData.cs | 18 ++-- src/LiveChartsCore/Kernel/Drawing/Sketch.cs | 26 ++--- .../Kernel/Events/ChartCommandArgs.cs | 16 ++-- .../Kernel/Events/PointerCommandArgs.cs | 30 +++--- src/LiveChartsCore/Kernel/Extensions.cs | 27 ++---- src/LiveChartsCore/Kernel/SeriesContext.cs | 28 ++---- .../Kernel/TooltipPlacementContext.cs | 16 ++-- src/LiveChartsCore/Measure/AxisLimit.cs | 36 +++---- src/LiveChartsCore/Measure/VectorManager.cs | 20 ++-- src/LiveChartsCore/PieChart.cs | 55 +++++------ src/LiveChartsCore/PolarChart.cs | 65 ++++++------- .../VisualElements/AngularTicksVisual.cs | 15 +-- .../VisualElements/StackPanel.cs | 12 +-- .../VisualElements/TableLayout.cs | 46 ++++----- .../VisualElements/VariableGeometryVisual.cs | 28 +++--- .../MotionCanvas.axaml.cs | 20 +--- .../ResolutionHelper.cs | 22 ++--- .../Drawing/SkiaSharpDrawingContext.cs | 54 ++++------- .../Painting/Effects/DashEffect.cs | 20 ++-- .../Painting/ImageFilters/Blur.cs | 32 ++----- .../Painting/ImageFilters/DropShadow.cs | 44 +++------ .../ImageFiltersMergeOperation.cs | 25 ++--- .../Painting/LinearGradientPaint.cs | 95 ++++++++----------- .../VisualElements/VariableGeometryVisual.cs | 5 +- .../JsInterop/DomJsInterop.cs | 19 ++-- .../OtherTests/DataProviderTest.cs | 9 +- 47 files changed, 441 insertions(+), 780 deletions(-) diff --git a/samples/MauiSample/Platforms/Android/MainApplication.cs b/samples/MauiSample/Platforms/Android/MainApplication.cs index 3869c13e3..314a4a2b0 100644 --- a/samples/MauiSample/Platforms/Android/MainApplication.cs +++ b/samples/MauiSample/Platforms/Android/MainApplication.cs @@ -4,13 +4,8 @@ namespace MauiSample { [Application] - public class MainApplication : MauiApplication + public class MainApplication(IntPtr handle, JniHandleOwnership ownership) : MauiApplication(handle, ownership) { - public MainApplication(IntPtr handle, JniHandleOwnership ownership) - : base(handle, ownership) - { - } - protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); } } \ No newline at end of file diff --git a/samples/ViewModelsSamples/Financial/BasicCandlesticks/ViewModel.cs b/samples/ViewModelsSamples/Financial/BasicCandlesticks/ViewModel.cs index c4b845567..6660ab7db 100644 --- a/samples/ViewModelsSamples/Financial/BasicCandlesticks/ViewModel.cs +++ b/samples/ViewModelsSamples/Financial/BasicCandlesticks/ViewModel.cs @@ -63,20 +63,11 @@ public ViewModel() public ISeries[] Series { get; set; } } -public class FinancialData +public class FinancialData(DateTime date, double high, double open, double close, double low) { - public FinancialData(DateTime date, double high, double open, double close, double low) - { - Date = date; - High = high; - Open = open; - Close = close; - Low = low; - } - - public DateTime Date { get; set; } - public double High { get; set; } - public double Open { get; set; } - public double Close { get; set; } - public double Low { get; set; } + public DateTime Date { get; set; } = date; + public double High { get; set; } = high; + public double Open { get; set; } = open; + public double Close { get; set; } = close; + public double Low { get; set; } = low; } diff --git a/samples/ViewModelsSamples/General/ConditionalDraw/City.cs b/samples/ViewModelsSamples/General/ConditionalDraw/City.cs index 9d9c39a4f..aa68c9700 100644 --- a/samples/ViewModelsSamples/General/ConditionalDraw/City.cs +++ b/samples/ViewModelsSamples/General/ConditionalDraw/City.cs @@ -2,13 +2,8 @@ namespace ViewModelsSamples.General.ConditionalDraw; -public partial class City : ObservableObject +public partial class City(double population) : ObservableObject { - public City(double population) - { - _population = population; - } - [ObservableProperty] - private double _population; + private double _population = population; } diff --git a/samples/ViewModelsSamples/General/Legends/AvailablePosition.cs b/samples/ViewModelsSamples/General/Legends/AvailablePosition.cs index 81eb6b253..6a55595e1 100644 --- a/samples/ViewModelsSamples/General/Legends/AvailablePosition.cs +++ b/samples/ViewModelsSamples/General/Legends/AvailablePosition.cs @@ -2,14 +2,8 @@ namespace ViewModelsSamples.General.Legends; -public class AvailablePosition +public class AvailablePosition(string name, LegendPosition position) { - public AvailablePosition(string name, LegendPosition position) - { - Name = name; - Position = position; - } - - public string Name { get; set; } - public LegendPosition Position { get; set; } + public string Name { get; set; } = name; + public LegendPosition Position { get; set; } = position; } diff --git a/samples/ViewModelsSamples/General/Tooltips/AvailablePositions.cs b/samples/ViewModelsSamples/General/Tooltips/AvailablePositions.cs index c46af296a..a0c6bf2e0 100644 --- a/samples/ViewModelsSamples/General/Tooltips/AvailablePositions.cs +++ b/samples/ViewModelsSamples/General/Tooltips/AvailablePositions.cs @@ -2,14 +2,8 @@ namespace ViewModelsSamples.General.Tooltips; -public class AvailablePositions +public class AvailablePositions(string name, TooltipPosition position) { - public AvailablePositions(string name, TooltipPosition position) - { - Name = name; - Position = position; - } - - public string Name { get; set; } - public TooltipPosition Position { get; set; } + public string Name { get; set; } = name; + public TooltipPosition Position { get; set; } = position; } diff --git a/samples/WPFSample/Command.cs b/samples/WPFSample/Command.cs index ea1f0e079..40b011afc 100644 --- a/samples/WPFSample/Command.cs +++ b/samples/WPFSample/Command.cs @@ -3,16 +3,10 @@ namespace WPFSample; -public class Command : ICommand +public class Command(Action command) : ICommand { - private readonly Action command; public event EventHandler CanExecuteChanged; - public Command(Action command) - { - this.command = command; - } - public bool CanExecute(object parameter) { return true; diff --git a/src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs b/src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs index f13a43fe0..a67c18b2d 100644 --- a/src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs +++ b/src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs @@ -125,21 +125,14 @@ protected void OnAndroidTouched(object? sender, View.TouchEventArgs e) viewGroup.RequestDisallowInterceptTouchEvent(isChartInteraction); } - private class CustomScaleListener : ScaleGestureDetector.SimpleOnScaleGestureListener + private class CustomScaleListener(Action onScaled) : ScaleGestureDetector.SimpleOnScaleGestureListener { - private readonly Action _onScaled; - - public CustomScaleListener(Action onScaled) - { - _onScaled = onScaled; - } - public bool Paused { get; set; } public override bool OnScale(ScaleGestureDetector? detector) { if (detector is null || detector.ScaleFactor == 1 || Paused) return false; - _onScaled(detector.ScaleFactor); + onScaled(detector.ScaleFactor); return true; } } diff --git a/src/LiveChartsCore.Behaviours/Events/EventArgs.cs b/src/LiveChartsCore.Behaviours/Events/EventArgs.cs index 079f81ddf..d8d1a4ec1 100644 --- a/src/LiveChartsCore.Behaviours/Events/EventArgs.cs +++ b/src/LiveChartsCore.Behaviours/Events/EventArgs.cs @@ -25,19 +25,15 @@ namespace LiveChartsCore.Behaviours.Events; /// /// Defines the screen event args. /// -public class EventArgs +/// +/// Initializes a new instance of the class. +/// +/// The original event. +public class EventArgs(object originalEvent) { - /// - /// Initializes a new instance of the class. - /// - /// The original event. - public EventArgs(object originalEvent) - { - OriginalEvent = originalEvent; - } /// /// Gets the original event. /// - public object OriginalEvent { get; } + public object OriginalEvent { get; } = originalEvent; } diff --git a/src/LiveChartsCore.Behaviours/Events/PinchEventArgs.cs b/src/LiveChartsCore.Behaviours/Events/PinchEventArgs.cs index d28efe6db..c5cd40264 100644 --- a/src/LiveChartsCore.Behaviours/Events/PinchEventArgs.cs +++ b/src/LiveChartsCore.Behaviours/Events/PinchEventArgs.cs @@ -27,28 +27,22 @@ namespace LiveChartsCore.Behaviours.Events; /// /// Defines the pinch event args. /// -public class PinchEventArgs : EventArgs +/// +/// Initializes a new instance of the class. +/// +/// The scale. +/// The start. +/// The original event. +public class PinchEventArgs(float scale, LvcPoint pinchStart, object originalEvent) : EventArgs(originalEvent) { - /// - /// Initializes a new instance of the class. - /// - /// The scale. - /// The start. - /// The original event. - public PinchEventArgs(float scale, LvcPoint pinchStart, object originalEvent) - : base(originalEvent) - { - Scale = scale; - PinchStart = pinchStart; - } /// /// Gets the scale. /// - public float Scale { get; } + public float Scale { get; } = scale; /// /// Gets the pinch star location. /// - public LvcPoint PinchStart { get; set; } + public LvcPoint PinchStart { get; set; } = pinchStart; } diff --git a/src/LiveChartsCore.Behaviours/Events/PressedEventArgs.cs b/src/LiveChartsCore.Behaviours/Events/PressedEventArgs.cs index 2aca80083..9a64ebeef 100644 --- a/src/LiveChartsCore.Behaviours/Events/PressedEventArgs.cs +++ b/src/LiveChartsCore.Behaviours/Events/PressedEventArgs.cs @@ -27,22 +27,17 @@ namespace LiveChartsCore.Behaviours.Events; /// /// Defines the pointer event args. /// -public class PressedEventArgs : ScreenEventArgs +/// +/// Initializes a new instance of the class. +/// +/// The pointer location. +/// Indicates whether the action is secondary. +/// The original event. +public class PressedEventArgs(LvcPoint location, bool isSecondaryPress, object originalEvent) : ScreenEventArgs(location, originalEvent) { - /// - /// Initializes a new instance of the class. - /// - /// The pointer location. - /// Indicates whether the action is secondary. - /// The original event. - public PressedEventArgs(LvcPoint location, bool isSecondaryPress, object originalEvent) - : base(location, originalEvent) - { - IsSecondaryPress = isSecondaryPress; - } /// /// Gets a value indicating whether the action is a secondary press. /// - public bool IsSecondaryPress { get; } + public bool IsSecondaryPress { get; } = isSecondaryPress; } diff --git a/src/LiveChartsCore.Behaviours/Events/ScreenEventArgs.cs b/src/LiveChartsCore.Behaviours/Events/ScreenEventArgs.cs index de073c169..704ef05f8 100644 --- a/src/LiveChartsCore.Behaviours/Events/ScreenEventArgs.cs +++ b/src/LiveChartsCore.Behaviours/Events/ScreenEventArgs.cs @@ -27,21 +27,16 @@ namespace LiveChartsCore.Behaviours.Events; /// /// Defines the screen event args. /// -public class ScreenEventArgs : EventArgs +/// +/// Initializes a new instance of the class. +/// +/// The pointer location. +/// The original event. +public class ScreenEventArgs(LvcPoint location, object originalEvent) : EventArgs(originalEvent) { - /// - /// Initializes a new instance of the class. - /// - /// The pointer location. - /// The original event. - public ScreenEventArgs(LvcPoint location, object originalEvent) - : base(originalEvent) - { - Location = location; - } /// /// Gets the pointer location. /// - public LvcPoint Location { get; } + public LvcPoint Location { get; } = location; } diff --git a/src/LiveChartsCore.Behaviours/Events/ScrollEventArgs.cs b/src/LiveChartsCore.Behaviours/Events/ScrollEventArgs.cs index 9c57b57a4..e95257cef 100644 --- a/src/LiveChartsCore.Behaviours/Events/ScrollEventArgs.cs +++ b/src/LiveChartsCore.Behaviours/Events/ScrollEventArgs.cs @@ -27,22 +27,17 @@ namespace LiveChartsCore.Behaviours.Events; /// /// Defines the scroll event args. /// -public class ScrollEventArgs : ScreenEventArgs +/// +/// Initializes a new instance of the class. +/// +/// The pointer location. +/// Indicates the scroll delta. +/// The original event. +public class ScrollEventArgs(LvcPoint location, double scrollDelta, object originalEvent) : ScreenEventArgs(location, originalEvent) { - /// - /// Initializes a new instance of the class. - /// - /// The pointer location. - /// Indicates the scroll delta. - /// The original event. - public ScrollEventArgs(LvcPoint location, double scrollDelta, object originalEvent) - : base(location, originalEvent) - { - ScrollDelta = scrollDelta; - } /// /// Gets the scroll delta. /// - public double ScrollDelta { get; } + public double ScrollDelta { get; } = scrollDelta; } diff --git a/src/LiveChartsCore/ConditionalDraw/ConditionalDrawBuilder.cs b/src/LiveChartsCore/ConditionalDraw/ConditionalDrawBuilder.cs index b9d262601..afa727ce9 100644 --- a/src/LiveChartsCore/ConditionalDraw/ConditionalDrawBuilder.cs +++ b/src/LiveChartsCore/ConditionalDraw/ConditionalDrawBuilder.cs @@ -29,29 +29,21 @@ namespace LiveChartsCore.ConditionalDraw; /// /// Defines a instance. /// +/// +/// Initializes a new builder for the given paint. +/// +/// The series. +/// The paint. [Obsolete("Replaced by MaPoints extensiion.")] -public class ConditionalPaintBuilder +public class ConditionalPaintBuilder(Series series, IPaint paint) where TDrawingContext : DrawingContext where TVisual : class, IGeometry, new() where TLabel : class, ILabelGeometry, new() { private bool _isPaintInCanvas = false; private object _clipFor = new(); - private readonly Series _series; - private readonly IPaint _paint; private Func, bool>? _whenPredicate; - /// - /// Initializes a new builder for the given paint. - /// - /// The series. - /// The paint. - public ConditionalPaintBuilder(Series series, IPaint paint) - { - _series = series; - _paint = paint; - } - /// /// Applies the paint when the given condition is true. /// @@ -60,8 +52,8 @@ public Series When( Func, bool> predicate) { _whenPredicate = predicate; - _series.PointMeasured += OnMeasured; - return _series; + series.PointMeasured += OnMeasured; + return series; } /// @@ -69,7 +61,7 @@ public Series When( /// public void UnSubscribe() { - _series.PointMeasured -= OnMeasured; + series.PointMeasured -= OnMeasured; } private void OnMeasured(ChartPoint point) @@ -83,8 +75,8 @@ private void OnMeasured(ChartPoint point) if (!_isPaintInCanvas) { - canvas.AddDrawableTask(_paint); - if (_paint.ZIndex == 0) _paint.ZIndex = int.MaxValue; + canvas.AddDrawableTask(paint); + if (paint.ZIndex == 0) paint.ZIndex = int.MaxValue; _isPaintInCanvas = true; } @@ -95,15 +87,15 @@ private void OnMeasured(ChartPoint point) { var drawLocation = cartesianChart.DrawMarginLocation; var drawMarginSize = cartesianChart.DrawMarginSize; - _paint.SetClipRectangle(cartesianChart.Canvas, new LvcRectangle(drawLocation, drawMarginSize)); + paint.SetClipRectangle(cartesianChart.Canvas, new LvcRectangle(drawLocation, drawMarginSize)); } } if (isTriggered) { - _paint.AddGeometryToPaintTask(canvas, drawable); + paint.AddGeometryToPaintTask(canvas, drawable); - foreach (var paint in _series.GetPaintTasks()) + foreach (var paint in series.GetPaintTasks()) { if (paint is null) continue; paint.RemoveGeometryFromPainTask(canvas, drawable); @@ -111,7 +103,7 @@ private void OnMeasured(ChartPoint point) } else { - _paint.RemoveGeometryFromPainTask(canvas, drawable); + paint.RemoveGeometryFromPainTask(canvas, drawable); } } } diff --git a/src/LiveChartsCore/CoreLineSeries.cs b/src/LiveChartsCore/CoreLineSeries.cs index 0236a83f7..110a929f6 100644 --- a/src/LiveChartsCore/CoreLineSeries.cs +++ b/src/LiveChartsCore/CoreLineSeries.cs @@ -761,23 +761,15 @@ private SegmentVisual GetSegmentVisual(int index, List container, return new SegmentVisual(isNew, path); } - private class SplineData + private class SplineData(ChartPoint start) { - public SplineData(ChartPoint start) - { - Previous = start; - Current = start; - Next = start; - AfterNext = start; - } - - public ChartPoint Previous { get; set; } + public ChartPoint Previous { get; set; } = start; - public ChartPoint Current { get; set; } + public ChartPoint Current { get; set; } = start; - public ChartPoint Next { get; set; } + public ChartPoint Next { get; set; } = start; - public ChartPoint AfterNext { get; set; } + public ChartPoint AfterNext { get; set; } = start; public bool IsFirst { get; set; } = true; @@ -790,16 +782,10 @@ public void GoNext(ChartPoint point) } } - private class SegmentVisual + private class SegmentVisual(bool isNew, TPathGeometry path) { - public SegmentVisual(bool isNew, TPathGeometry path) - { - IsNew = isNew; - Path = path; - } - - public bool IsNew { get; set; } + public bool IsNew { get; set; } = isNew; - public TPathGeometry Path { get; set; } + public TPathGeometry Path { get; set; } = path; } } diff --git a/src/LiveChartsCore/Drawing/LvcSize.cs b/src/LiveChartsCore/Drawing/LvcSize.cs index 3efc64844..080bf42c9 100644 --- a/src/LiveChartsCore/Drawing/LvcSize.cs +++ b/src/LiveChartsCore/Drawing/LvcSize.cs @@ -25,28 +25,23 @@ namespace LiveChartsCore.Drawing; /// /// Defines a size. /// -public struct LvcSize +/// +/// Initializes a new instance of the struct. +/// +/// The width. +/// The height. +public struct LvcSize(float width, float height) { - /// - /// Initializes a new instance of the struct. - /// - /// The width. - /// The height. - public LvcSize(float width, float height) - { - Width = width; - Height = height; - } /// /// Gets or sets the width. /// - public float Width { get; set; } + public float Width { get; set; } = width; /// /// Gets or sets the height. /// - public float Height { get; set; } + public float Height { get; set; } = height; /// /// Determines whether the instance is equals to the given instance. diff --git a/src/LiveChartsCore/Geo/LandDefinition.cs b/src/LiveChartsCore/Geo/LandDefinition.cs index e31a1d8a8..68774f89c 100644 --- a/src/LiveChartsCore/Geo/LandDefinition.cs +++ b/src/LiveChartsCore/Geo/LandDefinition.cs @@ -27,35 +27,29 @@ namespace LiveChartsCore.Geo; /// /// Defines the data of a lane in a map. /// -public class LandDefinition +/// +/// Initializes a new instance of the class. +/// +/// The short name. +/// The name. +/// The set of. +public class LandDefinition(string shortName, string name, string setOf) { - /// - /// Initializes a new instance of the class. - /// - /// The short name. - /// The name. - /// The set of. - public LandDefinition(string shortName, string name, string setOf) - { - Name = name; - ShortName = shortName; - SetOf = setOf; - } /// /// Gets the short name. /// - public string ShortName { get; } + public string ShortName { get; } = shortName; /// /// Gets the name. /// - public string Name { get; } + public string Name { get; } = name; /// /// Gets or sets the set of reference. /// - public string SetOf { get; set; } + public string SetOf { get; set; } = setOf; /// /// Gets the HSize. diff --git a/src/LiveChartsCore/Geo/MapContext.cs b/src/LiveChartsCore/Geo/MapContext.cs index c011cc43f..26d30aa54 100644 --- a/src/LiveChartsCore/Geo/MapContext.cs +++ b/src/LiveChartsCore/Geo/MapContext.cs @@ -28,41 +28,34 @@ namespace LiveChartsCore.Geo; /// Defines a map context. /// /// -public class MapContext +/// +/// Initializes a new instance of class. +/// +public class MapContext( + GeoMap core, + IGeoMapView view, + CoreMap map, + MapProjector projector) where TDrawingContext : DrawingContext { - /// - /// Initializes a new instance of class. - /// - public MapContext( - GeoMap core, - IGeoMapView view, - CoreMap map, - MapProjector projector) - { - CoreMap = core; - MapFile = map; - Projector = projector; - View = view; - } /// /// Gets the core map. /// - public GeoMap CoreMap { get; } + public GeoMap CoreMap { get; } = core; /// /// Gets the map file. /// - public CoreMap MapFile { get; } + public CoreMap MapFile { get; } = map; /// /// Gets the map projector. /// - public MapProjector Projector { get; } + public MapProjector Projector { get; } = projector; /// /// Gets the map view. /// - public IGeoMapView View { get; } + public IGeoMapView View { get; } = view; } diff --git a/src/LiveChartsCore/Geo/MapLayer.cs b/src/LiveChartsCore/Geo/MapLayer.cs index 029d3404d..3169aadd9 100644 --- a/src/LiveChartsCore/Geo/MapLayer.cs +++ b/src/LiveChartsCore/Geo/MapLayer.cs @@ -30,21 +30,15 @@ namespace LiveChartsCore.Geo; /// /// Defines a map layer. /// -public class MapLayer +/// +/// Initializes a new from the given . +/// +/// The layer name. +/// The stroke. +/// The fill. +public class MapLayer(string layerName, IPaint stroke, IPaint fill) where TDrawingContext : DrawingContext { - /// - /// Initializes a new from the given . - /// - /// The layer name. - /// The stroke. - /// The fill. - public MapLayer(string layerName, IPaint stroke, IPaint fill) - { - Name = layerName; - Stroke = stroke; - Fill = fill; - } /// /// Gets or sets the name. @@ -52,7 +46,7 @@ public MapLayer(string layerName, IPaint stroke, IPaint /// The name. /// - public string Name { get; set; } + public string Name { get; set; } = layerName; /// /// Gets or sets the layer process index. @@ -67,12 +61,12 @@ public MapLayer(string layerName, IPaint stroke, IPaint /// Gets or sets the stroke. /// - public IPaint? Stroke { get; set; } + public IPaint? Stroke { get; set; } = stroke; /// /// Gets or sets the fill. /// - public IPaint? Fill { get; set; } + public IPaint? Fill { get; set; } = fill; /// /// Gets or sets the X bounds. diff --git a/src/LiveChartsCore/Geo/MapShapeContext.cs b/src/LiveChartsCore/Geo/MapShapeContext.cs index e23b2cbab..e75207cdf 100644 --- a/src/LiveChartsCore/Geo/MapShapeContext.cs +++ b/src/LiveChartsCore/Geo/MapShapeContext.cs @@ -30,45 +30,38 @@ namespace LiveChartsCore.Geo; /// /// Defines the map shape context class. /// -public class MapShapeContext +/// +/// Initializes a new instance of the class. +/// +/// The chart. +/// The heat paint. +/// The heat stops. +/// The bounds. +public class MapShapeContext( + IGeoMapView chart, + IPaint heatPaint, + List> heatStops, + Bounds bounds) where TDrawingContext : DrawingContext { - /// - /// Initializes a new instance of the class. - /// - /// The chart. - /// The heat paint. - /// The heat stops. - /// The bounds. - public MapShapeContext( - IGeoMapView chart, - IPaint heatPaint, - List> heatStops, - Bounds bounds) - { - Chart = chart; - HeatPaint = heatPaint; - HeatStops = heatStops; - Bounds = bounds; - } /// /// Gets the chart. /// - public IGeoMapView Chart { get; } + public IGeoMapView Chart { get; } = chart; /// /// Gets the heat paint. /// - public IPaint HeatPaint { get; } + public IPaint HeatPaint { get; } = heatPaint; /// /// Gets the heat stops. /// - public List> HeatStops { get; } + public List> HeatStops { get; } = heatStops; /// /// Gets the bounds dictionary. /// - public Bounds Bounds { get; } + public Bounds Bounds { get; } = bounds; } diff --git a/src/LiveChartsCore/Geo/ZoomOnPointerView.cs b/src/LiveChartsCore/Geo/ZoomOnPointerView.cs index 241124653..8677fae0b 100644 --- a/src/LiveChartsCore/Geo/ZoomOnPointerView.cs +++ b/src/LiveChartsCore/Geo/ZoomOnPointerView.cs @@ -28,26 +28,21 @@ namespace LiveChartsCore.Geo; /// /// Defines the /// -public class ZoomOnPointerView +/// +/// Initializes a new instance of the command. +/// +/// The pivot. +/// The direction. +public class ZoomOnPointerView(LvcPoint pivot, ZoomDirection direction) { - /// - /// Initializes a new instance of the command. - /// - /// The pivot. - /// The direction. - public ZoomOnPointerView(LvcPoint pivot, ZoomDirection direction) - { - Pivot = pivot; - Direction = direction; - } /// /// Gets the pivot. /// - public LvcPoint Pivot { get; } + public LvcPoint Pivot { get; } = pivot; /// /// Gets the direction. /// - public ZoomDirection Direction { get; } + public ZoomDirection Direction { get; } = direction; } diff --git a/src/LiveChartsCore/Kernel/ActionThrottler.cs b/src/LiveChartsCore/Kernel/ActionThrottler.cs index 44040170f..5913c5e37 100644 --- a/src/LiveChartsCore/Kernel/ActionThrottler.cs +++ b/src/LiveChartsCore/Kernel/ActionThrottler.cs @@ -28,23 +28,16 @@ namespace LiveChartsCore.Kernel; /// /// An object that is able to throttle an action. /// -public class ActionThrottler +/// +/// Initializes a new instance of the class. +/// +/// The target action to throttle. +/// The throttling time. +public class ActionThrottler(Func targetAction, TimeSpan time) { private readonly object _sync = new(); - private readonly Func _action; private bool _isWaiting = false; - /// - /// Initializes a new instance of the class. - /// - /// The target action to throttle. - /// The throttling time. - public ActionThrottler(Func targetAction, TimeSpan time) - { - _action = targetAction; - ThrottlerTimeSpan = time; - } - #if DEBUG /// /// Gets the calls. @@ -61,7 +54,7 @@ public ActionThrottler(Func targetAction, TimeSpan time) /// /// The throttler time span. /// - public TimeSpan ThrottlerTimeSpan { get; set; } + public TimeSpan ThrottlerTimeSpan { get; set; } = time; /// /// Schedules a call to the target action. @@ -89,7 +82,7 @@ public async void Call() _isWaiting = false; } - await Task.WhenAny(_action()); + await Task.WhenAny(targetAction()); } /// @@ -98,6 +91,6 @@ public async void Call() /// public void ForceCall() { - _ = _action(); + _ = targetAction(); } } diff --git a/src/LiveChartsCore/Kernel/ChartEntityMetaData.cs b/src/LiveChartsCore/Kernel/ChartEntityMetaData.cs index 6bc98a98b..249fd6cc5 100644 --- a/src/LiveChartsCore/Kernel/ChartEntityMetaData.cs +++ b/src/LiveChartsCore/Kernel/ChartEntityMetaData.cs @@ -29,20 +29,14 @@ namespace LiveChartsCore.Kernel; /// /// Represents additional data required by LiveCharts to draw a point. /// -public class ChartEntityMetaData +/// +/// Initializes a new instance of the class. +/// +/// The callback to call when the entity index changes. +public class ChartEntityMetaData(Action? onEntityIndexChanged = null) { - private readonly Action? _entityIndexChangedCallback; private int _entityIndex; - /// - /// Initializes a new instance of the class. - /// - /// The callback to call when the entity index changes. - public ChartEntityMetaData(Action? onEntityIndexChanged = null) - { - _entityIndexChangedCallback = onEntityIndexChanged; - } - /// /// Gets the entity index, a consecutive integer based on the position of the entity in the data collection. /// @@ -53,7 +47,7 @@ public int EntityIndex { if (value == _entityIndex) return; _entityIndex = value; - _entityIndexChangedCallback?.Invoke(value); + onEntityIndexChanged?.Invoke(value); } } diff --git a/src/LiveChartsCore/Kernel/Drawing/Sketch.cs b/src/LiveChartsCore/Kernel/Drawing/Sketch.cs index 7cf7b81e7..a81be0d60 100644 --- a/src/LiveChartsCore/Kernel/Drawing/Sketch.cs +++ b/src/LiveChartsCore/Kernel/Drawing/Sketch.cs @@ -29,21 +29,15 @@ namespace LiveChartsCore.Kernel.Drawing; /// Defines the paint context. /// /// The type of the drawing context. -public class Sketch +/// +/// Initializes a new instance of the class. +/// +/// The widht. +/// The height. +/// The svg path. +public class Sketch(double width, double height, string? svg) where TDrawingContext : DrawingContext { - /// - /// Initializes a new instance of the class. - /// - /// The widht. - /// The height. - /// The svg path. - public Sketch(double width, double height, string? svg) - { - Svg = svg; - Width = width; - Height = height; - } /// /// Gets or sets the width. @@ -51,7 +45,7 @@ public Sketch(double width, double height, string? svg) /// /// The width. /// kjio9 - public double Width { get; set; } + public double Width { get; set; } = width; /// /// Gets or sets the height. @@ -59,12 +53,12 @@ public Sketch(double width, double height, string? svg) /// /// The height. /// - public double Height { get; set; } + public double Height { get; set; } = height; /// /// Gets or sets the Svg. /// / - public string? Svg { get; set; } + public string? Svg { get; set; } = svg; /// /// Gets or sets the paint schedules. diff --git a/src/LiveChartsCore/Kernel/Events/ChartCommandArgs.cs b/src/LiveChartsCore/Kernel/Events/ChartCommandArgs.cs index 10347e2ee..fba1982e7 100644 --- a/src/LiveChartsCore/Kernel/Events/ChartCommandArgs.cs +++ b/src/LiveChartsCore/Kernel/Events/ChartCommandArgs.cs @@ -28,19 +28,15 @@ namespace LiveChartsCore.Kernel.Events; /// /// Command arguments that describe when a chart event occurs. /// -public class ChartCommandArgs +/// +/// Initializes a new instance of the class. +/// +/// The chart that fired the event. +public class ChartCommandArgs(IChartView chart) { - /// - /// Initializes a new instance of the class. - /// - /// The chart that fired the event. - public ChartCommandArgs(IChartView chart) - { - Chart = chart; - } /// /// Gets the sender chart. /// - public IChartView Chart { get; } + public IChartView Chart { get; } = chart; } diff --git a/src/LiveChartsCore/Kernel/Events/PointerCommandArgs.cs b/src/LiveChartsCore/Kernel/Events/PointerCommandArgs.cs index d23516924..5fe90d32e 100644 --- a/src/LiveChartsCore/Kernel/Events/PointerCommandArgs.cs +++ b/src/LiveChartsCore/Kernel/Events/PointerCommandArgs.cs @@ -29,31 +29,25 @@ namespace LiveChartsCore.Kernel.Events; /// /// Command arguments that describe a pointer event in a LiveChart view. /// -public class PointerCommandArgs : ChartCommandArgs +/// +/// Initializes a new instance of the class. +/// +/// The chart that fired the event. +/// The pointer position. +/// The original event args. +public class PointerCommandArgs( + IChartView chart, + LvcPointD pointerPosition, + object originalEventArgs) : ChartCommandArgs(chart) { - /// - /// Initializes a new instance of the class. - /// - /// The chart that fired the event. - /// The pointer position. - /// The original event args. - public PointerCommandArgs( - IChartView chart, - LvcPointD pointerPosition, - object originalEventArgs) - : base(chart) - { - PointerPosition = pointerPosition; - OriginalEventArgs = originalEventArgs; - } /// /// Gets the pointer position relative to the chart. /// - public LvcPointD PointerPosition { get; set; } + public LvcPointD PointerPosition { get; set; } = pointerPosition; /// /// Gets the framework-specific event arguments. /// - public object OriginalEventArgs { get; set; } + public object OriginalEventArgs { get; set; } = originalEventArgs; } diff --git a/src/LiveChartsCore/Kernel/Extensions.cs b/src/LiveChartsCore/Kernel/Extensions.cs index 0e5285b65..df78ad8de 100644 --- a/src/LiveChartsCore/Kernel/Extensions.cs +++ b/src/LiveChartsCore/Kernel/Extensions.cs @@ -709,14 +709,9 @@ private static IEnumerable YieldReturnUntilNextNullChartPoint( builder.Finished = true; } - private class GapsBuilder : IDisposable + private class GapsBuilder(IEnumerator enumerator) : IDisposable { - public GapsBuilder(IEnumerator enumerator) - { - Enumerator = enumerator; - } - - public IEnumerator Enumerator { get; } + public IEnumerator Enumerator { get; } = enumerator; public bool IsEmpty { get; set; } = true; @@ -728,23 +723,15 @@ public void Dispose() } } - internal class SplineData + internal class SplineData(ChartPoint start) { - public SplineData(ChartPoint start) - { - Previous = start; - Current = start; - Next = start; - AfterNext = start; - } - - public ChartPoint Previous { get; set; } + public ChartPoint Previous { get; set; } = start; - public ChartPoint Current { get; set; } + public ChartPoint Current { get; set; } = start; - public ChartPoint Next { get; set; } + public ChartPoint Next { get; set; } = start; - public ChartPoint AfterNext { get; set; } + public ChartPoint AfterNext { get; set; } = start; public bool IsFirst { get; set; } = true; public bool IsNextEmpty { get; set; } diff --git a/src/LiveChartsCore/Kernel/SeriesContext.cs b/src/LiveChartsCore/Kernel/SeriesContext.cs index 385361ee5..be8c9e553 100644 --- a/src/LiveChartsCore/Kernel/SeriesContext.cs +++ b/src/LiveChartsCore/Kernel/SeriesContext.cs @@ -33,11 +33,14 @@ namespace LiveChartsCore.Kernel; /// Defines a series context. /// /// The type of the drawing context. -public class SeriesContext +/// +/// Initializes a new instance of the class. +/// +/// The series. +/// The chart +public class SeriesContext(IEnumerable> series, IChart chart) where TDrawingContext : DrawingContext { - private readonly IEnumerable> _series; - private int _columnsCount = 0; private int _rowsCount = 0; private int _boxCount = 0; @@ -55,19 +58,6 @@ public class SeriesContext private readonly Dictionary> _stackers = []; - private readonly IChart _chart; - - /// - /// Initializes a new instance of the class. - /// - /// The series. - /// The chart - public SeriesContext(IEnumerable> series, IChart chart) - { - _series = series; - _chart = chart; - } - #region columns and rows /// @@ -202,7 +192,7 @@ private void IndexBars() _stackedColumnsCount = 0; _stackedRowsCount = 0; - foreach (var item in _series) + foreach (var item in series) { if (!item.IsBarSeries() && !item.IsBoxSeries()) continue; @@ -288,7 +278,7 @@ private Stacker GetStacker(IChartSeries series private void CalculatePieLabelsOuterSpace() where TLabel : class, ILabelGeometry, new() { - foreach (var series in _series) + foreach (var series in series) { if (!series.IsPieSeries()) continue; var pieSeries = (IPieSeries)series; @@ -302,7 +292,7 @@ private void CalculatePieLabelsOuterSpace() var stacker = GetStackPosition(series, series.GetStackGroup()) ?? throw new NullReferenceException("Unexpected null stacker"); - foreach (var point in pieSeries.Fetch(_chart)) + foreach (var point in pieSeries.Fetch(chart)) { _ = stacker.GetStack(point); // builds the stacked value for the point. diff --git a/src/LiveChartsCore/Kernel/TooltipPlacementContext.cs b/src/LiveChartsCore/Kernel/TooltipPlacementContext.cs index b38fec0cb..eddba87ae 100644 --- a/src/LiveChartsCore/Kernel/TooltipPlacementContext.cs +++ b/src/LiveChartsCore/Kernel/TooltipPlacementContext.cs @@ -27,21 +27,17 @@ namespace LiveChartsCore.Kernel; /// /// Defines the tooltip placement context class. /// -public class TooltipPlacementContext +/// +/// Intializes a new instance of the class. +/// +/// +public class TooltipPlacementContext(TooltipPosition position) { - /// - /// Intializes a new instance of the class. - /// - /// - public TooltipPlacementContext(TooltipPosition position) - { - Position = position; - } /// /// Gets the tool tip position. /// - public TooltipPosition Position { get; set; } + public TooltipPosition Position { get; set; } = position; /// /// Gets or sets the value for the pop-up placement. diff --git a/src/LiveChartsCore/Measure/AxisLimit.cs b/src/LiveChartsCore/Measure/AxisLimit.cs index 31034e389..37df73eb0 100644 --- a/src/LiveChartsCore/Measure/AxisLimit.cs +++ b/src/LiveChartsCore/Measure/AxisLimit.cs @@ -25,49 +25,41 @@ namespace LiveChartsCore.Measure; /// /// Defines the axis limit structure. /// -public struct AxisLimit +/// +/// Initializes a new instance of the struct. +/// +/// The min value. +/// The masx value. +/// The min delta. +/// The data min value. +/// The data max value. +public struct AxisLimit(double min, double max, double minDelta, double dataMin, double dataMax) { - /// - /// Initializes a new instance of the struct. - /// - /// The min value. - /// The masx value. - /// The min delta. - /// The data min value. - /// The data max value. - public AxisLimit(double min, double max, double minDelta, double dataMin, double dataMax) - { - Min = min; - Max = max; - MinDelta = minDelta; - DataMin = dataMin; - DataMax = dataMax; - } /// /// Gets or sets the minimum value. /// - public double Min { get; set; } + public double Min { get; set; } = min; /// /// Gets or sets the maximum value. /// - public double Max { get; set; } + public double Max { get; set; } = max; /// /// Gets or sets the minimum value. /// - public double DataMin { get; set; } + public double DataMin { get; set; } = dataMin; /// /// Gets or sets the maximum value. /// - public double DataMax { get; set; } + public double DataMax { get; set; } = dataMax; /// /// Gets or sets the min delta. /// - public double MinDelta { get; set; } + public double MinDelta { get; set; } = minDelta; internal static void ValidateLimits(ref double min, ref double max) { diff --git a/src/LiveChartsCore/Measure/VectorManager.cs b/src/LiveChartsCore/Measure/VectorManager.cs index 925dc03b7..ce23f27da 100644 --- a/src/LiveChartsCore/Measure/VectorManager.cs +++ b/src/LiveChartsCore/Measure/VectorManager.cs @@ -32,27 +32,21 @@ namespace LiveChartsCore.Measure; /// /// The type of the segment. /// The type of the drawing context. -public class VectorManager +/// +/// Initializes a new instance of the class. +/// +/// The area geometry +public class VectorManager(IVectorGeometry areaGeometry) where TDrawingContext : DrawingContext where TSegment : IConsecutivePathSegment, IAnimatable { - private LinkedListNode? _nextNode; + private LinkedListNode? _nextNode = areaGeometry.Commands.First; private LinkedListNode? _currentNode; - /// - /// Initializes a new instance of the class. - /// - /// The area geometry - public VectorManager(IVectorGeometry areaGeometry) - { - AreaGeometry = areaGeometry; - _nextNode = areaGeometry.Commands.First; - } - /// /// Gets the area geometry. /// - public IVectorGeometry AreaGeometry { get; private set; } + public IVectorGeometry AreaGeometry { get; private set; } = areaGeometry; /// /// Adds a segment to the area geometry. diff --git a/src/LiveChartsCore/PieChart.cs b/src/LiveChartsCore/PieChart.cs index bfbb00723..76c6dc399 100644 --- a/src/LiveChartsCore/PieChart.cs +++ b/src/LiveChartsCore/PieChart.cs @@ -37,32 +37,25 @@ namespace LiveChartsCore; /// /// The type of the drawing context. /// -public class PieChart : Chart +/// +/// Initializes a new instance of the class. +/// +/// The view. +/// The default platform configuration. +/// The canvas. +/// Forces the legends to redraw with every measure request. +public class PieChart( + IPieChartView view, + Action defaultPlatformConfig, + MotionCanvas canvas, + bool requiresLegendMeasureAlways = false) : Chart(canvas, defaultPlatformConfig, view) where TDrawingContext : DrawingContext { - private readonly IPieChartView _chartView; private int _nextSeries = 0; - /// - /// Initializes a new instance of the class. - /// - /// The view. - /// The default platform configuration. - /// The canvas. - /// Forces the legends to redraw with every measure request. - public PieChart( - IPieChartView view, - Action defaultPlatformConfig, - MotionCanvas canvas, - bool requiresLegendMeasureAlways = false) - : base(canvas, defaultPlatformConfig, view) - { - _chartView = view; - } - /// public override IEnumerable> Series => - _chartView.Series.Cast>(); + view.Series.Cast>(); /// public override IEnumerable> VisibleSeries => @@ -74,7 +67,7 @@ public PieChart( /// /// The view. /// - public override IChartView View => _chartView; + public override IChartView View => view; /// /// Gets the value bounds. @@ -107,7 +100,7 @@ public PieChart( /// public override IEnumerable FindHoveredPointsBy(LvcPoint pointerPosition) { - return _chartView.Series + return view.Series .Where(series => (series is IPieSeries pieSeries) && !pieSeries.IsFillSeries) .Where(series => series.IsHoverable) .SelectMany(series => series.FindHitPoints(this, pointerPosition, TooltipFindingStrategy.CompareAll)); @@ -142,19 +135,19 @@ protected internal override void Measure() MeasureWork = new object(); - var viewDrawMargin = _chartView.DrawMargin; - ControlSize = _chartView.ControlSize; + var viewDrawMargin = view.DrawMargin; + ControlSize = view.ControlSize; - VisualElements = _chartView.VisualElements ?? Array.Empty>(); + VisualElements = view.VisualElements ?? Array.Empty>(); - LegendPosition = _chartView.LegendPosition; - Legend = _chartView.Legend; + LegendPosition = view.LegendPosition; + Legend = view.Legend; - TooltipPosition = _chartView.TooltipPosition; - Tooltip = _chartView.Tooltip; + TooltipPosition = view.TooltipPosition; + Tooltip = view.Tooltip; - AnimationsSpeed = _chartView.AnimationsSpeed; - EasingFunction = _chartView.EasingFunction; + AnimationsSpeed = view.AnimationsSpeed; + EasingFunction = view.EasingFunction; SeriesContext = new SeriesContext(VisibleSeries, this); var isNewTheme = LiveCharts.DefaultSettings.CurrentThemeId != ThemeId; diff --git a/src/LiveChartsCore/PolarChart.cs b/src/LiveChartsCore/PolarChart.cs index 98087cb57..54ec19aa1 100644 --- a/src/LiveChartsCore/PolarChart.cs +++ b/src/LiveChartsCore/PolarChart.cs @@ -37,29 +37,22 @@ namespace LiveChartsCore; /// /// The type of the drawing context. /// -public class PolarChart : Chart +/// +/// Initializes a new instance of the class. +/// +/// The view. +/// The default platform configuration. +/// The canvas. +/// Forces the legends to redraw with every measure request. +public class PolarChart( + IPolarChartView view, + Action defaultPlatformConfig, + MotionCanvas canvas, + bool requiresLegendMeasureAlways = false) : Chart(canvas, defaultPlatformConfig, view) where TDrawingContext : DrawingContext { - private readonly IPolarChartView _chartView; private int _nextSeries = 0; - /// - /// Initializes a new instance of the class. - /// - /// The view. - /// The default platform configuration. - /// The canvas. - /// Forces the legends to redraw with every measure request. - public PolarChart( - IPolarChartView view, - Action defaultPlatformConfig, - MotionCanvas canvas, - bool requiresLegendMeasureAlways = false) - : base(canvas, defaultPlatformConfig, view) - { - _chartView = view; - } - /// /// Gets the angle axes. /// @@ -78,7 +71,7 @@ public PolarChart( /// public override IEnumerable> Series => - _chartView.Series.Cast>(); + view.Series.Cast>(); /// public override IEnumerable> VisibleSeries => @@ -119,7 +112,7 @@ public PolarChart( /// /// The view. /// - public override IChartView View => _chartView; + public override IChartView View => view; /// /// Finds the points near to the specified point. @@ -163,29 +156,29 @@ protected internal override void Measure() #region copy the current data in the view - var viewDrawMargin = _chartView.DrawMargin; - ControlSize = _chartView.ControlSize; + var viewDrawMargin = view.DrawMargin; + ControlSize = view.ControlSize; - AngleAxes = _chartView.AngleAxes.Cast().ToArray(); - RadiusAxes = _chartView.RadiusAxes.Cast().ToArray(); + AngleAxes = view.AngleAxes.Cast().ToArray(); + RadiusAxes = view.RadiusAxes.Cast().ToArray(); var theme = LiveCharts.DefaultSettings.GetTheme(); - LegendPosition = _chartView.LegendPosition; - Legend = _chartView.Legend; + LegendPosition = view.LegendPosition; + Legend = view.Legend; - TooltipPosition = _chartView.TooltipPosition; - Tooltip = _chartView.Tooltip; + TooltipPosition = view.TooltipPosition; + Tooltip = view.Tooltip; - AnimationsSpeed = _chartView.AnimationsSpeed; - EasingFunction = _chartView.EasingFunction; + AnimationsSpeed = view.AnimationsSpeed; + EasingFunction = view.EasingFunction; - FitToBounds = _chartView.FitToBounds; - TotalAnge = (float)_chartView.TotalAngle; - InnerRadius = (float)_chartView.InnerRadius; - InitialRotation = (float)_chartView.InitialRotation; + FitToBounds = view.FitToBounds; + TotalAnge = (float)view.TotalAngle; + InnerRadius = (float)view.InnerRadius; + InitialRotation = (float)view.InitialRotation; - VisualElements = _chartView.VisualElements ?? Array.Empty>(); + VisualElements = view.VisualElements ?? Array.Empty>(); #endregion diff --git a/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs b/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs index a9a3218e9..0a7a10e01 100644 --- a/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs +++ b/src/LiveChartsCore/VisualElements/AngularTicksVisual.cs @@ -305,18 +305,11 @@ protected internal override void SetParent(IGeometry parent) return new[] { _stroke, _labelsPaint }; } - private class TickVisual + private class TickVisual(TLabelGeometry label, TLineGeometry line, TLineGeometry[] subseparator) { - public TickVisual(TLabelGeometry label, TLineGeometry line, TLineGeometry[] subseparator) - { - Label = label; - Tick = line; - Subseparator = subseparator; - } - - public TLabelGeometry Label { get; set; } - public TLineGeometry Tick { get; set; } - public TLineGeometry[] Subseparator { get; set; } + public TLabelGeometry Label { get; set; } = label; + public TLineGeometry Tick { get; set; } = line; + public TLineGeometry[] Subseparator { get; set; } = subseparator; public object UpdateId { get; set; } = new(); } } diff --git a/src/LiveChartsCore/VisualElements/StackPanel.cs b/src/LiveChartsCore/VisualElements/StackPanel.cs index 7189be31f..b44439804 100644 --- a/src/LiveChartsCore/VisualElements/StackPanel.cs +++ b/src/LiveChartsCore/VisualElements/StackPanel.cs @@ -287,15 +287,9 @@ public override void RemoveFromUI(Chart chart) base.RemoveFromUI(chart); } - private class MeasureResult + private class MeasureResult(VisualElement visual, LvcSize size) { - public MeasureResult(VisualElement visual, LvcSize size) - { - Visual = visual; - Size = size; - } - - public VisualElement Visual { get; set; } - public LvcSize Size { get; set; } + public VisualElement Visual { get; set; } = visual; + public LvcSize Size { get; set; } = size; } } diff --git a/src/LiveChartsCore/VisualElements/TableLayout.cs b/src/LiveChartsCore/VisualElements/TableLayout.cs index 436e5b4af..831d7f28b 100644 --- a/src/LiveChartsCore/VisualElements/TableLayout.cs +++ b/src/LiveChartsCore/VisualElements/TableLayout.cs @@ -287,54 +287,46 @@ internal override IEnumerable> IsHitBy(Chart /// Defines a cell in the . /// - public class TableCell + /// + /// Initializes a new instance of the class. + /// + /// The row index. + /// The column index. + /// The visual to add. + /// The cell vertical alignment, if null the alignment will be defined by the layout. + /// The cell horizontal alignment, if null the alignment will be defined by the layout. + public class TableCell( + int row, + int column, + VisualElement visualElement, + Align? verticalAlign = null, + Align? horizontalAlign = null) { - /// - /// Initializes a new instance of the class. - /// - /// The row index. - /// The column index. - /// The visual to add. - /// The cell vertical alignment, if null the alignment will be defined by the layout. - /// The cell horizontal alignment, if null the alignment will be defined by the layout. - public TableCell( - int row, - int column, - VisualElement visualElement, - Align? verticalAlign = null, - Align? horizontalAlign = null) - { - Row = row; - Column = column; - VisualElement = visualElement; - VerticalAlign = verticalAlign; - HorizontalAlign = horizontalAlign; - } /// /// Gets the row. /// - public int Row { get; } + public int Row { get; } = row; /// /// Gets the column. /// - public int Column { get; } + public int Column { get; } = column; /// /// Gets or sets the vertical alignment. /// - public Align? VerticalAlign { get; } + public Align? VerticalAlign { get; } = verticalAlign; /// /// Gets or sets the horizontal alignment. /// - public Align? HorizontalAlign { get; } + public Align? HorizontalAlign { get; } = horizontalAlign; /// /// Gets the visual element. /// - public VisualElement VisualElement { get; } + public VisualElement VisualElement { get; } = visualElement; } } diff --git a/src/LiveChartsCore/VisualElements/VariableGeometryVisual.cs b/src/LiveChartsCore/VisualElements/VariableGeometryVisual.cs index 5324a7ab3..612db235e 100644 --- a/src/LiveChartsCore/VisualElements/VariableGeometryVisual.cs +++ b/src/LiveChartsCore/VisualElements/VariableGeometryVisual.cs @@ -31,31 +31,25 @@ namespace LiveChartsCore.VisualElements; /// Defines a visual element that is useful to create series miniatures in the tool tips and legends. /// /// The type of the drawing context. -public class VariableGeometryVisual : BaseGeometryVisual +/// +/// Initializes a new instance of the class. +/// +/// +public class VariableGeometryVisual(ISizedGeometry geometry) : BaseGeometryVisual where TDrawingContext : DrawingContext { - private ISizedGeometry _geometry; private bool _isInitialized; - /// - /// Initializes a new instance of the class. - /// - /// - public VariableGeometryVisual(ISizedGeometry geometry) - { - _geometry = geometry; - } - /// /// Gets or sets the geometry. /// public ISizedGeometry Geometry { - get => _geometry; + get => geometry; set { - if (_geometry == value) return; - _geometry = value; + if (geometry == value) return; + geometry = value; _isInitialized = false; OnPropertyChanged(); } @@ -68,7 +62,7 @@ public ISizedGeometry Geometry internal override IAnimatable?[] GetDrawnGeometries() { - return new IAnimatable?[] { _geometry }; + return new IAnimatable?[] { geometry }; } /// @@ -127,8 +121,8 @@ protected internal override void OnInvalidated(Chart chart) /// protected internal override void SetParent(IGeometry parent) { - if (_geometry is null) return; - _geometry.Parent = parent; + if (geometry is null) return; + geometry.Parent = parent; } /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/MotionCanvas.axaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/MotionCanvas.axaml.cs index efee6ad2c..5f1a3f0af 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/MotionCanvas.axaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/MotionCanvas.axaml.cs @@ -140,22 +140,12 @@ private void MotionCanvas_DetachedFromVisualTree(object sender, VisualTreeAttach // based on: // https://github.com/AvaloniaUI/Avalonia/blob/release/11.0.0-preview1/samples/RenderDemo/Pages/CustomSkiaPage.cs - private class CustomDrawOp : ICustomDrawOperation + private class CustomDrawOp( + MotionCanvas avaloniaControl, MotionCanvas motionCanvas, Rect bounds) : ICustomDrawOperation { - private readonly MotionCanvas _avaloniaControl; - private readonly MotionCanvas _motionCanvas; - - public CustomDrawOp( - MotionCanvas avaloniaControl, MotionCanvas motionCanvas, Rect bounds) - { - _avaloniaControl = avaloniaControl; - _motionCanvas = motionCanvas; - Bounds = bounds; - } - public void Dispose() { } - public Rect Bounds { get; } + public Rect Bounds { get; } = bounds; public bool HitTest(Point p) { @@ -182,9 +172,9 @@ public void Render(a.ImmediateDrawingContext context) $"tread: {Environment.CurrentManagedThreadId}"); } #endif - _motionCanvas.DrawFrame( + motionCanvas.DrawFrame( new SkiaSharpDrawingContext( - _motionCanvas, + motionCanvas, new SKImageInfo((int)Bounds.Width, (int)Bounds.Height), lease.SkSurface, lease.SkCanvas, diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/ResolutionHelper.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/ResolutionHelper.cs index e34121489..125f066c5 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/ResolutionHelper.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/ResolutionHelper.cs @@ -25,26 +25,20 @@ namespace LiveChartsCore.SkiaSharpView.WPF; /// /// A helper class to get the screen resolution. /// -public class ResolutionHelper +/// +/// Initializes a new instance of the class. +/// +/// The horizontal resolution. +/// The vertical resolution. +public class ResolutionHelper(float dpix, float dpiy) { /// /// Gets or sets the horizontal dpi. /// - public float dpix { get; set; } - - /// - /// Initializes a new instance of the class. - /// - /// The horizontal resolution. - /// The vertical resolution. - public ResolutionHelper(float dpix, float dpiy) - { - this.dpix = dpix; - this.dpiy = dpiy; - } + public float dpix { get; set; } = dpix; /// /// Gets or sets the vertical dpi. /// - public float dpiy { get; set; } + public float dpiy { get; set; } = dpiy; } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/SkiaSharpDrawingContext.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/SkiaSharpDrawingContext.cs index 449252191..c6f459640 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/SkiaSharpDrawingContext.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/SkiaSharpDrawingContext.cs @@ -31,33 +31,21 @@ namespace LiveChartsCore.SkiaSharpView.Drawing; /// Defines a skia sharp drawing context. /// /// -public class SkiaSharpDrawingContext : DrawingContext +/// +/// Initializes a new instance of the class. +/// +/// The motion canvas. +/// The information. +/// The surface. +/// The canvas. +/// Indicates whether the canvas is cleared on frame draw. +public class SkiaSharpDrawingContext( + MotionCanvas motionCanvas, + SKImageInfo info, + SKSurface surface, + SKCanvas canvas, + bool clearOnBeginDraw = true) : DrawingContext { - private readonly bool _clearOnBegingDraw; - - /// - /// Initializes a new instance of the class. - /// - /// The motion canvas. - /// The information. - /// The surface. - /// The canvas. - /// Indicates whether the canvas is cleared on frame draw. - public SkiaSharpDrawingContext( - MotionCanvas motionCanvas, - SKImageInfo info, - SKSurface surface, - SKCanvas canvas, - bool clearOnBeginDraw = true) - { - MotionCanvas = motionCanvas; - Info = info; - Surface = surface; - Canvas = canvas; - PaintTask = null!; - Paint = null!; - _clearOnBegingDraw = clearOnBeginDraw; - } /// /// Initializes a new instance of the class. @@ -86,7 +74,7 @@ public SkiaSharpDrawingContext( /// /// The motion canvas. /// - public MotionCanvas MotionCanvas { get; set; } + public MotionCanvas MotionCanvas { get; set; } = motionCanvas; /// /// Gets or sets the information. @@ -94,7 +82,7 @@ public SkiaSharpDrawingContext( /// /// The information. /// - public SKImageInfo Info { get; set; } + public SKImageInfo Info { get; set; } = info; /// /// Gets or sets the surface. @@ -102,7 +90,7 @@ public SkiaSharpDrawingContext( /// /// The surface. /// - public SKSurface Surface { get; set; } + public SKSurface Surface { get; set; } = surface; /// /// Gets or sets the canvas. @@ -110,7 +98,7 @@ public SkiaSharpDrawingContext( /// /// The canvas. /// - public SKCanvas Canvas { get; set; } + public SKCanvas Canvas { get; set; } = canvas; /// /// Gets or sets the paint task. @@ -118,7 +106,7 @@ public SkiaSharpDrawingContext( /// /// The paint task. /// - public Paint PaintTask { get; set; } + public Paint PaintTask { get; set; } = null!; /// /// Gets or sets the paint. @@ -126,7 +114,7 @@ public SkiaSharpDrawingContext( /// /// The paint. /// - public SKPaint Paint { get; set; } + public SKPaint Paint { get; set; } = null!; /// /// Gets or sets the background. @@ -136,7 +124,7 @@ public SkiaSharpDrawingContext( /// public override void OnBeginDraw() { - if (_clearOnBegingDraw) Canvas.Clear(); + if (clearOnBeginDraw) Canvas.Clear(); if (Background != SKColor.Empty) { Canvas.DrawRect(Info.Rect, new SKPaint { Color = Background }); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/Effects/DashEffect.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/Effects/DashEffect.cs index c6ae2e4c8..973187f7d 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/Effects/DashEffect.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/Effects/DashEffect.cs @@ -29,19 +29,11 @@ namespace LiveChartsCore.SkiaSharpView.Painting.Effects; /// Creates a stroke dash effect. /// /// -public class DashEffect : PathEffect +/// +/// Initializes a new instance of the class. +/// +public class DashEffect(float[] dashArray, float phase = 0) : PathEffect { - private readonly float[] _dashArray; - private readonly float _phase = 0; - - /// - /// Initializes a new instance of the class. - /// - public DashEffect(float[] dashArray, float phase = 0) - { - _dashArray = dashArray; - _phase = phase; - } /// /// Creates a new object that is a copy of the current instance. @@ -52,7 +44,7 @@ public DashEffect(float[] dashArray, float phase = 0) /// public override PathEffect Clone() { - return new DashEffect(_dashArray, _phase); + return new DashEffect(dashArray, phase); } /// @@ -61,6 +53,6 @@ public override PathEffect Clone() /// The drawing context. public override void CreateEffect(SkiaSharpDrawingContext drawingContext) { - SKPathEffect = SKPathEffect.CreateDash(_dashArray, _phase); + SKPathEffect = SKPathEffect.CreateDash(dashArray, phase); } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/Blur.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/Blur.cs index b53637fbc..e8c59c842 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/Blur.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/Blur.cs @@ -29,27 +29,15 @@ namespace LiveChartsCore.SkiaSharpView.Painting.ImageFilters; /// Creates a blur image filter. /// /// -public class Blur : ImageFilter +/// +/// Initializes a new instance of the class. +/// +/// The sigma x. +/// The sigma y. +/// The input. +/// The crop rect. +public class Blur(float sigmaX, float sigmaY, SKImageFilter? input = null, SKImageFilter.CropRect? cropRect = null) : ImageFilter { - private readonly float _sigmaX; - private readonly float _sigmaY; - private readonly SKImageFilter? _filter = null; - private readonly SKImageFilter.CropRect? _cropRect = null; - - /// - /// Initializes a new instance of the class. - /// - /// The sigma x. - /// The sigma y. - /// The input. - /// The crop rect. - public Blur(float sigmaX, float sigmaY, SKImageFilter? input = null, SKImageFilter.CropRect? cropRect = null) - { - _sigmaX = sigmaX; - _sigmaY = sigmaY; - _filter = input; - _cropRect = cropRect; - } /// /// Clones this instance. @@ -58,7 +46,7 @@ public Blur(float sigmaX, float sigmaY, SKImageFilter? input = null, SKImageFilt /// public override ImageFilter Clone() { - return new Blur(_sigmaX, _sigmaY, _filter, _cropRect); + return new Blur(sigmaX, sigmaY, input, cropRect); } /// @@ -68,6 +56,6 @@ public override ImageFilter Clone() /// public override void CreateFilter(SkiaSharpDrawingContext drawingContext) { - SKImageFilter = SKImageFilter.CreateBlur(_sigmaX, _sigmaY, _filter, _cropRect); + SKImageFilter = SKImageFilter.CreateBlur(sigmaX, sigmaY, input, cropRect); } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/DropShadow.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/DropShadow.cs index 5ae555eff..5113677a0 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/DropShadow.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/DropShadow.cs @@ -29,36 +29,18 @@ namespace LiveChartsCore.SkiaSharpView.Painting.ImageFilters; /// Creates a drop shadow image filter. /// /// -public class DropShadow : ImageFilter +/// +/// Initializes a new instance of the class. +/// +/// The dx. +/// The dy. +/// The sigma x. +/// The sigma y. +/// The color. +/// The input. +/// The crop rect. +public class DropShadow(float dx, float dy, float sigmaX, float sigmaY, SKColor color, SKImageFilter? input = null, SKImageFilter.CropRect? cropRect = null) : ImageFilter { - private readonly float _dx; - private readonly float _dy; - private readonly float _sigmaX; - private readonly float _sigmaY; - private readonly SKColor _color; - private readonly SKImageFilter? _filter = null; - private readonly SKImageFilter.CropRect? _cropRect = null; - - /// - /// Initializes a new instance of the class. - /// - /// The dx. - /// The dy. - /// The sigma x. - /// The sigma y. - /// The color. - /// The input. - /// The crop rect. - public DropShadow(float dx, float dy, float sigmaX, float sigmaY, SKColor color, SKImageFilter? input = null, SKImageFilter.CropRect? cropRect = null) - { - _dx = dx; - _dy = dy; - _sigmaX = sigmaX; - _sigmaY = sigmaY; - _color = color; - _filter = input; - _cropRect = cropRect; - } /// /// Clones this instance. @@ -67,7 +49,7 @@ public DropShadow(float dx, float dy, float sigmaX, float sigmaY, SKColor color, /// public override ImageFilter Clone() { - return new DropShadow(_dx, _dy, _sigmaX, _sigmaY, _color, _filter, _cropRect); + return new DropShadow(dx, dy, sigmaX, sigmaY, color, input, cropRect); } /// @@ -76,6 +58,6 @@ public override ImageFilter Clone() /// The drawing context. public override void CreateFilter(SkiaSharpDrawingContext drawingContext) { - SKImageFilter = SKImageFilter.CreateDropShadow(_dx, _dy, _sigmaX, _sigmaY, _color, _filter, _cropRect); + SKImageFilter = SKImageFilter.CreateDropShadow(dx, dy, sigmaX, sigmaY, color, input, cropRect); } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/ImageFiltersMergeOperation.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/ImageFiltersMergeOperation.cs index a6e326021..08d674150 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/ImageFiltersMergeOperation.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/ImageFilters/ImageFiltersMergeOperation.cs @@ -29,21 +29,14 @@ namespace LiveChartsCore.SkiaSharpView.Painting.ImageFilters; /// Merges multiple image filters. /// /// -public class ImageFiltersMergeOperation : ImageFilter +/// +/// Initializes a new instance of the class. +/// +/// The image filters. +/// The crop rect. +public class ImageFiltersMergeOperation(ImageFilter[] imageFilters, SKImageFilter.CropRect? cropRect = null) : ImageFilter { - private readonly ImageFilter[] _filters; - private readonly SKImageFilter.CropRect? _cropRect = null; - - /// - /// Initializes a new instance of the class. - /// - /// The image filters. - /// The crop rect. - public ImageFiltersMergeOperation(ImageFilter[] imageFilters, SKImageFilter.CropRect? cropRect = null) - { - _filters = imageFilters; - _cropRect = cropRect; - } + private readonly ImageFilter[] _filters = imageFilters; /// /// Clones this instance. @@ -52,7 +45,7 @@ public ImageFiltersMergeOperation(ImageFilter[] imageFilters, SKImageFilter.Crop /// public override ImageFilter Clone() { - return new ImageFiltersMergeOperation(_filters, _cropRect); + return new ImageFiltersMergeOperation(_filters, cropRect); } /// @@ -72,7 +65,7 @@ public override void CreateFilter(SkiaSharpDrawingContext drawingContext) imageFilters[i++] = item.SKImageFilter; } - SKImageFilter = SKImageFilter.CreateMerge(imageFilters, _cropRect); + SKImageFilter = SKImageFilter.CreateMerge(imageFilters, cropRect); } /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/LinearGradientPaint.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/LinearGradientPaint.cs index 13b4b5928..342efc8a8 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/LinearGradientPaint.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/LinearGradientPaint.cs @@ -31,7 +31,30 @@ namespace LiveChartsCore.SkiaSharpView.Painting; /// Defines a set of geometries that will be painted using a linear gradient shader. /// /// -public class LinearGradientPaint : Paint +/// +/// Initializes a new instance of the class. +/// +/// The gradient stops. +/// +/// The start point, both X and Y in the range of 0 to 1, where 0 is the start of the axis and 1 the end. +/// +/// +/// The end point, both X and Y in the range of 0 to 1, where 0 is the start of the axis and 1 the end. +/// +/// +/// An array of integers in the range of 0 to 1. +/// These integers indicate the relative positions of the colors, You can set that argument to null to equally +/// space the colors, default is null. +/// +/// +/// The shader tile mode, default is . +/// +public class LinearGradientPaint( + SKColor[] gradientStops, + SKPoint startPoint, + SKPoint endPoint, + float[]? colorPos = null, + SKShaderTileMode tileMode = SKShaderTileMode.Repeat) : Paint { /// /// Default start point. @@ -42,46 +65,8 @@ public class LinearGradientPaint : Paint /// Default end point. /// protected static readonly SKPoint s_defaultEndPoint = new(1, 0.5f); - - private readonly SKColor[] _gradientStops; - private readonly SKPoint _startPoint; - private readonly SKPoint _endPoint; - private readonly float[]? _colorPos; - private readonly SKShaderTileMode _tileMode; private SkiaSharpDrawingContext? _drawingContext; - /// - /// Initializes a new instance of the class. - /// - /// The gradient stops. - /// - /// The start point, both X and Y in the range of 0 to 1, where 0 is the start of the axis and 1 the end. - /// - /// - /// The end point, both X and Y in the range of 0 to 1, where 0 is the start of the axis and 1 the end. - /// - /// - /// An array of integers in the range of 0 to 1. - /// These integers indicate the relative positions of the colors, You can set that argument to null to equally - /// space the colors, default is null. - /// - /// - /// The shader tile mode, default is . - /// - public LinearGradientPaint( - SKColor[] gradientStops, - SKPoint startPoint, - SKPoint endPoint, - float[]? colorPos = null, - SKShaderTileMode tileMode = SKShaderTileMode.Repeat) - { - _gradientStops = gradientStops; - _startPoint = startPoint; - _endPoint = endPoint; - _colorPos = colorPos; - _tileMode = tileMode; - } - /// /// Initializes a new instance of the class. /// @@ -114,7 +99,7 @@ public LinearGradientPaint(SKColor start, SKColor end) /// public override IPaint CloneTask() { - return new LinearGradientPaint(_gradientStops, _startPoint, _endPoint, _colorPos, _tileMode) + return new LinearGradientPaint(gradientStops, startPoint, endPoint, colorPos, tileMode) { Style = Style, IsStroke = IsStroke, @@ -146,15 +131,15 @@ public override void ApplyOpacityMask(SkiaSharpDrawingContext context, IPaintabl var yf = size.Location.Y; var yt = yf + size.Height; - var start = new SKPoint(xf + (xt - xf) * _startPoint.X, yf + (yt - yf) * _startPoint.Y); - var end = new SKPoint(xf + (xt - xf) * _endPoint.X, yf + (yt - yf) * _endPoint.Y); + var start = new SKPoint(xf + (xt - xf) * startPoint.X, yf + (yt - yf) * startPoint.Y); + var end = new SKPoint(xf + (xt - xf) * endPoint.X, yf + (yt - yf) * endPoint.Y); _skiaPaint.Shader = SKShader.CreateLinearGradient( start, end, - _gradientStops.Select(x => new SKColor(x.Red, x.Green, x.Blue, (byte)(255 * geometry.Opacity))).ToArray(), - _colorPos, - _tileMode); + gradientStops.Select(x => new SKColor(x.Red, x.Green, x.Blue, (byte)(255 * geometry.Opacity))).ToArray(), + colorPos, + tileMode); } /// @@ -170,15 +155,15 @@ public override void RestoreOpacityMask(SkiaSharpDrawingContext context, IPainta var yf = size.Location.Y; var yt = yf + size.Height; - var start = new SKPoint(xf + (xt - xf) * _startPoint.X, yf + (yt - yf) * _startPoint.Y); - var end = new SKPoint(xf + (xt - xf) * _endPoint.X, yf + (yt - yf) * _endPoint.Y); + var start = new SKPoint(xf + (xt - xf) * startPoint.X, yf + (yt - yf) * startPoint.Y); + var end = new SKPoint(xf + (xt - xf) * endPoint.X, yf + (yt - yf) * endPoint.Y); _skiaPaint.Shader = SKShader.CreateLinearGradient( start, end, - _gradientStops, - _colorPos, - _tileMode); + gradientStops, + colorPos, + tileMode); } /// @@ -194,15 +179,15 @@ public override void InitializeTask(SkiaSharpDrawingContext drawingContext) var yf = size.Location.Y; var yt = yf + size.Height; - var start = new SKPoint(xf + (xt - xf) * _startPoint.X, yf + (yt - yf) * _startPoint.Y); - var end = new SKPoint(xf + (xt - xf) * _endPoint.X, yf + (yt - yf) * _endPoint.Y); + var start = new SKPoint(xf + (xt - xf) * startPoint.X, yf + (yt - yf) * startPoint.Y); + var end = new SKPoint(xf + (xt - xf) * endPoint.X, yf + (yt - yf) * endPoint.Y); _skiaPaint.Shader = SKShader.CreateLinearGradient( start, end, - _gradientStops, - _colorPos, - _tileMode); + gradientStops, + colorPos, + tileMode); _skiaPaint.IsAntialias = IsAntialias; _skiaPaint.IsStroke = true; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/VisualElements/VariableGeometryVisual.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/VisualElements/VariableGeometryVisual.cs index 4b8ba46e6..85b8ad7e5 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/VisualElements/VariableGeometryVisual.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/VisualElements/VariableGeometryVisual.cs @@ -27,9 +27,6 @@ namespace LiveChartsCore.SkiaSharpView.VisualElements; /// -public class VariableGeometryVisual : VariableGeometryVisual +public class VariableGeometryVisual(ISizedGeometry geometry) : VariableGeometryVisual(geometry) { - public VariableGeometryVisual(ISizedGeometry geometry) - : base(geometry) - { } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/JsInterop/DomJsInterop.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/JsInterop/DomJsInterop.cs index 4abb8e974..154a8f358 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/JsInterop/DomJsInterop.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/JsInterop/DomJsInterop.cs @@ -29,23 +29,18 @@ namespace LiveChartsCore.SkiaSharpView.Blazor; /// /// An object that handles the comminication with the DOM. /// -public class DomJsInterop : IAsyncDisposable +/// +/// Initialized a new instance of the class. +/// +/// +public class DomJsInterop(IJSRuntime jsRuntime) : IAsyncDisposable { - private readonly Lazy> _moduleTask; - private static readonly Dictionary>> s_resizeEvent = []; - - /// - /// Initialized a new instance of the class. - /// - /// - public DomJsInterop(IJSRuntime jsRuntime) - { - _moduleTask = new Lazy>(() => + private readonly Lazy> _moduleTask = new Lazy>(() => jsRuntime.InvokeAsync( "import", "./_content/LiveChartsCore.SkiaSharpView.Blazor/domInterop.js") .AsTask()); - } + private static readonly Dictionary>> s_resizeEvent = []; /// /// Gets the bounding client rectangle of the given element. diff --git a/tests/LiveChartsCore.UnitTesting/OtherTests/DataProviderTest.cs b/tests/LiveChartsCore.UnitTesting/OtherTests/DataProviderTest.cs index 03651e4a2..bd31d06ba 100644 --- a/tests/LiveChartsCore.UnitTesting/OtherTests/DataProviderTest.cs +++ b/tests/LiveChartsCore.UnitTesting/OtherTests/DataProviderTest.cs @@ -307,13 +307,8 @@ public void FetchNull() Assert.IsTrue(emptyCount == 2); } - public class City + public class City(double? population) { - public City(double? population) - { - Population = population; - } - - public double? Population { get; set; } + public double? Population { get; set; } = population; } } From b74ce6709c6c01c8380e6c60a898233fd4ca4a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Fri, 17 Nov 2023 18:14:16 -0600 Subject: [PATCH 05/23] remove obsolete parameters --- src/LiveChartsCore/PieChart.cs | 4 +--- src/LiveChartsCore/PolarChart.cs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/LiveChartsCore/PieChart.cs b/src/LiveChartsCore/PieChart.cs index 76c6dc399..f482a6707 100644 --- a/src/LiveChartsCore/PieChart.cs +++ b/src/LiveChartsCore/PieChart.cs @@ -43,12 +43,10 @@ namespace LiveChartsCore; /// The view. /// The default platform configuration. /// The canvas. -/// Forces the legends to redraw with every measure request. public class PieChart( IPieChartView view, Action defaultPlatformConfig, - MotionCanvas canvas, - bool requiresLegendMeasureAlways = false) : Chart(canvas, defaultPlatformConfig, view) + MotionCanvas canvas) : Chart(canvas, defaultPlatformConfig, view) where TDrawingContext : DrawingContext { private int _nextSeries = 0; diff --git a/src/LiveChartsCore/PolarChart.cs b/src/LiveChartsCore/PolarChart.cs index 54ec19aa1..cdf72b386 100644 --- a/src/LiveChartsCore/PolarChart.cs +++ b/src/LiveChartsCore/PolarChart.cs @@ -43,12 +43,10 @@ namespace LiveChartsCore; /// The view. /// The default platform configuration. /// The canvas. -/// Forces the legends to redraw with every measure request. public class PolarChart( IPolarChartView view, Action defaultPlatformConfig, - MotionCanvas canvas, - bool requiresLegendMeasureAlways = false) : Chart(canvas, defaultPlatformConfig, view) + MotionCanvas canvas) : Chart(canvas, defaultPlatformConfig, view) where TDrawingContext : DrawingContext { private int _nextSeries = 0; From c8b24dc799fddc324695ed4c485316412bf1e11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Fri, 17 Nov 2023 18:15:28 -0600 Subject: [PATCH 06/23] use collection expression to replace array.empty --- src/LiveChartsCore/CartesianChart.cs | 4 ++-- src/LiveChartsCore/CoreHeatLandSeries.cs | 2 +- src/LiveChartsCore/Geo/LandDefinition.cs | 2 +- src/LiveChartsCore/Geo/MapLayer.cs | 4 ++-- src/LiveChartsCore/PolarChart.cs | 4 ++-- src/LiveChartsCore/Themes/Theme.cs | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/LiveChartsCore/CartesianChart.cs b/src/LiveChartsCore/CartesianChart.cs index 29387eac8..173a8dd0b 100644 --- a/src/LiveChartsCore/CartesianChart.cs +++ b/src/LiveChartsCore/CartesianChart.cs @@ -79,7 +79,7 @@ public CartesianChart( /// The x axes. /// public ICartesianAxis[] XAxes { get; private set; } = - Array.Empty>(); + []; /// /// Gets the y axes. @@ -88,7 +88,7 @@ public CartesianChart( /// The y axes. /// public ICartesianAxis[] YAxes { get; private set; } = - Array.Empty>(); + []; /// /// Gets the sections. diff --git a/src/LiveChartsCore/CoreHeatLandSeries.cs b/src/LiveChartsCore/CoreHeatLandSeries.cs index 4c084d996..2d3b79a41 100644 --- a/src/LiveChartsCore/CoreHeatLandSeries.cs +++ b/src/LiveChartsCore/CoreHeatLandSeries.cs @@ -41,7 +41,7 @@ public class CoreHeatLandSeries : IGeoSeries, { private IPaint? _heatPaint; private bool _isHeatInCanvas = false; - private LvcColor[] _heatMap = Array.Empty(); + private LvcColor[] _heatMap = []; private double[]? _colorStops; private IEnumerable? _lands; private bool _isVisible; diff --git a/src/LiveChartsCore/Geo/LandDefinition.cs b/src/LiveChartsCore/Geo/LandDefinition.cs index 68774f89c..907e3ed95 100644 --- a/src/LiveChartsCore/Geo/LandDefinition.cs +++ b/src/LiveChartsCore/Geo/LandDefinition.cs @@ -80,5 +80,5 @@ public class LandDefinition(string shortName, string name, string setOf) /// /// Gets or sets the data. /// - public LandData[] Data { get; set; } = Array.Empty(); + public LandData[] Data { get; set; } = []; } diff --git a/src/LiveChartsCore/Geo/MapLayer.cs b/src/LiveChartsCore/Geo/MapLayer.cs index 3169aadd9..4f98989aa 100644 --- a/src/LiveChartsCore/Geo/MapLayer.cs +++ b/src/LiveChartsCore/Geo/MapLayer.cs @@ -71,12 +71,12 @@ public class MapLayer(string layerName, IPaint /// /// Gets or sets the X bounds. /// - public double[] Max { get; set; } = Array.Empty(); + public double[] Max { get; set; } = []; /// /// Gets or sets the Y bounds. /// - public double[] Min { get; set; } = Array.Empty(); + public double[] Min { get; set; } = []; /// /// Gets the lands. diff --git a/src/LiveChartsCore/PolarChart.cs b/src/LiveChartsCore/PolarChart.cs index cdf72b386..38f229667 100644 --- a/src/LiveChartsCore/PolarChart.cs +++ b/src/LiveChartsCore/PolarChart.cs @@ -57,7 +57,7 @@ public class PolarChart( /// /// The x axes. /// - public IPolarAxis[] AngleAxes { get; private set; } = Array.Empty(); + public IPolarAxis[] AngleAxes { get; private set; } = []; /// /// Gets the radius axes. @@ -65,7 +65,7 @@ public class PolarChart( /// /// The y axes. /// - public IPolarAxis[] RadiusAxes { get; private set; } = Array.Empty(); + public IPolarAxis[] RadiusAxes { get; private set; } = []; /// public override IEnumerable> Series => diff --git a/src/LiveChartsCore/Themes/Theme.cs b/src/LiveChartsCore/Themes/Theme.cs index e425a3ec1..20076fadf 100644 --- a/src/LiveChartsCore/Themes/Theme.cs +++ b/src/LiveChartsCore/Themes/Theme.cs @@ -40,7 +40,7 @@ public class Theme /// /// Gets or sets the theme colors. /// - public LvcColor[] Colors { get; set; } = Array.Empty(); + public LvcColor[] Colors { get; set; } = []; /// /// Gets or sets the axis builder. From 7f7496956d9b97fdbecee45472261414c9064c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Fri, 17 Nov 2023 18:41:56 -0600 Subject: [PATCH 07/23] clean behaviours assembly warnings --- .../ChartBehaviour.Android.cs | 16 +++++++++++ .../ChartBehaviour.MacCatalyst.cs | 27 +++++++++++++++++++ .../ChartBehaviour.Windows.cs | 25 +++++++++++++++++ .../LiveChartsCore.Behaviours.csproj | 5 ++++ 4 files changed, 73 insertions(+) diff --git a/src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs b/src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs index a67c18b2d..cb0e5144c 100644 --- a/src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs +++ b/src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs @@ -41,6 +41,11 @@ public abstract partial class ChartBehaviour private CustomScaleListener _customScaleListener = null!; private DateTime _previousPress = DateTime.MinValue; + /// + /// Called on android hover events. + /// + /// the sender. + /// the event args. protected void OnAndroidHover(object? sender, View.HoverEventArgs e) { if (e.Event is null) return; @@ -49,6 +54,11 @@ protected void OnAndroidHover(object? sender, View.HoverEventArgs e) Moved?.Invoke(sender, new(p, e.Event)); } + /// + /// Called on android touch events. + /// + /// the sender. + /// the event args. protected void OnAndroidTouched(object? sender, View.TouchEventArgs e) { var viewGroup = (ViewGroup?)sender; @@ -66,6 +76,11 @@ protected void OnAndroidTouched(object? sender, View.TouchEventArgs e) _ = _scaleDetector.OnTouchEvent(e.Event); + // MotionEventActions.ButtonPress + // is supported from API 23, the min target it 21 + // we are intentionally ignoring the warning here. + +#pragma warning disable CA1416 switch (e.Event.ActionMasked) { case MotionEventActions.ButtonPress: @@ -110,6 +125,7 @@ protected void OnAndroidTouched(object? sender, View.TouchEventArgs e) default: break; } +#pragma warning restore CA1416 _lastTouch = p; diff --git a/src/LiveChartsCore.Behaviours/ChartBehaviour.MacCatalyst.cs b/src/LiveChartsCore.Behaviours/ChartBehaviour.MacCatalyst.cs index f25772112..0c350ce29 100644 --- a/src/LiveChartsCore.Behaviours/ChartBehaviour.MacCatalyst.cs +++ b/src/LiveChartsCore.Behaviours/ChartBehaviour.MacCatalyst.cs @@ -36,6 +36,13 @@ public partial class ChartBehaviour { private DateTime _previousPress = DateTime.MinValue; +#if MACCATALYST + + /// + /// Builds a mac catalyst gesture recognizer. + /// + /// the view. + /// the recognizer. protected UIHoverGestureRecognizer GetMacCatalystHover(UIView view) { return new UIHoverGestureRecognizer((UIHoverGestureRecognizer e) => @@ -58,7 +65,13 @@ protected UIHoverGestureRecognizer GetMacCatalystHover(UIView view) } }); } +#endif + /// + /// Builds a mac catalyst gesture recognizer. + /// + /// the view. + /// the recognizer. protected UILongPressGestureRecognizer GetMacCatalystLongPress(UIView view) { return new UILongPressGestureRecognizer((UILongPressGestureRecognizer e) => @@ -94,6 +107,12 @@ protected UILongPressGestureRecognizer GetMacCatalystLongPress(UIView view) } private float _previousScale = 1; + + /// + /// Builds a mac catalyst gesture recognizer. + /// + /// the view. + /// the recognizer. protected UIPinchGestureRecognizer GetMacCatalystPinch(UIView view) { return new UIPinchGestureRecognizer((UIPinchGestureRecognizer e) => @@ -126,6 +145,12 @@ protected UIPinchGestureRecognizer GetMacCatalystPinch(UIView view) } private CGPoint? _last; + + /// + /// Builds a mac catalyst gesture recognizer. + /// + /// The view. + /// The recognizer. protected UIPanGestureRecognizer GetMacCatalystOnPan(UIView view) { return new UIPanGestureRecognizer((UIPanGestureRecognizer e) => @@ -141,7 +166,9 @@ protected UIPanGestureRecognizer GetMacCatalystOnPan(UIView view) _last = l; }) { +#if MACCATALYST AllowedScrollTypesMask = UIScrollTypeMask.Discrete | UIScrollTypeMask.Continuous, +#endif MinimumNumberOfTouches = 0, ShouldRecognizeSimultaneously = (g1, g2) => true }; diff --git a/src/LiveChartsCore.Behaviours/ChartBehaviour.Windows.cs b/src/LiveChartsCore.Behaviours/ChartBehaviour.Windows.cs index 18c51f016..a41443e1d 100644 --- a/src/LiveChartsCore.Behaviours/ChartBehaviour.Windows.cs +++ b/src/LiveChartsCore.Behaviours/ChartBehaviour.Windows.cs @@ -32,6 +32,11 @@ namespace LiveChartsCore.Behaviours; /// public partial class ChartBehaviour { + /// + /// Called on windows pointer pressed events. + /// + /// The sender. + /// The event args. protected void OnWindowsPointerPressed(object sender, PointerRoutedEventArgs e) { var p = e.GetCurrentPoint(sender as UIElement); @@ -42,6 +47,11 @@ protected void OnWindowsPointerPressed(object sender, PointerRoutedEventArgs e) new(new(p.Position.X, p.Position.Y), p.Properties.IsRightButtonPressed, e)); } + /// + /// Called on windows pointer moved events. + /// + /// The sender. + /// The events. protected void OnWindowsPointerMoved(object sender, PointerRoutedEventArgs e) { var p = e.GetCurrentPoint(sender as UIElement); @@ -52,6 +62,11 @@ protected void OnWindowsPointerMoved(object sender, PointerRoutedEventArgs e) new(new(p.Position.X, p.Position.Y), e)); } + /// + /// Called on windows pointer released events. + /// + /// The sender. + /// The event args. protected void OnWindowsPointerReleased(object sender, PointerRoutedEventArgs e) { var p = e.GetCurrentPoint(sender as UIElement); @@ -62,12 +77,22 @@ protected void OnWindowsPointerReleased(object sender, PointerRoutedEventArgs e) new(new(p.Position.X, p.Position.Y), p.Properties.IsRightButtonPressed, e)); } + /// + /// Called on windows pointer wheel changed events. + /// + /// The sender. + /// The event args. protected void OnWindowsPointerWheelChanged(object sender, PointerRoutedEventArgs e) { var p = e.GetCurrentPoint(sender as UIElement); Scrolled?.Invoke(sender, new(new(p.Position.X, p.Position.Y), p.Properties.MouseWheelDelta, e)); } + /// + /// Called on windows pointer entered events. + /// + /// The sender. + /// The event args. protected void OnWindowsPointerExited(object sender, PointerRoutedEventArgs e) { Exited?.Invoke(sender, new(e)); diff --git a/src/LiveChartsCore.Behaviours/LiveChartsCore.Behaviours.csproj b/src/LiveChartsCore.Behaviours/LiveChartsCore.Behaviours.csproj index ea7bdb3ba..32ec40329 100644 --- a/src/LiveChartsCore.Behaviours/LiveChartsCore.Behaviours.csproj +++ b/src/LiveChartsCore.Behaviours/LiveChartsCore.Behaviours.csproj @@ -44,6 +44,11 @@ bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + + bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + true + + From 51645c8bb32d6c1b47ef321f118db07c683aaf35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Fri, 17 Nov 2023 18:48:40 -0600 Subject: [PATCH 08/23] explain more about disable --- src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs b/src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs index cb0e5144c..4584a0736 100644 --- a/src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs +++ b/src/LiveChartsCore.Behaviours/ChartBehaviour.Android.cs @@ -78,7 +78,8 @@ protected void OnAndroidTouched(object? sender, View.TouchEventArgs e) // MotionEventActions.ButtonPress // is supported from API 23, the min target it 21 - // we are intentionally ignoring the warning here. + // we are intentionally ignoring the warning here + // because the switch should never reach the case from api 21 or 22 #pragma warning disable CA1416 switch (e.Event.ActionMasked) From 9ade2364e24bd8e0722eace0c1f714576fa80630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Fri, 17 Nov 2023 19:35:57 -0600 Subject: [PATCH 09/23] remove skaisharp assembly warnings --- .../LiveChartsCore.SkiaSharp/BoxSeries.cs | 6 +++--- .../CandlesticksSeries.cs | 6 +++--- .../LiveChartsCore.SkiaSharp/ColumnSeries.cs | 6 +++--- .../Drawing/Geometries/ArcGeometry.cs | 1 - .../Drawing/Geometries/HeatPathShape.cs | 2 ++ .../Drawing/Geometries/PopUpGeometry.cs | 1 + .../Drawing/Segments/MoveToPathCommand.cs | 1 - .../Extensions/BaseGaugeItem.cs | 4 ++++ .../LiveChartsCore.SkiaSharp/HeatSeries.cs | 6 +++--- .../LiveChartsCore.SkiaSharp/LineSeries.cs | 6 +++--- .../LiveChartsSkiaSharp.cs | 17 ----------------- .../LiveChartsCore.SkiaSharp/Painting/Paint.cs | 18 ++---------------- .../LiveChartsCore.SkiaSharp/PieSeries.cs | 6 +++--- .../PolarLineSeries.cs | 6 +++--- .../LiveChartsCore.SkiaSharp/RowSeries.cs | 6 +++--- .../LiveChartsCore.SkiaSharp/ScatterSeries.cs | 6 +++--- .../StackedAreaSeries.cs | 6 +++--- .../StackedColumnSeries.cs | 6 +++--- .../StackedRowSeries.cs | 6 +++--- .../StackedStepAreaSeries.cs | 6 +++--- .../LiveChartsCore.SkiaSharp/StepLineSeries.cs | 6 +++--- 21 files changed, 51 insertions(+), 77 deletions(-) diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/BoxSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/BoxSeries.cs index 7674c327d..25b487bcd 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/BoxSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/BoxSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -46,7 +46,7 @@ public class BoxSeries : CoreBoxSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -63,7 +63,7 @@ public class BoxSeries : CoreBoxSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/CandlesticksSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/CandlesticksSeries.cs index c1774069e..06d5a33ad 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/CandlesticksSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/CandlesticksSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -46,7 +46,7 @@ public class CandlesticksSeries : CandlesticksSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -63,7 +63,7 @@ public class CandlesticksSeries : CandlesticksSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/ColumnSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/ColumnSeries.cs index 7d43f8edc..b8932857f 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/ColumnSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/ColumnSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -46,7 +46,7 @@ public class ColumnSeries : ColumnSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -63,7 +63,7 @@ public class ColumnSeries : ColumnSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/ArcGeometry.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/ArcGeometry.cs index c2e4ce5ee..cf14697ab 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/ArcGeometry.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/ArcGeometry.cs @@ -53,7 +53,6 @@ public override void OnDraw(SkiaSharpDrawingContext context, SKPaint paint) using var path = new SKPath(); var cx = CenterX; var cy = CenterY; - var wedge = 20; var r = Width * 0.5f; var startAngle = StartAngle; var sweepAngle = SweepAngle; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/HeatPathShape.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/HeatPathShape.cs index 489f72f71..426ca77b8 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/HeatPathShape.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/HeatPathShape.cs @@ -33,7 +33,9 @@ namespace LiveChartsCore.SkiaSharpView.Drawing.Geometries; /// Defines a path geometry with a specified color. /// /// +#pragma warning disable CS0612 // Type or member is obsolete public class HeatPathShape : PathGeometry, IHeatPathShape +#pragma warning restore CS0612 // Type or member is obsolete { private readonly ColorMotionProperty _fillProperty; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/PopUpGeometry.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/PopUpGeometry.cs index 1e8895024..62b3bfbfb 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/PopUpGeometry.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Geometries/PopUpGeometry.cs @@ -51,6 +51,7 @@ public class PopUpGeometry : SizedGeometry /// public PopUpPlacement Placement { get; set; } = PopUpPlacement.Bottom; + /// public override void OnDraw(SkiaSharpDrawingContext context, SKPaint paint) { using var path = new SKPath(); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Segments/MoveToPathCommand.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Segments/MoveToPathCommand.cs index d9c6979be..8438674ff 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Segments/MoveToPathCommand.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/Segments/MoveToPathCommand.cs @@ -50,7 +50,6 @@ public MoveToPathCommand() /// public override void Execute(SKPath path, long currentTime, Animatable pathGeometry) { - currentTime = currentTime; path.MoveTo(X, Y); } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/BaseGaugeItem.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/BaseGaugeItem.cs index 1e480aea7..f58a8bdab 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/BaseGaugeItem.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Extensions/BaseGaugeItem.cs @@ -27,6 +27,10 @@ namespace LiveChartsCore.SkiaSharpView.Extensions; +/// +/// Defines an item for a gauge series. +/// +/// The type of the series. public class BaseGaugeItem where TSeries : IPieSeries, new() { diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/HeatSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/HeatSeries.cs index dbdcf8452..9ff68a689 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/HeatSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/HeatSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -46,7 +46,7 @@ public class HeatSeries : HeatSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -63,7 +63,7 @@ public class HeatSeries : HeatSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/LineSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/LineSeries.cs index c1e4a6885..e74bba48e 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/LineSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/LineSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -46,7 +46,7 @@ public class LineSeries : LineSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -63,7 +63,7 @@ public class LineSeries : LineSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsSkiaSharp.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsSkiaSharp.cs index 89192b92f..120cccec7 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsSkiaSharp.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/LiveChartsSkiaSharp.cs @@ -116,23 +116,6 @@ public static LvcColor AsLvcColor(this SKColor color) return new LvcColor(color.Red, color.Green, color.Blue, color.Alpha); } - /// - /// Gets the key. - /// - [Obsolete($"Use {nameof(Paint)}.{nameof(Paint.SKTypeface)} instead.")] - public const string SkiaFontMatchChar = "matchChar"; - - /// - /// Matches - /// - /// - /// - [Obsolete($"Use {nameof(Paint)}.{nameof(Paint.SKTypeface)} instead.")] - public static string MatchChar(char @char) - { - return $"{SkiaFontMatchChar}|{@char}"; - } - /// /// Converts an IEnumerable to an ObservableCollection of pie series. /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/Paint.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/Paint.cs index 35189b4e9..76e21fe7e 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/Paint.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Painting/Paint.cs @@ -38,10 +38,8 @@ public abstract class Paint : Animatable, IDisposable, IPaint, HashSet>> _geometriesByCanvas = []; private readonly Dictionary, LvcRectangle> _clipRectangles = []; - private char? _matchesChar = null; internal SKPaint? _skiaPaint; internal FloatMotionProperty _strokeWidthTransition; - private string? _fontFamily; /// /// Initializes a new instance of the class. @@ -82,16 +80,7 @@ protected Paint(SKColor color) : this() public bool IsFill { get; set; } /// - public string? FontFamily - { - get => _fontFamily; - set - { - _fontFamily = value; - if (!(_fontFamily?.Contains(LiveChartsSkiaSharp.SkiaFontMatchChar) ?? false)) return; - _matchesChar = Convert.ToChar(_fontFamily.Split('|')[1]); - } - } + public string? FontFamily { get; set; } /// /// Gets or sets the font style. @@ -271,11 +260,8 @@ protected internal SKTypeface GetSKTypeface() // return the defined typeface. if (SKTypeface is not null) return SKTypeface; - // Obsolete method used in older versions of LiveCharts... - if (_matchesChar is not null) return SKFontManager.Default.MatchCharacter(_matchesChar.Value); - // create one from the font family. - if (FontFamily is not null) return SKTypeface.FromFamilyName(_fontFamily, SKFontStyle ?? new SKFontStyle()); + if (FontFamily is not null) return SKTypeface.FromFamilyName(FontFamily, SKFontStyle ?? new SKFontStyle()); // other wise ose the globally defined typeface. return LiveChartsSkiaSharp.DefaultSKTypeface ?? SKTypeface.Default; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/PieSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/PieSeries.cs index 6ed8eb6df..7f0344628 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/PieSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/PieSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -60,7 +60,7 @@ public PieSeries(bool isGauge = false, bool isGaugeFill = false) : base(isGauge, /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -91,7 +91,7 @@ public PieSeries(bool isGauge = false, bool isGaugeFill = false) : base(isGauge, /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/PolarLineSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/PolarLineSeries.cs index 5839681db..72db1c6bc 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/PolarLineSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/PolarLineSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -46,7 +46,7 @@ public class PolarLineSeries : PolarLineSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -63,7 +63,7 @@ public class PolarLineSeries : PolarLineSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/RowSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/RowSeries.cs index ecff7d52c..3c7fe24fe 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/RowSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/RowSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// data label of every point. @@ -46,7 +46,7 @@ public class RowSeries : RowSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -63,7 +63,7 @@ public class RowSeries : RowSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/ScatterSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/ScatterSeries.cs index 5225e9b10..4ebcf32e8 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/ScatterSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/ScatterSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -46,7 +46,7 @@ public class ScatterSeries : ScatterSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -63,7 +63,7 @@ public class ScatterSeries : ScatterSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedAreaSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedAreaSeries.cs index 26539eeb2..b09cacfba 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedAreaSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedAreaSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -46,7 +46,7 @@ public class StackedAreaSeries : StackedAreaSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -63,7 +63,7 @@ public class StackedAreaSeries : StackedAreaSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedColumnSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedColumnSeries.cs index d5c32337d..da6cd82e7 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedColumnSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedColumnSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -46,7 +46,7 @@ public class StackedColumnSeries : StackedColumnSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -63,7 +63,7 @@ public class StackedColumnSeries : StackedColumnSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedRowSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedRowSeries.cs index 0d6af70bf..5d2e5f417 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedRowSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedRowSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -46,7 +46,7 @@ public class StackedRowSeries : StackedRowSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -63,7 +63,7 @@ public class StackedRowSeries : StackedRowSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedStepAreaSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedStepAreaSeries.cs index c232b98e5..8dac0ef75 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/StackedStepAreaSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/StackedStepAreaSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -47,7 +47,7 @@ public class StackedStepAreaSeries /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -65,7 +65,7 @@ public class StackedStepAreaSeries /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/StepLineSeries.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/StepLineSeries.cs index c4b50c87c..09409ccac 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/StepLineSeries.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/StepLineSeries.cs @@ -33,7 +33,7 @@ namespace LiveChartsCore.SkiaSharpView; /// /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -46,7 +46,7 @@ public class StepLineSeries : StepLineSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// @@ -63,7 +63,7 @@ public class StepLineSeries : StepLineSeries /// The type of the points, you can use any type, the library already knows how to handle the most common numeric types, /// to use a custom type, you must register the type globally -/// () +/// () /// or at the series level /// (). /// From 0ee98ec80d2d116503c44f367f6bc9123c83f7b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 12:59:17 -0600 Subject: [PATCH 10/23] remove warning from avalonia assembly --- .../CartesianChart.axaml.cs | 4 +- .../GeoMap.axaml.cs | 2 +- .../MotionCanvas.axaml.cs | 51 ++++++++----------- .../PieChart.axaml.cs | 8 +-- .../PolarChart.axaml.cs | 4 +- .../Drawing/SkiaSharpDrawingContext.cs | 6 +-- 6 files changed, 33 insertions(+), 42 deletions(-) diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs index bc161f226..b8c4b49fe 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs @@ -850,12 +850,12 @@ private void OnCoreMeasuring(IChartView chart) Measuring?.Invoke(this); } - private void CartesianChart_AttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e) + private void CartesianChart_AttachedToVisualTree(object? sender, VisualTreeAttachmentEventArgs e) { _core?.Load(); } - private void CartesianChart_DetachedFromVisualTree(object sender, VisualTreeAttachmentEventArgs e) + private void CartesianChart_DetachedFromVisualTree(object? sender, VisualTreeAttachmentEventArgs e) { _core?.Unload(); } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/GeoMap.axaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/GeoMap.axaml.cs index 5f42f7255..287b4794f 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/GeoMap.axaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/GeoMap.axaml.cs @@ -274,7 +274,7 @@ private void OnPointerLeave(object? sender, PointerEventArgs e) _core?.InvokePointerLeft(); } - private void GeoMap_DetachedFromVisualTree(object sender, VisualTreeAttachmentEventArgs e) + private void GeoMap_DetachedFromVisualTree(object? sender, VisualTreeAttachmentEventArgs e) { if (_core is null) return; _core.Unload(); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/MotionCanvas.axaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/MotionCanvas.axaml.cs index 5f1a3f0af..2a892d280 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/MotionCanvas.axaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/MotionCanvas.axaml.cs @@ -22,7 +22,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; @@ -35,7 +34,7 @@ using LiveChartsCore.Motion; using LiveChartsCore.SkiaSharpView.Drawing; using SkiaSharp; -using a = Avalonia.Media; +using AvaloniaMedia = Avalonia.Media; namespace LiveChartsCore.SkiaSharpView.Avalonia; @@ -91,10 +90,10 @@ public List> PaintTasks /// Renders the control. /// p /// - public override void Render(a.DrawingContext context) + public override void Render(AvaloniaMedia.DrawingContext context) { if (_isDeatached) return; - var drawOperation = new CustomDrawOp(this, CanvasCore, new Rect(0, 0, Bounds.Width, Bounds.Height)); + var drawOperation = new CustomDrawOp(CanvasCore, new Rect(0, 0, Bounds.Width, Bounds.Height)); context.Custom(drawOperation); if (CanvasCore.IsValid) return; @@ -125,13 +124,13 @@ private void OnCanvasCoreInvalidated(MotionCanvas sende InvalidateVisual(); } - private void MotionCanvas_AttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e) + private void MotionCanvas_AttachedToVisualTree(object? sender, VisualTreeAttachmentEventArgs e) { _isDeatached = false; CanvasCore.Invalidated += OnCanvasCoreInvalidated; } - private void MotionCanvas_DetachedFromVisualTree(object sender, VisualTreeAttachmentEventArgs e) + private void MotionCanvas_DetachedFromVisualTree(object? sender, VisualTreeAttachmentEventArgs e) { _isDeatached = true; CanvasCore.Invalidated -= OnCanvasCoreInvalidated; @@ -139,39 +138,19 @@ private void MotionCanvas_DetachedFromVisualTree(object sender, VisualTreeAttach } // based on: - // https://github.com/AvaloniaUI/Avalonia/blob/release/11.0.0-preview1/samples/RenderDemo/Pages/CustomSkiaPage.cs - private class CustomDrawOp( - MotionCanvas avaloniaControl, MotionCanvas motionCanvas, Rect bounds) : ICustomDrawOperation + // https://github.com/AvaloniaUI/Avalonia/blob/release/11.0.0/samples/RenderDemo/Pages/CustomSkiaPage.cs + private class CustomDrawOp(MotionCanvas motionCanvas, Rect bounds) + : ICustomDrawOperation { - public void Dispose() { } - public Rect Bounds { get; } = bounds; - public bool HitTest(Point p) - { - return false; - } - - public bool Equals(ICustomDrawOperation? other) - { - return false; - } - - public void Render(a.ImmediateDrawingContext context) + public void Render(AvaloniaMedia.ImmediateDrawingContext context) { if (!context.TryGetFeature(out var leaseFeature)) throw new Exception("SkiaSharp is not supported."); using var lease = leaseFeature.Lease(); -#if DEBUG - if (LiveCharts.EnableLogging) - { - Trace.WriteLine( - $"[rendering] ".PadRight(60) + - $"tread: {Environment.CurrentManagedThreadId}"); - } -#endif motionCanvas.DrawFrame( new SkiaSharpDrawingContext( motionCanvas, @@ -180,5 +159,17 @@ public void Render(a.ImmediateDrawingContext context) lease.SkCanvas, false)); } + + public void Dispose() { } + + public bool HitTest(Point p) + { + return false; + } + + public bool Equals(ICustomDrawOperation? other) + { + return false; + } } } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PieChart.axaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PieChart.axaml.cs index 7b0042005..54d8d9672 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PieChart.axaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PieChart.axaml.cs @@ -646,7 +646,7 @@ private void Chart_PointerMoved(object? sender, PointerEventArgs e) _core?.InvokePointerMove(new LvcPoint((float)p.X, (float)p.Y)); } - private void Chart_PointerPressed(object sender, PointerPressedEventArgs e) + private void Chart_PointerPressed(object? sender, PointerPressedEventArgs e) { var p = e.GetPosition(this); @@ -659,7 +659,7 @@ private void Chart_PointerPressed(object sender, PointerPressedEventArgs e) _core?.InvokePointerDown(new LvcPoint((float)p.X, (float)p.Y), false); } - private void PieChart_PointerReleased(object sender, PointerReleasedEventArgs e) + private void PieChart_PointerReleased(object? sender, PointerReleasedEventArgs e) { var p = e.GetPosition(this); @@ -696,12 +696,12 @@ private void Chart_PointerLeave(object? sender, PointerEventArgs e) _core?.InvokePointerLeft(); } - private void OnAttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e) + private void OnAttachedToVisualTree(object? sender, VisualTreeAttachmentEventArgs e) { _core?.Load(); } - private void PieChart_DetachedFromVisualTree(object sender, VisualTreeAttachmentEventArgs e) + private void PieChart_DetachedFromVisualTree(object? sender, VisualTreeAttachmentEventArgs e) { _core?.Unload(); } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PolarChart.axaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PolarChart.axaml.cs index 41293b4d6..3bca3486b 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PolarChart.axaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PolarChart.axaml.cs @@ -773,12 +773,12 @@ private void PolarChart_PointerLeave(object? sender, PointerEventArgs e) _core?.InvokePointerLeft(); } - private void OnAttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e) + private void OnAttachedToVisualTree(object? sender, VisualTreeAttachmentEventArgs e) { _core?.Load(); } - private void PolarChart_DetachedFromVisualTree(object sender, VisualTreeAttachmentEventArgs e) + private void PolarChart_DetachedFromVisualTree(object? sender, VisualTreeAttachmentEventArgs e) { _core?.Unload(); } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/SkiaSharpDrawingContext.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/SkiaSharpDrawingContext.cs index c6f459640..3c103401b 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/SkiaSharpDrawingContext.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/Drawing/SkiaSharpDrawingContext.cs @@ -42,7 +42,7 @@ namespace LiveChartsCore.SkiaSharpView.Drawing; public class SkiaSharpDrawingContext( MotionCanvas motionCanvas, SKImageInfo info, - SKSurface surface, + SKSurface? surface, SKCanvas canvas, bool clearOnBeginDraw = true) : DrawingContext { @@ -59,7 +59,7 @@ public class SkiaSharpDrawingContext( public SkiaSharpDrawingContext( MotionCanvas motionCanvas, SKImageInfo info, - SKSurface surface, + SKSurface? surface, SKCanvas canvas, SKColor background, bool clearOnBeginDraw = true) @@ -90,7 +90,7 @@ public SkiaSharpDrawingContext( /// /// The surface. /// - public SKSurface Surface { get; set; } = surface; + public SKSurface? Surface { get; set; } = surface; /// /// Gets or sets the canvas. From 4266bc905c1c9b6553072fd5e19377cb7b73316d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 13:07:24 -0600 Subject: [PATCH 11/23] ignore blazor warnings --- .../LiveChartsCore.SkiaSharpView.Blazor.csproj | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj index 7cb2b775e..37c1f40e3 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj @@ -20,6 +20,15 @@ True + + + BL0007 + + True From 16ee99a647ff82486892b014008ef5cccbfa0e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 13:20:14 -0600 Subject: [PATCH 12/23] fix eto --- src/LiveChartsCore/Kernel/LiveChartsSettings.cs | 5 +---- src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PieChart.cs | 2 +- src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PolarChart.cs | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/LiveChartsCore/Kernel/LiveChartsSettings.cs b/src/LiveChartsCore/Kernel/LiveChartsSettings.cs index d70782269..a440515f3 100644 --- a/src/LiveChartsCore/Kernel/LiveChartsSettings.cs +++ b/src/LiveChartsCore/Kernel/LiveChartsSettings.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Generic; -using LiveChartsCore.Defaults; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel.Providers; using LiveChartsCore.Measure; @@ -382,9 +381,7 @@ public Theme GetTheme() } /// - /// Enables LiveCharts to be able to plot short, int, long, float, double, decimal, short?, int?, long?, float?, double?, decimal?, - /// , , , and - /// . + /// Enables LiveCharts to be able to plot short, int, long, float, double, decimal, short?, int?, long?, float?, double?, decimal?. /// /// public LiveChartsSettings AddDefaultMappers() diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PieChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PieChart.cs index 0a1325f85..16c476e8f 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PieChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PieChart.cs @@ -127,7 +127,7 @@ public override IEnumerable> GetVisualsAt protected override void InitializeCore() { core = new PieChart( - this, config => config.UseDefaults(), motionCanvas.CanvasCore, true); + this, config => config.UseDefaults(), motionCanvas.CanvasCore); core.Update(); } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PolarChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PolarChart.cs index 54cdf910a..8c13d9882 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PolarChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/PolarChart.cs @@ -176,7 +176,7 @@ public IEnumerable RadiusAxes protected override void InitializeCore() { core = new PolarChart( - this, config => config.UseDefaults(), motionCanvas.CanvasCore, true); + this, config => config.UseDefaults(), motionCanvas.CanvasCore); core.Update(); } From 14e22daaef2f7318e919189b9dd4a509009c396b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 13:31:27 -0600 Subject: [PATCH 13/23] add no warn --- .../LiveChartsCore.SkiaSharpView.Blazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj index 37c1f40e3..16142dd9b 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj @@ -26,7 +26,7 @@ but LiveCharts updates automatically, and we need to let the core of the library know about the change. --> - BL0007 + $(NoWarn);BL0007 From 15ce19f5e21dc7c85b300574e98ed99c62e57c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 13:31:36 -0600 Subject: [PATCH 14/23] fix maui warnings --- .../ChartBehaviour.cs | 5 ++++- .../LiveChartsCore.SkiaSharpView.Maui.csproj | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/ChartBehaviour.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/ChartBehaviour.cs index 67b775bb6..ab34ab782 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/ChartBehaviour.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/ChartBehaviour.cs @@ -1,4 +1,5 @@ -// The MIT License(MIT) + +// The MIT License(MIT) // // Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors // @@ -59,7 +60,9 @@ public void On(Microsoft.Maui.Controls.VisualElement element) contentView.UserInteractionEnabled = true; +#if MACCATALYST contentView.AddGestureRecognizer(GetMacCatalystHover(contentView)); +#endif contentView.AddGestureRecognizer(GetMacCatalystLongPress(contentView)); contentView.AddGestureRecognizer(GetMacCatalystPinch(contentView)); contentView.AddGestureRecognizer(GetMacCatalystOnPan(contentView)); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj index 076d8db22..58d7994d1 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj @@ -25,6 +25,12 @@ 10.0.17763.0 6.5 + + win-x86;win-x64;win-arm64 + 2.0.0-rc2 icon.png Simple, flexible, interactive and powerful data visualization for Maui. @@ -36,8 +42,8 @@ True bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml - - + + Date: Sat, 18 Nov 2023 13:35:44 -0600 Subject: [PATCH 15/23] remove uno warnings --- .../LiveChartsCore.SkiaSharpView.Uno.WinUI/ChartBehaviour.cs | 2 ++ .../ChartBehaviour.uno.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/ChartBehaviour.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/ChartBehaviour.cs index ae0a983d6..49b273d94 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/ChartBehaviour.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/ChartBehaviour.cs @@ -54,7 +54,9 @@ public void On(FrameworkElement element) #elif MACCATALYST || IOS element.UserInteractionEnabled = true; +#if MACCATALYST element.AddGestureRecognizer(GetMacCatalystHover(element)); +#endif element.AddGestureRecognizer(GetMacCatalystLongPress(element)); element.AddGestureRecognizer(GetMacCatalystPinch(element)); element.AddGestureRecognizer(GetMacCatalystOnPan(element)); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/ChartBehaviour.uno.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/ChartBehaviour.uno.cs index 9eadfca40..f22d9aa97 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/ChartBehaviour.uno.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/ChartBehaviour.uno.cs @@ -22,7 +22,7 @@ #if (HAS_UNO || HAS_UNO_WINUI) && !ANDROID && !IOS && !MACCATALYST && !WINDOWS -// Work around for Uno (WASM and SKIA), we use the same code as WinUI, but we +// Workaround for Uno (WASM and SKIA), we use the same code as WinUI, but we // can not call this from the behaviours assembly because it does not have // a reference to the Uno assembly. So we have to copy the code here. From 3bb90c58af5a0fb39194f9332251f1d028ac609b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 13:40:22 -0600 Subject: [PATCH 16/23] fix winforms warnings --- .../LiveChartsCore.SkiaSharpView.WinForms.csproj | 5 +++++ src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs | 2 +- .../LiveChartsCore.SkiaSharp.WinForms/PolarChart.cs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj index a5eafa041..837e5129d 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj @@ -20,6 +20,11 @@ https://github.com/beto-rodriguez/LiveCharts2 + + + $(NoWarn);NU1701 + + bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml true diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs index 9bdb28601..4e35130ae 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PieChart.cs @@ -133,7 +133,7 @@ public override IEnumerable> GetVisualsAt protected override void InitializeCore() { core = new PieChart( - this, config => config.UseDefaults(), motionCanvas.CanvasCore, true); + this, config => config.UseDefaults(), motionCanvas.CanvasCore); if (((IChartView)this).DesignerMode) return; core.Update(); } diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PolarChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PolarChart.cs index 204cdda25..d0632c564 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PolarChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/PolarChart.cs @@ -184,7 +184,7 @@ public IEnumerable RadiusAxes protected override void InitializeCore() { core = new PolarChart( - this, config => config.UseDefaults(), motionCanvas.CanvasCore, true); + this, config => config.UseDefaults(), motionCanvas.CanvasCore); if (((IChartView)this).DesignerMode) return; core.Update(); } From a2cf4a1faa1d812c10b47d03abd3b25c7573b8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 13:58:12 -0600 Subject: [PATCH 17/23] fix winui warnings --- .../LiveChartsCore.SkiaSharpView.WinUI.csproj | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj b/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj index 6d8da1b2e..2e0ba4e0f 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj @@ -8,7 +8,7 @@ net7.0-windows10.0.19041.0; net8.0-windows10.0.19041.0 - + 10.0.17763.0 + $(NoWarn);NETSDK1206 + + bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml True From 6a9922bc7da71538263b4daf5752791ab6ca51b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 14:00:34 -0600 Subject: [PATCH 18/23] fix wpf warnings --- src/skiasharp/LiveChartsCore.SkiaSharp.WPF/CartesianChart.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/CartesianChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/CartesianChart.cs index 68cc522c1..17d2de249 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/CartesianChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/CartesianChart.cs @@ -406,7 +406,7 @@ private void OnMouseWheel(object? sender, MouseWheelEventArgs e) c.Zoom(new LvcPoint((float)p.X, (float)p.Y), e.Delta > 0 ? ZoomDirection.ZoomIn : ZoomDirection.ZoomOut); } - private void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e) + private void OnManipulationDelta(object? sender, ManipulationDeltaEventArgs e) { if (core is null) throw new Exception("core not found"); var c = (CartesianChart)core; @@ -425,7 +425,7 @@ private void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e) return; } } - private void OnManipulationStarting(object sender, ManipulationStartingEventArgs e) + private void OnManipulationStarting(object? sender, ManipulationStartingEventArgs e) { e.ManipulationContainer = this; e.Handled = true; From b952924573ea9ec1f7fbfc33c347a48f962c415d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 14:02:21 -0600 Subject: [PATCH 19/23] remove manual workload installation --- build/build-windows.ps1 | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/build/build-windows.ps1 b/build/build-windows.ps1 index a681c9c93..cc05fbb57 100644 --- a/build/build-windows.ps1 +++ b/build/build-windows.ps1 @@ -15,12 +15,7 @@ $msbuild = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere. /p:configuration=$configuration ` /restore -dotnet workload install macos -dotnet workload install ios -dotnet workload install maccatalyst -dotnet workload install android - & $msbuild ` ./src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj ` /p:configuration=$configuration ` - /restore \ No newline at end of file + /restore From 868b2689b8008740078603bcf752406dfc1cd508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 14:18:10 -0600 Subject: [PATCH 20/23] try vs 17.8 --- .github/workflows/compile-all-views.yml | 5 +++++ .github/workflows/run-unit-tests.yml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/compile-all-views.yml b/.github/workflows/compile-all-views.yml index e3b238bfa..721a2fcc3 100644 --- a/.github/workflows/compile-all-views.yml +++ b/.github/workflows/compile-all-views.yml @@ -23,6 +23,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.1 + with: + vs-version: '17.8' + - uses: actions/setup-dotnet@v3 with: dotnet-version: '8.0.x' diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index 1e823bcb4..cc051e96c 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -23,6 +23,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.1 + with: + vs-version: '17.8' + - uses: actions/setup-dotnet@v3 with: dotnet-version: '8.0.x' From 67049133f88be34b70a9951b92efa02b5d91e06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 14:33:39 -0600 Subject: [PATCH 21/23] try this... --- .github/workflows/compile-all-views.yml | 5 ----- .github/workflows/run-unit-tests.yml | 5 ----- build/build-windows.ps1 | 25 ++++++++++++++++--------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.github/workflows/compile-all-views.yml b/.github/workflows/compile-all-views.yml index 721a2fcc3..e3b238bfa 100644 --- a/.github/workflows/compile-all-views.yml +++ b/.github/workflows/compile-all-views.yml @@ -23,11 +23,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.1 - with: - vs-version: '17.8' - - uses: actions/setup-dotnet@v3 with: dotnet-version: '8.0.x' diff --git a/.github/workflows/run-unit-tests.yml b/.github/workflows/run-unit-tests.yml index cc051e96c..1e823bcb4 100644 --- a/.github/workflows/run-unit-tests.yml +++ b/.github/workflows/run-unit-tests.yml @@ -23,11 +23,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.1 - with: - vs-version: '17.8' - - uses: actions/setup-dotnet@v3 with: dotnet-version: '8.0.x' diff --git a/build/build-windows.ps1 b/build/build-windows.ps1 index cc05fbb57..19f949896 100644 --- a/build/build-windows.ps1 +++ b/build/build-windows.ps1 @@ -8,14 +8,21 @@ dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore. dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/LiveChartsCore.SkiaSharpView.Eto.csproj -c $configuration dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj -c $configuration -$msbuild = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe +# LiveCharts requires VisualStudio 17.8 +# but it seems that the current image installed is 17.6 +# for now we are skiping msbuilds +# on the Github action we are running on Debug -& $msbuild ` - ./src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj ` - /p:configuration=$configuration ` - /restore +if ($configuration = "Release") { + $msbuild = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe -& $msbuild ` - ./src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj ` - /p:configuration=$configuration ` - /restore + & $msbuild ` + ./src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj ` + /p:configuration=$configuration ` + /restore + + & $msbuild ` + ./src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj ` + /p:configuration=$configuration ` + /restore +} From dd81d037c781ac68879c9f60dd23ccfa924b609b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 14:36:03 -0600 Subject: [PATCH 22/23] better like this --- build/build-windows.ps1 | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/build/build-windows.ps1 b/build/build-windows.ps1 index 19f949896..3849bb73a 100644 --- a/build/build-windows.ps1 +++ b/build/build-windows.ps1 @@ -11,18 +11,15 @@ dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.Sk # LiveCharts requires VisualStudio 17.8 # but it seems that the current image installed is 17.6 # for now we are skiping msbuilds -# on the Github action we are running on Debug -if ($configuration = "Release") { - $msbuild = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe +# $msbuild = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe - & $msbuild ` - ./src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj ` - /p:configuration=$configuration ` - /restore - - & $msbuild ` - ./src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj ` - /p:configuration=$configuration ` - /restore -} +# & $msbuild ` +# ./src/skiasharp/LiveChartsCore.SkiaSharpView.WinUI/LiveChartsCore.SkiaSharpView.WinUI.csproj ` +# /p:configuration=$configuration ` +# /restore + +# & $msbuild ` +# ./src/skiasharp/LiveChartsCore.SkiaSharpView.Uno.WinUI/LiveChartsCore.SkiaSharpView.Uno.WinUI.csproj ` +# /p:configuration=$configuration ` +# /restore From ce430c6ed475127f470d6e05cb413741a7134998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Rodr=C3=ADguez?= Date: Sat, 18 Nov 2023 14:51:36 -0600 Subject: [PATCH 23/23] also remove maui --- build/build-windows.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/build-windows.ps1 b/build/build-windows.ps1 index 3849bb73a..d2cdda589 100644 --- a/build/build-windows.ps1 +++ b/build/build-windows.ps1 @@ -6,12 +6,13 @@ dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharp.Wpf/LiveChartsCore.SkiaSha dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/LiveChartsCore.SkiaSharpView.Xamarin.Forms.csproj -c $configuration dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharpView.Blazor/LiveChartsCore.SkiaSharpView.Blazor.csproj -c $configuration dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharpView.Eto/LiveChartsCore.SkiaSharpView.Eto.csproj -c $configuration -dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj -c $configuration # LiveCharts requires VisualStudio 17.8 # but it seems that the current image installed is 17.6 # for now we are skiping msbuilds +# dotnet build ./src/skiasharp/LiveChartsCore.SkiaSharpView.Maui/LiveChartsCore.SkiaSharpView.Maui.csproj -c $configuration + # $msbuild = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe # & $msbuild `