// Copyright (C) Stichting Deltares 2018. All rights reserved.
//
// This file is part of the application DAM - UI.
//
// DAM - UI 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.Collections.Generic;
using System.Linq;
using Deltares.Dam.Data;
using Deltares.Geotechnics;
using Deltares.Geotechnics.Soils;
using Deltares.Standard.Reflection;
namespace Deltares.Dam.Forms
{
public class DamContext: GeotechnicsContext
{
private bool wti = true;
private Dictionary>> filters = new Dictionary>>();
private const string LocationScenarioInsideStability = "InsideStabilityScenarioCategory";
private const string LocationScenarioPiping = "PipingScenarioCategory";
private const string LocationScenarioPlLineSchematization = "PlLineSchematizationScenarioCategory";
public bool Wti
{
get { return wti; }
set { wti = value; }
}
public DamContext()
{
SetUpFilterDictionary();
}
private void SetUpFilterDictionary()
{
var locationScenarioFilter = new Dictionary>();
filters[typeof(Scenario)] = locationScenarioFilter;
locationScenarioFilter.Add(LocationScenarioInsideStability, new List
{
StaticReflection.GetMemberName(x => x.LocationScenarioID),
StaticReflection.GetMemberName(x => x.RiverLevel),
StaticReflection.GetMemberName(x => x.DikeTableHeight),
StaticReflection.GetMemberName(x => x.RequiredSafetyFactorStabilityInnerSlope),
StaticReflection.GetMemberName(x => x.HeadPl3),
StaticReflection.GetMemberName(x => x.HeadPl4)
});
locationScenarioFilter.Add(LocationScenarioPiping, new List
{
StaticReflection.GetMemberName(x => x.LocationScenarioID),
StaticReflection.GetMemberName(x => x.RiverLevel),
StaticReflection.GetMemberName(x => x.DikeTableHeight),
StaticReflection.GetMemberName(x => x.RequiredSafetyFactorPiping),
StaticReflection.GetMemberName(x => x.HeadPl3),
StaticReflection.GetMemberName(x => x.HeadPl4)
});
locationScenarioFilter.Add(LocationScenarioPlLineSchematization, new List
{
StaticReflection.GetMemberName(x => x.LocationScenarioID),
StaticReflection.GetMemberName(x => x.RiverLevel),
StaticReflection.GetMemberName(x => x.PlLineOffsetBelowDikeTopAtRiver),
StaticReflection.GetMemberName(x => x.PlLineOffsetBelowDikeTopAtPolder),
StaticReflection.GetMemberName(x => x.PlLineOffsetBelowShoulderBaseInside),
StaticReflection.GetMemberName(x => x.PlLineOffsetBelowDikeToeAtPolder),
StaticReflection.GetMemberName(x => x.PlLineOffsetBelowDikeCrestMiddle),
StaticReflection.GetMemberName(x => x.PlLineOffsetFactorBelowShoulderCrest),
StaticReflection.GetMemberName(x => x.UsePlLineOffsetBelowDikeCrestMiddle),
StaticReflection.GetMemberName(x => x.UsePlLineOffsetFactorBelowShoulderCrest)
});
}
///
/// Returns the possible named filters for a given type.
///
/// A type for which named filters will be returned.
/// A of the named filters or null if no named filters exists.
public IEnumerable GetColumnNamedFilters(Type type)
{
if (filters.ContainsKey(type))
{
return filters[type].Keys.ToArray();
}
return null;
}
///
/// Returns a list of visible properties for a type and a named filter returned by .
///
/// A type for which named filters are defined.
/// One of the named filters for this type.
/// A list of visible properties.
public IList GetFilteredColumns(Type type, string value)
{
if (filters.ContainsKey(type) && filters[type].ContainsKey(value))
{
return filters[type][value];
}
return null;
}
public override bool? IsVisible(object source, string member)
{
var locationScenariosControl = source as LocationScenariosControl;
if (null != locationScenariosControl)
{
if (member == StaticReflection.GetMemberName(x => x.SelectedContextFilter))
{
return locationScenariosControl.HasItems;
}
}
if (source is SoilList)
{
switch (member)
{
case "Soils" : return Wti;
}
}
if (source is Location && member == StaticReflection.GetMemberName(x => x.SurfaceLine2))
{
return false;
}
return base.IsVisible(source, member);
}
public override bool? IsEnabled(object source, string member)
{
if (source is Soil && member != StaticReflection.GetMemberName(x => x.StrengthIncreaseExponent))
{
return false;
}
return base.IsEnabled(source, member);
}
}
}