/Scenes/Tests/BorderedDesignTests.cs
C# | 99 lines | 74 code | 8 blank | 17 comment | 2 complexity | bcc9cf661bc76db2286b6ce3b3f7d00a MD5 | raw file
Possible License(s): Apache-2.0
- using Delta.Engine;
- using Delta.InputSystem;
- using Delta.InputSystem.Devices;
- using Delta.Rendering.Basics.Fonts;
- using Delta.Rendering.Basics.Materials;
- using Delta.Scenes.UserInterfaces;
- using Delta.Scenes.UserInterfaces.Controls;
- using Delta.Scenes.UserInterfaces.Designs;
- using Delta.Utilities.Datatypes;
- using NUnit.Framework;
-
- namespace Delta.Scenes.Tests
- {
- /// <summary>
- /// Bordered design tests
- /// </summary>
- internal class BorderedDesignTests
- {
- #region DisplayImage (LongRunning)
- /// <summary>
- /// Display image
- /// </summary>
- [Test, Category("Visual")]
- public static void DisplayImage()
- {
- Image testImage = new Image
- {
- LocalArea = new Rectangle(0.25f, 0.25f, 0.5f, 0.5f),
- CustomDesign = new BorderedControlDesign
- {
- Background = new Material2DColored("DefaultButtonBackground"),
- BorderWidth = 0.03f,
- },
- };
-
- Screen testScene = new Screen();
- testScene.Add(testImage);
-
- // Open now the scene to "activate" for the test
- testScene.Open();
-
- // We just call here the "StartTest()" to display the image, but we
- // don't need to call the "Image.Draw()" explicitely, bacause this
- // already handled automatically by the UI manager
- Application.Start(delegate
- {
- BaseMouse mouse = Input.Mouse;
- if (Input.Gestures.IsHorizontalDrag ||
- Input.Gestures.IsVerticalDrag)
- {
- testImage.Size = new Size(testImage.Size.Width + mouse.Movement.X,
- testImage.Size.Height + mouse.Movement.Y);
- } // if
- });
- }
- #endregion
-
- #region DisplayLabel (LongRunning)
- /// <summary>
- /// Display label
- /// </summary>
- [Test, Category("Visual")]
- public static void DisplayLabel()
- {
- Screen testScene = new Screen();
-
- Label testLabel = new Label
- {
- LocalArea = new Rectangle(0.25f, 0.25f, 0.5f, 0.5f),
- CustomDesign = new BorderedTextControlDesign
- {
- Background = new Material2DColored("DefaultButtonBackground"),
- BorderWidth = 0.03f,
- TextFont = new Font(Font.Default, Color.Red),
- },
- Text = "A text for that bordered label.",
- };
- testScene.Add(testLabel);
-
- // Open now the scene to "activate" for the test
- testScene.Open();
-
- // We just call here the "StartTest()" to display the image, but we
- // don't need to call the "Image.Draw()" explicitely, bacause this
- // already handled automatically by the UI manager
- Application.Start(delegate
- {
- BaseMouse mouse = Input.Mouse;
- if (Input.Gestures.IsHorizontalDrag ||
- Input.Gestures.IsVerticalDrag)
- {
- testLabel.Size = new Size(testLabel.Size.Width + mouse.Movement.X,
- testLabel.Size.Height + mouse.Movement.Y);
- } // if
- });
- }
- #endregion
- }
- }