Index: Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsLocationControlTest.cs =================================================================== diff -u -r2650526158a18c2ac5bf518957e5fa260d882538 -r989b295c5e839ce65caaa61fde353ef330411463 --- Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsLocationControlTest.cs (.../WmtsLocationControlTest.cs) (revision 2650526158a18c2ac5bf518957e5fa260d882538) +++ Core/Components/test/Core.Components.DotSpatial.Forms.Test/Views/WmtsLocationControlTest.cs (.../WmtsLocationControlTest.cs) (revision 989b295c5e839ce65caaa61fde353ef330411463) @@ -328,7 +328,7 @@ using (ShowFullyConfiguredWmtsLocationControl(form)) { // Assert - var dataGridViewControl = (DataGridViewControl)new ControlTester("dataGridViewControl", form).TheObject; + var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", form).TheObject; DataGridViewRowCollection rows = dataGridViewControl.Rows; Assert.AreEqual(2, rows.Count); @@ -408,7 +408,7 @@ using (var form = new Form()) using (WmtsLocationControl control = ShowFullyConfiguredWmtsLocationControl(form)) { - var dataGridViewControl = (DataGridViewControl)new ControlTester("dataGridViewControl", form).TheObject; + var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", form).TheObject; dataGridViewControl.SetCurrentCell(dataGridViewControl.GetCell(1, 0)); // Call @@ -646,7 +646,7 @@ [Test] [Apartment(ApartmentState.STA)] - public void GivenWmtsLocationControlAndAddLocationClicked_WhenConfigFileInUse_ThenWmtsLocationsNotUpdatedAndLoggenerated() + public void GivenWmtsLocationControlAndAddLocationClicked_WhenConfigFileInUse_ThenWmtsLocationsNotUpdatedAndLogGenerated() { // Given const string name = @"someName"; @@ -830,7 +830,7 @@ connectToButton.Click(); // Then - var dataGridViewControl = (DataGridViewControl)new ControlTester("dataGridViewControl", form).TheObject; + var dataGridViewControl = (DataGridViewControl) new ControlTester("dataGridViewControl", form).TheObject; DataGridViewRowCollection rows = dataGridViewControl.Rows; Assert.AreEqual(1, rows.Count); Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.Designer.cs =================================================================== diff -u -rd506ab6eea64d53852f6419f39493e3a326078b0 -r989b295c5e839ce65caaa61fde353ef330411463 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.Designer.cs (.../BackgroundMapDataSelectionDialog.Designer.cs) (revision d506ab6eea64d53852f6419f39493e3a326078b0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.Designer.cs (.../BackgroundMapDataSelectionDialog.Designer.cs) (revision 989b295c5e839ce65caaa61fde353ef330411463) @@ -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 { partial class BackgroundMapDataSelectionDialog @@ -72,9 +74,12 @@ // // mapLayerComboBox // + this.mapLayerComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.mapLayerComboBox.FormattingEnabled = true; resources.ApplyResources(this.mapLayerComboBox, "mapLayerComboBox"); this.mapLayerComboBox.Name = "mapLayerComboBox"; + this.mapLayerComboBox.Sorted = true; + this.mapLayerComboBox.SelectedIndexChanged += new System.EventHandler(this.MapLayerComboBox_OnSelectedIndexChanged); // // flowLayoutPanel1 // @@ -95,6 +100,7 @@ resources.ApplyResources(this.selectButton, "selectButton"); this.selectButton.Name = "selectButton"; this.selectButton.UseVisualStyleBackColor = true; + this.selectButton.Click += new System.EventHandler(this.OnSelectButtonClick); // // propertiesGroupBox // Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs =================================================================== diff -u -r8ed20afbbecb8d353372e6623e7bbf68cdee543c -r989b295c5e839ce65caaa61fde353ef330411463 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs (.../BackgroundMapDataSelectionDialog.cs) (revision 8ed20afbbecb8d353372e6623e7bbf68cdee543c) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs (.../BackgroundMapDataSelectionDialog.cs) (revision 989b295c5e839ce65caaa61fde353ef330411463) @@ -37,7 +37,7 @@ public partial class BackgroundMapDataSelectionDialog : DialogBase { private readonly List mapDatas; - private IBackgroundMapDataSelectionControl currentMapDataControl; + private IBackgroundMapDataSelectionControl currentBackgroundMapDataSelectionControl; /// /// Creates a new instance of . @@ -58,7 +58,6 @@ InitializeComponent(); InitializeButtons(); InitializeComboBox(); - InitializeEventHandlers(); } /// @@ -75,27 +74,20 @@ base.Dispose(disposing); } - private void SetSelectedMapData() + private void UpdatePropertiesGroupBox(IBackgroundMapDataSelectionControl newBackgroundMapDataSelectionControl) { - SelectedMapData = currentMapDataControl?.SelectedMapData; - } - - private void UpdatePropertiesGroupBox() - { - if (currentMapDataControl != null) + if (currentBackgroundMapDataSelectionControl != null) { - var currentHasMapData = propertiesGroupBox.Controls.OfType().FirstOrDefault() as IBackgroundMapDataSelectionControl; - if (currentHasMapData != null) - { - currentHasMapData.SelectedMapDataChanged -= OnSelectedMapDataChanged; - } - - propertiesGroupBox.Controls.Clear(); - Control userControl = currentMapDataControl.UserControl; - propertiesGroupBox.Controls.Add(userControl); - userControl.Dock = DockStyle.Fill; - currentMapDataControl.SelectedMapDataChanged += OnSelectedMapDataChanged; + currentBackgroundMapDataSelectionControl.SelectedMapDataChanged -= OnSelectedMapDataSelectionChanged; } + + propertiesGroupBox.Controls.Clear(); + Control userControl = newBackgroundMapDataSelectionControl.UserControl; + propertiesGroupBox.Controls.Add(userControl); + userControl.Dock = DockStyle.Fill; + newBackgroundMapDataSelectionControl.SelectedMapDataChanged += OnSelectedMapDataSelectionChanged; + + currentBackgroundMapDataSelectionControl = newBackgroundMapDataSelectionControl; } #region Buttons @@ -107,7 +99,7 @@ private void UpdateSelectButton() { - selectButton.Enabled = currentMapDataControl?.SelectedMapData != null; + selectButton.Enabled = currentBackgroundMapDataSelectionControl?.SelectedMapData != null; } protected override Button GetCancelButton() @@ -121,9 +113,6 @@ private void InitializeComboBox() { - mapLayerComboBox.SelectedIndexChanged += MapLayerComboBox_OnSelectedIndexChanged; - mapLayerComboBox.DropDownStyle = ComboBoxStyle.DropDownList; - mapLayerComboBox.Sorted = true; UpdateComboBoxDataSource(); mapLayerComboBox.Enabled = false; @@ -133,25 +122,22 @@ { mapLayerComboBox.DataSource = mapDatas; mapLayerComboBox.DisplayMember = nameof(IBackgroundMapDataSelectionControl.DisplayName); + + currentBackgroundMapDataSelectionControl = mapDatas.FirstOrDefault(); } #endregion #region Event handlers - private void InitializeEventHandlers() - { - selectButton.Click += OnSelectButtonClick; - } - private void OnSelectButtonClick(object sender, EventArgs e) { - SetSelectedMapData(); + SelectedMapData = currentBackgroundMapDataSelectionControl?.SelectedMapData; DialogResult = DialogResult.OK; Close(); } - private void OnSelectedMapDataChanged(object sender, EventArgs e) + private void OnSelectedMapDataSelectionChanged(object sender, EventArgs e) { UpdateSelectButton(); } @@ -164,8 +150,7 @@ return; } - currentMapDataControl = selectedItem; - UpdatePropertiesGroupBox(); + UpdatePropertiesGroupBox(selectedItem); } #endregion