// 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.Diagnostics; using System.Diagnostics.Eventing.Reader; using System.IO; using System.Windows.Forms; using Deltares.Dam.Data; using Deltares.Standard; 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(); this.Name = "Calculation"; BindSupport.BindTextAndValue(this, this.LocationLabel, this.LocationEdit, a => a.LocationName); BindSupport.BindTextAndValue(this, this.ProfileLabel, this.ProfileEdit, a => a.ProfileName); BindSupport.BindTextAndValue(this, this.ModelLabel, this.ModelEdit, a => a.StabilityModel); BindSupport.BindTextAndValue(this, this.ModelPipingLabel, this.ModelPipingEdit, a => a.PipingModel); BindSupport.BindTextAndValue(this, this.ScenarioLabel, this.ScenarioEdit, a => a.ScenarioName); BindSupport.BindTextValueAndUnit(this, this.SafetyFactorLabel, this.SafetyFactorEdit, a => a.SafetyFactor); BindSupport.BindTextAndValue(this, this.CalculationLabel, this.CalculationComboBox, a => a.CalculationResult); BindSupport.BindTextAndValue(this, this.NumberOfIterationsLabel, this.NumberOfIterationsEdit, a => a.NumberOfIterations); BindSupport.Bind(this, this.AcceptedCheckEdit, a => a.ResultEvaluation, ResultEvaluation.Accepted); BindSupport.Bind(this, this.RejectedCheckEdit, a => a.ResultEvaluation, ResultEvaluation.Rejected); BindSupport.Bind(this, this.NotEvaluatedCheckEdit, a => a.ResultEvaluation, ResultEvaluation.NotEvaluated); //#Best name in edits added LocalizationSupport.Register(typeof(CsvExportData), this.AcceptedCheckEdit, this.RejectedCheckEdit, this.NotEvaluatedCheckEdit, this.groupControl1, this.groupControl2, this.EvaluationGroupControl); BindSupport.BindTextAndValue(this, this.NotesLabel, this.NotesEdit, a => a.Notes); BindSupport.Bind(this, OpenFileButton, typeof(CsvExportData), "OpenCalculationFile"); BindSupport.Assign(this.EvaluationGroupControl, this); FormsSupport.RepairRightAnchoredControls(this); DataEventPublisher.OnAfterChange += DataEventPublisher_OnAfterChange; } private void DataEventPublisher_OnAfterChange(object sender, PublishEventArgs e) { if (sender is LocationJobSymbol) { soilProfileName = ((LocationJobSymbol)sender).CurrentProfileName; scenarioName = ((LocationJobSymbol) sender).CurrentScenarioName; calculationName = ((LocationJobSymbol)sender).CurrentCalculation; } } #region IPropertyControl Members public object SelectedObject { get { return result; } set { if (value is CsvExportData) { result = value as CsvExportData; locationJob = null; BindSupport.Assign(this, result); } else if (value is LocationJob) { locationJob = (LocationJob) value; if (result == null || !result.LocationName.Equals((locationJob).Location.Name) || (locationJob).HasScenarioResults == 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) { return locationJob.GetFirstDesignResult() != null; } else { return this.result != null; } } } #endregion } }