Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs =================================================================== diff -u -r2a9a0a500bc605a383e700b6d8f4b407abd42486 -rf06f5ec5e879a3790c3826bcd3d3855bea1ffef9 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs (.../BackgroundMapDataSelectionDialog.cs) (revision 2a9a0a500bc605a383e700b6d8f4b407abd42486) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/BackgroundMapDataSelectionDialog.cs (.../BackgroundMapDataSelectionDialog.cs) (revision f06f5ec5e879a3790c3826bcd3d3855bea1ffef9) @@ -54,21 +54,15 @@ }; InitializeComponent(); + InitializeButtons(); InitializeComboBox(); - - UpdateSelectButton(); + InitializeEventHandlers(); } /// /// Gets the from the selected row in the . /// - public MapData SelectedMapData - { - get - { - return currentMapDataControl?.SelectedMapData; - } - } + public MapData SelectedMapData { get; private set; } protected override void Dispose(bool disposing) { @@ -79,16 +73,11 @@ base.Dispose(disposing); } - protected override Button GetCancelButton() + private void SetSelectedMapData() { - return cancelButton; + SelectedMapData = currentMapDataControl?.SelectedMapData; } - private void UpdateSelectButton() - { - selectButton.Enabled = SelectedMapData != null; - } - private void UpdatePropertiesGroupBox() { if (currentMapDataControl != null) @@ -107,11 +96,25 @@ } } - private void OnSelectedMapDataChanged(object sender, EventArgs e) + #region Buttons + + private void InitializeButtons() { UpdateSelectButton(); } + private void UpdateSelectButton() + { + selectButton.Enabled = SelectedMapData != null; + } + + protected override Button GetCancelButton() + { + return cancelButton; + } + + #endregion + #region ComboBox private void InitializeComboBox() @@ -124,6 +127,32 @@ mapLayerComboBox.Enabled = false; } + private void UpdateComboBoxDataSource() + { + mapLayerComboBox.DataSource = mapDatas; + mapLayerComboBox.DisplayMember = nameof(IHasMapData.DisplayName); + } + + #endregion + + #region Event handlers + + private void InitializeEventHandlers() + { + selectButton.Click += OnSelectButtonClick; + } + + private void OnSelectButtonClick(object sender, EventArgs e) + { + SetSelectedMapData(); + Close(); + } + + private void OnSelectedMapDataChanged(object sender, EventArgs e) + { + UpdateSelectButton(); + } + private void MapLayerComboBox_OnSelectedIndexChanged(object sender, EventArgs eventArgs) { var selectedItem = mapLayerComboBox.SelectedItem as IHasMapData; @@ -136,12 +165,6 @@ UpdatePropertiesGroupBox(); } - private void UpdateComboBoxDataSource() - { - mapLayerComboBox.DataSource = mapDatas; - mapLayerComboBox.DisplayMember = nameof(IHasMapData.DisplayName); - } - #endregion } } \ No newline at end of file