// Copyright (C) Stichting Deltares 2025. 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.ComponentModel; using System.Windows.Forms; using Deltares.Dam.Data; using Deltares.Standard; using Deltares.Standard.Attributes; using Deltares.Standard.Calculate; using Deltares.Standard.EventPublisher; using Deltares.Standard.Forms; using Deltares.Standard.Forms.DExpress; namespace Deltares.Dam.Forms { public partial class WaterBoardPropertyControl : UserControl, IPropertyControl, IVisibleEnabled { private WaterBoard waterBoard; public WaterBoardPropertyControl() { InitializeComponent(); Name = "WaterBoard"; BindSupport.BindTextAndValue(this, NumberOfDikesLabel, NumberOfDikesTextEdit, typeof(WaterBoard), "NumberOfDikes"); BindSupport.BindTextAndValue(this, WaterLevelTimeSeriesFileNameLabel, WaterLevelTimeSeriesFileNameEdit, typeof(WaterBoard), "WaterLevelTimeSeriesFileName"); BindSupport.Bind(TimeSeriesGroupControl, FileSelectButton, GetType(), "BrowseTimeSeries"); FormsSupport.RepairRightAnchoredControls(this); FormsSupport.AdjustSizeToContents(TimeSeriesGroupControl); DataEventPublisher.OnAfterChange += DataEventPublisher_OnAfterChange; LocalizationSupport.Register(typeof(WaterBoard), CalculationGroup, groupControl1); BindSupport.Assign(TimeSeriesGroupControl, this); } public void DoProgress(double progress) { if (InvokeRequired) { Invoke(new ProgressDelegate(DoProgress), progress); } else { CalculationProgressBar.EditValue = Math.Round(100 * progress); if (!CalculationGroup.Visible && progress < 1) { CalculationGroup.Visible = true; } Refresh(); } } public bool IsEnabled(string property) { return true; } bool IVisibleEnabled.IsVisible(string property) { switch (property) { case "BrowseTimeSeries": return Data.Location.DamProjectType == DamProjectType.Calamity; default: return true; } } private void DataEventPublisher_OnAfterChange(object sender, PublishEventArgs e) { if (InvokeRequired) { Invoke(new DataEventPublisherEventDelegate(DataEventPublisher_OnAfterChange), sender, e); } else { if (sender is CalculationManager) { bool running = ((CalculationManager) sender).IsRunning; CalculationGroup.Visible = running; if (!running) { CalculationProgressBar.EditValue = 0; } } else if (sender == waterBoard) { DataEventPublisher.AfterChange(this); } } } [Label("...")] [Description("Browse for time series file")] private void BrowseTimeSeries() { SelectFileDialog.FileName = waterBoard.WaterLevelTimeSeriesFileName; if (SelectFileDialog.ShowDialog() == DialogResult.OK) { waterBoard.WaterLevelTimeSeriesFileName = SelectFileDialog.FileName; } } #region IPropertyControl Members public object SelectedObject { get { return waterBoard; } set { if (value is DamProjectData) { if (waterBoard != value) { waterBoard = ((DamProjectData) value).WaterBoard; CalculationGroup.Visible = false; } } else if (value is WaterBoard) { if (waterBoard != value) { waterBoard = value as WaterBoard; CalculationGroup.Visible = false; } } else if (value is DamJob) { if (value is WaterBoardJob) { if (waterBoard != ((WaterBoardJob) value).Subject) { waterBoard = ((WaterBoardJob) value).Subject as WaterBoard; CalculationGroup.Visible = false; } } } BindSupport.Assign(this, waterBoard); } } public bool IsVisible { get { return true; } } #endregion } }