PageRenderTime 183ms CodeModel.GetById 101ms app.highlight 5ms RepoModel.GetById 75ms app.codeStats 0ms

/Scenes/Tests/UIThemeTests.cs

#
C# | 126 lines | 97 code | 13 blank | 16 comment | 0 complexity | a07b39c48d8cdd9a4929449215b69b20 MD5 | raw file
  1using Delta.Engine;
  2using Delta.Rendering.Basics.Fonts;
  3using Delta.Scenes.UserInterfaces;
  4using Delta.Scenes.UserInterfaces.Controls;
  5using Delta.Scenes.UserInterfaces.Designs;
  6using Delta.Utilities.Datatypes;
  7using NUnit.Framework;
  8
  9namespace Delta.Scenes.Tests
 10{
 11	/// <summary>
 12	/// UITheme tests
 13	/// </summary>
 14	public class UIThemeTests
 15	{
 16		#region CreateRedTheme (LongRunning)
 17		/// <summary>
 18		/// Create red theme
 19		/// </summary>
 20		[Test, Category("Visual")]
 21		private static Theme CreateRedTheme()
 22		{
 23			Theme redTheme = new Theme("<RedTheme>")
 24			{
 25				#region Label design
 26				LabelDesign = new TextControlDesign
 27				{
 28					Background = BaseTheme.GetUIMaterial("Panel"),
 29					Hover = BaseTheme.GetUIMaterial("Panel", BaseTheme.DefaultHoverColor),
 30					TextFont = new Font(Font.Default, BaseTheme.DefaultTextColor),
 31				},
 32				#endregion
 33
 34				#region Button design
 35				ButtonDesign = new TextControlDesign
 36				{
 37					Background = BaseTheme.GetUIMaterial("ButtonBackground"),
 38					Hover = BaseTheme.GetUIMaterial("ButtonHover",
 39						BaseTheme.DefaultHoverColor),
 40					TextFont = new Font(Font.Default, BaseTheme.DefaultTextColor),
 41					Pressed = BaseTheme.GetUIMaterial("ButtonPressed",
 42						BaseTheme.DefaultHoverColor),
 43				},
 44				#endregion
 45
 46				#region Checkbox design
 47				CheckboxDesign = new CheckboxDesign
 48				{
 49					TextBackground = BaseTheme.GetUIMaterial("Panel"),
 50					UncheckedSymbol = BaseTheme.GetUIMaterial("CheckboxOff"),
 51					CheckedSymbol = BaseTheme.GetUIMaterial("CheckboxOn"),
 52					UncheckedSymbolHover = BaseTheme.GetUIMaterial("CheckboxOffHover"),
 53					CheckedSymbolHover = BaseTheme.GetUIMaterial("CheckboxOnHover"),
 54					TextFont = new Font(Font.Default, BaseTheme.DefaultTextColor),
 55				},
 56				#endregion
 57
 58				#region Slider design
 59				SliderDesign = new SliderDesign
 60				{
 61					// Finally we normally don't need a background, because we have
 62					// the "TrackerbarDesign" instead for it (for the moment)
 63					Trackerbar = BaseTheme.GetUIMaterial("SliderBackground"),
 64					Tracker = BaseTheme.GetUIMaterial("Slider"),
 65					Hover = BaseTheme.GetUIMaterial("SliderHover"),
 66					TextFont = new Font(Font.Default, BaseTheme.DefaultTextColor),
 67				},
 68				#endregion
 69			};
 70
 71			return redTheme;
 72		}
 73		#endregion
 74
 75		#region RedTheme (LongRunning)
 76		/// <summary>
 77		/// Red theme
 78		/// </summary>
 79		[Test, Category("Visual")]
 80		public static void RedTheme()
 81		{
 82			// Our UI scene which manages our controls
 83			Screen testScene = new Screen();
 84
 85			Label testLabel = new Label
 86			{
 87				LocalArea = Rectangle.FromCenter(0.25f, 0.35f, 0.08f, 0.02f),
 88				Text = "RedLabel",
 89			};
 90			testScene.Add(testLabel);
 91
 92			Button testButton = new Button
 93			{
 94				LocalArea = Rectangle.FromCenter(0.75f, 0.35f, 0.25f, 0.1f),
 95				Text = "RedButton",
 96			};
 97			testScene.Add(testButton);
 98
 99			Checkbox testCheckbox = new Checkbox
100			{
101				LocalArea = Rectangle.FromCenter(0.25f, 0.65f, 0.4f, 0.05f),
102				Text = "RedCheckbox",
103				IsChecked = true,
104			};
105			testScene.Add(testCheckbox);
106
107			Slider testSlider = new Slider
108			{
109				LocalArea = Rectangle.FromCenter(0.75f, 0.65f, 0.4f, 0.05f),
110				Text = "RedSlider",
111			};
112			testScene.Add(testSlider);
113
114			Theme.Current = CreateRedTheme();
115
116			// Open now the scene to "activate" for the test
117			testScene.Open();
118
119			// We just call here the "StartTest()" to display the image, but we
120			// don't need to call the "Image.Draw()" explicitely, because this
121			// already handled automatically by the UI manager
122			Application.Start();
123		}
124		#endregion
125	}
126}