// 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; using System.Windows.Forms; using Deltares.Dam.Data; using Deltares.Standard.EventPublisher; using Deltares.Standard.Forms; using Deltares.Standard.Forms.DExpress; namespace Deltares.Dam.Forms { public partial class DamProjectCalculationOptionsPropertyControl : UserControl, IPropertyControl { private DamFailureMechanismeCalculationSpecification currentSpecification; public DamProjectCalculationOptionsPropertyControl() { InitializeComponent(); BindSupport.BindTextAndValue(SearchMethodPanelControl, SearchMethodLabel, SearchMethodCombobox, p => p.SearchMethod); BindSupport.BindTextAndValue(CircleDefinitionPanelControl, GridCreationLabel, GridCreationComboBox, p => p.GridSizeDetermination); BindSupport.BindTextAndValue(CircleDefinitionPanelControl, TangentLineBishopLabel, TangentLineBishopComboBox, p => p.BishopTangentLinesDefinition); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, DistanceTangentLinesBishopLabel, DistanceTangentLinesBishopEdit, p => p.BishopTangentLinesDistance); BindSupport.BindTextAndValue(CircleDefinitionPanelControl, TangentLineUpliftVanLabel, TangentLineUpliftVanComboBox, p => p.UpliftVanTangentLinesDefinition); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, DistanceTangentLinesUVLabel, DistanceTangentLinesUVEdit, p => p.UpliftVanTangentLinesDistance); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, LeftGridVerticalPointCountUVLabel, LeftGridVerticalPointCountUVEdit, p => p.UpliftVanLeftGridVerticalPointCount); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, LeftGridVerticalPointDistanceUVLabel, LeftGridVerticalPointDistanceUVEdit, p => p.UpliftVanLeftGridVerticalPointDistance); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, LeftGridHorizontalPointCountUVLabel, LeftGridHorizontalPointCountUVEdit, p => p.UpliftVanLeftGridHorizontalPointCount); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, LeftGridHorizontalPointDistanceUVLabel, LeftGridHorizontalPointDistanceUVEdit, p => p.UpliftVanLeftGridHorizontalPointDistance); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, RightGridVerticalPointCountUVLabel, RightGridVerticalPointCountUVEdit, p => p.UpliftVanRightGridVerticalPointCount); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, RightGridVerticalPointDistanceUVLabel, RightGridVerticalPointDistanceUVEdit, p => p.UpliftVanRightGridVerticalPointDistance); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, RightGridHorizontalPointCountUVLabel, RightGridHorizontalPointCountUVEdit, p => p.UpliftVanRightGridHorizontalPointCount); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, RightGridHorizontalPointDistanceUVLabel, RightGridHorizontalPointDistanceUVEdit, p => p.UpliftVanRightGridHorizontalPointDistance); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, GridVerticalPointCountBishopLabel, GridVerticalPointCountBishopEdit, p => p.BishopGridVerticalPointCount); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, GridVerticalPointDistanceBishopLabel, GridVerticalPointDistanceBishopEdit, p => p.BishopGridVerticalPointDistance); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, GridHorizontalPointCountBishopLabel, GridHorizontalPointCountBishopEdit, p => p.BishopGridHorizontalPointCount); BindSupport.BindTextValueAndUnit(CircleDefinitionPanelControl, GridHorizontalPointDistanceBishopLabel, GridHorizontalPointDistanceBishopEdit, p => p.BishopGridHorizontalPointDistance); StabilityGroupControl.Text = "StabilityOptionsGroupControl"; LocalizationSupport.RegisterAndTranslate(typeof(DamProjectCalculationOptionsPropertyControl), StabilityGroupControl); DataEventPublisher.OnAfterChange += DataEventPublisher_OnAfterChange; FormsSupport.RepairRightAnchoredControls(this); FormsSupport.AdjustSizeToContents(SearchMethodPanelControl); FormsSupport.AdjustSizeToContents(CircleDefinitionPanelControl); } public object SelectedObject { get { return currentSpecification; } set { if (value is DamFailureMechanismeCalculationSpecification specification) { currentSpecification = specification; BindSupport.Assign(SearchMethodPanelControl, currentSpecification.FailureMechanismeParamatersMStab.MStabParameters); BindSupport.Assign(CircleDefinitionPanelControl, currentSpecification.FailureMechanismeParamatersMStab.MStabParameters.SlipCircleDefinition); } } } public bool IsVisible { get { return true; } } private void DataEventPublisher_OnAfterChange(object sender, PublishEventArgs e) { if (sender is DamFailureMechanismeCalculationSpecification specification) { currentSpecification = specification; SetSelectedDamCalculationSpecification(); } if (sender is DamProject pd) { currentSpecification = pd.DamProjectData.DamProjectCalculationSpecification.CurrentSpecification; SetSelectedDamCalculationSpecification(); } } private void SetSelectedDamCalculationSpecification() { if (currentSpecification != null) { currentSpecification.FailureMechanismeParamatersMStab.MStabParameters.SlipCircleDefinition.Specification = currentSpecification; if (SearchMethodPanelControl.InvokeRequired) { Action action = () => BindSupport.Assign(SearchMethodPanelControl, currentSpecification.FailureMechanismeParamatersMStab.MStabParameters); SearchMethodPanelControl.Invoke(action); } else { BindSupport.Assign(SearchMethodPanelControl, currentSpecification.FailureMechanismeParamatersMStab.MStabParameters); } if (CircleDefinitionPanelControl.InvokeRequired) { Action action = () => BindSupport.Assign(CircleDefinitionPanelControl, currentSpecification.FailureMechanismeParamatersMStab.MStabParameters.SlipCircleDefinition); CircleDefinitionPanelControl.Invoke(action); } else { BindSupport.Assign(CircleDefinitionPanelControl, currentSpecification.FailureMechanismeParamatersMStab.MStabParameters.SlipCircleDefinition); } // if (selection.FailureMechanismSystemType != FailureMechanismSystemType.Piping && firstEdit) // { // // this is a hack to force update on ill placed edits. // this.Width = this.Width + 1; // firstEdit = false; // } } } } }