Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs =================================================================== diff -u -r3da240045144c791411261f41434d6532f1801eb -rdf04570fbd1050020c8d7aad47655d56d46a6ff7 --- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 3da240045144c791411261f41434d6532f1801eb) +++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision df04570fbd1050020c8d7aad47655d56d46a6ff7) @@ -109,13 +109,13 @@ using Riskeer.WaveImpactAsphaltCover.Data; using Riskeer.WaveImpactAsphaltCover.Forms.PresentationObjects; using CoreGuiResources = Core.Gui.Properties.Resources; +using FontFamily = System.Windows.Media.FontFamily; using RiskeerDataResources = Riskeer.Integration.Data.Properties.Resources; using RiskeerFormsResources = Riskeer.Integration.Forms.Properties.Resources; using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources; using RiskeerCommonIOResources = Riskeer.Common.IO.Properties.Resources; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; using RiskeerCommonServiceResources = Riskeer.Common.Service.Properties.Resources; -using FontFamily = System.Windows.Media.FontFamily; namespace Riskeer.Integration.Plugin { @@ -242,12 +242,13 @@ #endregion - private IHydraulicBoundaryLocationCalculationGuiService hydraulicBoundaryLocationCalculationGuiService; - private AssessmentSectionMerger assessmentSectionMerger; private static readonly FontFamily fontFamily = new FontFamily( new Uri($"{PackUriHelper.UriSchemePack}://application:,,,/Riskeer.Integration.Plugin;component/Resources/"), "./#Symbols"); + private IHydraulicBoundaryLocationCalculationGuiService hydraulicBoundaryLocationCalculationGuiService; + private AssessmentSectionMerger assessmentSectionMerger; + public override IGui Gui { get => base.Gui; @@ -1635,12 +1636,12 @@ private ContextMenuStrip BackgroundDataMenuStrip(BackgroundData nodeData, object parentData, TreeViewControl treeViewControl) { - var assessmentSection = parentData as IAssessmentSection; + var assessmentSectionStateRootContext = (AssessmentSectionStateRootContext) parentData; var mapDataItem = new StrictContextMenuItem( Resources.BackgroundData_SelectMapData, Resources.BackgroundData_SelectMapData_Tooltip, - RiskeerCommonFormsResources.MapsIcon, (sender, args) => SelectMapData(assessmentSection, nodeData)); + RiskeerCommonFormsResources.MapsIcon, (sender, args) => SelectMapData(assessmentSectionStateRootContext.WrappedData, nodeData)); return Gui.Get(nodeData, treeViewControl) .AddCustomItem(mapDataItem) @@ -1651,11 +1652,6 @@ private void SelectMapData(IAssessmentSection assessmentSection, BackgroundData backgroundData) { - if (assessmentSection == null) - { - return; - } - ImageBasedMapData currentData = BackgroundDataConverter.ConvertFrom(backgroundData); using (var dialog = new BackgroundMapDataSelectionDialog(Gui.MainWindow, currentData)) { Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/BackgroundDataTreeNodeInfoTest.cs =================================================================== diff -u -r48244f68eee25ef1d91701d82e4c4867f0252ffc -rdf04570fbd1050020c8d7aad47655d56d46a6ff7 --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/BackgroundDataTreeNodeInfoTest.cs (.../BackgroundDataTreeNodeInfoTest.cs) (revision 48244f68eee25ef1d91701d82e4c4867f0252ffc) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/BackgroundDataTreeNodeInfoTest.cs (.../BackgroundDataTreeNodeInfoTest.cs) (revision df04570fbd1050020c8d7aad47655d56d46a6ff7) @@ -44,7 +44,9 @@ using Riskeer.Common.Data.AssessmentSection; using Riskeer.Common.Data.TestUtil; using Riskeer.Common.Util.TypeConverters; +using Riskeer.Integration.Data; using Riskeer.Integration.Forms.Dialogs; +using Riskeer.Integration.Forms.PresentationObjects; using Riskeer.Integration.Forms.Properties; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; @@ -241,7 +243,7 @@ var backgroundData = new BackgroundData(new TestBackgroundDataConfiguration()); var mockRepository = new MockRepository(); - var assessmentSection = mockRepository.Stub(); + var assessmentSectionStateRootContext = new AssessmentSectionStateRootContext(new AssessmentSection(AssessmentSectionComposition.Dike)); using (var treeViewControl = new TreeViewControl()) { var gui = mockRepository.Stub(); @@ -256,7 +258,7 @@ plugin.Gui = gui; // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(backgroundData, assessmentSection, treeViewControl)) + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(backgroundData, assessmentSectionStateRootContext, treeViewControl)) { const string expectedItemText = "&Selecteren..."; const string expectedItemTooltip = "Selecteer een achtergrondkaart."; @@ -312,7 +314,8 @@ gui.Stub(cmp => cmp.Get(backgroundData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); mockRepository.ReplayAll(); - var assessmentSection = new AssessmentSectionStub(); + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSectionStateRootContext = new AssessmentSectionStateRootContext(assessmentSection); assessmentSection.BackgroundData.Attach(backgroundDataObserver); DialogBoxHandler = (name, wnd) => @@ -332,7 +335,7 @@ TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; - using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(backgroundData, assessmentSection, treeViewControl)) + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(backgroundData, assessmentSectionStateRootContext, treeViewControl)) { // When contextMenuStrip.Items[selectContextMenuIndex].PerformClick(); @@ -373,7 +376,8 @@ gui.Stub(cmp => cmp.Get(backgroundData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); mockRepository.ReplayAll(); - var assessmentSection = new AssessmentSectionStub(); + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSectionStateRootContext = new AssessmentSectionStateRootContext(assessmentSection); assessmentSection.Attach(assessmentSectionObserver); assessmentSection.BackgroundData.Attach(backgroundDataObserver); @@ -389,7 +393,7 @@ TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; - using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(backgroundData, assessmentSection, treeViewControl)) + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(backgroundData, assessmentSectionStateRootContext, treeViewControl)) { // When contextMenuStrip.Items[selectContextMenuIndex].PerformClick(); @@ -416,7 +420,8 @@ WmtsMapData newMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData(); BackgroundData newBackgroundData = BackgroundDataConverter.ConvertTo(newMapData); - var assessmentSection = new AssessmentSectionStub(); + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSectionStateRootContext = new AssessmentSectionStateRootContext(assessmentSection); using (new UseCustomSettingsHelper(new TestSettingsHelper { @@ -457,7 +462,7 @@ TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; - using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(newBackgroundData, assessmentSection, treeViewControl)) + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(newBackgroundData, assessmentSectionStateRootContext, treeViewControl)) { // When contextMenuStrip.Items[selectContextMenuIndex].PerformClick(); @@ -481,7 +486,8 @@ WmtsMapData mapData = WmtsMapDataTestHelper.CreateUnconnectedMapData(); - var assessmentSection = new AssessmentSectionStub(); + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSectionStateRootContext = new AssessmentSectionStateRootContext(assessmentSection); const WellKnownTileSource wellKnownTileSource = WellKnownTileSource.BingAerial; var newMapData = new WellKnownTileSourceMapData(wellKnownTileSource); @@ -525,7 +531,7 @@ TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; - using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(newBackgroundData, assessmentSection, treeViewControl)) + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(newBackgroundData, assessmentSectionStateRootContext, treeViewControl)) { // When contextMenuStrip.Items[selectContextMenuIndex].PerformClick(); @@ -571,7 +577,8 @@ gui.Stub(cmp => cmp.Get(newBackgroundData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); mockRepository.ReplayAll(); - var assessmentSection = new AssessmentSectionStub(); + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSectionStateRootContext = new AssessmentSectionStateRootContext(assessmentSection); assessmentSection.Attach(assessmentSectionObserver); assessmentSection.BackgroundData.Attach(backgroundDataObserver); @@ -587,7 +594,7 @@ TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; - using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(newBackgroundData, assessmentSection, treeViewControl)) + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(newBackgroundData, assessmentSectionStateRootContext, treeViewControl)) { // When contextMenuStrip.Items[selectContextMenuIndex].PerformClick();