// 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 Core.Common.Base.Data; using Core.Common.Gui.Attributes; using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Integration.Forms.Properties; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using GisFormsResources = Core.Components.Gis.Forms.Properties.Resources; namespace Ringtoets.Integration.Forms.PropertyClasses { /// /// ViewModel of the for properties panel. /// public class BackgroundDataProperties : ObjectProperties { /// /// Creates a new instance of . /// /// The data for which the properties are shown. /// Thrown when /// is null. public BackgroundDataProperties(BackgroundData backgroundData) { if (backgroundData == null) { throw new ArgumentNullException(nameof(backgroundData)); } Data = backgroundData; } [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.BackgroundDataProperties_Name_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.BackgroundDataProperties_Name_Description))] public string Name { get { var configuration = data.Configuration as WmtsBackgroundDataConfiguration; return configuration != null ? (configuration.IsConfigured ? data.Name : string.Empty) : data.Name; } } [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.BackgroundDataProperties_Transparency_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.BackgroundDataProperties_Transparency_Description))] public RoundedDouble Transparency { get { return data.Transparency; } set { data.Transparency = value; data.NotifyObservers(); } } [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.BackgroundDataProperties_IsVisible_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.BackgroundDataProperties_IsVisible_Description))] public bool IsVisible { get { return data.IsVisible; } set { data.IsVisible = value; data.NotifyObservers(); } } [DynamicVisibleValidationMethod] public bool DynamicVisibleValidationMethod(string propertyName) { var configuration = data.Configuration as WmtsBackgroundDataConfiguration; return configuration != null && configuration.IsConfigured; } #region Wmts MapData [DynamicVisible] [ResourcesCategory(typeof(Resources), nameof(Resources.BackgroundDataProperties_Wmts_Category))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.BackgroundDataProperties_Wmts_Url_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.BackgroundDataProperties_Wmts_Url_Description))] public string SourceCapabilitiesUrl { get { return GetBackgroundDataProperty(dataConfiguration => dataConfiguration.SourceCapabilitiesUrl); } } [DynamicVisible] [ResourcesCategory(typeof(Resources), nameof(Resources.BackgroundDataProperties_Wmts_Category))] [ResourcesDisplayName(typeof(GisFormsResources), nameof(GisFormsResources.WmtsCapability_MapLayer_Id))] [ResourcesDescription(typeof(Resources), nameof(Resources.BackgroundDataProperties_Wmts_SelectedCapabilityIdentifier_Description))] public string SelectedCapabilityIdentifier { get { return GetBackgroundDataProperty(dataConfiguration => dataConfiguration.SelectedCapabilityIdentifier); } } [DynamicVisible] [ResourcesCategory(typeof(Resources), nameof(Resources.BackgroundDataProperties_Wmts_Category))] [ResourcesDisplayName(typeof(GisFormsResources), nameof(GisFormsResources.WmtsCapability_MapLayer_Format))] [ResourcesDescription(typeof(Resources), nameof(Resources.BackgroundDataProperties_Wmts_PreferredFormat_Description))] public string PreferredFormat { get { return GetBackgroundDataProperty(dataConfiguration => dataConfiguration.PreferredFormat); } } private string GetBackgroundDataProperty(Func getProperty) { var configuration = data.Configuration as WmtsBackgroundDataConfiguration; return configuration != null && configuration.IsConfigured ? getProperty(configuration) : string.Empty; } #endregion } }