set row visibility with common pattern
fixed scale not updating to % correctly issue: MatterHackers/MCCentral#4993 Scale object is not updating properties on change
This commit is contained in:
parent
23a162cf57
commit
b60cc5a7f0
8 changed files with 54 additions and 61 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set the visability of a property line item in the property editor
|
||||
/// </summary>
|
||||
/// <param name="editRowName"></param>
|
||||
/// <param name="change"></param>
|
||||
/// <param name="visible"></param>
|
||||
public void SetRowVisible(string editRowName, Func<bool> visible)
|
||||
{
|
||||
var editRow = this.Context.GetEditRow(editRowName);
|
||||
if (editRow != null)
|
||||
{
|
||||
editRow.Visible = visible.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface ITransformWarpperObject3D
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue