Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/LiveChartsCore/CoreHeatLandSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void Measure(MapContext context)

if (!_isHeatInCanvas)
{
context.View.Canvas.AddDrawableTask(_heatPaint);
context.View.CoreCanvas.AddDrawableTask(_heatPaint);
_isHeatInCanvas = true;
}

Expand All @@ -124,7 +124,7 @@ public void Measure(MapContext context)
foreach (var land in Lands ?? [])
{
_ = Maps.BuildProjector(
context.View.MapProjection, [context.View.Width, context.View.Height]);
context.View.MapProjection, [context.View.ControlSize.Width, context.View.ControlSize.Height]);

var heat = HeatFunctions.InterpolateColor((float)land.Value, bounds, HeatMap, heatStops);

Expand Down Expand Up @@ -156,8 +156,11 @@ public void Delete(MapContext context)
/// <summary>
/// Initializes the series.
/// </summary>
protected void IntitializeSeries(Paint heatPaint) =>
protected void IntitializeSeries(Paint heatPaint)
{
heatPaint.PaintStyle = PaintStyle.Fill;
_heatPaint = heatPaint;
}

/// <summary>
/// Called to invoke the property changed event.
Expand Down
27 changes: 6 additions & 21 deletions src/LiveChartsCore/Geo/IGeoMapView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,21 @@

using System;
using System.Collections.Generic;
using LiveChartsCore.Motion;
using LiveChartsCore.Kernel.Sketches;
using LiveChartsCore.Painting;

namespace LiveChartsCore.Geo;

