Skip to content

Commit

Permalink
design mode
Browse files Browse the repository at this point in the history
  • Loading branch information
beto-rodriguez committed Aug 20, 2021
1 parent 5327529 commit 976ff1d
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/LiveChartsCore/CartesianChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public CartesianChart(
/// <inheritdoc cref="IChart.Update(ChartUpdateParams?)" />
public override void Update(ChartUpdateParams? chartUpdateParams = null)
{
if (View.DesignerMode) return;

chartUpdateParams ??= new ChartUpdateParams();
if (chartUpdateParams.IsAutomaticUpdate && !View.AutoUpdateEnabled) return;
if (!chartUpdateParams.Throttling)
Expand Down
6 changes: 5 additions & 1 deletion src/LiveChartsCore/Kernel/Sketches/IChartView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Threading.Tasks;

namespace LiveChartsCore.Kernel.Sketches
{
Expand All @@ -43,6 +42,11 @@ public interface IChartView
/// </value>
IChart CoreChart { get; }

/// <summary>
/// Gets whether the control is in designer mode.
/// </summary>
bool DesignerMode { get; }

/// <summary>
/// Sets the back color of the control.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions src/LiveChartsCore/PieChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ public override TooltipPoint[] FindPointsNearTo(PointF pointerPosition)
/// <inheritdoc cref="IChart.Update(ChartUpdateParams?)" />
public override void Update(ChartUpdateParams? chartUpdateParams = null)
{
if (View.DesignerMode) return;

chartUpdateParams ??= new ChartUpdateParams();

if (chartUpdateParams.IsAutomaticUpdate && !View.AutoUpdateEnabled) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ public CartesianChart()

#region properties

/// <inheritdoc cref="IChartView.DesignerMode" />
public bool DesignerMode => Design.IsDesignMode;

/// <inheritdoc cref="IChartView.CoreChart" />
public IChart CoreChart => core ?? throw new Exception("Core not set yet.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ public PieChart()

#region properties

/// <inheritdoc cref="IChartView.DesignerMode" />
public bool DesignerMode => Design.IsDesignMode;

/// <inheritdoc cref="IChartView.CoreChart" />
public IChart CoreChart => core ?? throw new Exception("Core not set yet.");

Expand Down
5 changes: 4 additions & 1 deletion src/skiasharp/LiveChartsCore.SkiaSharp.WPF/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -289,6 +289,9 @@ protected Chart()

#region properties

/// <inheritdoc cref="IChartView.DesignerMode" />
public bool DesignerMode => DesignerProperties.GetIsInDesignMode(this);

/// <inheritdoc cref="IChartView.CoreChart" />
public IChart CoreChart => core ?? throw new Exception("Core not set yet.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public DrawMarginFrame<SkiaSharpDrawingContext>? DrawMarginFrame
public double ZoomingSpeed { get; set; } = LiveCharts.CurrentSettings.DefaultZoomSpeed;

/// <inheritdoc cref="ICartesianChartView{TDrawingContext}.TooltipFindingStrategy" />
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public TooltipFindingStrategy TooltipFindingStrategy { get => _tooltipFindingStrategy; set { _tooltipFindingStrategy = value; OnPropertyChanged(); } }

/// <summary>
Expand Down
5 changes: 4 additions & 1 deletion src/skiasharp/LiveChartsCore.SkiaSharp.WinForms/Chart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -136,6 +135,9 @@ protected Chart(IChartTooltip<SkiaSharpDrawingContext>? tooltip, IChartLegend<Sk

#region properties

/// <inheritdoc cref="IChartView.DesignerMode" />
public bool DesignerMode => LicenseManager.UsageMode == LicenseUsageMode.Designtime;

/// <inheritdoc cref="IChartView.CoreChart" />
public IChart CoreChart => core ?? throw new Exception("Core not set yet.");

Expand Down Expand Up @@ -214,6 +216,7 @@ Color IChartView.BackColor
public IChartLegend<SkiaSharpDrawingContext>? Legend => legend;

/// <inheritdoc cref="IChartView.LegendPosition" />
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public TooltipPosition TooltipPosition { get => _tooltipPosition; set { _tooltipPosition = value; OnPropertyChanged(); } }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<OutputType>WinExe</OutputType>
Expand All @@ -9,7 +9,7 @@
<TargetFrameworks>net462;netcoreapp3.0</TargetFrameworks>
<AssemblyName>LiveChartsCore.SkiaSharpView.WinForms</AssemblyName>
<RootNamespace>LiveChartsCore.SkiaSharpView.WinForms</RootNamespace>
<Version>2.0.0-beta.50</Version>
<Version>2.0.0-beta.55</Version>
<PackageIcon>icon.png</PackageIcon>
<Description>Simple, flexible, interactive and powerful data visualization for WindowsForms.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ public CartesianChart()

#region properties

/// <inheritdoc cref="IChartView.DesignerMode" />
public bool DesignerMode => DesignMode.IsDesignModeEnabled;

/// <inheritdoc cref="IChartView.CoreChart" />
public IChart CoreChart => core ?? throw new Exception("Core not set yet.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -303,6 +302,9 @@ public PieChart()

#region properties

/// <inheritdoc cref="IChartView.DesignerMode" />
public bool DesignerMode => DesignMode.IsDesignModeEnabled;

/// <inheritdoc cref="IChartView.CoreChart" />
public IChart CoreChart => core ?? throw new Exception("Core not set yet.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -76,6 +75,10 @@ public SKCartesianChart(ICartesianChartView<SkiaSharpDrawingContext> view) : thi
PointStates = view.PointStates;
}


/// <inheritdoc cref="IChartView.DesignerMode" />
public bool DesignerMode => false;

/// <summary>
/// Gets or sets the background.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions src/skiasharp/LiveChartsCore.SkiaSharp/SKCharts/SKPieChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public SKPieChart(IPieChartView<SkiaSharpDrawingContext> view) : this()
Total = view.Total;
}


/// <inheritdoc cref="IChartView.DesignerMode" />
public bool DesignerMode => false;

/// <summary>
/// Gets or sets the background.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ public CartesianChart()
FrameworkElement IWinUIChart.Canvas => motionCanvas;
FrameworkElement IWinUIChart.Legend => legend;

/// <inheritdoc cref="IChartView.DesignerMode" />
public bool DesignerMode => Windows.ApplicationModel.DesignMode.DesignModeEnabled;

/// <inheritdoc cref="IChartView.CoreChart" />
public IChart CoreChart => _core ?? throw new Exception("Core not set yet.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -315,6 +312,9 @@ public PieChart()
FrameworkElement IWinUIChart.Canvas => motionCanvas;
FrameworkElement IWinUIChart.Legend => legend;

/// <inheritdoc cref="IChartView.DesignerMode" />
public bool DesignerMode => Windows.ApplicationModel.DesignMode.DesignModeEnabled;

/// <inheritdoc cref="IChartView.CoreChart" />
public IChart CoreChart => _core ?? throw new Exception("Core not set yet.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -381,6 +380,9 @@ public CartesianChart()
FrameworkElement IUwpChart.Canvas => motionCanvas;
FrameworkElement IUwpChart.Legend => legend;

/// <inheritdoc cref="IChartView.DesignerMode" />
public bool DesignerMode => Windows.ApplicationModel.DesignMode.DesignModeEnabled;

/// <inheritdoc cref="IChartView.CoreChart" />
public IChart CoreChart => _core ?? throw new Exception("Core not set yet.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -314,6 +313,9 @@ public PieChart()
FrameworkElement IUwpChart.Canvas => motionCanvas;
FrameworkElement IUwpChart.Legend => legend;

/// <inheritdoc cref="IChartView.DesignerMode" />
public bool DesignerMode => Windows.ApplicationModel.DesignMode.DesignModeEnabled;

/// <inheritdoc cref="IChartView.CoreChart" />
public IChart CoreChart => _core ?? throw new Exception("Core not set yet.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public TestCartesianChartView()
this, LiveChartsSkiaSharp.DefaultPlatformBuilder, CoreCanvas);
}

public bool DesignerMode => false;

IChart IChartView.CoreChart => Core;

public CartesianChart<SkiaSharpDrawingContext> Core { get; }
Expand Down

0 comments on commit 976ff1d

Please sign in to comment.