Index: Core/Components/src/Core.Components.Charting.Forms/IChartControl.cs =================================================================== diff -u -r30b12b82918d500fe834eafd9f6cd9b2c5dbe60f -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed --- Core/Components/src/Core.Components.Charting.Forms/IChartControl.cs (.../IChartControl.cs) (revision 30b12b82918d500fe834eafd9f6cd9b2c5dbe60f) +++ Core/Components/src/Core.Components.Charting.Forms/IChartControl.cs (.../IChartControl.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) @@ -57,5 +57,23 @@ /// Zooms to a level so that everything is in view. /// void ZoomToAll(); + + /// + /// Sets the title of the chart. + /// + /// The title to set. + void SetChartTitle(string title); + + /// + /// Sets the title of the bottom axis in the view. + /// + /// The title to set. + void SetBottomAxisTitle(string title); + + /// + /// Sets the title of the left axis in the view. + /// + /// The title to set. + void SetLeftAxisTitle(string title); } } \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs =================================================================== diff -u -r8aa11a9aa48733a5b5b72c58c71674472825b26c -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed --- Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs (.../ChartControl.cs) (revision 8aa11a9aa48733a5b5b72c58c71674472825b26c) +++ Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs (.../ChartControl.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) @@ -154,6 +154,21 @@ DrawSeries(); } + public void SetChartTitle(string title) + { + view.SetModelTitle(title); + } + + public void SetBottomAxisTitle(string title) + { + view.SetBottomAxisTitle(title); + } + + public void SetLeftAxisTitle(string title) + { + view.SetLeftAxisTitle(title); + } + #endregion } } \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs =================================================================== diff -u -r30b12b82918d500fe834eafd9f6cd9b2c5dbe60f -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed --- Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs (.../LinearPlotView.cs) (revision 30b12b82918d500fe834eafd9f6cd9b2c5dbe60f) +++ Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs (.../LinearPlotView.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Linq; using System.Windows.Forms; using Core.Components.OxyPlot.Forms.Properties; using OxyPlot; @@ -52,6 +53,50 @@ Invalidated += OnInvalidated; } + /// + /// Zooms to a level so that everything is in view. + /// + public void ZoomToAll() + { + ActualModel.ResetAllAxes(); + InvalidatePlot(false); + } + + /// + /// Sets the title of the plot view. + /// + /// The title to set. + public void SetModelTitle(string title) + { + Model.Title = title; + } + + /// + /// Sets the title of the bottom axis in the view. + /// + /// The title to set. + public void SetBottomAxisTitle(string title) + { + var axis = GetAxisOnPosition(AxisPosition.Bottom); + if (axis != null) + { + axis.Title = title; + } + } + + /// + /// Sets the title of the left axis in the view. + /// + /// The title to set. + public void SetLeftAxisTitle(string title) + { + var axis = GetAxisOnPosition(AxisPosition.Left); + if (axis != null) + { + axis.Title = title; + } + } + private void OnInvalidated(object sender, EventArgs e) { FixateZoom(); @@ -90,13 +135,9 @@ }; } - /// - /// Zooms to a level so that everything is in view. - /// - public void ZoomToAll() + private Axis GetAxisOnPosition(AxisPosition position) { - ActualModel.ResetAllAxes(); - InvalidatePlot(false); + return Model.Axes.First(a => a.Position == position); } } } \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Forms.Test/ChartControlTest.cs =================================================================== diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed --- Core/Components/test/Core.Components.OxyPlot.Forms.Test/ChartControlTest.cs (.../ChartControlTest.cs) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21) +++ Core/Components/test/Core.Components.OxyPlot.Forms.Test/ChartControlTest.cs (.../ChartControlTest.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) @@ -28,6 +28,7 @@ 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 @@ -235,5 +236,65 @@ Assert.AreEqual(1, view.Model.Series.Count); Assert.AreNotSame(series[0], view.Model.Series[0]); } + + [Test] + [TestCase("Title")] + [TestCase("Test")] + [TestCase("Label")] + public void SetBottomAxisTitle_Always_SetsNewTitleToBottomAxis(string newTitle) + { + // Setup + var form = new Form(); + var chart = new ChartControl(); + var view = TypeUtils.GetField(chart, "view"); + + form.Show(); + + // Call + chart.SetBottomAxisTitle(newTitle); + + // Assert + Assert.AreEqual(view.Model.Axes.First(a => a.Position == AxisPosition.Bottom).Title, newTitle); + } + + [Test] + [TestCase("Title")] + [TestCase("Test")] + [TestCase("Label")] + public void SetLeftAxisTitle_Always_SetsNewTitleToLeftAxis(string newTitle) + { + // Setup + var form = new Form(); + var chart = new ChartControl(); + var view = TypeUtils.GetField(chart, "view"); + + form.Show(); + + // Call + chart.SetLeftAxisTitle(newTitle); + + // Assert + Assert.AreEqual(view.Model.Axes.First(a => a.Position == AxisPosition.Left).Title, newTitle); + } + + [Test] + [TestCase("Title")] + [TestCase("Test")] + [TestCase("Label")] + public void SetModelTitle_Always_SetsNewTitleToModel(string newTitle) + { + // Setup + var form = new Form(); + var chart = new ChartControl(); + var view = TypeUtils.GetField(chart, "view"); + + form.Show(); + + // Call + chart.SetChartTitle(newTitle); + + // Assert + Assert.AreEqual(view.Model.Title, newTitle); + } } } \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs =================================================================== diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed --- Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs (.../LinearPlotViewTest.cs) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21) +++ Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs (.../LinearPlotViewTest.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) @@ -75,5 +75,62 @@ // Assert Assert.AreEqual(1, invalidated); } + + [Test] + [TestCase("Title")] + [TestCase("Test")] + [TestCase("Label")] + public void SetModelTitle_Always_SetsNewTitleToModel(string newTitle) + { + // Setup + var form = new Form(); + var view = new LinearPlotView(); + + form.Show(); + + // Call + view.SetModelTitle(newTitle); + + // Assert + Assert.AreEqual(view.Model.Title, newTitle); + } + + [Test] + [TestCase("Title")] + [TestCase("Test")] + [TestCase("Label")] + public void SetBottomAxisTitle_Always_SetsNewTitleToBottomAxis(string newTitle) + { + // Setup + var form = new Form(); + var view = new LinearPlotView(); + + form.Show(); + + // Call + view.SetBottomAxisTitle(newTitle); + + // Assert + Assert.AreEqual(view.Model.Axes.First(a => a.Position == AxisPosition.Bottom).Title, newTitle); + } + + [Test] + [TestCase("Title")] + [TestCase("Test")] + [TestCase("Label")] + public void SetLeftAxisTitle_Always_SetsNewTitleToLeftAxis(string newTitle) + { + // Setup + var form = new Form(); + var view = new LinearPlotView(); + + form.Show(); + + // Call + view.SetLeftAxisTitle(newTitle); + + // Assert + Assert.AreEqual(view.Model.Axes.First(a => a.Position == AxisPosition.Left).Title, newTitle); + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -rba8739d97f3effe6ff34e5165038fe4adba0e77b -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ba8739d97f3effe6ff34e5165038fe4adba0e77b) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Runtime Version:4.0.30319.17929 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -1032,6 +1032,24 @@ } /// + /// Looks up a localized string similar to Afstand [m]. + /// + public static string PipingInputView_Distance_DisplayName { + get { + return ResourceManager.GetString("PipingInputView_Distance_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hoogte [m+NAP]. + /// + public static string PipingInputView_Height_DisplayName { + get { + return ResourceManager.GetString("PipingInputView_Height_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Heave. /// public static string PipingSemiProbabilisticOutput_Categories_Heave { Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx =================================================================== diff -u -rba8739d97f3effe6ff34e5165038fe4adba0e77b -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision ba8739d97f3effe6ff34e5165038fe4adba0e77b) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) @@ -673,4 +673,10 @@ De berekening + + Afstand [m] + + + Hoogte [m+NAP] + \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs =================================================================== diff -u -r985b7690055ffc0570e0608c3de6c2f645cafc3b -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs (.../PipingInputView.cs) (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs (.../PipingInputView.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) @@ -21,6 +21,8 @@ using System.Windows.Forms; using Core.Components.Charting.Forms; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Forms.Properties; namespace Ringtoets.Piping.Forms.Views { @@ -29,22 +31,65 @@ /// public partial class PipingInputView : UserControl, IChartView { + private PipingInput data; + private PipingCalculationScenario calculation; + /// /// Creates a new instance of . /// public PipingInputView() { InitializeComponent(); + + SetChartAxisTitles(); } - public object Data { get; set; } + /// + /// Gets or sets the calculation the input belongs to. + /// + public PipingCalculationScenario Calculation + { + get + { + return calculation; + } + set + { + calculation = value; + SetChartTitle(); + } + } + + public object Data + { + get + { + return data; + } + set + { + data = value as PipingInput; + } + } + public IChartControl Chart { get { return chartControl; } } + + private void SetChartTitle() + { + chartControl.SetChartTitle(calculation.Name); + } + + private void SetChartAxisTitles() + { + chartControl.SetBottomAxisTitle(Resources.PipingInputView_Distance_DisplayName); + chartControl.SetLeftAxisTitle(Resources.PipingInputView_Height_DisplayName); + } } -} +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs =================================================================== diff -u -r985b7690055ffc0570e0608c3de6c2f645cafc3b -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) @@ -116,7 +116,11 @@ GetViewData = context => context.WrappedData, GetViewName = (view, input) => PipingFormsResources.PipingInputContext_NodeDisplayName, Image = PipingFormsResources.PipingInputIcon, - CloseForData = ClosePipingInutViewForData + CloseForData = ClosePipingInutViewForData, + AfterCreate = (view, context) => + { + view.Calculation = context.PipingCalculation; + } }; } Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj =================================================================== diff -u -r985b7690055ffc0570e0608c3de6c2f645cafc3b -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) @@ -136,6 +136,10 @@ {2465CCA1-C505-4827-9454-4FD5FD9194CD} Core.Components.Charting.Forms + + {516ebc95-b8f2-428c-b7f6-733f01bf8fdd} + Core.Components.Charting + {5A91174A-FB95-4C9D-9CA5-81C0B8D4361A} Core.Components.DotSpatial.Forms @@ -148,6 +152,10 @@ {318ba582-88c9-4816-a54a-a7e431461de3} Core.Components.Gis + + {DADAA0A5-288C-49CB-9F08-337F16832C86} + Core.Components.OxyPlot.Forms + {d4200f43-3f72-4f42-af0a-8ced416a38ec} Ringtoets.Common.Data Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs =================================================================== diff -u -r985b7690055ffc0570e0608c3de6c2f645cafc3b -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs (.../PipingInputViewTest.cs) (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs (.../PipingInputViewTest.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) @@ -21,7 +21,9 @@ using System.Windows.Forms; using Core.Components.Charting.Forms; +using Core.Components.OxyPlot.Forms; using NUnit.Framework; +using Ringtoets.Piping.Data; using Ringtoets.Piping.Forms.Views; namespace Ringtoets.Piping.Forms.Test.Views @@ -33,13 +35,69 @@ public void DefaultConstructor_DefaultValues() { // Call - var view = new PipingInputView(); + PipingInputView view = new PipingInputView(); // Assert Assert.IsInstanceOf(view); Assert.IsInstanceOf(view); Assert.IsNotNull(view.Chart); Assert.IsNull(view.Data); } + + [Test] + public void DefaultConstructor_Always_AddChartControl() + { + // Call + PipingInputView view = new PipingInputView(); + + // Assert + Assert.AreEqual(1, view.Controls.Count); + ChartControl chartControl = view.Controls[0] as ChartControl; + Assert.IsNotNull(chartControl); + Assert.AreEqual(DockStyle.Fill, chartControl.Dock); + Assert.IsNull(chartControl.Data); + } + + [Test] + public void Data_PipingInput_DataSet() + { + // Setup + PipingInput input = new PipingInput(new GeneralPipingInput()); + PipingInputView view = new PipingInputView(); + + // Call + view.Data = input; + + // Assert + Assert.AreSame(input, view.Data); + } + + [Test] + public void Data_OtherThanPipingInput_DataNull() + { + // Setup + object input = new object(); + PipingInputView view = new PipingInputView(); + + // Call + view.Data = input; + + // Assert + Assert.IsNull(view.Data); + } + + [Test] + public void Calculation_Always_SetsCalculation() + { + // Setup + PipingCalculationScenario calculation = new PipingCalculationScenario(new GeneralPipingInput()); + PipingInputView view = new PipingInputView(); + + // Call + view.Calculation = calculation; + + // Assert + Assert.AreSame(calculation, view.Calculation); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingInputViewInfoTest.cs =================================================================== diff -u -r985b7690055ffc0570e0608c3de6c2f645cafc3b -re5eb6aafecb6223ded5109bc1f76b4d3b35e21ed --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingInputViewInfoTest.cs (.../PipingInputViewInfoTest.cs) (revision 985b7690055ffc0570e0608c3de6c2f645cafc3b) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ViewInfos/PipingInputViewInfoTest.cs (.../PipingInputViewInfoTest.cs) (revision e5eb6aafecb6223ded5109bc1f76b4d3b35e21ed) @@ -512,5 +512,32 @@ Assert.IsFalse(closeForData); mocks.VerifyAll(); } + + [Test] + public void AfterCreate_Always_SetsSpecificPropertiesToView() + { + // Setup + IAssessmentSection assessmentSection = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingCalculationScenario pipingCalculation = new PipingCalculationScenario(new GeneralPipingInput()); + PipingInputContext context = new PipingInputContext(pipingCalculation.InputParameters, pipingCalculation, + Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + + PipingInputView view = new PipingInputView + { + Data = pipingCalculation.InputParameters + }; + + // Call + info.AfterCreate(view, context); + + // Assert + Assert.AreSame(pipingCalculation, view.Calculation); + mocks.VerifyAll(); + } } } \ No newline at end of file