Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsInputView.cs =================================================================== diff -u -r18a53a9b2a6c09a3af46cb9c023de3f323639f30 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsInputView.cs (.../GrassCoverErosionInwardsInputView.cs) (revision 18a53a9b2a6c09a3af46cb9c023de3f323639f30) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsInputView.cs (.../GrassCoverErosionInwardsInputView.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -21,8 +21,11 @@ using System.Windows.Forms; using Core.Common.Base; +using Core.Components.Charting.Data; using Core.Components.Charting.Forms; +using Ringtoets.Common.Forms.Views; using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Forms.Properties; namespace Ringtoets.GrassCoverErosionInwards.Forms.Views { @@ -31,8 +34,9 @@ /// public partial class GrassCoverErosionInwardsInputView : UserControl, IChartView, IObserver { - private object data; + private GrassCoverErosionInwardsInput data; private GrassCoverErosionInwardsCalculation calculation; + private ChartData dikeProfileData; /// /// Creates a new instance of . @@ -68,7 +72,19 @@ } set { - data = value as GrassCoverErosionInwardsInput; + var newValue = value as GrassCoverErosionInwardsInput; + + DetachFromData(); + data = newValue; + + if (data == null) + { + Chart.ResetChartData(); + return; + } + + SetDataToChart(); + AttachToData(); } } @@ -83,8 +99,46 @@ public void UpdateObserver() { SetChartTitle(); + SetDataToChart(); } + private void SetDataToChart() + { + chartControl.Data.Name = Resources.GrassCoverErosionInwardsInputContext_NodeDisplayName; + + if (data != null) + { + // Bottom most layer + dikeProfileData = AddOrUpdateChartData(dikeProfileData, GetDikeProfileData()); + // Top most layer + } + + chartControl.Data.NotifyObservers(); + } + + private ChartData GetDikeProfileData() + { + if (data == null || data.DikeProfile == null) + { + return ChartDataFactory.CreateEmptyLineData(Resources.DikeProfile_DisplayName); + } + return GrassCoverErosionInwardsChartDataFactory.Create(data.DikeProfile); + } + + private ChartData AddOrUpdateChartData(ChartData oldChartData, ChartData newChartData) + { + if (oldChartData != null) + { + chartControl.Data.Remove(oldChartData); + } + if (newChartData != null) + { + chartControl.Data.Add(newChartData); + } + + return newChartData; + } + private void SetChartTitle() { chartControl.ChartTitle = calculation != null ? calculation.Name : string.Empty; @@ -96,6 +150,11 @@ { calculation.Detach(this); } + + if (data != null) + { + data.Detach(this); + } } private void AttachToData() @@ -104,6 +163,11 @@ { calculation.Attach(this); } + + if (data != null) + { + data.Attach(this); + } } } } \ No newline at end of file