// Copyright (C) Stichting Deltares 2024. 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.Windows.Forms; using Deltares.Dam.Data; using Deltares.Geotechnics.Soils; using Deltares.Standard.EventPublisher; using Deltares.Standard.Forms; using Deltares.Standard.Forms.DExpress; namespace Deltares.Dam.Forms { public partial class DesignCalculationPropertyControl : UserControl, IPropertyControl { private CsvExportData result; private LocationJob locationJob; private string soilProfileName; private string scenarioName; private string calculationName; public DesignCalculationPropertyControl() { InitializeComponent(); Name = "Calculation"; BindSupport.BindTextAndValue(this, LocationLabel, LocationEdit, a => a.LocationName); BindSupport.BindTextAndValue(this, ProfileLabel, ProfileEdit, a => a.ProfileName); BindSupport.BindTextAndValue(this, ModelLabel, ModelEdit, a => a.StabilityModel); BindSupport.BindTextAndValue(this, ModelPipingLabel, ModelPipingEdit, a => a.PipingModel); BindSupport.BindTextAndValue(this, ScenarioLabel, ScenarioEdit, a => a.ScenarioName); BindSupport.BindTextValueAndUnit(this, SafetyFactorLabel, SafetyFactorEdit, a => a.SafetyFactor); BindSupport.BindTextAndValue(this, CalculationLabel, CalculationComboBox, a => a.CalculationResult); BindSupport.BindTextAndValue(this, NumberOfIterationsLabel, NumberOfIterationsEdit, a => a.NumberOfIterations); BindSupport.Bind(this, AcceptedCheckEdit, a => a.ResultEvaluation, ResultEvaluation.Accepted); BindSupport.Bind(this, RejectedCheckEdit, a => a.ResultEvaluation, ResultEvaluation.Rejected); BindSupport.Bind(this, NotEvaluatedCheckEdit, a => a.ResultEvaluation, ResultEvaluation.NotEvaluated); //#Best name in edits added LocalizationSupport.Register(typeof(CsvExportData), AcceptedCheckEdit, RejectedCheckEdit, NotEvaluatedCheckEdit, groupControl1, groupControl2, EvaluationGroupControl); BindSupport.BindTextAndValue(this, NotesLabel, NotesEdit, a => a.Notes); BindSupport.Bind(this, OpenFileButton, typeof(CsvExportData), "OpenCalculationFile"); BindSupport.Assign(EvaluationGroupControl, this); FormsSupport.RepairRightAnchoredControls(this); DataEventPublisher.OnAfterChange += DataEventPublisher_OnAfterChange; } private void DataEventPublisher_OnAfterChange(object sender, PublishEventArgs e) { if (sender is LocationJobSymbol symbol) { soilProfileName = symbol.CurrentProfileName; scenarioName = symbol.CurrentScenarioName; calculationName = symbol.CurrentCalculation; } else if (sender is SoilProfile1D profile1D && locationJob != null) { string profileName = profile1D.Name; result = locationJob.GetDesignResultByProfileScenarioAndCalculationName(profileName, scenarioName, calculationName); BindSupport.Assign(this, result); } } #region IPropertyControl Members public object SelectedObject { get { return result; } set { if (value is CsvExportData data) { result = data; locationJob = null; BindSupport.Assign(this, result); } else if (value is LocationJob job) { locationJob = job; if (result == null || !result.LocationName.Equals((locationJob).Location.Name) || (locationJob).HasDesignScenarioResults == false || result.ProfileName != soilProfileName || result.ScenarioName != scenarioName || result.Calculation != calculationName) { // Note: if no results for this locationjob (the third condition) the result will be set to null, so dialog will be hidden CsvExportData locationResult = locationJob.GetDesignResultByProfileScenarioAndCalculationName( soilProfileName, scenarioName, calculationName); if (locationResult != result || locationResult == null) { result = locationResult; BindSupport.Assign(this, result); } } } } } public bool IsVisible { get { if (locationJob != null) { CsvExportData designResult = locationJob.GetDesignResultByProfileScenarioAndCalculationName( soilProfileName, scenarioName, calculationName); if (designResult != null) { return true; } return locationJob.GetFirstDesignResult() != null; } return result != null; } } #endregion } }