Text3D variable bindings.

This commit is contained in:
Michael Smith 2016-03-03 22:09:38 -08:00
parent 5726b63dec
commit 047a6472b1
2 changed files with 34 additions and 0 deletions

View File

@ -83,5 +83,19 @@ namespace OSCADSharp.UnitTests
Assert.IsTrue(script.Contains(String.Format("direction = {0}", direction.Name)));
Assert.IsTrue(script.Contains(String.Format("language = {0}", language.Name)));
}
[TestMethod]
public void Text_BindingConstructorAffectsOutput()
{
var text = new Variable("txt", "Greetings, Earthlings");
var size = new Variable("txtSize", 82);
var txt = new Text3D(text, size);
string script = txt.ToString();
Assert.IsTrue(script.Contains(String.Format("text(\"{0}\"", text.Name)));
Assert.IsTrue(script.Contains(String.Format("size = {0}", size.Name)));
}
}
}

View File

@ -69,6 +69,26 @@ namespace OSCADSharp.Solids
this.Text = text;
this.Size = size;
}
/// <summary>
/// Creates a 3d text object with pre-bound variables
/// </summary>
/// <param name="text"></param>
/// <param name="size"></param>
/// <param name="font"></param>
/// <param name="spacing"></param>
/// <param name="language"></param>
/// <param name="textdirection"></param>
public Text3D(Variable text = null, Variable size = null, Variable font = null,
Variable spacing = null, Variable language = null, Variable textdirection = null)
{
this.BindIfVariableNotNull("text", text);
this.BindIfVariableNotNull("size", size);
this.BindIfVariableNotNull("font", font);
this.BindIfVariableNotNull("spacing", spacing);
this.BindIfVariableNotNull("language", language);
this.BindIfVariableNotNull("textdirection", textdirection);
}
#endregion
#region Overrides