Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultPerSectionMapView.Designer.cs =================================================================== diff -u -r2794e5d3080e926d032d890062523aa7f33bdb5d -rcaad12e5f1c6609ba855c7fa088b3ba74e24eb11 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultPerSectionMapView.Designer.cs (.../AssemblyResultPerSectionMapView.Designer.cs) (revision 2794e5d3080e926d032d890062523aa7f33bdb5d) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultPerSectionMapView.Designer.cs (.../AssemblyResultPerSectionMapView.Designer.cs) (revision caad12e5f1c6609ba855c7fa088b3ba74e24eb11) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Windows.Forms; + namespace Ringtoets.Integration.Forms.Views { partial class AssemblyResultPerSectionMapView @@ -36,29 +38,92 @@ /// private void InitializeComponent() { + this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); this.ringtoetsMapControl = new Ringtoets.Common.Forms.Views.RingtoetsMapControl(); + this.warningPanel = new System.Windows.Forms.Panel(); + this.warningIcon = new System.Windows.Forms.PictureBox(); + this.warningText = new System.Windows.Forms.Label(); + this.tableLayoutPanel.SuspendLayout(); + this.warningPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.warningIcon)).BeginInit(); this.SuspendLayout(); // - // ringtoetsMapControl1 + // tableLayoutPanel // + this.tableLayoutPanel.ColumnCount = 1; + this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel.Controls.Add(this.ringtoetsMapControl, 0, 1); + this.tableLayoutPanel.Controls.Add(this.warningPanel, 0, 0); + this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel.Name = "tableLayoutPanel"; + this.tableLayoutPanel.RowCount = 2; + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel.Size = new System.Drawing.Size(562, 150); + this.tableLayoutPanel.TabIndex = 0; + // + // ringtoetsMapControl + // this.ringtoetsMapControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.ringtoetsMapControl.Location = new System.Drawing.Point(0, 0); + this.ringtoetsMapControl.Location = new System.Drawing.Point(3, 22); this.ringtoetsMapControl.Name = "ringtoetsMapControl"; - this.ringtoetsMapControl.Size = new System.Drawing.Size(150, 150); + this.ringtoetsMapControl.Size = new System.Drawing.Size(556, 125); this.ringtoetsMapControl.TabIndex = 0; // + // warningPanel + // + this.warningPanel.AutoSize = true; + this.warningPanel.Controls.Add(this.warningIcon); + this.warningPanel.Controls.Add(this.warningText); + this.warningPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.warningPanel.Location = new System.Drawing.Point(3, 3); + this.warningPanel.Name = "warningPanel"; + this.warningPanel.Size = new System.Drawing.Size(556, 13); + this.warningPanel.TabIndex = 1; + // + // warningIcon + // + this.warningIcon.Dock = System.Windows.Forms.DockStyle.Left; + this.warningIcon.Location = new System.Drawing.Point(0, 0); + this.warningIcon.MaximumSize = new System.Drawing.Size(16, 16); + this.warningIcon.Name = "warningIcon"; + this.warningIcon.Size = new System.Drawing.Size(16, 16); + this.warningIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.warningIcon.TabIndex = 1; + this.warningIcon.TabStop = false; + // + // warningText + // + this.warningText.AutoSize = true; + this.warningText.Location = new System.Drawing.Point(22, 0); + this.warningText.Name = "warningText"; + this.warningText.Size = new System.Drawing.Size(500, 13); + this.warningText.TabIndex = 1; + this.warningText.Text = "Toetsoordeel is (deels) gebaseerd op handmatig overschreven toetsoordelen."; + // // AssemblyResultPerSectionMapView // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.ringtoetsMapControl); + this.Controls.Add(this.tableLayoutPanel); this.Name = "AssemblyResultPerSectionMapView"; + this.Size = new System.Drawing.Size(562, 150); + this.tableLayoutPanel.ResumeLayout(false); + this.tableLayoutPanel.PerformLayout(); + this.warningPanel.ResumeLayout(false); + this.warningPanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.warningIcon)).EndInit(); this.ResumeLayout(false); } #endregion + private TableLayoutPanel tableLayoutPanel; private Common.Forms.Views.RingtoetsMapControl ringtoetsMapControl; + private Panel warningPanel; + private Label warningText; + private PictureBox warningIcon; } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultPerSectionMapView.cs =================================================================== diff -u -refb5a7db973f4a0e5b5f0532a594d7fa14159f41 -rcaad12e5f1c6609ba855c7fa088b3ba74e24eb11 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultPerSectionMapView.cs (.../AssemblyResultPerSectionMapView.cs) (revision efb5a7db973f4a0e5b5f0532a594d7fa14159f41) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultPerSectionMapView.cs (.../AssemblyResultPerSectionMapView.cs) (revision caad12e5f1c6609ba855c7fa088b3ba74e24eb11) @@ -28,9 +28,11 @@ using Ringtoets.Common.Forms.Factories; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Integration.Data; +using Ringtoets.Integration.Data.Assembly; using Ringtoets.Integration.Forms.Factories; using Ringtoets.Integration.Forms.Observers; using Ringtoets.Integration.Forms.Properties; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.Integration.Forms.Views { @@ -70,6 +72,7 @@ } InitializeComponent(); + InitializeWarningPanel(); AssessmentSection = assessmentSection; @@ -85,6 +88,7 @@ mapDataCollection.Add(assemblyResultsMapData); SetAllMapDataFeatures(); + SetWarningPanel(); ringtoetsMapControl.SetAllData(mapDataCollection, assessmentSection.BackgroundData); } @@ -133,8 +137,12 @@ Observable = AssessmentSection }; - assessmentSectionObserver = new Observer(UpdateAssemblyResultsMapData) + assessmentSectionObserver = new Observer(() => { + UpdateAssemblyResultsMapData(); + SetWarningPanel(); + }) + { Observable = new AssessmentSectionResultObserver(AssessmentSection) }; @@ -161,6 +169,11 @@ }; } + private void InitializeWarningPanel() + { + warningIcon.Image = RingtoetsCommonFormsResources.PencilWarning.ToBitmap(); + } + private void SetAllMapDataFeatures() { if (AssessmentSection.ReferenceLine == null) @@ -173,6 +186,17 @@ SetAssemblyResultsMapData(); } + private void SetWarningPanel() + { + if (AssessmentSectionHelper.HasManualAssemblyResults(AssessmentSection)) + { + warningPanel.Visible = true; + return; + } + + warningPanel.Visible = false; + } + #region AssemblyResults MapData private void UpdateAssemblyResultsMapData() Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultPerSectionMapViewTest.cs =================================================================== diff -u -refb5a7db973f4a0e5b5f0532a594d7fa14159f41 -rcaad12e5f1c6609ba855c7fa088b3ba74e24eb11 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultPerSectionMapViewTest.cs (.../AssemblyResultPerSectionMapViewTest.cs) (revision efb5a7db973f4a0e5b5f0532a594d7fa14159f41) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultPerSectionMapViewTest.cs (.../AssemblyResultPerSectionMapViewTest.cs) (revision caad12e5f1c6609ba855c7fa088b3ba74e24eb11) @@ -48,6 +48,8 @@ using Ringtoets.Integration.Data.Assembly; using Ringtoets.Integration.Forms.Views; using Ringtoets.Integration.Util; +using Ringtoets.Piping.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.Integration.Forms.Test.Views { @@ -84,9 +86,21 @@ Assert.IsNull(view.Data); Assert.AreEqual(1, view.Controls.Count); - Assert.IsInstanceOf(view.Controls[0]); - Assert.AreSame(view.Map, ((RingtoetsMapControl) view.Controls[0]).MapControl); + Assert.IsInstanceOf(view.Controls[0]); + + var layoutPanel = (TableLayoutPanel) view.Controls[0]; + Assert.AreEqual(1, layoutPanel.ColumnCount); + Assert.AreEqual(2, layoutPanel.RowCount); + Assert.AreEqual(DockStyle.Fill, layoutPanel.Dock); + + var warningPanel = (Panel) layoutPanel.GetControlFromPosition(0, 0); + Assert.AreEqual(DockStyle.Fill, warningPanel.Dock); + Assert.IsFalse(warningPanel.Visible); + + var mapControl = (RingtoetsMapControl) layoutPanel.GetControlFromPosition(0, 1); + Assert.AreSame(view.Map, mapControl.MapControl); Assert.AreEqual(DockStyle.Fill, ((Control) view.Map).Dock); + Assert.AreSame(assessmentSection, view.AssessmentSection); MapDataCollection mapDataCollection = view.Map.Data; @@ -195,7 +209,7 @@ using (var view = new AssemblyResultPerSectionMapView(assessmentSection)) { - IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; + IMapControl map = GetMapControl(view); var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); @@ -230,7 +244,7 @@ using (var view = new AssemblyResultPerSectionMapView(assessmentSection)) { - IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; + IMapControl map = GetMapControl(view); var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); @@ -271,7 +285,7 @@ using (var view = new AssemblyResultPerSectionMapView(assessmentSection)) { - IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl; + IMapControl map = GetMapControl(view); var mocks = new MockRepository(); IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection); @@ -401,6 +415,79 @@ } } + [Test] + [TestCase(true)] + [TestCase(false)] + public void GivenViewWithManualAssemblyResults_WhenShowingView_ThenExpectedWarningSet(bool hasManualAssembly) + { + // Given + AssessmentSection assessmentSection = CreateAssessmentSectionWithReferenceLine(); + PipingFailureMechanism failureMechanism = assessmentSection.Piping; + FailureMechanismTestHelper.AddSections(failureMechanism, 1); + failureMechanism.SectionResults.Single().UseManualAssembly = hasManualAssembly; + + // When + using (var view = new AssemblyResultPerSectionMapView(assessmentSection)) + { + // Then + var layoutPanel = (TableLayoutPanel) view.Controls[0]; + var warningPanel = (Panel) layoutPanel.GetControlFromPosition(0, 0); + Assert.AreEqual(hasManualAssembly, warningPanel.Visible); + AssertWarningPanel(warningPanel); + } + } + + [Test] + public void GivenViewWithoutManualAssemblyResults_WhenAssessmentSectionWithManualAssemblyResultsAndNotifiesObservers_ThenExpectedWarningSet() + { + // Given + AssessmentSection assessmentSection = CreateAssessmentSectionWithReferenceLine(); + + using (var view = new AssemblyResultPerSectionMapView(assessmentSection)) + { + // Precondition + var layoutPanel = (TableLayoutPanel) view.Controls[0]; + var warningPanel = (Panel) layoutPanel.GetControlFromPosition(0, 0); + Assert.IsFalse(warningPanel.Visible); + + // When + PipingFailureMechanism failureMechanism = assessmentSection.Piping; + FailureMechanismTestHelper.AddSections(failureMechanism, 1); + failureMechanism.SectionResults.Single().UseManualAssembly = true; + failureMechanism.NotifyObservers(); + + // Then + Assert.IsTrue(warningPanel.Visible); + AssertWarningPanel(warningPanel); + } + } + + [Test] + public void GivenViewWithManualAssemblyResults_WhenAssessmentSectionWithoutManualAssemblyResultsAndNotifiesObservers_ThenExpectedWarningSet() + { + // Given + AssessmentSection assessmentSection = CreateAssessmentSectionWithReferenceLine(); + PipingFailureMechanism failureMechanism = assessmentSection.Piping; + FailureMechanismTestHelper.AddSections(failureMechanism, 1); + failureMechanism.SectionResults.Single().UseManualAssembly = true; + + using (var view = new AssemblyResultPerSectionMapView(assessmentSection)) + { + // Precondition + var layoutPanel = (TableLayoutPanel) view.Controls[0]; + var warningPanel = (Panel) layoutPanel.GetControlFromPosition(0, 0); + Assert.IsTrue(warningPanel.Visible); + AssertWarningPanel(warningPanel); + + // When + failureMechanism.SectionResults.Single().UseManualAssembly = false; + failureMechanism.NotifyObservers(); + + // Then + Assert.IsFalse(warningPanel.Visible); + } + } + private static AssessmentSection CreateAssessmentSection() { var random = new Random(21); @@ -469,6 +556,28 @@ } } + private static void AssertWarningPanel(Panel warningPanel) + { + Assert.AreEqual(2, warningPanel.Controls.Count); + + var warningIcon = (PictureBox) warningPanel.Controls.Find("warningIcon", false).Single(); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.PencilWarning.ToBitmap(), warningIcon.Image); + Assert.AreEqual(DockStyle.Left, warningIcon.Dock); + Assert.AreEqual(16, warningIcon.MaximumSize.Height); + Assert.AreEqual(16, warningIcon.MaximumSize.Width); + Assert.AreEqual(PictureBoxSizeMode.StretchImage, warningIcon.SizeMode); + + var warningText = (Label) warningPanel.Controls.Find("warningText", false).Single(); + Assert.AreEqual("Toetsoordeel is (deels) gebaseerd op handmatig overschreven toetsoordelen.", warningText.Text); + } + + private static IMapControl GetMapControl(AssemblyResultPerSectionMapView view) + { + var layoutPanel = (TableLayoutPanel) view.Controls[0]; + var ringtoetsMapControl = (RingtoetsMapControl) layoutPanel.GetControlFromPosition(0, 1); + return ringtoetsMapControl.MapControl; + } + private static void AssertEqualPointCollections(ReferenceLine referenceLine, CombinedFailureMechanismSectionAssemblyResult sectionAssemblyResult, MapGeometry geometry)