Index: Core/Components/src/Core.Components.DotSpatial.Forms/Views/IHasMapData.cs =================================================================== diff -u -rd506ab6eea64d53852f6419f39493e3a326078b0 -r2a9a0a500bc605a383e700b6d8f4b407abd42486 --- Core/Components/src/Core.Components.DotSpatial.Forms/Views/IHasMapData.cs (.../IHasMapData.cs) (revision d506ab6eea64d53852f6419f39493e3a326078b0) +++ Core/Components/src/Core.Components.DotSpatial.Forms/Views/IHasMapData.cs (.../IHasMapData.cs) (revision 2a9a0a500bc605a383e700b6d8f4b407abd42486) @@ -19,6 +19,7 @@ // 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; @@ -30,6 +31,11 @@ public interface IHasMapData { /// + /// Fired when the has been changed. + /// + event EventHandler SelectedMapDataChanged; + + /// /// Gets the display name of the user control; /// string DisplayName { get; } Index: Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsLocationControl.cs =================================================================== diff -u -r336c86d498d517c66d854fc0e91a6a06f1e582c2 -r2a9a0a500bc605a383e700b6d8f4b407abd42486 --- Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision 336c86d498d517c66d854fc0e91a6a06f1e582c2) +++ Core/Components/src/Core.Components.DotSpatial.Forms/Views/WmtsLocationControl.cs (.../WmtsLocationControl.cs) (revision 2a9a0a500bc605a383e700b6d8f4b407abd42486) @@ -53,6 +53,8 @@ InitializeDataGridView(); InitializeComboBoxDataSource(); InitializeEventHandlers(); + + UpdateConnectToButton(); } public string DisplayName @@ -112,6 +114,11 @@ } } + private void UpdateConnectToButton() + { + connectToButton.Enabled = urlLocationComboBox.SelectedItem != null; + } + #region DataGridView private void InitializeDataGridView() @@ -127,10 +134,12 @@ true); dataGridViewControl.AddTextBoxColumn(nameof(WmtsCapabilityRow.CoordinateSystem), Resources.WmtsCapability_MapLayer_CoordinateSystem, true); - dataGridViewControl.AddCurrentCellChangedHandler(DataGridViewCurrentCellChangedHandler); } - private void DataGridViewCurrentCellChangedHandler(object sender, EventArgs e) {} + private void DataGridViewCurrentCellChangedHandler(object sender, EventArgs e) + { + SelectedMapDataChanged?.Invoke(this, e); + } private void UpdateDataGridViewDataSource(IEnumerable wmtsCapabilities) { @@ -146,6 +155,7 @@ private void UpdateDataGridViewDataSource() { dataGridViewControl.SetDataSource(capabilities.ToArray()); + dataGridViewControl.ClearCurrentCell(); } private WmtsCapabilityRow GetSelectedWmtsCapabilityRow() @@ -200,25 +210,22 @@ private void InitializeEventHandlers() { - UpdateConnectToButton(); - urlLocationComboBox.SelectedIndexChanged += UrlLocation_SelectedIndexChanged; - connectToButton.Click += ConnectToButtonOnClick; - addLocationButton.Click += AddLocationButtonOnClick; - editLocationButton.Click += EditLocationButtonOnClick; + dataGridViewControl.AddCurrentCellChangedHandler(DataGridViewCurrentCellChangedHandler); + + urlLocationComboBox.SelectedIndexChanged += OnUrlLocationSelectedIndexChanged; + + connectToButton.Click += OnConnectToButtonClick; + addLocationButton.Click += OnAddLocationButtonClick; + editLocationButton.Click += OnEditLocationButtonClick; } - private void UrlLocation_SelectedIndexChanged(object sender, EventArgs e) + private void OnUrlLocationSelectedIndexChanged(object sender, EventArgs e) { ClearDataGridViewDataSource(); } - private void UpdateConnectToButton() + private void OnConnectToButtonClick(object sender, EventArgs e) { - connectToButton.Enabled = urlLocationComboBox.SelectedItem != null; - } - - private void ConnectToButtonOnClick(object sender, EventArgs e) - { var selectedWmtsConnectionInfo = urlLocationComboBox.SelectedItem as WmtsConnectionInfo; try @@ -235,7 +242,7 @@ } } - private void AddLocationButtonOnClick(object sender, EventArgs eventArgs) + private void OnAddLocationButtonClick(object sender, EventArgs eventArgs) { Form controlForm = FindForm(); using (var dialog = new WmtsConnectionDialog(controlForm)) @@ -255,7 +262,7 @@ } } - private void EditLocationButtonOnClick(object sender, EventArgs eventArgs) + private void OnEditLocationButtonClick(object sender, EventArgs eventArgs) { var selectedWmtsConnectionInfo = urlLocationComboBox.SelectedItem as WmtsConnectionInfo; if (selectedWmtsConnectionInfo == null) @@ -281,6 +288,8 @@ } } + public event EventHandler SelectedMapDataChanged; + #endregion } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs =================================================================== diff -u -rd506ab6eea64d53852f6419f39493e3a326078b0 -r2a9a0a500bc605a383e700b6d8f4b407abd42486 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs (.../BackgroundMapDataSelectionDialog.cs) (revision d506ab6eea64d53852f6419f39493e3a326078b0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs (.../BackgroundMapDataSelectionDialog.cs) (revision 2a9a0a500bc605a383e700b6d8f4b407abd42486) @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; using Core.Common.Controls.DataGrid; using Core.Common.Controls.Dialogs; @@ -55,7 +56,7 @@ InitializeComponent(); InitializeComboBox(); - selectButton.Enabled = false; + UpdateSelectButton(); } /// @@ -83,17 +84,34 @@ return cancelButton; } + private void UpdateSelectButton() + { + selectButton.Enabled = SelectedMapData != null; + } + private void UpdatePropertiesGroupBox() { if (currentMapDataControl != null) { + var currentHasMapData = propertiesGroupBox.Controls.OfType().FirstOrDefault() as IHasMapData; + if (currentHasMapData != null) + { + currentHasMapData.SelectedMapDataChanged -= OnSelectedMapDataChanged; + } + propertiesGroupBox.Controls.Clear(); Control userControl = currentMapDataControl.UserControl; propertiesGroupBox.Controls.Add(userControl); userControl.Dock = DockStyle.Fill; + currentMapDataControl.SelectedMapDataChanged += OnSelectedMapDataChanged; } } + private void OnSelectedMapDataChanged(object sender, EventArgs e) + { + UpdateSelectButton(); + } + #region ComboBox private void InitializeComboBox()