diff --git a/src/LiveChartsCore/CartesianChart.cs b/src/LiveChartsCore/CartesianChart.cs index 4cb11f983..41d179c49 100644 --- a/src/LiveChartsCore/CartesianChart.cs +++ b/src/LiveChartsCore/CartesianChart.cs @@ -144,6 +144,8 @@ public CartesianChart( /// public override void Update(ChartUpdateParams? chartUpdateParams = null) { + if (View.DesignerMode) return; + chartUpdateParams ??= new ChartUpdateParams(); if (chartUpdateParams.IsAutomaticUpdate && !View.AutoUpdateEnabled) return; if (!chartUpdateParams.Throttling) diff --git a/src/LiveChartsCore/Kernel/Sketches/IChartView.cs b/src/LiveChartsCore/Kernel/Sketches/IChartView.cs index 5d1e3f77a..e6d78289c 100644 --- a/src/LiveChartsCore/Kernel/Sketches/IChartView.cs +++ b/src/LiveChartsCore/Kernel/Sketches/IChartView.cs @@ -26,7 +26,6 @@ using System; using System.Collections.Generic; using System.Drawing; -using System.Threading.Tasks; namespace LiveChartsCore.Kernel.Sketches { @@ -43,6 +42,11 @@ public interface IChartView /// IChart CoreChart { get; } + /// + /// Gets whether the control is in designer mode. + /// + bool DesignerMode { get; } + /// /// Sets the back color of the control. /// diff --git a/src/LiveChartsCore/PieChart.cs b/src/LiveChartsCore/PieChart.cs index bc4238649..63555a01b 100644 --- a/src/LiveChartsCore/PieChart.cs +++ b/src/LiveChartsCore/PieChart.cs @@ -139,6 +139,8 @@ public override TooltipPoint[] FindPointsNearTo(PointF pointerPosition) /// public override void Update(ChartUpdateParams? chartUpdateParams = null) { + if (View.DesignerMode) return; + chartUpdateParams ??= new ChartUpdateParams(); if (chartUpdateParams.IsAutomaticUpdate && !View.AutoUpdateEnabled) return; diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs index d251df8ed..3363b0460 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/CartesianChart.axaml.cs @@ -323,6 +323,9 @@ public CartesianChart() #region properties + /// + public bool DesignerMode => Design.IsDesignMode; + /// public IChart CoreChart => core ?? throw new Exception("Core not set yet."); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PieChart.axaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PieChart.axaml.cs index aa716525b..2d441e613 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PieChart.axaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Avalonia/PieChart.axaml.cs @@ -289,6 +289,9 @@ public PieChart() #region properties + /// + public bool DesignerMode => Design.IsDesignMode; + /// public IChart CoreChart => core ?? throw new Exception("Core not set yet."); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/Chart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/Chart.cs index 5b9f50781..00d98bf17 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/Chart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WPF/Chart.cs @@ -35,7 +35,7 @@ using FontStyle = System.Windows.FontStyle; using LiveChartsCore.Kernel.Events; using LiveChartsCore.Kernel.Sketches; -using System.Threading.Tasks; +using System.ComponentModel; namespace LiveChartsCore.SkiaSharpView.WPF { @@ -289,6 +289,9 @@ protected Chart() #region properties + /// + public bool DesignerMode => DesignerProperties.GetIsInDesignMode(this); + /// public IChart CoreChart => core ?? throw new Exception("Core not set yet."); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/CartesianChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/CartesianChart.cs index b35b8ad8f..0540765ff 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/CartesianChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/CartesianChart.cs @@ -160,6 +160,7 @@ public DrawMarginFrame? DrawMarginFrame public double ZoomingSpeed { get; set; } = LiveCharts.CurrentSettings.DefaultZoomSpeed; /// + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public TooltipFindingStrategy TooltipFindingStrategy { get => _tooltipFindingStrategy; set { _tooltipFindingStrategy = value; OnPropertyChanged(); } } /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/Chart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/Chart.cs index 8737ac576..f7b1d6c1d 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/Chart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/Chart.cs @@ -30,7 +30,6 @@ using System.Collections.Generic; using System.ComponentModel; using System.Drawing; -using System.Threading.Tasks; using System.Windows.Forms; namespace LiveChartsCore.SkiaSharpView.WinForms @@ -136,6 +135,9 @@ protected Chart(IChartTooltip? tooltip, IChartLegend + public bool DesignerMode => LicenseManager.UsageMode == LicenseUsageMode.Designtime; + /// public IChart CoreChart => core ?? throw new Exception("Core not set yet."); @@ -214,6 +216,7 @@ Color IChartView.BackColor public IChartLegend? Legend => legend; /// + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public TooltipPosition TooltipPosition { get => _tooltipPosition; set { _tooltipPosition = value; OnPropertyChanged(); } } /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj index dd12afa98..b5dcb3e1e 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/LiveChartsCore.SkiaSharpView.WinForms.csproj @@ -1,4 +1,4 @@ - + WinExe @@ -9,7 +9,7 @@ net462;netcoreapp3.0 LiveChartsCore.SkiaSharpView.WinForms LiveChartsCore.SkiaSharpView.WinForms - 2.0.0-beta.50 + 2.0.0-beta.55 icon.png Simple, flexible, interactive and powerful data visualization for WindowsForms. MIT diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/CartesianChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/CartesianChart.xaml.cs index 4c1354f65..84f28ed4b 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/CartesianChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/CartesianChart.xaml.cs @@ -358,6 +358,9 @@ public CartesianChart() #region properties + /// + public bool DesignerMode => DesignMode.IsDesignModeEnabled; + /// public IChart CoreChart => core ?? throw new Exception("Core not set yet."); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/PieChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/PieChart.xaml.cs index cbfbafc04..e3caeb15a 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/PieChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp.Xamarin.Forms/PieChart.xaml.cs @@ -32,7 +32,6 @@ using System.Collections.Specialized; using System.ComponentModel; using System.Drawing; -using System.Threading.Tasks; using Xamarin.Essentials; using Xamarin.Forms; using Xamarin.Forms.Xaml; @@ -303,6 +302,9 @@ public PieChart() #region properties + /// + public bool DesignerMode => DesignMode.IsDesignModeEnabled; + /// public IChart CoreChart => core ?? throw new Exception("Core not set yet."); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKCartesianChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKCartesianChart.cs index 25c5881dd..56ea7b785 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKCartesianChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKCartesianChart.cs @@ -24,7 +24,6 @@ using System.Collections.Generic; using System.Drawing; using System.IO; -using System.Threading.Tasks; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.Kernel.Events; @@ -76,6 +75,10 @@ public SKCartesianChart(ICartesianChartView view) : thi PointStates = view.PointStates; } + + /// + public bool DesignerMode => false; + /// /// Gets or sets the background. /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKPieChart.cs b/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKPieChart.cs index 990cc4632..1ccb8ad7f 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKPieChart.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKPieChart.cs @@ -73,6 +73,10 @@ public SKPieChart(IPieChartView view) : this() Total = view.Total; } + + /// + public bool DesignerMode => false; + /// /// Gets or sets the background. /// diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpVew.WinUI/CartesianChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpVew.WinUI/CartesianChart.xaml.cs index d9c44e391..54dbe9fd7 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpVew.WinUI/CartesianChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpVew.WinUI/CartesianChart.xaml.cs @@ -377,6 +377,9 @@ public CartesianChart() FrameworkElement IWinUIChart.Canvas => motionCanvas; FrameworkElement IWinUIChart.Legend => legend; + /// + public bool DesignerMode => Windows.ApplicationModel.DesignMode.DesignModeEnabled; + /// public IChart CoreChart => _core ?? throw new Exception("Core not set yet."); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpVew.WinUI/PieChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpVew.WinUI/PieChart.xaml.cs index 7fb60f0bb..d4dde2964 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpVew.WinUI/PieChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpVew.WinUI/PieChart.xaml.cs @@ -24,7 +24,6 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; -using System.Threading.Tasks; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.Kernel.Events; @@ -35,8 +34,6 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media; -using Windows.ApplicationModel.Core; -using Windows.UI.Core; using Windows.UI.Text; namespace LiveChartsCore.SkiaSharpView.WinUI @@ -315,6 +312,9 @@ public PieChart() FrameworkElement IWinUIChart.Canvas => motionCanvas; FrameworkElement IWinUIChart.Legend => legend; + /// + public bool DesignerMode => Windows.ApplicationModel.DesignMode.DesignModeEnabled; + /// public IChart CoreChart => _core ?? throw new Exception("Core not set yet."); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/CartesianChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/CartesianChart.xaml.cs index 413ccf1fc..bab22143a 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/CartesianChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/CartesianChart.xaml.cs @@ -25,7 +25,6 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; -using System.Threading.Tasks; using LiveChartsCore.Drawing; using LiveChartsCore.Kernel; using LiveChartsCore.Kernel.Events; @@ -381,6 +380,9 @@ public CartesianChart() FrameworkElement IUwpChart.Canvas => motionCanvas; FrameworkElement IUwpChart.Legend => legend; + /// + public bool DesignerMode => Windows.ApplicationModel.DesignMode.DesignModeEnabled; + /// public IChart CoreChart => _core ?? throw new Exception("Core not set yet."); diff --git a/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/PieChart.xaml.cs b/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/PieChart.xaml.cs index e523c32eb..c7ce5d83d 100644 --- a/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/PieChart.xaml.cs +++ b/src/skiasharp/LiveChartsCore.SkiaSharpView.UWP/PieChart.xaml.cs @@ -35,7 +35,6 @@ using LiveChartsCore.Kernel.Events; using LiveChartsCore.Drawing; using Windows.UI.Xaml.Input; -using System.Threading.Tasks; using Windows.ApplicationModel.Core; using Windows.UI.Core; @@ -314,6 +313,9 @@ public PieChart() FrameworkElement IUwpChart.Canvas => motionCanvas; FrameworkElement IUwpChart.Legend => legend; + /// + public bool DesignerMode => Windows.ApplicationModel.DesignMode.DesignModeEnabled; + /// public IChart CoreChart => _core ?? throw new Exception("Core not set yet."); diff --git a/tests/LiveChartsCore.UnitTesting/MockedObjects/TestCartesianChartView.cs b/tests/LiveChartsCore.UnitTesting/MockedObjects/TestCartesianChartView.cs index 5797acbc0..857031134 100644 --- a/tests/LiveChartsCore.UnitTesting/MockedObjects/TestCartesianChartView.cs +++ b/tests/LiveChartsCore.UnitTesting/MockedObjects/TestCartesianChartView.cs @@ -28,6 +28,8 @@ public TestCartesianChartView() this, LiveChartsSkiaSharp.DefaultPlatformBuilder, CoreCanvas); } + public bool DesignerMode => false; + IChart IChartView.CoreChart => Core; public CartesianChart Core { get; }