Index: src/Deltares.DSoilModel.Forms/Translations.xml =================================================================== diff -u -r220 -r222 --- src/Deltares.DSoilModel.Forms/Translations.xml (.../Translations.xml) (revision 220) +++ src/Deltares.DSoilModel.Forms/Translations.xml (.../Translations.xml) (revision 222) @@ -87,4 +87,5 @@ - + + \ No newline at end of file Index: src/Deltares.DSoilModel.Forms/DSoilModelPlugin.cs =================================================================== diff -u -r220 -r222 --- src/Deltares.DSoilModel.Forms/DSoilModelPlugin.cs (.../DSoilModelPlugin.cs) (revision 220) +++ src/Deltares.DSoilModel.Forms/DSoilModelPlugin.cs (.../DSoilModelPlugin.cs) (revision 222) @@ -360,8 +360,6 @@ case "SoilSegmentsShapeImport": // needs soilprofiles + segment csv return (project != null && project.SoilSegments.Count > 0 && (project.SoilProfiles1D.Count > 0 || project.SoilProfiles2D.Count > 0)); - case "ExecuteClearGeometryCommand": - return GeometryEditor.SpatialEditor.EmptySelection != null; default: return true; } @@ -773,15 +771,6 @@ }); BindSupport.Bind(pluginPanel, importOldProjectItemMenuItem, p => p.OldProjectImport()); } - - - var clearGeometryMenuItem = new BarButtonItem - { - Caption = LocalizationManager.GetTranslatedText(this, "Clear geometry"), - Name = "clearGeometryMenuItem" - }; - mainForm.EditMenu.AddItems(new BarItem[] { clearGeometryMenuItem }); - BindSupport.Bind(pluginPanel, clearGeometryMenuItem, p => p.ExecuteClearGeometryCommand()); } private void FilmStripContainer_OnSizeChanged(object sender, EventArgs e) @@ -1846,20 +1835,5 @@ filmStrip.Refresh(false); } - - private void ExecuteClearGeometryCommand() - { - var selected = (GeometryEditor.SpatialEditor.EmptySelection.DataObject as SoilProfile2D); - if (selected == null) - { - return; - } - selected.Geometry.Clear(); - selected.Surfaces.Clear(); - - DataEventPublisher.DataListModified(selected.Geometry.Points); - DataEventPublisher.DataListModified(selected.Geometry.Curves); - DataEventPublisher.DataListModified(selected.Surfaces); - } } } \ No newline at end of file Index: src/Deltares.DSoilModel.Forms/DSoilModelGeometryEditor.cs =================================================================== diff -u -r220 -r222 --- src/Deltares.DSoilModel.Forms/DSoilModelGeometryEditor.cs (.../DSoilModelGeometryEditor.cs) (revision 220) +++ src/Deltares.DSoilModel.Forms/DSoilModelGeometryEditor.cs (.../DSoilModelGeometryEditor.cs) (revision 222) @@ -184,10 +184,10 @@ } } - public SpatialEditor SpatialEditor + private SpatialEditor SpatialEditor { get { return spatialEditor; } - private set { throw new NotImplementedException(); } + set { throw new NotImplementedException(); } } /// @@ -330,7 +330,13 @@ public bool IsEnabled(string property) { - return true; + switch (property) + { + case "ExecuteClearGeometryCommand": + return SpatialEditor.EmptySelection != null; + default: + return true; + } } /// @@ -496,6 +502,7 @@ var addSurfaceLineToCreateNew2DProfileMenuItem = new ToolStripMenuItem("Add surfaceLine to create new 2D profile"); var addSurfaceLineToCreate2DProfileMenuItem = new ToolStripMenuItem("Add surfaceLine to create 2D profile"); var add1DProfileToCreate2DProfileMenuItem = new ToolStripMenuItem("Add 1D profile to create 2D profile"); + var clearGeometryMenuItem = new ToolStripMenuItem("Clear geometry"); spatialEditor.ContextMenuStrip.Items.Add(deleteLooseLinesMenuItem); spatialEditor.ContextMenuStrip.Items.Add(insertCptMenuItem); spatialEditor.ContextMenuStrip.Items.Add(insertBoringMenuItem); @@ -505,6 +512,7 @@ spatialEditor.ContextMenuStrip.Items.Add(addSurfaceLineToCreateNew2DProfileMenuItem); spatialEditor.ContextMenuStrip.Items.Add(addSurfaceLineToCreate2DProfileMenuItem); spatialEditor.ContextMenuStrip.Items.Add(add1DProfileToCreate2DProfileMenuItem); + spatialEditor.ContextMenuStrip.Items.Add(clearGeometryMenuItem); BindSupport.Bind(panel, deleteLooseLinesMenuItem, ge => ge.DeleteLooseLines()); BindSupport.Bind(panel, insertCptMenuItem, ge => ge.InsertCpt()); BindSupport.Bind(panel, insertBoringMenuItem, ge => ge.InsertBoring()); @@ -514,9 +522,38 @@ BindSupport.Bind(panel, addSurfaceLineToCreateNew2DProfileMenuItem, ge => ge.AddSurfaceLineToCreateNew2DProfile()); BindSupport.Bind(panel, addSurfaceLineToCreate2DProfileMenuItem, ge => ge.AddSurfaceLineToCreate2DProfile()); BindSupport.Bind(panel, add1DProfileToCreate2DProfileMenuItem, ge => ge.Add1DProfileToCreate2DProfile()); + BindSupport.Bind(panel, clearGeometryMenuItem, ge => ge.ExecuteClearGeometryCommand()); BindSupport.Assign(panel, this); } + private bool AskUserWantsToClearGeometry() + { + var msg = LocalizationManager.GetTranslatedText(this, "ExecuteClearGeometryCommandUserConfirm"); + var caption = LocalizationManager.GetTranslatedText(this, "ExecuteClearGeometryCommand"); + return MessageBox.Show(msg, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; + } + + private void ExecuteClearGeometryCommand() + { + var selected = (SpatialEditor.EmptySelection.DataObject as SoilProfile2D); + if (selected == null) + { + return; + } + + if (!AskUserWantsToClearGeometry()) + { + return; + } + + selected.Geometry.Clear(); + selected.Surfaces.Clear(); + + DataEventPublisher.DataListModified(selected.Geometry.Points); + DataEventPublisher.DataListModified(selected.Geometry.Curves); + DataEventPublisher.DataListModified(selected.Surfaces); + } + private void spatialEditor_ShapeRemoved(object sender, ShapeEventArgs e) { // if a CPT/Boring/Soilprofile Lookup is deleted, remove it from the project