// Copyright (C) Stichting Deltares 2017. 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 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 General Public License for more details.
//
// You should have received a copy of the GNU 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.Collections.Generic;
using System.Linq;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.Forms.GuiServices;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
namespace Ringtoets.Common.Forms.Views
{
///
/// Base view for views which should be derived in order to get a consistent look and feel.
///
/// The type of the row objects which are shown in the data table.
public abstract partial class HydraulicBoundaryLocationsView : CalculatableView where T : HydraulicBoundaryLocationRow
{
private IEnumerable locations;
public override object Data
{
get
{
return locations;
}
set
{
locations = value as IEnumerable;
UpdateDataGridViewDataSource();
}
}
///
/// Gets or sets the .
///
public IHydraulicBoundaryLocationCalculationGuiService CalculationGuiService { get; set; }
///
/// Gets or sets the .
///
public abstract IAssessmentSection AssessmentSection { get; set; }
protected override void InitializeDataGridView()
{
base.InitializeDataGridView();
dataGridViewControl.AddCheckBoxColumn(nameof(HydraulicBoundaryLocationRow.IncludeIllustrationPoints),
RingtoetsCommonFormsResources.HydraulicBoundaryLocationCalculationInput_IncludeIllustrationPoints_DisplayName);
dataGridViewControl.AddTextBoxColumn(nameof(HydraulicBoundaryLocationRow.Name),
RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Location_Name_DisplayName);
dataGridViewControl.AddTextBoxColumn(nameof(HydraulicBoundaryLocationRow.Id),
RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Location_Id_DisplayName);
dataGridViewControl.AddTextBoxColumn(nameof(HydraulicBoundaryLocationRow.Location),
RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Location_Coordinates_DisplayName);
}
///
/// Creates a new row that is added to the data table.
///
/// The location for which to create a new row.
/// The newly created row.
protected abstract T CreateNewRow(HydraulicBoundaryLocation location);
///
/// Handles the calculation of the .
///
/// The enumeration of to use in the calculation.
protected abstract void HandleCalculateSelectedLocations(IEnumerable locations);
protected override void CalculateForSelectedRows()
{
if (CalculationGuiService == null)
{
return;
}
IEnumerable selectedLocations = GetSelectedCalculatableObjects();
HandleCalculateSelectedLocations(selectedLocations);
}
protected override void SetDataSource()
{
dataGridViewControl.SetDataSource(locations?.Select(CreateNewRow).ToArray());
}
}
}