Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Controls/FailureMechanismAssemblyResultControl.cs =================================================================== diff -u -re066f6fce8df4604082ede0fcd13921a8d66c560 -r718d74086633d91a350d60a463715d3bd360468b --- Ringtoets/Common/src/Ringtoets.Common.Forms/Controls/FailureMechanismAssemblyResultControl.cs (.../FailureMechanismAssemblyResultControl.cs) (revision e066f6fce8df4604082ede0fcd13921a8d66c560) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Controls/FailureMechanismAssemblyResultControl.cs (.../FailureMechanismAssemblyResultControl.cs) (revision 718d74086633d91a350d60a463715d3bd360468b) @@ -21,6 +21,9 @@ using System; using System.Windows.Forms; +using Core.Common.Util; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.Common.Forms.Helpers; namespace Ringtoets.Common.Forms.Controls { @@ -37,11 +40,20 @@ InitializeComponent(); } + /// + /// Clears the error message of the control. + /// public void ClearError() { ErrorProvider.SetError(this, string.Empty); } + /// + /// Sets the error message of the control. + /// + /// The error message to set. + /// Thrown when + /// is null. public void SetError(string error) { if (error == null) @@ -51,5 +63,21 @@ ErrorProvider.SetError(this, error); } + + /// + /// Set the values of the to the control. + /// + /// The to set on the control. + /// Thrown when is null. + public virtual void SetAssemblyResult(FailureMechanismAssembly assembly) + { + if (assembly == null) + { + throw new ArgumentNullException(nameof(assembly)); + } + + GroupLabel.Text = new EnumDisplayWrapper(assembly.Group).DisplayName; + GroupLabel.BackColor = AssemblyCategoryGroupColorHelper.GetFailureMechanismAssemblyCategoryGroupColor(assembly.Group); + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Controls/FailureMechanismAssemblyResultWithProbabilityControl.Designer.cs =================================================================== diff -u -r9c341ce32f55de21dcc7ab33717e1750c437fb0e -r718d74086633d91a350d60a463715d3bd360468b --- Ringtoets/Common/src/Ringtoets.Common.Forms/Controls/FailureMechanismAssemblyResultWithProbabilityControl.Designer.cs (.../FailureMechanismAssemblyResultWithProbabilityControl.Designer.cs) (revision 9c341ce32f55de21dcc7ab33717e1750c437fb0e) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Controls/FailureMechanismAssemblyResultWithProbabilityControl.Designer.cs (.../FailureMechanismAssemblyResultWithProbabilityControl.Designer.cs) (revision 718d74086633d91a350d60a463715d3bd360468b) @@ -50,39 +50,38 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FailureMechanismAssemblyResultWithProbabilityControl)); - this.ProbabilityLabel = new Ringtoets.Common.Forms.Controls.BoxedLabel(); - this.ProbabilityPanel = new System.Windows.Forms.TableLayoutPanel(); - this.ProbabilityPanel.SuspendLayout(); + this.probabilityLabel = new Ringtoets.Common.Forms.Controls.BoxedLabel(); + this.probabilityPanel = new System.Windows.Forms.TableLayoutPanel(); + this.probabilityPanel.SuspendLayout(); this.SuspendLayout(); // // ProbabilityLabel // - resources.ApplyResources(this.ProbabilityLabel, "ProbabilityLabel"); - this.ProbabilityLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.ProbabilityLabel.Name = "ProbabilityLabel"; + resources.ApplyResources(this.probabilityLabel, "probabilityLabel"); + this.probabilityLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.probabilityLabel.Name = "probabilityLabel"; // - // ProbabilityPanel + // probabilityPanel // - resources.ApplyResources(this.ProbabilityPanel, "ProbabilityPanel"); - this.ProbabilityPanel.Controls.Add(this.ProbabilityLabel, 0, 0); - this.ProbabilityPanel.Name = "ProbabilityPanel"; + resources.ApplyResources(this.probabilityPanel, "probabilityPanel"); + this.probabilityPanel.Controls.Add(this.probabilityLabel, 0, 0); + this.probabilityPanel.Name = "probabilityPanel"; // // FailureMechanismAssemblyResultWithProbabilityControl // resources.ApplyResources(this, "$this"); - this.Controls.Add(this.ProbabilityPanel); + this.Controls.Add(this.probabilityPanel); this.Name = "FailureMechanismAssemblyResultWithProbabilityControl"; - this.Controls.SetChildIndex(this.ProbabilityPanel, 0); - this.ProbabilityPanel.ResumeLayout(false); - this.ProbabilityPanel.PerformLayout(); + this.Controls.SetChildIndex(this.probabilityPanel, 0); + this.probabilityPanel.ResumeLayout(false); + this.probabilityPanel.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion - - public BoxedLabel ProbabilityLabel; - public System.Windows.Forms.TableLayoutPanel ProbabilityPanel; + private BoxedLabel probabilityLabel; + private System.Windows.Forms.TableLayoutPanel probabilityPanel; } } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Controls/FailureMechanismAssemblyResultWithProbabilityControl.cs =================================================================== diff -u -r9c341ce32f55de21dcc7ab33717e1750c437fb0e -r718d74086633d91a350d60a463715d3bd360468b --- Ringtoets/Common/src/Ringtoets.Common.Forms/Controls/FailureMechanismAssemblyResultWithProbabilityControl.cs (.../FailureMechanismAssemblyResultWithProbabilityControl.cs) (revision 9c341ce32f55de21dcc7ab33717e1750c437fb0e) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Controls/FailureMechanismAssemblyResultWithProbabilityControl.cs (.../FailureMechanismAssemblyResultWithProbabilityControl.cs) (revision 718d74086633d91a350d60a463715d3bd360468b) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using Ringtoets.AssemblyTool.Data; +using Ringtoets.Common.Forms.TypeConverters; namespace Ringtoets.Common.Forms.Controls { @@ -34,5 +36,12 @@ { InitializeComponent(); } + + public override void SetAssemblyResult(FailureMechanismAssembly assembly) + { + base.SetAssemblyResult(assembly); + + probabilityLabel.Text = new NoProbabilityValueDoubleConverter().ConvertToString(assembly.Probability); + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Controls/FailureMechanismAssemblyResultWithProbabilityControl.resx =================================================================== diff -u -r9c341ce32f55de21dcc7ab33717e1750c437fb0e -r718d74086633d91a350d60a463715d3bd360468b --- Ringtoets/Common/src/Ringtoets.Common.Forms/Controls/FailureMechanismAssemblyResultWithProbabilityControl.resx (.../FailureMechanismAssemblyResultWithProbabilityControl.resx) (revision 9c341ce32f55de21dcc7ab33717e1750c437fb0e) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Controls/FailureMechanismAssemblyResultWithProbabilityControl.resx (.../FailureMechanismAssemblyResultWithProbabilityControl.resx) (revision 718d74086633d91a350d60a463715d3bd360468b) @@ -118,81 +118,81 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + True - + Fill - + 3, 3 - + 3, 3, 3, 3 - + 50, 2 - + 5, 0, 5, 0 - + 50, 144 - + 0 - + MiddleLeft - - ProbabilityLabel + + probabilityLabel - + Ringtoets.Common.Forms.Controls.BoxedLabel, Ringtoets.Common.Forms, Version=18.1.1.1, Culture=neutral, PublicKeyToken=null - - ProbabilityPanel + + probabilityPanel - + 0 - + True - + 1 - + Left - + 259, 0 - + 1 - + 56, 150 - + 1 - - ProbabilityPanel + + probabilityPanel - + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - + 0 - + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="ProbabilityLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0" /><Rows Styles="Percent,100" /></TableLayoutSettings> Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyResultControlTest.cs =================================================================== diff -u -re066f6fce8df4604082ede0fcd13921a8d66c560 -r718d74086633d91a350d60a463715d3bd360468b --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyResultControlTest.cs (.../FailureMechanismAssemblyResultControlTest.cs) (revision e066f6fce8df4604082ede0fcd13921a8d66c560) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyResultControlTest.cs (.../FailureMechanismAssemblyResultControlTest.cs) (revision 718d74086633d91a350d60a463715d3bd360468b) @@ -23,9 +23,12 @@ using System.Drawing; using System.Windows.Forms; using Core.Common.TestUtil; +using Core.Common.Util; using Core.Common.Util.Reflection; using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Forms.Controls; +using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.Properties; namespace Ringtoets.Common.Forms.Test.Controls @@ -44,7 +47,7 @@ Assert.IsInstanceOf(resultControl); Assert.IsTrue(resultControl.AutoSize); - var groupPanel = TypeUtils.GetField(resultControl, "GroupPanel"); + TableLayoutPanel groupPanel = GetGroupPanel(resultControl); Assert.AreEqual(2, groupPanel.ColumnCount); Assert.AreEqual(1, groupPanel.RowCount); @@ -64,6 +67,41 @@ } [Test] + public void SetAssemblyResult_AssemblyNull_ThrowsArgumentNullException() + { + // Setup + var resultControl = new FailureMechanismAssemblyResultWithProbabilityControl(); + + // Call + TestDelegate test = () => resultControl.SetAssemblyResult(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("assembly", exception.ParamName); + } + + [Test] + public void SetAssemblyResult_WithAssembly_SetsValuesOnControl() + { + // Setup + var random = new Random(39); + var assembly = new FailureMechanismAssembly(random.NextDouble(), + random.NextEnumValue()); + var resultControl = new FailureMechanismAssemblyResultControl(); + + // Call + resultControl.SetAssemblyResult(assembly); + + // Assert + Control groupLabel = GetGroupPanel(resultControl).GetControlFromPosition(1, 0); + + Assert.AreEqual(new EnumDisplayWrapper(assembly.Group).DisplayName, + groupLabel.Text); + Assert.AreEqual(AssemblyCategoryGroupColorHelper.GetFailureMechanismAssemblyCategoryGroupColor(assembly.Group), + groupLabel.BackColor); + } + + [Test] public void SetError_ErrorNull_ThrowsArgumentNullException() { // Setup @@ -110,5 +148,10 @@ { return TypeUtils.GetField(resultControl, "ErrorProvider"); } + + private static TableLayoutPanel GetGroupPanel(FailureMechanismAssemblyResultControl resultControl) + { + return TypeUtils.GetField(resultControl, "GroupPanel"); + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyResultWithProbabilityControlTest.cs =================================================================== diff -u -r9c341ce32f55de21dcc7ab33717e1750c437fb0e -r718d74086633d91a350d60a463715d3bd360468b --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyResultWithProbabilityControlTest.cs (.../FailureMechanismAssemblyResultWithProbabilityControlTest.cs) (revision 9c341ce32f55de21dcc7ab33717e1750c437fb0e) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Controls/FailureMechanismAssemblyResultWithProbabilityControlTest.cs (.../FailureMechanismAssemblyResultWithProbabilityControlTest.cs) (revision 718d74086633d91a350d60a463715d3bd360468b) @@ -19,11 +19,18 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Drawing; using System.Windows.Forms; +using Core.Common.TestUtil; +using Core.Common.Util; using Core.Common.Util.Reflection; using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Forms.Controls; +using Ringtoets.Common.Forms.Helpers; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Common.Forms.TypeConverters; namespace Ringtoets.Common.Forms.Test.Controls { @@ -37,23 +44,85 @@ var resultControl = new FailureMechanismAssemblyResultWithProbabilityControl(); // Assert + Assert.AreEqual(2, resultControl.Controls.Count); Assert.IsInstanceOf(resultControl); Assert.IsTrue(resultControl.AutoSize); - Assert.IsInstanceOf(resultControl.GroupLabel); - Assert.IsTrue(resultControl.GroupLabel.AutoSize); - Assert.AreEqual(DockStyle.Fill, resultControl.GroupLabel.Dock); - Assert.AreEqual(new Padding(5, 0, 5, 0), resultControl.GroupLabel.Padding); - Assert.IsInstanceOf(resultControl.ProbabilityLabel); - Assert.IsTrue(resultControl.ProbabilityLabel.AutoSize); - Assert.AreEqual(DockStyle.Fill, resultControl.ProbabilityLabel.Dock); - Assert.AreEqual(new Padding(5, 0, 5, 0), resultControl.ProbabilityLabel.Padding); + TableLayoutPanel groupPanel = GetGroupPanel(resultControl); + Assert.AreEqual(2, groupPanel.ColumnCount); + Assert.AreEqual(1, groupPanel.RowCount); - var description = TypeUtils.GetField