Index: Core/Components/src/Core.Components.Charting.Forms/IChartControl.cs =================================================================== diff -u -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed -r0fdde49cfbdc5a411fac387d6a99484f05112700 --- Core/Components/src/Core.Components.Charting.Forms/IChartControl.cs (.../IChartControl.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) +++ Core/Components/src/Core.Components.Charting.Forms/IChartControl.cs (.../IChartControl.cs) (revision 0fdde49cfbdc5a411fac387d6a99484f05112700) @@ -44,36 +44,33 @@ ChartData Data { get; set; } /// - /// Toggles panning of the . Panning is invoked by clicking the left mouse-button. + /// Gets or sets the title of the chart. /// - void TogglePanning(); + string ChartTitle { get; set; } /// - /// Toggles rectangle zooming of the . Rectangle zooming is invoked by clicking the left mouse-button. + /// Gets or sets the title of the bottom axis in the view. /// - void ToggleRectangleZooming(); + string BottomAxisTitle { get; set; } /// - /// Zooms to a level so that everything is in view. + /// Gets or sets the title of the left axis in the view. /// - void ZoomToAll(); + string LeftAxisTitle { get; set; } /// - /// Sets the title of the chart. + /// Toggles panning of the . Panning is invoked by clicking the left mouse-button. /// - /// The title to set. - void SetChartTitle(string title); + void TogglePanning(); /// - /// Sets the title of the bottom axis in the view. + /// Toggles rectangle zooming of the . Rectangle zooming is invoked by clicking the left mouse-button. /// - /// The title to set. - void SetBottomAxisTitle(string title); + void ToggleRectangleZooming(); /// - /// Sets the title of the left axis in the view. + /// Zooms to a level so that everything is in view. /// - /// The title to set. - void SetLeftAxisTitle(string title); + void ZoomToAll(); } } \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs =================================================================== diff -u -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed -r0fdde49cfbdc5a411fac387d6a99484f05112700 --- Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs (.../ChartControl.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) +++ Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs (.../ChartControl.cs) (revision 0fdde49cfbdc5a411fac387d6a99484f05112700) @@ -23,8 +23,8 @@ using System.Drawing; using System.Windows.Forms; using Core.Common.Base; -using Core.Components.Charting.Forms; using Core.Components.Charting.Data; +using Core.Components.Charting.Forms; using Core.Components.OxyPlot.Converter; using OxyPlot.WindowsForms; @@ -134,39 +134,60 @@ } } - public void TogglePanning() + public string ChartTitle { - controller.TogglePanning(); + get + { + return view.ModelTitle; + } + set + { + view.ModelTitle = value; + } } - public void ToggleRectangleZooming() + public string BottomAxisTitle { - controller.ToggleRectangleZooming(); + get + { + return view.BottomAxisTitle; + } + set + { + view.BottomAxisTitle = value; + } } - public void ZoomToAll() + public string LeftAxisTitle { - view.ZoomToAll(); + get + { + return view.LeftAxisTitle; + } + set + { + view.LeftAxisTitle = value; + } } - public void UpdateObserver() + public void TogglePanning() { - DrawSeries(); + controller.TogglePanning(); } - public void SetChartTitle(string title) + public void ToggleRectangleZooming() { - view.SetModelTitle(title); + controller.ToggleRectangleZooming(); } - public void SetBottomAxisTitle(string title) + public void ZoomToAll() { - view.SetBottomAxisTitle(title); + view.ZoomToAll(); } - public void SetLeftAxisTitle(string title) + public void UpdateObserver() { - view.SetLeftAxisTitle(title); + DrawSeries(); } #endregion Index: Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs =================================================================== diff -u -ra48c03b64398a22699c3c6de2daca0b80447076e -r0fdde49cfbdc5a411fac387d6a99484f05112700 --- Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs (.../LinearPlotView.cs) (revision a48c03b64398a22699c3c6de2daca0b80447076e) +++ Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs (.../LinearPlotView.cs) (revision 0fdde49cfbdc5a411fac387d6a99484f05112700) @@ -54,47 +54,69 @@ } /// - /// Zooms to a level so that everything is in view. + /// Sets the title of the plot view. /// - public void ZoomToAll() + public string ModelTitle { - ActualModel.ResetAllAxes(); - InvalidatePlot(false); + get + { + return Model.Title; + } + set + { + Model.Title = value; + InvalidatePlot(false); + } } /// - /// Sets the title of the plot view. + /// Sets the title of the bottom axis in the view. /// - /// The title to set. - public void SetModelTitle(string title) + public string BottomAxisTitle { - Model.Title = title; - InvalidatePlot(false); + get + { + var axis = GetAxisOnPosition(AxisPosition.Bottom); + return axis != null ? axis.Title : null; + } + set + { + SetAxisTitle(AxisPosition.Bottom, value); + } } /// - /// Sets the title of the bottom axis in the view. + /// Sets the title of the left axis in the view. /// - /// The title to set. - public void SetBottomAxisTitle(string title) + public string LeftAxisTitle { - var axis = GetAxisOnPosition(AxisPosition.Bottom); - if (axis != null) + get { - axis.Title = title; + var axis = GetAxisOnPosition(AxisPosition.Left); + return axis != null ? axis.Title : null; } + set + { + SetAxisTitle(AxisPosition.Left, value); + } } /// - /// Sets the title of the left axis in the view. + /// Zooms to a level so that everything is in view. /// - /// The title to set. - public void SetLeftAxisTitle(string title) + public void ZoomToAll() { - var axis = GetAxisOnPosition(AxisPosition.Left); + ActualModel.ResetAllAxes(); + InvalidatePlot(false); + } + + private void SetAxisTitle(AxisPosition axisPosition, string value) + { + var axis = GetAxisOnPosition(axisPosition); if (axis != null) { - axis.Title = title; + axis.Title = value; + InvalidatePlot(false); } } Index: Core/Components/test/Core.Components.OxyPlot.Forms.Test/ChartControlTest.cs =================================================================== diff -u -ra48c03b64398a22699c3c6de2daca0b80447076e -r0fdde49cfbdc5a411fac387d6a99484f05112700 --- Core/Components/test/Core.Components.OxyPlot.Forms.Test/ChartControlTest.cs (.../ChartControlTest.cs) (revision a48c03b64398a22699c3c6de2daca0b80447076e) +++ Core/Components/test/Core.Components.OxyPlot.Forms.Test/ChartControlTest.cs (.../ChartControlTest.cs) (revision 0fdde49cfbdc5a411fac387d6a99484f05112700) @@ -28,7 +28,6 @@ using Core.Components.Charting.Data; using Core.Components.Charting.TestUtil; using NUnit.Framework; -using OxyPlot.Axes; using OxyPlot.WindowsForms; namespace Core.Components.OxyPlot.Forms.Test @@ -241,7 +240,7 @@ [TestCase("Title")] [TestCase("Test")] [TestCase("Label")] - public void SetBottomAxisTitle_Always_SetsNewTitleToBottomAxis(string newTitle) + public void BottomAxisTitle_Always_SetsNewTitleToBottomAxis(string newTitle) { // Setup var form = new Form(); @@ -251,11 +250,15 @@ form.Show(); + var invalidated = 0; + view.Invalidated += (sender, args) => invalidated++; + // Call - chart.SetBottomAxisTitle(newTitle); + chart.BottomAxisTitle = newTitle; // Assert - Assert.AreEqual(view.Model.Axes.First(a => a.Position == AxisPosition.Bottom).Title, newTitle); + Assert.AreEqual(chart.BottomAxisTitle, newTitle); + Assert.AreEqual(1, invalidated); } [Test] @@ -272,11 +275,15 @@ form.Show(); + var invalidated = 0; + view.Invalidated += (sender, args) => invalidated++; + // Call - chart.SetLeftAxisTitle(newTitle); + chart.LeftAxisTitle = newTitle; // Assert - Assert.AreEqual(view.Model.Axes.First(a => a.Position == AxisPosition.Left).Title, newTitle); + Assert.AreEqual(chart.LeftAxisTitle, newTitle); + Assert.AreEqual(1, invalidated); } [Test] @@ -293,15 +300,14 @@ form.Show(); - var invalidated = 0; view.Invalidated += (sender, args) => invalidated++; // Call - chart.SetChartTitle(newTitle); + chart.ChartTitle = newTitle; // Assert - Assert.AreEqual(view.Model.Title, newTitle); + Assert.AreEqual(chart.ChartTitle, newTitle); Assert.AreEqual(1, invalidated); } } Index: Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs =================================================================== diff -u -ra48c03b64398a22699c3c6de2daca0b80447076e -r0fdde49cfbdc5a411fac387d6a99484f05112700 --- Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs (.../LinearPlotViewTest.cs) (revision a48c03b64398a22699c3c6de2daca0b80447076e) +++ Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs (.../LinearPlotViewTest.cs) (revision 0fdde49cfbdc5a411fac387d6a99484f05112700) @@ -80,7 +80,7 @@ [TestCase("Title")] [TestCase("Test")] [TestCase("Label")] - public void SetModelTitle_Always_SetsNewTitleToModelAndInvalidatesView(string newTitle) + public void ModelTitle_Always_SetsNewTitleToModelAndInvalidatesView(string newTitle) { // Setup var form = new Form(); @@ -92,51 +92,57 @@ form.Show(); // Call - view.SetModelTitle(newTitle); + view.ModelTitle = newTitle; // Assert - Assert.AreEqual(view.Model.Title, newTitle); + Assert.AreEqual(view.ModelTitle, newTitle); Assert.AreEqual(1, invalidated); } [Test] [TestCase("Title")] [TestCase("Test")] [TestCase("Label")] - public void SetBottomAxisTitle_Always_SetsNewTitleToBottomAxis(string newTitle) + public void BottomAxisTitle_Always_SetsNewTitleToBottomAxisAndInvalidatesView(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(); // Call - view.SetBottomAxisTitle(newTitle); + view.BottomAxisTitle = newTitle; // Assert - Assert.AreEqual(view.Model.Axes.First(a => a.Position == AxisPosition.Bottom).Title, newTitle); + Assert.AreEqual(view.BottomAxisTitle, newTitle); + Assert.AreEqual(1, invalidated); } [Test] [TestCase("Title")] [TestCase("Test")] [TestCase("Label")] - public void SetLeftAxisTitle_Always_SetsNewTitleToLeftAxis(string newTitle) + public void SetLeftAxisTitle_Always_SetsNewTitleToLeftAxisAndInvalidatesView(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(); // Call - view.SetLeftAxisTitle(newTitle); + view.LeftAxisTitle = newTitle; // Assert - Assert.AreEqual(view.Model.Axes.First(a => a.Position == AxisPosition.Left).Title, newTitle); + Assert.AreEqual(view.LeftAxisTitle, newTitle); + Assert.AreEqual(1, invalidated); } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.Designer.cs =================================================================== diff -u -r985b7690055ffc0570e0608c3de6c2f645cafc3b -r0fdde49cfbdc5a411fac387d6a99484f05112700 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.Designer.cs (.../PipingInputView.Designer.cs) (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.Designer.cs (.../PipingInputView.Designer.cs) (revision 0fdde49cfbdc5a411fac387d6a99484f05112700) @@ -1,4 +1,6 @@ -namespace Ringtoets.Piping.Forms.Views +using Ringtoets.Piping.Forms.Properties; + +namespace Ringtoets.Piping.Forms.Views { partial class PipingInputView { @@ -40,6 +42,8 @@ this.chartControl.Size = new System.Drawing.Size(150, 150); this.chartControl.TabIndex = 0; this.chartControl.Text = "chartControl1"; + this.chartControl.BottomAxisTitle = Resources.PipingInputView_Distance_DisplayName; + this.chartControl.LeftAxisTitle = Resources.PipingInputView_Height_DisplayName; // // PipingInputView // Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs =================================================================== diff -u -ra48c03b64398a22699c3c6de2daca0b80447076e -r0fdde49cfbdc5a411fac387d6a99484f05112700 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs (.../PipingInputView.cs) (revision a48c03b64398a22699c3c6de2daca0b80447076e) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs (.../PipingInputView.cs) (revision 0fdde49cfbdc5a411fac387d6a99484f05112700) @@ -23,7 +23,6 @@ using Core.Common.Base; using Core.Components.Charting.Forms; using Ringtoets.Piping.Data; -using Ringtoets.Piping.Forms.Properties; namespace Ringtoets.Piping.Forms.Views { @@ -41,8 +40,6 @@ public PipingInputView() { InitializeComponent(); - - SetChartAxisTitles(); } /// @@ -90,15 +87,9 @@ private void SetChartTitle() { - chartControl.SetChartTitle(calculation.Name); + chartControl.ChartTitle = calculation.Name; } - private void SetChartAxisTitles() - { - chartControl.SetBottomAxisTitle(Resources.PipingInputView_Distance_DisplayName); - chartControl.SetLeftAxisTitle(Resources.PipingInputView_Height_DisplayName); - } - private void DetachFromData() { if (calculation != null) Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs =================================================================== diff -u -r5e6eacaf76f765ba77febee673e9e94895e46feb -r0fdde49cfbdc5a411fac387d6a99484f05112700 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 5e6eacaf76f765ba77febee673e9e94895e46feb) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 0fdde49cfbdc5a411fac387d6a99484f05112700) @@ -116,7 +116,7 @@ GetViewData = context => context.WrappedData, GetViewName = (view, input) => PipingFormsResources.PipingInputContext_NodeDisplayName, Image = PipingFormsResources.PipingInputIcon, - CloseForData = ClosePipingInutViewForData, + CloseForData = ClosePipingInputViewForData, AfterCreate = (view, context) => { view.Calculation = context.PipingCalculation; @@ -315,7 +315,7 @@ #region PipingInputView ViewInfo - private bool ClosePipingInutViewForData(PipingInputView view, object o) + private bool ClosePipingInputViewForData(PipingInputView view, object o) { var pipingCalculationScenarioContext = o as PipingCalculationScenarioContext; if (pipingCalculationScenarioContext != null) Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs =================================================================== diff -u -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed -r0fdde49cfbdc5a411fac387d6a99484f05112700 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs (.../PipingInputViewTest.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs (.../PipingInputViewTest.cs) (revision 0fdde49cfbdc5a411fac387d6a99484f05112700) @@ -24,6 +24,7 @@ using Core.Components.OxyPlot.Forms; using NUnit.Framework; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Forms.Views; namespace Ringtoets.Piping.Forms.Test.Views @@ -55,7 +56,9 @@ ChartControl chartControl = view.Controls[0] as ChartControl; Assert.IsNotNull(chartControl); Assert.AreEqual(DockStyle.Fill, chartControl.Dock); - Assert.IsNull(chartControl.Data); + Assert.IsNull(chartControl.Data); + Assert.AreEqual(Resources.PipingInputView_Distance_DisplayName, chartControl.BottomAxisTitle); + Assert.AreEqual(Resources.PipingInputView_Height_DisplayName, chartControl.LeftAxisTitle); } [Test] @@ -87,17 +90,21 @@ } [Test] - public void Calculation_Always_SetsCalculation() + public void Calculation_Always_SetsCalculationAndUpdateChartTitle() { // Setup - PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()) + { + Name = "Test name" + }; PipingInputView view = new PipingInputView(); // Call view.Calculation = calculation; // Assert Assert.AreSame(calculation, view.Calculation); + Assert.AreEqual(calculation.Name, view.Chart.ChartTitle); } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingInputViewInfoTest.cs =================================================================== diff -u -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed -r0fdde49cfbdc5a411fac387d6a99484f05112700 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingInputViewInfoTest.cs (.../PipingInputViewInfoTest.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingInputViewInfoTest.cs (.../PipingInputViewInfoTest.cs) (revision 0fdde49cfbdc5a411fac387d6a99484f05112700) @@ -514,7 +514,7 @@ } [Test] - public void AfterCreate_Always_SetsSpecificPropertiesToView() + public void AfterCreate_Always_SetsCalculationOnView() { // Setup IAssessmentSection assessmentSection = mocks.StrictMock();