Index: Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs =================================================================== diff -u -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed -ra48c03b64398a22699c3c6de2daca0b80447076e --- Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs (.../LinearPlotView.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) +++ Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs (.../LinearPlotView.cs) (revision a48c03b64398a22699c3c6de2daca0b80447076e) @@ -69,6 +69,7 @@ public void SetModelTitle(string title) { Model.Title = title; + InvalidatePlot(false); } /// Index: Core/Components/test/Core.Components.OxyPlot.Forms.Test/ChartControlTest.cs =================================================================== diff -u -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed -ra48c03b64398a22699c3c6de2daca0b80447076e --- Core/Components/test/Core.Components.OxyPlot.Forms.Test/ChartControlTest.cs (.../ChartControlTest.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) +++ Core/Components/test/Core.Components.OxyPlot.Forms.Test/ChartControlTest.cs (.../ChartControlTest.cs) (revision a48c03b64398a22699c3c6de2daca0b80447076e) @@ -247,6 +247,7 @@ var form = new Form(); var chart = new ChartControl(); var view = TypeUtils.GetField(chart, "view"); + form.Controls.Add(chart); form.Show(); @@ -267,6 +268,7 @@ var form = new Form(); var chart = new ChartControl(); var view = TypeUtils.GetField(chart, "view"); + form.Controls.Add(chart); form.Show(); @@ -281,20 +283,26 @@ [TestCase("Title")] [TestCase("Test")] [TestCase("Label")] - public void SetModelTitle_Always_SetsNewTitleToModel(string newTitle) + public void SetModelTitle_Always_SetsNewTitleToModelAndViewInvalidated(string newTitle) { // Setup var form = new Form(); var chart = new ChartControl(); var view = TypeUtils.GetField(chart, "view"); + form.Controls.Add(chart); form.Show(); + + var invalidated = 0; + view.Invalidated += (sender, args) => invalidated++; + // Call chart.SetChartTitle(newTitle); // Assert Assert.AreEqual(view.Model.Title, newTitle); + Assert.AreEqual(1, invalidated); } } } \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs =================================================================== diff -u -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed -ra48c03b64398a22699c3c6de2daca0b80447076e --- Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs (.../LinearPlotViewTest.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) +++ Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs (.../LinearPlotViewTest.cs) (revision a48c03b64398a22699c3c6de2daca0b80447076e) @@ -80,11 +80,14 @@ [TestCase("Title")] [TestCase("Test")] [TestCase("Label")] - public void SetModelTitle_Always_SetsNewTitleToModel(string newTitle) + public void SetModelTitle_Always_SetsNewTitleToModelAndInvalidatesView(string newTitle) { // Setup var form = new Form(); var view = new LinearPlotView(); + form.Controls.Add(view); + var invalidated = 0; + view.Invalidated += (sender, args) => invalidated++; form.Show(); @@ -93,6 +96,7 @@ // Assert Assert.AreEqual(view.Model.Title, newTitle); + Assert.AreEqual(1, invalidated); } [Test] @@ -104,6 +108,7 @@ // Setup var form = new Form(); var view = new LinearPlotView(); + form.Controls.Add(view); form.Show(); @@ -123,6 +128,7 @@ // Setup var form = new Form(); var view = new LinearPlotView(); + form.Controls.Add(view); form.Show(); Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs =================================================================== diff -u -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed -ra48c03b64398a22699c3c6de2daca0b80447076e --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs (.../PipingInputView.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs (.../PipingInputView.cs) (revision a48c03b64398a22699c3c6de2daca0b80447076e) @@ -20,6 +20,7 @@ // All rights reserved. using System.Windows.Forms; +using Core.Common.Base; using Core.Components.Charting.Forms; using Ringtoets.Piping.Data; using Ringtoets.Piping.Forms.Properties; @@ -29,7 +30,7 @@ /// /// This class is a view to show the piping input. /// - public partial class PipingInputView : UserControl, IChartView + public partial class PipingInputView : UserControl, IChartView, IObserver { private PipingInput data; private PipingCalculationScenario calculation; @@ -55,9 +56,10 @@ } set { + DetachFromData(); calculation = value; - SetChartTitle(); + AttachToData(); } } @@ -81,6 +83,11 @@ } } + public void UpdateObserver() + { + SetChartTitle(); + } + private void SetChartTitle() { chartControl.SetChartTitle(calculation.Name); @@ -91,5 +98,21 @@ chartControl.SetBottomAxisTitle(Resources.PipingInputView_Distance_DisplayName); chartControl.SetLeftAxisTitle(Resources.PipingInputView_Height_DisplayName); } + + private void DetachFromData() + { + if (calculation != null) + { + calculation.Detach(this); + } + } + + private void AttachToData() + { + if (calculation != null) + { + calculation.Attach(this); + } + } } } \ No newline at end of file