Control Name Property Delta Engine Documentation

Namespace: DeltaEngine.Scenes.Controls
Assembly: DeltaEngine.Scenes (in DeltaEngine.Scenes.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public string Name { get; set; }

Property Value

Type: String
Remarks

Tests: DeltaEngine.Scenes.Tests.Controls.ControlTests
Remarks

Tests: DeltaEngine.Scenes.Tests.Controls.ButtonTests
Examples

1 unit tests call DeltaEngine.Scenes.Controls.Control.Name
[Test]
public void EachControlShouldHaveAnUniqueName()
{
    var button1 = new Button(new Theme(), new Rectangle());
    Assert.IsTrue(button1.Name.StartsWith("Button"));
    var button2 = new Button(new Theme(), new Rectangle());
    Assert.IsTrue(button2.Name.StartsWith("Button"));
    Assert.AreNotEqual(button1.Name, button2.Name);
    var picture1 = new Picture(new Theme(),
        new Material(Color.Red, ShaderFlags.Position2DColored), new Rectangle());
    Assert.IsTrue(picture1.Name.StartsWith("Picture"));
}
Examples

2 unit tests call DeltaEngine.Scenes.Controls.Control.Name
[Test, CloseAfterFirstFrame]
public void DefaultNames()
{
    var button2 = new Button(Center, "Click Me");
    Assert.IsTrue(button.Name.StartsWith("Button"));
    Assert.IsTrue(button2.Name.StartsWith("Button"));
    Assert.Greater(int.Parse(button2.Name.Replace("Button", "")),
        int.Parse(button.Name.Replace("Button", "")));
}
[Test, CloseAfterFirstFrame]
public void SaveAndLoad()
{
    button.Name = "New Name";
    var stream = BinaryDataExtensions.SaveToMemoryStream(button);
    var loadedButton = (Button)stream.CreateFromMemoryStream();
    Assert.AreEqual(Center, loadedButton.DrawArea);
    Assert.AreEqual("Click Me", loadedButton.Text);
    Assert.AreEqual("New Name", loadedButton.Name);
}
See Also