PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/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
  1. using Delta.Engine;
  2. using Delta.InputSystem;
  3. using Delta.InputSystem.Devices;
  4. using Delta.Rendering.Basics.Fonts;
  5. using Delta.Rendering.Basics.Materials;
  6. using Delta.Scenes.UserInterfaces;
  7. using Delta.Scenes.UserInterfaces.Controls;
  8. using Delta.Scenes.UserInterfaces.Designs;
  9. using Delta.Utilities.Datatypes;
  10. using NUnit.Framework;
  11. namespace Delta.Scenes.Tests
  12. {
  13. /// <summary>
  14. /// Bordered design tests
  15. /// </summary>
  16. internal class BorderedDesignTests
  17. {
  18. #region DisplayImage (LongRunning)
  19. /// <summary>
  20. /// Display image
  21. /// </summary>
  22. [Test, Category("Visual")]
  23. public static void DisplayImage()
  24. {
  25. Image testImage = new Image
  26. {
  27. LocalArea = new Rectangle(0.25f, 0.25f, 0.5f, 0.5f),
  28. CustomDesign = new BorderedControlDesign
  29. {
  30. Background = new Material2DColored("DefaultButtonBackground"),
  31. BorderWidth = 0.03f,
  32. },
  33. };
  34. Screen testScene = new Screen();
  35. testScene.Add(testImage);
  36. // Open now the scene to "activate" for the test
  37. testScene.Open();
  38. // We just call here the "StartTest()" to display the image, but we
  39. // don't need to call the "Image.Draw()" explicitely, bacause this
  40. // already handled automatically by the UI manager
  41. Application.Start(delegate
  42. {
  43. BaseMouse mouse = Input.Mouse;
  44. if (Input.Gestures.IsHorizontalDrag ||
  45. Input.Gestures.IsVerticalDrag)
  46. {
  47. testImage.Size = new Size(testImage.Size.Width + mouse.Movement.X,
  48. testImage.Size.Height + mouse.Movement.Y);
  49. } // if
  50. });
  51. }
  52. #endregion
  53. #region DisplayLabel (LongRunning)
  54. /// <summary>
  55. /// Display label
  56. /// </summary>
  57. [Test, Category("Visual")]
  58. public static void DisplayLabel()
  59. {
  60. Screen testScene = new Screen();
  61. Label testLabel = new Label
  62. {
  63. LocalArea = new Rectangle(0.25f, 0.25f, 0.5f, 0.5f),
  64. CustomDesign = new BorderedTextControlDesign
  65. {
  66. Background = new Material2DColored("DefaultButtonBackground"),
  67. BorderWidth = 0.03f,
  68. TextFont = new Font(Font.Default, Color.Red),
  69. },
  70. Text = "A text for that bordered label.",
  71. };
  72. testScene.Add(testLabel);
  73. // Open now the scene to "activate" for the test
  74. testScene.Open();
  75. // We just call here the "StartTest()" to display the image, but we
  76. // don't need to call the "Image.Draw()" explicitely, bacause this
  77. // already handled automatically by the UI manager
  78. Application.Start(delegate
  79. {
  80. BaseMouse mouse = Input.Mouse;
  81. if (Input.Gestures.IsHorizontalDrag ||
  82. Input.Gestures.IsVerticalDrag)
  83. {
  84. testLabel.Size = new Size(testLabel.Size.Width + mouse.Movement.X,
  85. testLabel.Size.Height + mouse.Movement.Y);
  86. } // if
  87. });
  88. }
  89. #endregion
  90. }
  91. }