/// <summary>
/// Defines a geographic map.
/// </summary>
public interface IGeoMapView
public interface IGeoMapView : IDrawnView
{
/// <summary>
/// Gets or sets the active map.
/// </summary>
DrawnMap ActiveMap { get; set; }

/// <summary>
/// Gets the motion canvas.
/// </summary>
CoreMotionCanvas Canvas { get; }

/// <summary>
/// Gets the control width.
/// </summary>
float Width { get; }

/// <summary>
/// Gets the control height.
/// </summary>
float Height { get; }

/// <summary>
/// Gets or sets the stroke.
/// </summary>
Expand Down Expand Up @@ -83,10 +68,10 @@ public interface IGeoMapView
/// </summary>
object SyncContext { get; set; }

/// <summary>
/// Gets or sets the view command.
/// </summary>
object? ViewCommand { get; set; }
///// <summary>
///// Gets or sets the view command.
///// </summary>
//object? ViewCommand { get; set; }

/// <summary>
/// Invokes an action in the UI thread.
Expand Down
30 changes: 15 additions & 15 deletions src/LiveChartsCore/GeoMapChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public virtual void Update(ChartUpdateParams? chartUpdateParams = null)
/// </summary>
public void Unload()
{
if (View.Stroke is not null) View.Canvas.RemovePaintTask(View.Stroke);
if (View.Fill is not null) View.Canvas.RemovePaintTask(View.Fill);
if (View.Stroke is not null) View.CoreCanvas.RemovePaintTask(View.Stroke);
if (View.Fill is not null) View.CoreCanvas.RemovePaintTask(View.Fill);

_everMeasuredSeries.Clear();
_heatPaint = null!;
Expand All @@ -125,7 +125,7 @@ public void Unload()
_activeMap = null!;
_mapFactory = null!;

View.Canvas.Dispose();
View.CoreCanvas.Dispose();
}

/// <summary>
Expand Down Expand Up @@ -161,7 +161,7 @@ protected virtual Task UpdateThrottlerUnlocked()
{
View.InvokeOnUIThread(() =>
{
lock (View.Canvas.Sync)
lock (View.CoreCanvas.Sync)
{
if (_isUnloaded) return;
Measure();
Expand All @@ -177,32 +177,32 @@ protected internal void Measure()
{
if (_activeMap is not null && _activeMap != View.ActiveMap)
{
_previousStroke?.ClearGeometriesFromPaintTask(View.Canvas);
_previousFill?.ClearGeometriesFromPaintTask(View.Canvas);
_previousStroke?.ClearGeometriesFromPaintTask(View.CoreCanvas);
_previousFill?.ClearGeometriesFromPaintTask(View.CoreCanvas);

_previousFill = null;
_previousStroke = null;

View.Canvas.Clear();
View.CoreCanvas.Clear();
}
_activeMap = View.ActiveMap;

if (!_isHeatInCanvas)
{
View.Canvas.AddDrawableTask(_heatPaint);
View.CoreCanvas.AddDrawableTask(_heatPaint);
_isHeatInCanvas = true;
}

if (_previousStroke != View.Stroke)
{
if (_previousStroke is not null)
View.Canvas.RemovePaintTask(_previousStroke);
View.CoreCanvas.RemovePaintTask(_previousStroke);

if (View.Stroke is not null)
{
if (View.Stroke.ZIndex == 0) View.Stroke.ZIndex = PaintConstants.GeoMapStrokeZIndex;
View.Stroke.PaintStyle = PaintStyle.Stroke;
View.Canvas.AddDrawableTask(View.Stroke);
View.CoreCanvas.AddDrawableTask(View.Stroke);
}

_previousStroke = View.Stroke;
Expand All @@ -211,12 +211,12 @@ protected internal void Measure()
if (_previousFill != View.Fill)
{
if (_previousFill is not null)
View.Canvas.RemovePaintTask(_previousFill);
View.CoreCanvas.RemovePaintTask(_previousFill);

if (View.Fill is not null)
{
View.Fill.PaintStyle = PaintStyle.Fill;
View.Canvas.AddDrawableTask(View.Fill);
View.CoreCanvas.AddDrawableTask(View.Fill);
}

_previousFill = View.Fill;
Expand All @@ -227,7 +227,7 @@ protected internal void Measure()

var context = new MapContext(
this, View, View.ActiveMap,
Maps.BuildProjector(View.MapProjection, [View.Width, View.Height]));
Maps.BuildProjector(View.MapProjection, [View.ControlSize.Width, View.ControlSize.Height]));

_mapFactory.GenerateLands(context);

Expand All @@ -245,15 +245,15 @@ protected internal void Measure()
_ = _everMeasuredSeries.Remove(series);
}

View.Canvas.Invalidate();
View.CoreCanvas.Invalidate();
}

private Task PanningThrottlerUnlocked()
{
return Task.Run(() =>
View.InvokeOnUIThread(() =>
{
lock (View.Canvas.Sync)
lock (View.CoreCanvas.Sync)
{
Pan(
new LvcPoint(
Expand Down
19 changes: 1 addition & 18 deletions src/LiveChartsCore/Kernel/Sketches/IChartView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
using LiveChartsCore.Drawing;
using LiveChartsCore.Kernel.Events;
using LiveChartsCore.Measure;
using LiveChartsCore.Motion;
using LiveChartsCore.Painting;
using LiveChartsCore.Themes;
using LiveChartsCore.VisualElements;
Expand All @@ -35,7 +34,7 @@ namespace LiveChartsCore.Kernel.Sketches;
/// <summary>
/// Defines a chart view
/// </summary>
public interface IChartView
public interface IChartView : IDrawnView
{
/// <summary>
/// Gets or sets the series collection.
Expand Down Expand Up @@ -80,14 +79,6 @@ public interface IChartView
/// </value>
LvcColor BackColor { get; }

/// <summary>
/// Gets the size of the control.
/// </summary>
/// <value>
/// The size of the control.
/// </value>
LvcSize ControlSize { get; }

/// <summary>
/// Gets or sets the draw margin, if this property is null, the library will calculate a margin, this margin is the distance
/// between the view bounds and the drawable area.
Expand Down Expand Up @@ -176,14 +167,6 @@ public interface IChartView
/// </value>
bool AutoUpdateEnabled { get; set; }

/// <summary>
/// Gets the core canvas.
/// </summary>
/// <value>
/// The core canvas.
/// </value>
CoreMotionCanvas CoreCanvas { get; }

/// <summary>
/// Gets or sets the chart title.
/// </summary>
Expand Down
45 changes: 45 additions & 0 deletions src/LiveChartsCore/Kernel/Sketches/IDrawnView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// The MIT License(MIT)
//
// Copyright(c) 2021 Alberto Rodriguez Orozco & LiveCharts Contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using LiveChartsCore.Drawing;
using LiveChartsCore.Motion;

namespace LiveChartsCore.Kernel.Sketches;

/// <summary>
/// Defines a drawn view.
/// </summary>
public interface IDrawnView
{
/// <summary>
/// Gets the motion canvas.
/// </summary>
CoreMotionCanvas CoreCanvas { get; }

/// <summary>
/// Gets the size of the control.
/// </summary>
/// <value>
/// The size of the control.
/// </value>
LvcSize ControlSize { get; }
}
Loading
Loading