PageRenderTime 103ms CodeModel.GetById 61ms app.highlight 4ms RepoModel.GetById 36ms app.codeStats 0ms

/Scenes/Tests/BaseControlsTests.cs

#
C# | 120 lines | 54 code | 7 blank | 59 comment | 3 complexity | 5d646861bc888f9c5dcd9d53baf0894d MD5 | raw file
  1using Delta.Engine;
  2using Delta.InputSystem;
  3using Delta.Scenes.Enums;
  4using Delta.Scenes.UserInterfaces;
  5using Delta.Scenes.UserInterfaces.Controls;
  6using Delta.Scenes.UserInterfaces.Designs;
  7using Delta.Utilities.Datatypes;
  8using NUnit.Framework;
  9
 10namespace Delta.Scenes.Tests
 11{
 12	/// <summary>
 13	/// Base controls tests
 14	/// </summary>
 15	internal static class BaseControlsTests
 16	{
 17		#region Dragging (LongRunning)
 18		/// <summary>
 19		/// Dragging
 20		/// </summary>
 21		[Test, Category("Visual")]
 22		public static void Dragging()
 23		{
 24			Settings.Extra.LimitFramerateNumber = 30;
 25
 26			// Create our test scene
 27			Screen testScene = new Screen();
 28
 29			// a label as 
 30			Label dragLabel = new Label
 31			{
 32				LocalArea = new Rectangle(0.3f, 0.3f, 0.2f, 0.2f),
 33				CustomDesign = new TextControlDesign
 34				{
 35					Background = BaseTheme.GetUIMaterial(Color.Green),
 36					TextFont = Theme.Current.LabelDesign.TextFont,
 37				}
 38			};
 39
 40			bool isDragging = false;
 41			dragLabel.Dragging += delegate(BaseControl sender, DragState dragState,
 42				CommandTrigger input)
 43			{
 44				isDragging = dragState != DragState.DragEnd;
 45				if (dragState == DragState.DragMove)
 46				{
 47					sender.LocalArea = sender.LocalArea.Move(input.Movement);
 48				} // if
 49				input.IsHandled = true;
 50			};
 51			testScene.Add(dragLabel);
 52
 53			// Open now the scene to "activate" for the test
 54			testScene.Open();
 55
 56			// Finally start the test app
 57			Application.Start(delegate
 58			{
 59				// whereby we show the current mode in the text of the child label
 60				dragLabel.Text = "IsDragging=" + isDragging;
 61			});
 62		}
 63		#endregion
 64
 65		#region AnchorPoint
 66		/// <summary>
 67		/// Anchor point
 68		/// </summary>
 69		[Test]
 70		public static void AnchorPoint()
 71		{
 72	//	  // Create our test scene
 73	//	  UserScreen testScene = new UserScreen();
 74  //
 75	//	  // a normal label as a parent
 76	//	  Label parentLabel = new Label
 77	//	  {
 78	//	    LocalArea = new Rectangle(0.3f, 0.3f, 0.2f, 0.2f),
 79	//	    CustomDesign = new TextControlDesign
 80	//	    {
 81	//	      Background = UserTheme.GetUIMaterial(Color.Green),
 82	//	      TextFont = UserTheme.Current.LabelDesign.TextFont,
 83	//	    }
 84	//	  };
 85	//	  testScene.Add(parentLabel);
 86  //
 87	//	  // for the child control because without a parent the anchor point
 88	//	  // feature doesn't make sense and the scene root control has the mostly
 89	//	  // time a bigger area as is visible on the screen
 90	//	  Label childLabel = new Label
 91	//	  {
 92	//	    LocalArea = new Rectangle(0.05f, 0.03f, 0.05f, 0.05f),
 93	//	    CustomDesign = new TextControlDesign
 94	//	    {
 95	//	      Background = UserTheme.GetUIMaterial(Color.Yellow),
 96	//	      TextFont = UserTheme.Current.LabelDesign.TextFont,
 97	//	    }
 98	//	  };
 99	//	  parentLabel.Add(childLabel);
100//
101	//	  // Open now the scene to "activate" for the test
102	//	  testScene.Open();
103//
104	//	  // Finally start the test app
105	//	  Application.Start(delegate
106	//	  {
107	//	    // and allow toggle the anchor point modes by the "Space" key
108	//	    if (Input.Keyboard.SpaceReleased)
109	//	    {
110	//	      childLabel.AnchorPoint =
111	//	        EnumHelper.NextValue(childLabel.AnchorPoint);
112	//	    }
113//
114	//	    // whereby we show the current mode in the text of the (child)label
115	//	    childLabel.Text = "AnchorPoint." + childLabel.AnchorPoint;
116	//	  });
117		}
118		#endregion
119	}
120}