// Copyright (C) Stichting Deltares 2023. 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; using System.Collections.Generic; using System.ComponentModel; using System.Xml.Serialization; using Deltares.Standard; using Deltares.Standard.Attributes; using Deltares.Standard.EventPublisher; using DotSpatial.Projections; namespace Deltares.Dam.Data.UISupport { public class DAMNewProjectData : IVisibleEnabled, IDomain { private DamProjectType damProjectType; private string damDataSourceFileName; private string damProjectFileName; private string sensorConfigurationFileName; private List selectedDikeRingIds = new List(); private string dataSourceEsriProjection; private string dataSourceProjectionName; private bool dataSourceProjectionUserDefined; [Label("Calculation type")] [Description("Indicates the purpose of the calculations")] [XmlIgnore] public DamProjectType DamProjectType { get { return damProjectType; } set { DataEventPublisher.BeforeChange(this, "DamProjectType"); damProjectType = value; DataEventPublisher.AfterChange(this, "DamProjectType"); } } [Label("DAM datasource file")] [Description("Indicates which \".defx\" import definition file to use")] [XmlIgnore] public string DamDataSourceFileName { get { return damDataSourceFileName; } set { DataEventPublisher.BeforeChange(this, "DamDataSourceFileName"); damDataSourceFileName = value; DataEventPublisher.AfterChange(this, "DamDataSourceFileName"); } } [XmlIgnore] public string SensorConfigurationFileName { get { return sensorConfigurationFileName; } set { DataEventPublisher.BeforeChange(this, "SensorConfigurationFileName"); sensorConfigurationFileName = value; DataEventPublisher.AfterChange(this, "SensorConfigurationFileName"); } } [XmlIgnore] public string DamProjectFileName { get { return damProjectFileName; } set { DataEventPublisher.BeforeChange(this, "DamProjectFileName"); damProjectFileName = value; DataEventPublisher.AfterChange(this, "DamProjectFileName"); } } [XmlIgnore] public string DataSourceEsriProjection { get { return dataSourceEsriProjection; } set { DataEventPublisher.BeforeChange(this, "DataSourceEsriProjection"); dataSourceEsriProjection = value; DataEventPublisher.AfterChange(this, "DataSourceEsriProjection"); try { var projection = ProjectionInfo.FromEsriString(value); DataSourceProjectionName = projection.Name ?? projection.ToString(); } catch (Exception) { DataSourceProjectionName = "Invalid projection"; } } } [XmlIgnore] [ReadOnly(true)] public string DataSourceProjectionName { get { return dataSourceProjectionName; } set { DataEventPublisher.BeforeChange(this, "DataSourceProjectionName"); dataSourceProjectionName = value; DataEventPublisher.AfterChange(this, "DataSourceProjectionName"); } } /// /// Selects the sensor configuration file. /// [Label("...")] public void SelectSensorConfigurationFile() { // This method is needed for the databinding to DamNewProjectDialog // The IsEnabled is implemented in this class // The UI code itself is implemented in the DamNewProjectDialog itself } /// /// Selects the projection. /// public void SelectProjection() { // This method is needed for the databinding to DamNewProjectDialog // The IsEnabled is implemented in this class // The UI code itself is implemented in the DamNewProjectDialog itself } public List SelectedDikeRingIds { get { return selectedDikeRingIds; } set { selectedDikeRingIds = value; } } public bool DataSourceProjectionUserDefined { get { return dataSourceProjectionUserDefined; } set { dataSourceProjectionUserDefined = value; } } public bool IsVisible(string property) { if (property == "SelectProjection") { return (string.IsNullOrEmpty(DataSourceEsriProjection) || DataSourceProjectionUserDefined); } return true; } public bool IsEnabled(string property) { if ((property == "SensorConfigurationFileName") || (property == "SelectSensorConfigurationFile")) { return (DamProjectType == DamProjectType.DamLiveConfiguration); } return true; } public ICollection GetDomain(string property) { switch (property) { case "DamProjectType": return new[] { DamProjectType.Design, DamProjectType.Calamity, DamProjectType.DamLiveConfiguration }; default: return null; } } } }