diff --git a/MatterControlLib/DesignTools/Interfaces/IPropertyGridModifier.cs b/MatterControlLib/DesignTools/Interfaces/IPropertyGridModifier.cs
index 213e62db2..03930ccf1 100644
--- a/MatterControlLib/DesignTools/Interfaces/IPropertyGridModifier.cs
+++ b/MatterControlLib/DesignTools/Interfaces/IPropertyGridModifier.cs
@@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
using MatterHackers.Agg.UI;
using MatterHackers.DataConverters3D;
using MatterHackers.MatterControl.PartPreviewWindow;
+using System;
using System.Collections.Generic;
namespace MatterHackers.MatterControl.DesignTools
@@ -61,6 +62,22 @@ namespace MatterHackers.MatterControl.DesignTools
this.Context = pPEContext;
this.Changed = propertyChanged;
}
+
+
+ ///
+ /// Set the visability of a property line item in the property editor
+ ///
+ ///
+ ///
+ ///
+ public void SetRowVisible(string editRowName, Func visible)
+ {
+ var editRow = this.Context.GetEditRow(editRowName);
+ if (editRow != null)
+ {
+ editRow.Visible = visible.Invoke();
+ }
+ }
}
public interface ITransformWarpperObject3D
diff --git a/MatterControlLib/DesignTools/Obsolete/FitToBoundsObject3D.cs b/MatterControlLib/DesignTools/Obsolete/FitToBoundsObject3D.cs
index 32de74918..0748062a8 100644
--- a/MatterControlLib/DesignTools/Obsolete/FitToBoundsObject3D.cs
+++ b/MatterControlLib/DesignTools/Obsolete/FitToBoundsObject3D.cs
@@ -272,18 +272,12 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
public void UpdateControls(PublicPropertyChange change)
{
- var editRow = change.Context.GetEditRow(nameof(Diameter));
- if(editRow != null) editRow.Visible = FitType != FitType.Box;
- editRow = change.Context.GetEditRow(nameof(Width));
- if (editRow != null) editRow.Visible = FitType == FitType.Box;
- editRow = change.Context.GetEditRow(nameof(Depth));
- if (editRow != null) editRow.Visible = FitType == FitType.Box;
- editRow = change.Context.GetEditRow(nameof(MaintainRatio));
- if (editRow != null) editRow.Visible = FitType == FitType.Box;
- editRow = change.Context.GetEditRow(nameof(StretchX));
- if (editRow != null) editRow.Visible = FitType == FitType.Box;
- editRow = change.Context.GetEditRow(nameof(StretchY));
- if (editRow != null) editRow.Visible = FitType == FitType.Box;
+ change.SetRowVisible(nameof(Diameter), () => FitType != FitType.Box);
+ change.SetRowVisible(nameof(Width), () => FitType != FitType.Box);
+ change.SetRowVisible(nameof(Depth), () => FitType != FitType.Box);
+ change.SetRowVisible(nameof(MaintainRatio), () => FitType != FitType.Box);
+ change.SetRowVisible(nameof(StretchX), () => FitType != FitType.Box);
+ change.SetRowVisible(nameof(StretchY), () => FitType != FitType.Box);
}
}
}
\ No newline at end of file
diff --git a/MatterControlLib/DesignTools/Operations/AlignObject3D.cs b/MatterControlLib/DesignTools/Operations/AlignObject3D.cs
index 1134ff803..fb88e2597 100644
--- a/MatterControlLib/DesignTools/Operations/AlignObject3D.cs
+++ b/MatterControlLib/DesignTools/Operations/AlignObject3D.cs
@@ -443,18 +443,12 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
public void UpdateControls(PublicPropertyChange change)
{
- var editRow = change.Context.GetEditRow(nameof(XAlignTo));
- if (editRow != null) editRow.Visible = Advanced;
- editRow = change.Context.GetEditRow(nameof(XOffset));
- if (editRow != null) editRow.Visible = Advanced;
- editRow = change.Context.GetEditRow(nameof(YAlignTo));
- if (editRow != null) editRow.Visible = Advanced;
- editRow = change.Context.GetEditRow(nameof(YOffset));
- if (editRow != null) editRow.Visible = Advanced;
- editRow = change.Context.GetEditRow(nameof(ZAlignTo));
- if (editRow != null) editRow.Visible = Advanced;
- editRow = change.Context.GetEditRow(nameof(ZOffset));
- if (editRow != null) editRow.Visible = Advanced;
+ change.SetRowVisible(nameof(XAlignTo), () => Advanced);
+ change.SetRowVisible(nameof(XOffset), () => Advanced);
+ change.SetRowVisible(nameof(YAlignTo), () => Advanced);
+ change.SetRowVisible(nameof(YOffset), () => Advanced);
+ change.SetRowVisible(nameof(ZAlignTo), () => Advanced);
+ change.SetRowVisible(nameof(ZOffset), () => Advanced);
}
private static bool IsSet(FaceAlign variableToCheck, FaceAlign faceToCheckFor, FaceAlign faceToAssertNot)
diff --git a/MatterControlLib/DesignTools/Operations/ScaleObject3D.cs b/MatterControlLib/DesignTools/Operations/ScaleObject3D.cs
index 384a8e082..0ff416c38 100644
--- a/MatterControlLib/DesignTools/Operations/ScaleObject3D.cs
+++ b/MatterControlLib/DesignTools/Operations/ScaleObject3D.cs
@@ -224,19 +224,12 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
public void UpdateControls(PublicPropertyChange change)
{
- var editRow = change.Context.GetEditRow(nameof(SizeX));
- if (editRow != null) editRow.Visible = Operation == ScaleType.Specify;
- editRow = change.Context.GetEditRow(nameof(SizeY));
- if (editRow != null) editRow.Visible = Operation == ScaleType.Specify;
- editRow = change.Context.GetEditRow(nameof(SizeZ));
- if (editRow != null) editRow.Visible = Operation == ScaleType.Specify;
-
- editRow = change.Context.GetEditRow(nameof(MaitainProportions));
- if (editRow != null) editRow.Visible = Operation == ScaleType.Specify;
- editRow = change.Context.GetEditRow(nameof(UsePercentage));
- if (editRow != null) editRow.Visible = Operation == ScaleType.Specify;
- editRow = change.Context.GetEditRow(nameof(ScaleAbout));
- if (editRow != null) editRow.Visible = Operation == ScaleType.Specify;
+ change.SetRowVisible(nameof(SizeX), () => Operation == ScaleType.Specify);
+ change.SetRowVisible(nameof(SizeY), () => Operation == ScaleType.Specify);
+ change.SetRowVisible(nameof(SizeZ), () => Operation == ScaleType.Specify);
+ change.SetRowVisible(nameof(MaitainProportions), () => Operation == ScaleType.Specify);
+ change.SetRowVisible(nameof(UsePercentage), () => Operation == ScaleType.Specify);
+ change.SetRowVisible(nameof(ScaleAbout), () => Operation == ScaleType.Specify);
if(change.Changed == nameof(Operation))
{
@@ -263,7 +256,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
else if(change.Changed == nameof(UsePercentage))
{
// make sure we update the controls on screen to reflect the different data type
- Invalidate(InvalidateType.Properties);
+ Invalidate(new InvalidateArgs(null, InvalidateType.Properties));
}
else if (change.Changed == nameof(MaitainProportions))
{
@@ -272,6 +265,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
var maxScale = Math.Max(ScaleRatio.X, Math.Max(ScaleRatio.Y, ScaleRatio.Z));
ScaleRatio = new Vector3(maxScale, maxScale, maxScale);
Rebuild();
+ // make sure we update the controls on screen to reflect the different data type
+ Invalidate(new InvalidateArgs(null, InvalidateType.Properties));
}
}
else if (change.Changed == nameof(SizeX))
@@ -281,7 +276,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
// scale y and z to match
ScaleRatio[1] = ScaleRatio[0];
ScaleRatio[2] = ScaleRatio[0];
- Rebuild();
+ // and invalidate the other properties
+ Invalidate(new InvalidateArgs(null, InvalidateType.Properties));
}
}
else if (change.Changed == nameof(SizeY))
@@ -291,7 +287,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
// scale y and z to match
ScaleRatio[0] = ScaleRatio[1];
ScaleRatio[2] = ScaleRatio[1];
- Rebuild();
+ // and invalidate the other properties
+ Invalidate(new InvalidateArgs(null, InvalidateType.Properties));
}
}
else if (change.Changed == nameof(SizeZ))
@@ -301,7 +298,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
// scale y and z to match
ScaleRatio[0] = ScaleRatio[2];
ScaleRatio[1] = ScaleRatio[2];
- Rebuild();
+ // and invalidate the other properties
+ Invalidate(new InvalidateArgs(null, InvalidateType.Properties));
}
}
}
diff --git a/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs b/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs
index 29f017a07..4c779993d 100644
--- a/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs
+++ b/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs
@@ -324,8 +324,7 @@ namespace MatterHackers.MatterControl.DesignTools
public void UpdateControls(PublicPropertyChange change)
{
- //var editRow = context.GetEditRow((this.ID, nameof(InfillAmount)));
- //if (editRow != null) editRow.Visible = CurrentBaseType == BaseTypes.Outline;
+ //change.SetRowVisible(nameof(InfillAmount), () => CurrentBaseType == BaseTypes.Outline);
}
}
}
\ No newline at end of file
diff --git a/MatterControlLib/DesignTools/Primitives/RingObject3D.cs b/MatterControlLib/DesignTools/Primitives/RingObject3D.cs
index 80a7da218..1972207e1 100644
--- a/MatterControlLib/DesignTools/Primitives/RingObject3D.cs
+++ b/MatterControlLib/DesignTools/Primitives/RingObject3D.cs
@@ -136,10 +136,8 @@ namespace MatterHackers.MatterControl.DesignTools
public void UpdateControls(PublicPropertyChange change)
{
- var editRow = change.Context.GetEditRow(nameof(StartingAngle));
- if (editRow != null) editRow.Visible = Advanced;
- editRow = change.Context.GetEditRow(nameof(EndingAngle));
- if (editRow != null) editRow.Visible = Advanced;
+ change.SetRowVisible(nameof(StartingAngle), () => Advanced);
+ change.SetRowVisible(nameof(EndingAngle), () => Advanced);
}
}
}
\ No newline at end of file
diff --git a/MatterControlLib/DesignTools/Primitives/SphereObject3D.cs b/MatterControlLib/DesignTools/Primitives/SphereObject3D.cs
index 2b49ec98b..32766b0c8 100644
--- a/MatterControlLib/DesignTools/Primitives/SphereObject3D.cs
+++ b/MatterControlLib/DesignTools/Primitives/SphereObject3D.cs
@@ -140,12 +140,9 @@ namespace MatterHackers.MatterControl.DesignTools
public void UpdateControls(PublicPropertyChange change)
{
- var editRow = change.Context.GetEditRow(nameof(StartingAngle));
- if (editRow != null) editRow.Visible = Advanced;
- editRow = change.Context.GetEditRow(nameof(EndingAngle));
- if (editRow != null) editRow.Visible = Advanced;
- editRow = change.Context.GetEditRow(nameof(LatitudeSides));
- if (editRow != null) editRow.Visible = Advanced;
+ change.SetRowVisible(nameof(StartingAngle), () => Advanced);
+ change.SetRowVisible(nameof(EndingAngle), () => Advanced);
+ change.SetRowVisible(nameof(LatitudeSides), () => Advanced);
}
}
}
\ No newline at end of file
diff --git a/MatterControlLib/DesignTools/Primitives/TorusObject3D.cs b/MatterControlLib/DesignTools/Primitives/TorusObject3D.cs
index d4140b3e6..d467a1650 100644
--- a/MatterControlLib/DesignTools/Primitives/TorusObject3D.cs
+++ b/MatterControlLib/DesignTools/Primitives/TorusObject3D.cs
@@ -136,14 +136,10 @@ namespace MatterHackers.MatterControl.DesignTools
public void UpdateControls(PublicPropertyChange change)
{
- var editRow = change.Context.GetEditRow(nameof(StartingAngle));
- if (editRow != null) editRow.Visible = Advanced;
- editRow = change.Context.GetEditRow(nameof(EndingAngle));
- if (editRow != null) editRow.Visible = Advanced;
- editRow = change.Context.GetEditRow(nameof(RingSides));
- if (editRow != null) editRow.Visible = Advanced;
- editRow = change.Context.GetEditRow(nameof(RingPhaseAngle));
- if (editRow != null) editRow.Visible = Advanced;
+ change.SetRowVisible(nameof(StartingAngle), () => Advanced);
+ change.SetRowVisible(nameof(EndingAngle), () => Advanced);
+ change.SetRowVisible(nameof(RingSides), () => Advanced);
+ change.SetRowVisible(nameof(RingPhaseAngle), () => Advanced);
}
}
}
\ No newline at end of file