Preserving single line mode of TextObject3D (multi line is option)
This commit is contained in:
parent
365a84327b
commit
40b89ecc4b
4 changed files with 61 additions and 20 deletions
|
|
@ -49,7 +49,7 @@ using Newtonsoft.Json.Converters;
|
|||
namespace MatterHackers.MatterControl.DesignTools
|
||||
{
|
||||
[HideChildrenFromTreeView]
|
||||
public class TextObject3D : Object3D
|
||||
public class TextObject3D : Object3D, IPropertyGridModifier
|
||||
{
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum TextAlign
|
||||
|
|
@ -80,6 +80,12 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
[DisplayName("Text")]
|
||||
public StringOrExpression NameToWrite { get; set; } = "Text";
|
||||
|
||||
[MultiLineEdit]
|
||||
[DisplayName("Text")]
|
||||
public StringOrExpression MultiLineText { get; set; } = "MultiLine\nText";
|
||||
|
||||
public bool MultiLine { get; set; }
|
||||
|
||||
[Slider(1, 48, snapDistance: 1)]
|
||||
public DoubleOrExpression PointSize { get; set; } = 24;
|
||||
|
||||
|
|
@ -145,7 +151,7 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
{
|
||||
bool valuesChanged = false;
|
||||
var height = Height.ClampIfNotCalculated(this, .01, 1000000, ref valuesChanged);
|
||||
var nameToWrite = NameToWrite.Value(this).Replace("\\n", "\n").Replace("\r", "\n").Replace("\n\n", "\n");
|
||||
var nameToWrite = MultiLine ? MultiLineText.Value(this).Replace("\\n", "\n").Replace("\r", "\n").Replace("\n\n", "\n") : NameToWrite.Value(this);
|
||||
if (string.IsNullOrWhiteSpace(nameToWrite))
|
||||
{
|
||||
Mesh = PlatonicSolids.CreateCube(20, 10, height);
|
||||
|
|
@ -271,5 +277,12 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateControls(PublicPropertyChange change)
|
||||
{
|
||||
change.SetRowVisible(nameof(MultiLineText), () => MultiLine);
|
||||
change.SetRowVisible(nameof(Alignment), () => MultiLine);
|
||||
change.SetRowVisible(nameof(NameToWrite), () => !MultiLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue