diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index 82b9c1144..d9da93fcb 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -361,7 +361,7 @@ namespace MatterHackers.MatterControl new SceneSelectionOperation() { TitleResolver = () => "Subtract & Replace".Localize(), - Action = (scene) => DoOpperation(scene, nameof(PaintMaterialEditor), "Subtract & Replace"), + Action = (scene) => DoOpperation(scene, nameof(SubtractAndReplace), "Subtract & Replace"), Icon = AggContext.StaticData.LoadIcon("paint.png").SetPreMultiply(), }, new SceneSelectionOperation() diff --git a/MatterControl.csproj b/MatterControl.csproj index 6157e16d1..808e9fe02 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -86,6 +86,7 @@ + @@ -140,7 +141,6 @@ - diff --git a/PartPreviewWindow/View3D/Actions/PaintMaterialEditor.cs b/PartPreviewWindow/View3D/Actions/SubtractAndReplace.cs similarity index 95% rename from PartPreviewWindow/View3D/Actions/PaintMaterialEditor.cs rename to PartPreviewWindow/View3D/Actions/SubtractAndReplace.cs index 439377276..f710753f4 100644 --- a/PartPreviewWindow/View3D/Actions/PaintMaterialEditor.cs +++ b/PartPreviewWindow/View3D/Actions/SubtractAndReplace.cs @@ -41,7 +41,7 @@ using MatterHackers.PolygonMesh; namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { #if DEBUG // keep this work in progress to the editor for now - public class PaintMaterialEditor : IObject3DEditor + public class SubtractAndReplace : IObject3DEditor { private MeshWrapperOperation group; private View3DWidget view3DWidget; @@ -93,7 +93,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { var children = group.Children.ToList(); - tabContainer.AddChild(new TextWidget("Set as Paint") + tabContainer.AddChild(new TextWidget("Set Replace") { TextColor = ActiveTheme.Instance.PrimaryTextColor, HAnchor = HAnchor.Left, @@ -104,7 +104,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D var updateButton = theme.ButtonFactory.Generate("Update".Localize()); updateButton.Margin = new BorderDouble(5); updateButton.HAnchor = HAnchor.Right; - updateButton.Enabled = false; // starts out disabled as there are no holes selected updateButton.Click += (s, e) => { // make sure the mesh on the group is not visible @@ -112,6 +111,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D ProcessBooleans(group); }; + int checkedCount = 0; List radioSiblings = new List(); for (int i = 0; i < children.Count; i++) { @@ -161,6 +161,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D }; tabContainer.AddChild(rowContainer); + checkedCount += checkBox.Checked ? 1 : 0; + } + + if(checkedCount == 0) // no items selected + { + // select the last item + if (tabContainer.Decendants().Where((d) => d is ICheckbox).Last() is ICheckbox firstCheckBox) + { + firstCheckBox.Checked = true; + } } // add this last so it is at the bottom diff --git a/PartPreviewWindow/View3D/Actions/SubtractEditor.cs b/PartPreviewWindow/View3D/Actions/SubtractEditor.cs index f17cdff3b..24a068d4f 100644 --- a/PartPreviewWindow/View3D/Actions/SubtractEditor.cs +++ b/PartPreviewWindow/View3D/Actions/SubtractEditor.cs @@ -58,7 +58,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D if (group is MeshWrapperOperation) { - AddHoleSelector(view3DWidget, mainContainer, theme); + AddSubtractSelector(view3DWidget, mainContainer, theme); } return mainContainer; @@ -69,11 +69,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D typeof(MeshWrapperOperation), }; - private void AddHoleSelector(View3DWidget view3DWidget, FlowLayoutWidget tabContainer, ThemeConfig theme) + private void AddSubtractSelector(View3DWidget view3DWidget, FlowLayoutWidget tabContainer, ThemeConfig theme) { var children = group.Children.ToList(); - tabContainer.AddChild(new TextWidget("Set as Hole") + tabContainer.AddChild(new TextWidget("Set Subtract") { TextColor = ActiveTheme.Instance.PrimaryTextColor, HAnchor = HAnchor.Left, @@ -84,7 +84,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D var updateButton = theme.ButtonFactory.Generate("Update".Localize()); updateButton.Margin = new BorderDouble(5); updateButton.HAnchor = HAnchor.Right; - updateButton.Enabled = false; // starts out disabled as there are no holes selected updateButton.Click += (s, e) => { // make sure the mesh on the group is not visible @@ -92,6 +91,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D ProcessBooleans(group); }; + int checkedCount = 0; List radioSiblings = new List(); for (int i = 0; i < children.Count; i++) { @@ -141,6 +141,16 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D }; tabContainer.AddChild(rowContainer); + checkedCount += checkBox.Checked ? 1 : 0; + } + + if (checkedCount == 0) // no items selected + { + // select the last item + if (tabContainer.Decendants().Where((d) => d is ICheckbox).Last() is ICheckbox firstCheckBox) + { + firstCheckBox.Checked = true; + } } // add this last so it is at the bottom diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 6151fbf50..65aa386c3 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 6151fbf50c3e657dc1e6c5059f8a9c12c1745d03 +Subproject commit 65aa386c3cd4aef5531c4c362031c340942a8ccb