Improving ShowUpdateButton api

This commit is contained in:
Lars Brubaker 2022-04-28 13:19:48 -07:00
parent 094324e645
commit cf5931d272
10 changed files with 13 additions and 12 deletions

View file

@ -34,11 +34,11 @@ namespace MatterHackers.MatterControl.DesignTools
[AttributeUsage(AttributeTargets.Class)]
public class ShowUpdateButtonAttribute : Attribute
{
public bool SuppressPropertyChangeUpdates { get; set; }
public bool Show { get; set; } = true;
public bool SuppressPropertyChangeUpdates { get; set; }
public ShowUpdateButtonAttribute(bool suppressPropertyChangeUpdates)
public ShowUpdateButtonAttribute()
{
SuppressPropertyChangeUpdates = suppressPropertyChangeUpdates;
}
}
}

View file

@ -44,7 +44,7 @@ using Newtonsoft.Json;
namespace MatterHackers.MatterControl.Plugins.Lithophane
{
[ShowUpdateButton(true)]
[ShowUpdateButton(SuppressPropertyChangeUpdates = true)]
public class LithophaneObject3D : Object3D
{
public LithophaneObject3D()

View file

@ -159,7 +159,8 @@ namespace MatterHackers.MatterControl.DesignTools
AddWebPageLinkIfRequired(context.item, mainContainer, theme);
// add in an Update button if applicable
if (context.item.GetType().GetCustomAttributes(typeof(ShowUpdateButtonAttribute), true).FirstOrDefault() is ShowUpdateButtonAttribute showUpdate)
var showUpdate = context.item.GetType().GetCustomAttributes(typeof(ShowUpdateButtonAttribute), true).FirstOrDefault() as ShowUpdateButtonAttribute;
if (showUpdate?.Show == true)
{
var updateButton = new TextButton("Update".Localize(), theme)
{

View file

@ -44,7 +44,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
[ShowUpdateButton(false)]
[ShowUpdateButton]
public class CombineObject3D_2 : OperationSourceContainerObject3D, IPropertyGridModifier, IBuildsOnThread
{
private CancellationTokenSource cancellationToken;

View file

@ -42,7 +42,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
[ShowUpdateButton(false)]
[ShowUpdateButton]
public class IntersectionObject3D_2 : OperationSourceContainerObject3D, IPropertyGridModifier
{
public IntersectionObject3D_2()

View file

@ -49,7 +49,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
[Obsolete("Use SubtractAndReplaceObject3D_2 instead", false)]
[ShowUpdateButton(true)]
[ShowUpdateButton(SuppressPropertyChangeUpdates = true)]
public class SubtractAndReplaceObject3D : MeshWrapperObject3D, ISelectableChildContainer
{
public SubtractAndReplaceObject3D()

View file

@ -45,7 +45,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
[ShowUpdateButton(false)]
[ShowUpdateButton]
public class SubtractAndReplaceObject3D_2 : OperationSourceContainerObject3D, ISelectableChildContainer, ICustomEditorDraw, IPropertyGridModifier
{
public SubtractAndReplaceObject3D_2()

View file

@ -47,7 +47,7 @@ using MatterHackers.PolygonMesh.Csg;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
[Obsolete("Use SubtractObject3D_2 instead", false)]
[ShowUpdateButton(true)]
[ShowUpdateButton(SuppressPropertyChangeUpdates = true)]
public class SubtractObject3D : MeshWrapperObject3D, ISelectableChildContainer
{
public SubtractObject3D()

View file

@ -44,7 +44,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.PartPreviewWindow.View3D
{
[ShowUpdateButton(false)]
[ShowUpdateButton]
public class SubtractObject3D_2 : OperationSourceContainerObject3D, ISelectableChildContainer, ICustomEditorDraw, IPropertyGridModifier, IBuildsOnThread
{
public SubtractObject3D_2()

@ -1 +1 @@
Subproject commit 9578a32e7032236c2ff7fc1a588c6d099eec333d
Subproject commit d318d70f3f2772d1b987a63291a1860c7dfc04f9