Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CustomFailureMechanismSectionResultRow.cs
===================================================================
diff -u -rea99af5c043eadf5c2ba83b82a847ae009181191 -r2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CustomFailureMechanismSectionResultRow.cs (.../CustomFailureMechanismSectionResultRow.cs) (revision ea99af5c043eadf5c2ba83b82a847ae009181191)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/CustomFailureMechanismSectionResultRow.cs (.../CustomFailureMechanismSectionResultRow.cs) (revision 2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f)
@@ -1,4 +1,25 @@
-using System;
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
using Core.Common.Base.Data;
using Ringtoets.Common.Data.FailureMechanism;
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs
===================================================================
diff -u -r80744f9014a001284116723df29bab8b319c38b7 -r2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision 80744f9014a001284116723df29bab8b319c38b7)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision 2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f)
@@ -59,7 +59,7 @@
///
/// Sets the failure mechanism.
///
- public IFailureMechanism FailureMechanism
+ public virtual IFailureMechanism FailureMechanism
{
set
{
@@ -127,15 +127,14 @@
}
///
- /// Gives the cell at , an
- /// enabled style.
+ /// Restore the initial style of the cell at , .
///
/// The row index of the cell.
/// The column index of the cell.
- protected void EnableCell(int rowIndex, int columnIndex)
+ protected void RestoreCell(int rowIndex, int columnIndex)
{
var cell = dataGridView.Rows[rowIndex].Cells[columnIndex];
- cell.ReadOnly = false;
+ cell.ReadOnly = GetDataGridColumns().ElementAt(columnIndex).ReadOnly;
SetCellStyle(cell, CellStyle.Enabled);
}
@@ -147,11 +146,16 @@
/// The column index of the cell.
protected void DisableCell(int rowIndex, int columnIndex)
{
- var cell = dataGridView.Rows[rowIndex].Cells[columnIndex];
+ var cell = GetCell(rowIndex, columnIndex);
cell.ReadOnly = true;
SetCellStyle(cell, CellStyle.Disabled);
}
+ protected DataGridViewCell GetCell(int rowIndex, int columnIndex)
+ {
+ return dataGridView.Rows[rowIndex].Cells[columnIndex];
+ }
+
///
/// Gets all the columns that should be added to the on the
/// .
@@ -176,6 +180,25 @@
}
///
+ /// Updates the data source of the data grid view with the current known failure mechanism section results.
+ ///
+ protected void UpdataDataGridViewDataSource()
+ {
+ EndEdit();
+ dataGridView.DataSource = failureMechanismSectionResult.Select(CreateFailureMechanismSectionResultRow).ToList();
+ }
+
+ ///
+ /// Gets data that is visualized on the row a the given .
+ ///
+ /// The position of the row in the data source.
+ /// The data bound to the row at index .
+ protected object GetDataAtRow(int rowIndex)
+ {
+ return dataGridView.Rows[rowIndex].DataBoundItem;
+ }
+
+ ///
/// Creates a display object for which is added to the
/// on the .
///
@@ -204,13 +227,6 @@
cell.Style.ForeColor = style.TextColor;
}
- private void UpdataDataGridViewDataSource()
- {
- EndEdit();
-
- dataGridView.DataSource = failureMechanismSectionResult.Select(sr => CreateFailureMechanismSectionResultRow(sr)).ToList();
- }
-
private void RefreshDataGridView()
{
dataGridView.Refresh();
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/SimpleFailureMechanismSectionResultRow.cs
===================================================================
diff -u -rea99af5c043eadf5c2ba83b82a847ae009181191 -r2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/SimpleFailureMechanismSectionResultRow.cs (.../SimpleFailureMechanismSectionResultRow.cs) (revision ea99af5c043eadf5c2ba83b82a847ae009181191)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/SimpleFailureMechanismSectionResultRow.cs (.../SimpleFailureMechanismSectionResultRow.cs) (revision 2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f)
@@ -1,4 +1,25 @@
-using System;
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
using Core.Common.Base.Data;
using Ringtoets.Common.Data.FailureMechanism;
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/CustomFailureMechanismSectionResultTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/CustomFailureMechanismSectionResultTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/CustomFailureMechanismSectionResultTest.cs (revision 2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f)
@@ -0,0 +1,61 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.Common.Data.FailureMechanism;
+
+namespace Ringtoets.Common.Data.Test.FailureMechanism
+{
+ [TestFixture]
+ public class CustomFailureMechanismSectionResultTest
+ {
+ [Test]
+ public void Constructor_WithoutSection_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new CustomFailureMechanismSectionResult(null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("section", paramName);
+ }
+
+ [Test]
+ public void Constructor_WithSection_ResultCreatedForSection()
+ {
+ // Setup
+ var section = new FailureMechanismSection("Section", new[] { new Point2D(0, 0) });
+
+ // Call
+ var result = new CustomFailureMechanismSectionResult(section);
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreSame(section, result.Section);
+ Assert.IsFalse(result.AssessmentLayerOne);
+ Assert.AreEqual(0, result.AssessmentLayerTwoA.Value);
+ Assert.AreEqual(0, result.AssessmentLayerTwoB.Value);
+ Assert.AreEqual(0, result.AssessmentLayerThree.Value);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 64d5609bb2912cd52dc74deffdd189222e240599 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/FailureMechanismSectionResultTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/SimpleFailureMechanismSectionResultTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/SimpleFailureMechanismSectionResultTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/FailureMechanism/SimpleFailureMechanismSectionResultTest.cs (revision 2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f)
@@ -0,0 +1,64 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.Common.Data.FailureMechanism;
+
+namespace Ringtoets.Common.Data.Test.FailureMechanism
+{
+ [TestFixture]
+ public class SimpleFailureMechanismSectionResultTest
+ {
+ [Test]
+ public void Constructor_WithoutSection_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new SimpleFailureMechanismSectionResult(null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("section", paramName);
+ }
+
+ [Test]
+ public void Constructor_WithSection_ResultCreatedForSection()
+ {
+ // Setup
+ var section = new FailureMechanismSection("Section", new[]
+ {
+ new Point2D(0, 0)
+ });
+
+ // Call
+ var result = new SimpleFailureMechanismSectionResult(section);
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreSame(section, result.Section);
+ Assert.IsFalse(result.AssessmentLayerOne);
+ Assert.AreEqual((AssessmentLayerTwoAResult)0, result.AssessmentLayerTwoA);
+ Assert.AreEqual(0, result.AssessmentLayerTwoB.Value);
+ Assert.AreEqual(0, result.AssessmentLayerThree.Value);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj
===================================================================
diff -u -r4936ea40e490dd8a3ed500e1c5a8f8390ff31491 -r2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 4936ea40e490dd8a3ed500e1c5a8f8390ff31491)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f)
@@ -62,9 +62,12 @@
+
+
+
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CustomFailureMechanismSectionResultRowTest.cs
===================================================================
diff -u -rea99af5c043eadf5c2ba83b82a847ae009181191 -r2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CustomFailureMechanismSectionResultRowTest.cs (.../CustomFailureMechanismSectionResultRowTest.cs) (revision ea99af5c043eadf5c2ba83b82a847ae009181191)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/CustomFailureMechanismSectionResultRowTest.cs (.../CustomFailureMechanismSectionResultRowTest.cs) (revision 2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f)
@@ -1,4 +1,25 @@
-using System;
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
using Core.Common.Base;
using Core.Common.Base.Data;
using Core.Common.Base.Geometry;
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/SimpleFailureMechanismSectionResultRowTest.cs
===================================================================
diff -u -rea99af5c043eadf5c2ba83b82a847ae009181191 -r2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/SimpleFailureMechanismSectionResultRowTest.cs (.../SimpleFailureMechanismSectionResultRowTest.cs) (revision ea99af5c043eadf5c2ba83b82a847ae009181191)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/SimpleFailureMechanismSectionResultRowTest.cs (.../SimpleFailureMechanismSectionResultRowTest.cs) (revision 2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f)
@@ -1,4 +1,25 @@
-using System;
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
using Core.Common.Base;
using Core.Common.Base.Data;
using Core.Common.Base.Geometry;
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Properties/AssemblyInfo.cs
===================================================================
diff -u -rd2b3e26fb42063a071bf4fc65b6198ef2369db30 -r2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision d2b3e26fb42063a071bf4fc65b6198ef2369db30)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision 2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f)
@@ -20,7 +20,9 @@
// All rights reserved.
using System.Reflection;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Ringtoets.GrassCoverErosionInwards.Forms")]
[assembly: AssemblyProduct("Ringtoets.GrassCoverErosionInwards.Forms")]
-[assembly: Guid("5f6091d8-2b96-427a-b6cb-8f629bcd2f0f")]
\ No newline at end of file
+[assembly: Guid("5f6091d8-2b96-427a-b6cb-8f629bcd2f0f")]
+[assembly: InternalsVisibleTo("Ringtoets.GrassCoverErosionInwards.Forms.Test")]
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs
===================================================================
diff -u -re24eab2c6007074685556ec97dbe45940a520687 -r2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision e24eab2c6007074685556ec97dbe45940a520687)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision 2fca3f7ae1037eaa9c355b64d7cd0c390143ea8f)
@@ -19,16 +19,14 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
using System.Collections.Generic;
-using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Core.Common.Base;
-using Core.Common.Controls.Views;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Forms.Properties;
+using Ringtoets.Common.Forms.Views;
using Ringtoets.GrassCoverErosionInwards.Data;
using CoreCommonResources = Core.Common.Base.Properties.Resources;
@@ -37,55 +35,32 @@
///
/// The view for the .
///
- public partial class GrassCoverErosionInwardsFailureMechanismResultView : UserControl, IView
+ public partial class GrassCoverErosionInwardsFailureMechanismResultView : FailureMechanismResultView
{
- private const double tolerance = 1e-6;
- private readonly Observer failureMechanismObserver;
- private readonly RecursiveObserver failureMechanismSectionResultObserver;
private readonly RecursiveObserver calculationInputObserver;
private readonly RecursiveObserver calculationOutputObserver;
private readonly RecursiveObserver calculationGroupObserver;
- private IEnumerable failureMechanismSectionResult;
- private GrassCoverErosionInwardsFailureMechanism failureMechanism;
- private DataGridViewTextBoxColumn assessmentLayerTwoA;
- private DataGridViewTextBoxColumn assessmentLayerTwoB;
- private DataGridViewTextBoxColumn assessmentLayerThree;
-
///
/// Creates a new instance of .
///
public GrassCoverErosionInwardsFailureMechanismResultView()
{
- InitializeComponent();
- InitializeDataGridView();
+ AddCellFormattingHandler(DisableIrrelevantFieldsFormatting);
- failureMechanismObserver = new Observer(UpdataDataGridViewDataSource);
- failureMechanismSectionResultObserver = new RecursiveObserver(RefreshDataGridView, mechanism => mechanism.SectionResults);
// The concat is needed to observe the input of calculations in child groups.
calculationInputObserver = new RecursiveObserver(UpdataDataGridViewDataSource, cg => cg.Children.Concat