Index: Core/Components/src/Core.Components.Gis.Forms/Core.Components.Gis.Forms.csproj =================================================================== diff -u -r08432b412fb47916669a52095d9e20afb24994c6 -r812f8fe99bacce6995493070b3d5cc41a2273019 --- Core/Components/src/Core.Components.Gis.Forms/Core.Components.Gis.Forms.csproj (.../Core.Components.Gis.Forms.csproj) (revision 08432b412fb47916669a52095d9e20afb24994c6) +++ Core/Components/src/Core.Components.Gis.Forms/Core.Components.Gis.Forms.csproj (.../Core.Components.Gis.Forms.csproj) (revision 812f8fe99bacce6995493070b3d5cc41a2273019) @@ -54,7 +54,9 @@ True Resources.resx - + + UserControl + UserControl Index: Core/Components/src/Core.Components.Gis.Forms/Views/BackgroundMapDataSelectionControl.cs =================================================================== diff -u --- Core/Components/src/Core.Components.Gis.Forms/Views/BackgroundMapDataSelectionControl.cs (revision 0) +++ Core/Components/src/Core.Components.Gis.Forms/Views/BackgroundMapDataSelectionControl.cs (revision 812f8fe99bacce6995493070b3d5cc41a2273019) @@ -0,0 +1,57 @@ +// 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 Lesser 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser 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 System.Windows.Forms; +using Core.Components.Gis.Data; + +namespace Core.Components.Gis.Forms.Views +{ + /// + /// Abstract base class for a user control used for selecting background map data. + /// + public abstract class BackgroundMapDataSelectionControl : UserControl + { + /// + /// Fired when the has been changed. + /// + public abstract event EventHandler SelectedMapDataChanged; + + /// + /// Creates a new instance of . + /// + /// The display name of the user control. + protected BackgroundMapDataSelectionControl(string displayName) + { + DisplayName = displayName; + } + + /// + /// Gets the display name of the user control. + /// + public string DisplayName { get; } + + /// + /// Gets the selected or null if none selected. + /// + public abstract ImageBasedMapData SelectedMapData { get; } + } +} \ No newline at end of file Fisheye: Tag 812f8fe99bacce6995493070b3d5cc41a2273019 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.Gis.Forms/Views/IBackgroundMapDataSelectionControl.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Components/src/Core.Components.Gis.Forms/Views/WellKnownMapDataControl.cs =================================================================== diff -u -r0e50500bb017c821970b286992f14b03dca0e69d -r812f8fe99bacce6995493070b3d5cc41a2273019 --- Core/Components/src/Core.Components.Gis.Forms/Views/WellKnownMapDataControl.cs (.../WellKnownMapDataControl.cs) (revision 0e50500bb017c821970b286992f14b03dca0e69d) +++ Core/Components/src/Core.Components.Gis.Forms/Views/WellKnownMapDataControl.cs (.../WellKnownMapDataControl.cs) (revision 812f8fe99bacce6995493070b3d5cc41a2273019) @@ -30,16 +30,17 @@ /// /// This class represents a where a well known map data layer can be selected. /// - public partial class WellKnownMapDataControl : UserControl, IBackgroundMapDataSelectionControl + public partial class WellKnownMapDataControl : BackgroundMapDataSelectionControl { - public event EventHandler SelectedMapDataChanged; + public override event EventHandler SelectedMapDataChanged; /// /// Creates a new instance of . /// /// The active /// or null if none active. public WellKnownMapDataControl(WellKnownTileSourceMapData activeWellKnownTileSourceMapData) + : base(Resources.WellKnownMapDataControl_DisplayName) { InitializeComponent(); InitializeDataGridView(); @@ -48,24 +49,14 @@ PreSelectDataGridView(activeWellKnownTileSourceMapData); } - public string DisplayName + public override ImageBasedMapData SelectedMapData { get { - return Resources.WellKnownMapDataControl_DisplayName; - } - } - - public ImageBasedMapData SelectedMapData - { - get - { return dataGridViewControl.CurrentRow?.DataBoundItem as WellKnownTileSourceMapData; } } - public UserControl UserControl => this; - private void PreSelectDataGridView(WellKnownTileSourceMapData activeWellKnownTileSourceMapData) { if (activeWellKnownTileSourceMapData == null) Index: Core/Components/src/Core.Components.Gis.Forms/Views/WmtsLocationControl.cs =================================================================== diff -u -r773c8bead12417f353dc62c006f93fee5a68d06e -r812f8fe99bacce6995493070b3d5cc41a2273019 --- Core/Components/src/Core.Components.Gis.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision 773c8bead12417f353dc62c006f93fee5a68d06e) +++ Core/Components/src/Core.Components.Gis.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision 812f8fe99bacce6995493070b3d5cc41a2273019) @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Windows.Forms; @@ -41,7 +40,7 @@ /// /// This class represents a where a WMTS layer can be selected. /// - public partial class WmtsLocationControl : UserControl, IBackgroundMapDataSelectionControl + public partial class WmtsLocationControl : BackgroundMapDataSelectionControl { private const string wmtsConnectionInfoFileName = "wmtsConnectionInfo.config"; private static readonly ILog log = LogManager.GetLogger(typeof(WmtsLocationControl)); @@ -60,6 +59,7 @@ /// The to use. /// Thrown when is null. public WmtsLocationControl(WmtsMapData activeWmtsMapData, IWmtsCapabilityFactory wmtsCapabilityFactory) + : base(Resources.WmtsLocationControl_DisplayName) { if (wmtsCapabilityFactory == null) { @@ -88,18 +88,10 @@ UpdateButtons(); } - public string DisplayName + public override ImageBasedMapData SelectedMapData { get { - return Resources.WmtsLocationControl_DisplayName; - } - } - - public ImageBasedMapData SelectedMapData - { - get - { WmtsCapability currentRow = GetSelectedWmtsCapability(); if (currentRow == null) { @@ -116,14 +108,6 @@ } } - public UserControl UserControl - { - get - { - return this; - } - } - protected override void Dispose(bool disposing) { if (disposing) @@ -401,7 +385,7 @@ UpdateComboBoxDataSource(createdWmtsConnectionInfos); } - public event EventHandler SelectedMapDataChanged; + public override event EventHandler SelectedMapDataChanged; #endregion } Index: Core/Components/test/Core.Components.Gis.Forms.Test/Core.Components.Gis.Forms.Test.csproj =================================================================== diff -u -r08432b412fb47916669a52095d9e20afb24994c6 -r812f8fe99bacce6995493070b3d5cc41a2273019 --- Core/Components/test/Core.Components.Gis.Forms.Test/Core.Components.Gis.Forms.Test.csproj (.../Core.Components.Gis.Forms.Test.csproj) (revision 08432b412fb47916669a52095d9e20afb24994c6) +++ Core/Components/test/Core.Components.Gis.Forms.Test/Core.Components.Gis.Forms.Test.csproj (.../Core.Components.Gis.Forms.Test.csproj) (revision 812f8fe99bacce6995493070b3d5cc41a2273019) @@ -61,6 +61,7 @@ Properties\GlobalAssembly.cs + Index: Core/Components/test/Core.Components.Gis.Forms.Test/Views/BackgroundMapDataSelectionControlTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.Gis.Forms.Test/Views/BackgroundMapDataSelectionControlTest.cs (revision 0) +++ Core/Components/test/Core.Components.Gis.Forms.Test/Views/BackgroundMapDataSelectionControlTest.cs (revision 812f8fe99bacce6995493070b3d5cc41a2273019) @@ -0,0 +1,54 @@ +// 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 Lesser 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser 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 System.Windows.Forms; +using Core.Components.Gis.Data; +using Core.Components.Gis.Forms.Views; +using NUnit.Framework; + +namespace Core.Components.Gis.Forms.Test.Views +{ + [TestFixture] + public class BackgroundMapDataSelectionControlTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var backgroundMapDataSelectionControl = new TestBackgroundMapDataSelectionControl("Random display name"); + + // Assert + Assert.IsInstanceOf(backgroundMapDataSelectionControl); + Assert.AreEqual("Random display name", backgroundMapDataSelectionControl.DisplayName); + } + + private class TestBackgroundMapDataSelectionControl : BackgroundMapDataSelectionControl + { + public override event EventHandler SelectedMapDataChanged; + + public TestBackgroundMapDataSelectionControl(string displayName) + : base(displayName) {} + + public override ImageBasedMapData SelectedMapData { get; } + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.Gis.Forms.Test/Views/WellKnownMapDataControlTest.cs =================================================================== diff -u -r08432b412fb47916669a52095d9e20afb24994c6 -r812f8fe99bacce6995493070b3d5cc41a2273019 --- Core/Components/test/Core.Components.Gis.Forms.Test/Views/WellKnownMapDataControlTest.cs (.../WellKnownMapDataControlTest.cs) (revision 08432b412fb47916669a52095d9e20afb24994c6) +++ Core/Components/test/Core.Components.Gis.Forms.Test/Views/WellKnownMapDataControlTest.cs (.../WellKnownMapDataControlTest.cs) (revision 812f8fe99bacce6995493070b3d5cc41a2273019) @@ -42,10 +42,9 @@ { // Assert Assert.IsInstanceOf(control); - Assert.IsInstanceOf(control); + Assert.IsInstanceOf(control); Assert.AreEqual("Bekende kaartlagen", control.DisplayName); Assert.IsNull(control.SelectedMapData); - Assert.AreSame(control, control.UserControl); } } Index: Core/Components/test/Core.Components.Gis.Forms.Test/Views/WmtsLocationControlTest.cs =================================================================== diff -u -r2db5ccc1fb164fc6f43733359a0e745ec6891edd -r812f8fe99bacce6995493070b3d5cc41a2273019 --- Core/Components/test/Core.Components.Gis.Forms.Test/Views/WmtsLocationControlTest.cs (.../WmtsLocationControlTest.cs) (revision 2db5ccc1fb164fc6f43733359a0e745ec6891edd) +++ Core/Components/test/Core.Components.Gis.Forms.Test/Views/WmtsLocationControlTest.cs (.../WmtsLocationControlTest.cs) (revision 812f8fe99bacce6995493070b3d5cc41a2273019) @@ -100,10 +100,9 @@ { // Assert Assert.IsInstanceOf(control); - Assert.IsInstanceOf(control); + Assert.IsInstanceOf(control); Assert.AreEqual("Web Map Tile Service (WMTS)", control.DisplayName); Assert.IsNull(control.SelectedMapData); - Assert.AreSame(control, control.UserControl); } } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs =================================================================== diff -u -r0631da0684dd736f5ca061237ea606314f272366 -r812f8fe99bacce6995493070b3d5cc41a2273019 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs (.../BackgroundMapDataSelectionDialog.cs) (revision 0631da0684dd736f5ca061237ea606314f272366) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs (.../BackgroundMapDataSelectionDialog.cs) (revision 812f8fe99bacce6995493070b3d5cc41a2273019) @@ -37,8 +37,8 @@ /// public partial class BackgroundMapDataSelectionDialog : DialogBase { - private readonly HashSet mapDatas; - private IBackgroundMapDataSelectionControl currentBackgroundMapDataSelectionControl; + private readonly HashSet mapDatas; + private BackgroundMapDataSelectionControl currentBackgroundMapDataSelectionControl; private bool mapLayerComboBoxUpdating; /// @@ -50,17 +50,16 @@ public BackgroundMapDataSelectionDialog(IWin32Window dialogParent, ImageBasedMapData mapData) : base(dialogParent, RingtoetsCommonFormsResources.SelectionDialogIcon, 500, 350) { - mapDatas = new HashSet + mapDatas = new HashSet { new WellKnownMapDataControl(mapData as WellKnownTileSourceMapData), new WmtsLocationControl(mapData as WmtsMapData, new BruTileWmtsCapabilityFactory()) }; InitializeComponent(); InitializeButtons(); - InitializeComboBox(); - IBackgroundMapDataSelectionControl controlToSelect = GetBackgroundMapDataControlToSelect(mapData); + BackgroundMapDataSelectionControl controlToSelect = GetBackgroundMapDataControlToSelect(mapData); PreSelectComboBox(controlToSelect); } @@ -78,7 +77,7 @@ base.Dispose(disposing); } - private IBackgroundMapDataSelectionControl GetBackgroundMapDataControlToSelect(ImageBasedMapData mapData) + private BackgroundMapDataSelectionControl GetBackgroundMapDataControlToSelect(ImageBasedMapData mapData) { if (mapData is WellKnownTileSourceMapData) { @@ -91,17 +90,16 @@ return mapDatas.First(); } - private void UpdatePropertiesGroupBox(IBackgroundMapDataSelectionControl newBackgroundMapDataSelectionControl) + private void UpdatePropertiesGroupBox(BackgroundMapDataSelectionControl newBackgroundMapDataSelectionControl) { if (currentBackgroundMapDataSelectionControl != null) { currentBackgroundMapDataSelectionControl.SelectedMapDataChanged -= OnSelectedMapDataSelectionChanged; } propertiesGroupBox.Controls.Clear(); - Control userControl = newBackgroundMapDataSelectionControl.UserControl; - propertiesGroupBox.Controls.Add(userControl); - userControl.Dock = DockStyle.Fill; + propertiesGroupBox.Controls.Add(newBackgroundMapDataSelectionControl); + newBackgroundMapDataSelectionControl.Dock = DockStyle.Fill; newBackgroundMapDataSelectionControl.SelectedMapDataChanged += OnSelectedMapDataSelectionChanged; currentBackgroundMapDataSelectionControl = newBackgroundMapDataSelectionControl; @@ -129,18 +127,13 @@ #region ComboBox - private void InitializeComboBox() + private void PreSelectComboBox(BackgroundMapDataSelectionControl controlToSelect) { - mapLayerComboBox.ValueMember = nameof(IBackgroundMapDataSelectionControl.UserControl); - } - - private void PreSelectComboBox(IBackgroundMapDataSelectionControl controlToSelect) - { mapLayerComboBox.BeginUpdate(); mapLayerComboBoxUpdating = true; mapLayerComboBox.DataSource = mapDatas.ToArray(); - mapLayerComboBox.DisplayMember = nameof(IBackgroundMapDataSelectionControl.DisplayName); + mapLayerComboBox.DisplayMember = nameof(BackgroundMapDataSelectionControl.DisplayName); mapLayerComboBox.SelectedItem = null; mapLayerComboBoxUpdating = false; @@ -173,7 +166,7 @@ return; } - UpdatePropertiesGroupBox((IBackgroundMapDataSelectionControl) mapLayerComboBox.SelectedItem); + UpdatePropertiesGroupBox((BackgroundMapDataSelectionControl) mapLayerComboBox.SelectedItem); } #endregion Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/BackgroundMapDataSelectionDialogTest.cs =================================================================== diff -u -r2db5ccc1fb164fc6f43733359a0e745ec6891edd -r812f8fe99bacce6995493070b3d5cc41a2273019 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/BackgroundMapDataSelectionDialogTest.cs (.../BackgroundMapDataSelectionDialogTest.cs) (revision 2db5ccc1fb164fc6f43733359a0e745ec6891edd) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/BackgroundMapDataSelectionDialogTest.cs (.../BackgroundMapDataSelectionDialogTest.cs) (revision 812f8fe99bacce6995493070b3d5cc41a2273019) @@ -432,21 +432,20 @@ } private static void AssertMapDataControls(BackgroundMapDataSelectionDialog dialog) - where T : UserControl, IBackgroundMapDataSelectionControl + where T : BackgroundMapDataSelectionControl { var mapLayers = (ComboBox) new ComboBoxTester("mapLayerComboBox", dialog).TheObject; Assert.AreEqual("DisplayName", mapLayers.DisplayMember); - Assert.AreEqual("UserControl", mapLayers.ValueMember); Assert.AreEqual(ComboBoxStyle.DropDownList, mapLayers.DropDownStyle); Assert.IsTrue(mapLayers.Sorted); Assert.IsInstanceOf(mapLayers.SelectedItem); - var backgroundMapDataSelectionControls = (IBackgroundMapDataSelectionControl[]) mapLayers.DataSource; + var backgroundMapDataSelectionControls = (BackgroundMapDataSelectionControl[]) mapLayers.DataSource; Assert.AreEqual(2, backgroundMapDataSelectionControls.Length); Assert.IsInstanceOf(backgroundMapDataSelectionControls[0]); Assert.IsInstanceOf(backgroundMapDataSelectionControls[1]); - Assert.IsInstanceOf(mapLayers.DataSource); + Assert.IsInstanceOf(mapLayers.DataSource); Assert.AreEqual("DisplayName", mapLayers.DisplayMember); var groupBoxProperties = (GroupBox) new ControlTester("propertiesGroupBox", dialog).TheObject; @@ -457,7 +456,7 @@ private static T GetComboBoxItem(ComboBox comboBox) { - return ((IBackgroundMapDataSelectionControl[]) comboBox.DataSource).OfType().First(); + return ((BackgroundMapDataSelectionControl[]) comboBox.DataSource).OfType().First(); } private static Icon BitmapToIcon(Bitmap icon) Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/BackgroundDataTreeNodeInfoTest.cs =================================================================== diff -u -r35fa216f8255ce431cd920b991297fa80592b64a -r812f8fe99bacce6995493070b3d5cc41a2273019 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/BackgroundDataTreeNodeInfoTest.cs (.../BackgroundDataTreeNodeInfoTest.cs) (revision 35fa216f8255ce431cd920b991297fa80592b64a) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/BackgroundDataTreeNodeInfoTest.cs (.../BackgroundDataTreeNodeInfoTest.cs) (revision 812f8fe99bacce6995493070b3d5cc41a2273019) @@ -492,7 +492,7 @@ var dialog = (BackgroundMapDataSelectionDialog) new FormTester(name).TheObject; var comboBox = (ComboBox) new ComboBoxTester("mapLayerComboBox", dialog).TheObject; - comboBox.SelectedItem = ((IBackgroundMapDataSelectionControl[]) comboBox.DataSource).OfType().First(); + comboBox.SelectedItem = ((BackgroundMapDataSelectionControl[]) comboBox.DataSource).OfType().First(); var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", dialog).TheObject; dataGridViewControl.SetCurrentCell(dataGridViewControl.GetCell(0, 0));