// 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;
using System.Globalization;
using Core.Common.Base.Data;
using Core.Common.Controls.DataGrid;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.Forms.ChangeHandlers;
using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Common.Forms.PropertyClasses;
using Ringtoets.MacroStabilityInwards.Data;
namespace Ringtoets.MacroStabilityInwards.Forms.Views
{
///
/// This class represents a row of in the .
///
internal class MacroStabilityInwardsCalculationRow
{
private readonly IObservablePropertyChangeHandler propertyChangeHandler;
///
/// Creates a new instance of .
///
/// The this row contains.
/// The handler responsible for handling effects of a property change.
/// Thrown when any parameter is null.
public MacroStabilityInwardsCalculationRow(MacroStabilityInwardsCalculationScenario macroStabilityInwardsCalculation,
IObservablePropertyChangeHandler handler)
{
if (macroStabilityInwardsCalculation == null)
{
throw new ArgumentNullException(nameof(macroStabilityInwardsCalculation));
}
if (handler == null)
{
throw new ArgumentNullException(nameof(handler));
}
MacroStabilityInwardsCalculation = macroStabilityInwardsCalculation;
propertyChangeHandler = handler;
}
///
/// Gets the this row contains.
///
public MacroStabilityInwardsCalculationScenario MacroStabilityInwardsCalculation { get; }
///
/// Gets or sets the name of the .
///
public string Name
{
get
{
return MacroStabilityInwardsCalculation.Name;
}
set
{
MacroStabilityInwardsCalculation.Name = value;
MacroStabilityInwardsCalculation.NotifyObservers();
}
}
///
/// Gets or sets the stochastic soil model of the .
///
public DataGridViewComboBoxItemWrapper StochasticSoilModel
{
get
{
return new DataGridViewComboBoxItemWrapper(MacroStabilityInwardsCalculation.InputParameters.StochasticSoilModel);
}
set
{
StochasticSoilModel valueToSet = value?.WrappedObject;
if (!ReferenceEquals(MacroStabilityInwardsCalculation.InputParameters.StochasticSoilModel, valueToSet))
{
PropertyChangeHelper.ChangePropertyAndNotify(() => MacroStabilityInwardsCalculation.InputParameters.StochasticSoilModel = valueToSet, propertyChangeHandler);
}
}
}
///
/// Gets or sets the stochastic soil profile of the .
///
public DataGridViewComboBoxItemWrapper StochasticSoilProfile
{
get
{
return new DataGridViewComboBoxItemWrapper(MacroStabilityInwardsCalculation.InputParameters.StochasticSoilProfile);
}
set
{
StochasticSoilProfile valueToSet = value?.WrappedObject;
if (!ReferenceEquals(MacroStabilityInwardsCalculation.InputParameters.StochasticSoilProfile, valueToSet))
{
PropertyChangeHelper.ChangePropertyAndNotify(() => MacroStabilityInwardsCalculation.InputParameters.StochasticSoilProfile = valueToSet, propertyChangeHandler);
}
}
}
///
/// Gets the stochastic soil profile probability of the .
///
public string StochasticSoilProfileProbability
{
get
{
return MacroStabilityInwardsCalculation.InputParameters.StochasticSoilProfile != null
? new RoundedDouble(3, MacroStabilityInwardsCalculation.InputParameters.StochasticSoilProfile.Probability * 100).Value.ToString(CultureInfo.CurrentCulture)
: new RoundedDouble(3).Value.ToString(CultureInfo.CurrentCulture);
}
}
///
/// Gets or sets the hydraulic boundary location of the .
///
public DataGridViewComboBoxItemWrapper SelectableHydraulicBoundaryLocation
{
get
{
if (MacroStabilityInwardsCalculation.InputParameters.HydraulicBoundaryLocation == null)
{
return new DataGridViewComboBoxItemWrapper(null);
}
return new DataGridViewComboBoxItemWrapper(
new SelectableHydraulicBoundaryLocation(MacroStabilityInwardsCalculation.InputParameters.HydraulicBoundaryLocation,
MacroStabilityInwardsCalculation.InputParameters.SurfaceLine?.ReferenceLineIntersectionWorldPoint));
}
set
{
HydraulicBoundaryLocation valueToSet = value?.WrappedObject?.HydraulicBoundaryLocation;
if (!ReferenceEquals(MacroStabilityInwardsCalculation.InputParameters.HydraulicBoundaryLocation, valueToSet))
{
PropertyChangeHelper.ChangePropertyAndNotify(() => MacroStabilityInwardsCalculation.InputParameters.HydraulicBoundaryLocation = valueToSet, propertyChangeHandler);
}
}
}
///
/// Gets or sets the damping factory exit mean of the .
///
public RoundedDouble DampingFactorExitMean
{
get
{
return MacroStabilityInwardsCalculation.InputParameters.DampingFactorExit.Mean;
}
set
{
if (!MacroStabilityInwardsCalculation.InputParameters.DampingFactorExit.Mean.Equals(value))
{
PropertyChangeHelper.ChangePropertyAndNotify(() => MacroStabilityInwardsCalculation.InputParameters.DampingFactorExit.Mean = value, propertyChangeHandler);
}
}
}
///
/// Gets or sets the phreatic level exit mean of the .
///
public RoundedDouble PhreaticLevelExitMean
{
get
{
return MacroStabilityInwardsCalculation.InputParameters.PhreaticLevelExit.Mean;
}
set
{
if (!MacroStabilityInwardsCalculation.InputParameters.PhreaticLevelExit.Mean.Equals(value))
{
PropertyChangeHelper.ChangePropertyAndNotify(() => MacroStabilityInwardsCalculation.InputParameters.PhreaticLevelExit.Mean = value, propertyChangeHandler);
}
}
}
///
/// Gets or sets the entry point l of the .
///
public RoundedDouble EntryPointL
{
get
{
return MacroStabilityInwardsCalculation.InputParameters.EntryPointL;
}
set
{
if (!MacroStabilityInwardsCalculation.InputParameters.EntryPointL.Equals(value))
{
PropertyChangeHelper.ChangePropertyAndNotify(() => MacroStabilityInwardsCalculation.InputParameters.EntryPointL = value, propertyChangeHandler);
}
}
}
///
/// Gets or sets the exit point l of the .
///
public RoundedDouble ExitPointL
{
get
{
return MacroStabilityInwardsCalculation.InputParameters.ExitPointL;
}
set
{
if (!MacroStabilityInwardsCalculation.InputParameters.ExitPointL.Equals(value))
{
PropertyChangeHelper.ChangePropertyAndNotify(() => MacroStabilityInwardsCalculation.InputParameters.ExitPointL = value, propertyChangeHandler);
}
}
}
}
}