// Copyright (C) Stichting Deltares 2017. 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.Collections; using System.Windows.Forms; using Deltares.Dam.Data; using Deltares.Standard; using Deltares.Standard.Forms.DExpress; using Deltares.Standard.Forms.Properties; using Deltares.Standard.Reflection; using DevExpress.XtraBars; using DevExpress.XtraEditors.Controls; using DevExpress.XtraEditors.Repository; namespace Deltares.Dam.Forms { /// /// Cross section spatialEditor for DAM /// public class DamGeometryEditor : IDomain { private DamSpatialEditorDecorator spatialEditor; private LocationJob locationJob = null; private FailureMechanismSystemType failureMechanismType = FailureMechanismSystemType.StabilityInside; private int index = 0; // Indicates the ranking in the probabilities private Panel panel = new Panel(); private bool openCharacteristicPointEditor; /// /// Cross-section geometry spatialEditor /// /// The cross section spatialEditor public DamGeometryEditor(GeometryEditor geometryEditor) { spatialEditor = new DamSpatialEditorDecorator(geometryEditor.SpatialEditor); var projectTypeComboBox = new RepositoryItemComboBox { TextEditStyle = TextEditStyles.DisableTextEditor }; var projectTypeBarItem = new BarEditItem { Width = 200, Edit = projectTypeComboBox }; var previousButton = new BarButtonItem { Glyph = Resources.Previous }; var nextButton = new BarButtonItem { Glyph = Resources.Next }; var probabilityItem = new BarStaticItem(); var soilProfileLabel = new BarStaticItem(); var editMode = new BarButtonItem { Glyph = Properties.Resources.pencil }; /** * TODO * DevExpress notes that using LinkPersistInfo directly is not the way to add items. * However, adding items using MainBar.AddItem adds the items to the front of the * mainbar instead of adding new items to the back */ geometryEditor.MainBar.LinksPersistInfo.Add(new LinkPersistInfo(projectTypeBarItem, true)); geometryEditor.MainBar.LinksPersistInfo.Add(new LinkPersistInfo(previousButton)); geometryEditor.MainBar.LinksPersistInfo.Add(new LinkPersistInfo(nextButton)); geometryEditor.MainBar.LinksPersistInfo.Add(new LinkPersistInfo(probabilityItem)); geometryEditor.MainBar.LinksPersistInfo.Add(new LinkPersistInfo(soilProfileLabel)); // geometryEditor.MainBar.LinksPersistInfo.Insert(2, new LinkPersistInfo(editMode)); // Disable line editing of characteristic points (MWDAM-915) BindSupport.Bind(panel, projectTypeBarItem, spatialEditor.GetType(), StaticReflection.GetMemberName(x => x.FailureMechanismType)); BindSupport.Bind(panel, previousButton, spatialEditor.GetType(), StaticReflection.GetMemberName(x => x.Previous())); BindSupport.Bind(panel, nextButton, spatialEditor.GetType(), StaticReflection.GetMemberName(x => x.Next())); BindSupport.Bind(panel, probabilityItem, spatialEditor.GetType(), StaticReflection.GetMemberName(x => x.ProbabilityString)); BindSupport.Bind(panel, soilProfileLabel, spatialEditor.GetType(), StaticReflection.GetMemberName(x => x.ProfileName)); BindSupport.Bind(panel, editMode, spatialEditor.GetType(), StaticReflection.GetMemberName(x => x.EditMode)); BindSupport.Assign(panel, spatialEditor); } public ICollection GetDomain(string property) { switch (property) { case "FailureMechanismType": { switch (LocationJob.DamProjectType) { case DamProjectType.Calamity: return new[] { FailureMechanismSystemType.StabilityInside, FailureMechanismSystemType.StabilityOutside, FailureMechanismSystemType.Piping }; case DamProjectType.Assessment: return new[] { FailureMechanismSystemType.StabilityInside, FailureMechanismSystemType.Piping, FailureMechanismSystemType.HorizontalBalance }; case DamProjectType.Design: { if (DamProjectCalculationSpecification.SelectedAnalysisType == AnalysisType.NoAdaption) { return new[] { FailureMechanismSystemType.StabilityInside, FailureMechanismSystemType.StabilityOutside, FailureMechanismSystemType.Piping }; } return new[] { FailureMechanismSystemType.StabilityInside, FailureMechanismSystemType.Piping }; } } break; } default: return null; } return null; } } }