PageRenderTime 26ms CodeModel.GetById 21ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Scenes/Tests/BorderedDesignTests.cs

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