PageRenderTime 47ms CodeModel.GetById 31ms app.highlight 10ms RepoModel.GetById 2ms app.codeStats 0ms

/Scenes/UserInterfaces/Controls/Label.cs

#
C# | 907 lines | 455 code | 98 blank | 354 comment | 25 complexity | ca64271f95c50e3fc365232addecd217 MD5 | raw file
  1using System;
  2using System.ComponentModel;
  3using System.IO;
  4using Delta.Engine;
  5using Delta.Engine.SettingsNodes;
  6using Delta.InputSystem;
  7using Delta.Rendering.Basics.Drawing;
  8using Delta.Rendering.Basics.Fonts;
  9using Delta.Scenes.Enums;
 10using Delta.Scenes.UserInterfaces.Designs;
 11using Delta.Utilities;
 12using Delta.Utilities.Datatypes;
 13using Delta.Utilities.Datatypes.Advanced;
 14using Delta.Utilities.Helpers;
 15using NUnit.Framework;
 16using Delta.ContentSystem.Xml;
 17
 18namespace Delta.Scenes.UserInterfaces.Controls
 19{
 20	/// <summary>
 21	/// This is a simple label control for displaying (read-only) text on a
 22	/// screen.
 23	/// </summary>
 24	public class Label : BaseControl
 25	{
 26		#region Constants
 27		/// <summary>
 28		/// The current version of the implementation of this control class.
 29		/// </summary>
 30		private const int VersionNumber = 1;
 31
 32		private const string TextElementName = "Label.TextContent";
 33		#endregion
 34
 35		#region Delegates
 36		/// <summary>
 37		/// The delegate declaration for the text changed event.
 38		/// </summary>
 39		/// <param name="sender">Sender</param>
 40		public delegate void TextChangedEvent(Label sender);
 41		#endregion
 42
 43		#region Text (Public)
 44		/// <summary>
 45		/// Text to display on this label.
 46		/// </summary>
 47		private string text;
 48		/// <summary>
 49		/// The displayed text, will be localized automatically (make sure you have
 50		/// an entry for this in your Localization.xml content file).
 51		/// </summary>
 52		[Browsable(true)]
 53		public string Text
 54		{
 55			get
 56			{
 57				return text;
 58			}
 59			set
 60			{
 61				// Note: If Localization.WarnIfLanguageKeyWasNotFound is on this might
 62				// produce warnings for text entries not found as language keys.
 63				text =
 64					String.IsNullOrEmpty(value)
 65						? value
 66						: Localization.Get(value);
 67			}
 68		}
 69		#endregion
 70
 71		#region TextContentElement (Public)
 72		/// <summary>
 73		/// The content element which 
 74		/// </summary>
 75		/// <returns>Dockable element</returns>
 76		public AlignableElement TextContentElement
 77		{
 78			get;
 79			set;
 80		}
 81		#endregion
 82
 83		#region IsTextElementAutoSizing
 84		/// <summary>
 85		/// Indicates if the TextContentElement applies the same size as the Label
 86		/// every time the size of this Label changes
 87		/// <para />
 88		/// Note: Default is 'true'.
 89		/// </summary>
 90		public bool IsTextElementAutoSizing
 91		{
 92			get;
 93			set;
 94		}
 95		#endregion
 96
 97		#region TextDrawArea (Public)
 98		/// <summary>
 99		/// Text draw area
100		/// </summary>
101		public Rectangle TextDrawArea
102		{
103			get
104			{
105				return TextContentElement.DrawArea;
106			} // get
107		}
108		#endregion
109
110		#region Protected
111
112		#region FallbackDesign (Protected)
113		/// <summary>
114		/// Defines the theme which will be used if no "Theme" was set explicitely.
115		/// </summary>
116		protected override ControlDesign FallbackDesign
117		{
118			get
119			{
120				return Theme.Current.LabelDesign;
121			} // get
122		}
123		#endregion
124
125		#region TextFont (Protected)
126		/// <summary>
127		/// The font which is used to displaying the text.
128		/// </summary>
129		/// <remarks>
130		/// This value get updated everytime the design of the Label changes.
131		/// </remarks>
132		/// <returns>Font</returns>
133		protected Font TextFont
134		{
135			get
136			{
137				// If we want to use the font right now but there is no valid one yet
138				// then we just use the Engine fallback font
139				return (labelDesign != null)
140								? labelDesign.TextFont
141								: Font.Default;
142			} // get
143		}
144		#endregion
145
146		#endregion
147
148		#region Private
149
150		#region lastText (Private)
151		/// <summary>
152		/// The last set text of this element which is used to "detect" text
153		/// changes of the element by the user.
154		/// </summary>
155		private string lastText;
156		#endregion
157
158		#region labelDesign (Private)
159		/// <summary>
160		/// Label design
161		/// </summary>
162		private ITextDesign labelDesign;
163		#endregion
164
165		#endregion
166
167		#region Constructors
168		/// <summary>
169		/// Create label
170		/// </summary>
171		public Label()
172		{
173			TextContentElement = new AlignableElement
174			{
175				Name = TextElementName,
176			};
177			Add(TextContentElement);
178
179			IsTextElementAutoSizing = true;
180		}
181		#endregion
182
183		#region TextChanged (Event)
184		/// <summary>
185		/// Occurs every time the text of the label will be changed.
186		/// </summary>
187		public event TextChangedEvent TextChanged;
188		#endregion
189
190		#region Save (Public)
191		/// <summary>
192		/// Saves all data which are necessary to restore the object again.
193		/// </summary>
194		/// <param name="dataWriter">
195		/// The writer which contains the stream where the data should be saved
196		/// into now.
197		/// </param>
198		public override void Save(BinaryWriter dataWriter)
199		{
200			// At first we write the data of the base class
201			base.Save(dataWriter);
202
203			// and then save the version of the current data format
204			dataWriter.Write(VersionNumber);
205
206			// before we can finally save the properties
207			Text.Save(dataWriter);
208		}
209		#endregion
210
211		#region Load (Public)
212		/// <summary>
213		/// Loads and restores all previously saved values that belongs to this
214		/// class only from the given data reader.
215		/// </summary>
216		/// <param name="dataReader">
217		/// The reader which contains the stream with the saved data which needs to
218		/// be loaded now.
219		/// </param>
220		public override void Load(BinaryReader dataReader)
221		{
222			// We have to remove the automatically created text area element because
223			// we will load (and create) it by the saved data, but still remember it
224			// to have the chance to restore it again in the case we will get an
225			// error while loading
226			AlignableElement orgTextAreaElement = TextContentElement;
227			Remove(TextContentElement);
228			TextContentElement = null;
229
230			// At first we need to load all data of the base class
231			base.Load(dataReader);
232
233			// and then check which version of the data need to load now
234			int version = dataReader.ReadInt32();
235			switch (version)
236			{
237				// Version 1
238				case VersionNumber:
239					Text = dataReader.ReadString();
240
241					// Look for the text area element we have to re-reference
242					foreach (AlignableElement child in Children)
243					{
244						if (child.Name == TextElementName)
245						{
246							// we have found it, so reference it
247							TextContentElement = child;
248							// and finally dispose the old element
249							orgTextAreaElement.Dispose();
250							break;
251						} // if
252					} // foreach
253
254					// If something went wrong
255					if (TextContentElement == null)
256					{
257						// notify the user
258						Log.Warning("The text area element couldn't be loaded.");
259						// and restore the old element
260						TextContentElement = orgTextAreaElement;
261						Add(TextContentElement);
262					} // if
263					break;
264
265				default:
266					Log.InvalidVersionWarning(GetType().Name, version, VersionNumber);
267					break;
268			} // switch
269		}
270		#endregion
271
272		#region Methods (Private)
273
274		#region OnSizeChanging
275		/// <summary>
276		/// On size changing
277		/// </summary>
278		/// <param name="oldSize">Old size</param>
279		/// <returns>
280		/// 'True' if the new value can be used or 'false' if the change should be
281		/// aborted.
282		/// </returns>
283		protected override bool OnSizeChanging(Size oldSize)
284		{
285			if (base.OnSizeChanging(oldSize))
286			{
287				if (IsTextElementAutoSizing)
288				{
289					TextContentElement.Size = Size;
290				} // if
291
292				return true;
293			} // if
294
295			return false;
296		}
297		#endregion
298
299		#region OnDesignChanging
300		/// <summary>
301		/// On design changed
302		/// </summary>
303		/// <param name="oldDesign">Old design</param>
304		/// <returns>
305		/// 'True' if the new value can be used or 'false' if the change should be
306		/// aborted.
307		/// </returns>
308		protected override bool OnDesignChanging(ControlDesign oldDesign)
309		{
310			if (base.OnDesignChanging(oldDesign))
311			{
312				// Check if the new design is a valid 'TextControlDesign' but
313				// Note: Even 'null' will be accepted and handled here
314				labelDesign = Design as ITextDesign;
315				if (labelDesign == null)
316				{
317					Log.Warning(
318						"The new design '" + Design + "' which will be set to the " +
319						"control '" + this + "' is no kind of a '" +
320						typeof(ITextDesign).Name +"' design which means that the text " +
321						"won't be displayed correctly.");
322				} // if
323
324				return true;
325			} // if
326
327			return false;
328		}
329		#endregion
330
331		#region OnTextChanging
332		/// <summary>
333		/// On text changing
334		/// </summary>
335		/// <param name="oldText">Old text</param>
336		/// <returns>
337		/// 'True' if the new value can be used or 'false' if the change should be
338		/// aborted.
339		/// </returns>
340		protected virtual bool OnTextChanging(string oldText)
341		{
342			// Always accept the text change but determine if this "auto fallback"
343			// decides it or we have an listener who can make a "real" decision
344			return true;
345		}
346		#endregion
347
348		#region DetectChanges
349		/// <summary>
350		/// This method implements the checks of the changes which are should be
351		/// detected in this element. It also cares about triggering the events and
352		/// the event handler methods.
353		/// </summary>
354		protected override void DetectChanges()
355		{
356			base.DetectChanges();
357
358			if (Text != lastText)
359			{
360				// Check now if the new value should be set
361				if (OnTextChanging(lastText))
362				{
363					lastText = Text;
364
365					// After setting the new value also inform all external listeners
366					// about the change
367					if (TextChanged != null &&
368						// but only if it isn't just the value initialization
369							isRuntimeValueChange)
370					{
371						TextChanged.Invoke(this);
372					} // if
373				} // if
374				else
375				{
376					// if the change is not ok, then just reset to old value again
377					Text = lastText;
378				} // else
379			} // if
380		}
381		#endregion
382
383		#region DrawData
384		/// <summary>
385		/// Draws all data of this Label which needs to be visualized.
386		/// </summary>
387		/// <remarks>
388		/// This method will only be called if the Label is in a visible state.
389		/// </remarks>
390		protected override void DrawData()
391		{
392			base.DrawData();
393
394			string displayText = GetDisplayText();
395
396			if (String.IsNullOrEmpty(displayText))
397			{
398				// It only make sense to call 'Font.Draw()' if we really have a text
399				return;
400			} // if
401
402			// Always draw the text even if the control is disabled
403			// Note: If the control is invisible, the draw won't be called anyway
404			Font textFont =
405				State == ElementState.Disabled
406					? labelDesign.DisabledTextFont
407					: labelDesign.TextFont;
408
409			// but only draw text if there is a valid font set
410			if (textFont != null)
411			{
412				textFont.Draw(displayText, TextContentElement.DrawArea, Rotation,
413					Point.Zero);
414			} // if
415		}
416		#endregion
417
418		#region GetDisplayText
419		/// <summary>
420		/// Get display text
421		/// </summary>
422		protected virtual string GetDisplayText()
423		{
424			return Text;
425		}
426		#endregion
427
428		#region DrawDebugInfo
429		/// <summary>
430		/// Draw debug info
431		/// </summary>
432		protected override void DrawDebugInfo()
433		{
434			base.DrawDebugInfo();
435
436			// Only really detailed visual information about this element if the UI
437			// profiling mode is enabled additional to the UI debug mode
438			if (Settings.Debug.IsProfilingModeOn(ProfilingMode.UI))
439			{
440				Rect.DrawFilled(DrawArea, Color.Green);
441			} // if
442
443				// otherwise just use the simple version
444			else
445			{
446				Rect.DrawOutline(DrawArea, Color.Green, Rotation);
447			} // else
448		}
449		#endregion
450
451		#region ShortElementInfo
452		/// <summary>
453		/// Short control info
454		/// </summary>
455		protected override string ShortElementInfo()
456		{
457			return base.ShortElementInfo() + ", Text=" + Text;
458		}
459		#endregion
460
461		#endregion
462
463		/// <summary>
464		/// Tests for Label controls
465		/// </summary>
466		[NUnit.Framework.Category("Visual")]
467		internal class LabelTests
468		{
469			#region Helpers
470
471			#region TestLabelDesign
472			/// <summary>
473			/// Test label design
474			/// </summary>
475			private static readonly TextControlDesign TestLabelDesign =
476				new TextControlDesign
477				{
478					Background = null,
479					DisabledBackground = null,
480					Hover = null,
481					TextFont = new Font(Font.Default, Color.Gold),
482					DisabledTextFont = new Font(Font.Default, Color.Black),
483					TextBackground = BaseTheme.GetUIMaterial("DefaultLabel"),
484					TextHoverBackground = BaseTheme.GetUIMaterial("DefaultLabel",
485						Color.Yellow),
486					DisabledTextBackground = BaseTheme.GetUIMaterial("DefaultLabel",
487						Color.Grey),
488				};
489			#endregion
490
491			#endregion
492
493			#region Clone (Static)
494			/// <summary>
495			/// Clone
496			/// </summary>
497			[Test]
498			public static void Clone()
499			{
500				using (Label testLabel = new Label
501				{
502					Name = "testButton",
503					Text = "testing",
504				})
505				{
506					Label clonedLabel = testLabel.Clone<Label>();
507					Assert.NotEqual(testLabel, clonedLabel);
508					Assert.NotEqual(testLabel.Children, clonedLabel.Children);
509					Assert.Equal(testLabel.Name, clonedLabel.Name);
510					Assert.Equal(testLabel.Text, clonedLabel.Text);
511				} // using
512			}
513			#endregion
514
515			#region DisplayLabel (Static)
516			/// <summary>
517			/// Display label
518			/// </summary>
519			[Test]
520			public static void DisplayLabel()
521			{
522				const string LabelInitText = "Text";
523				Label testLabel = new Label
524				{
525					LocalArea = Rectangle.FromCenter(0.35f, 0.35f, 0.4f, 0.125f),
526					Text = LabelInitText,
527					//Design = TestLabelDesign,
528				};
529
530				Screen testScene = new Screen();
531				testScene.Add(testLabel);
532
533				// Open now the scene to "activate" for the test
534				testScene.Open();
535
536				Application.Start(delegate
537				{
538					testLabel.Text =
539						Input.Keyboard.SpaceIsPressed
540							? "loooooooooooooooooooooong Text"
541							: LabelInitText;
542
543					Point pos = new Point(0.5f, ScreenSpace.DrawArea.Top + 0.01f);
544					const float LineGap = 0.02f;
545					Font.Default.Draw("MousePos='" + Input.Mouse.Position + "'",
546						Rectangle.FromCenter(pos, Size.Half));
547					pos.Y += LineGap;
548					Font.Default.Draw(
549						"TextArea='" + testLabel.TextContentElement.DrawArea + "'",
550						Rectangle.FromCenter(pos, Size.Half));
551					pos.Y += LineGap;
552				});
553			}
554			#endregion
555
556			#region DisabledLabel (Static)
557			/// <summary>
558			/// Disabled label
559			/// </summary>
560			[Test]
561			public static void DisabledLabel()
562			{
563				Label testLabel = new Label
564				{
565					LocalArea = new Rectangle(0.25f, 0.25f, 0.5f, 0.15f),
566					//Design = TestLabelDesign,
567					Text = "Enabled",
568				};
569
570				Screen testScene = new Screen();
571				testScene.Add(testLabel);
572
573				// Open now the scene to "activate" for the test
574				testScene.Open();
575
576				Application.Start(delegate
577				{
578					// Start the visual test to see the Label
579					// Disable/enable the Label by pressing the keyboard "Space" button
580					if (Input.Keyboard.SpaceReleased)
581					{
582						if (testLabel.State >= ElementState.Enabled)
583						{
584							testLabel.State = ElementState.Disabled;
585						}
586						else
587						{
588							testLabel.State =
589								testLabel.IsInControl(Input.Mouse.Position)
590									? ElementState.Hovered
591									: ElementState.Enabled;
592						} // else
593						testLabel.Text = testLabel.State.ToString();
594					}
595				});
596			}
597			#endregion
598
599			#region TextAlignment (Static)
600			/// <summary>
601			/// Text alignment
602			/// </summary>
603			[Test]
604			public static void TextAlignment()
605			{
606				// The used UI scene for the unit test
607				Screen testScene = new Screen();
608
609				Label testLabel = new Label
610				{
611					LocalArea = new Rectangle(0.15f, 0.3f, 0.4f, 0.15f),
612					CustomDesign = TestLabelDesign,
613					Text = "Please press 'Space'",
614				};
615				testScene.Add(testLabel);
616				//testImage.Text = "Alignment=" + testImage.Alignment;
617
618				// Open now the scene to "activate" for the test
619				testScene.Open();
620
621				Application.Start(delegate
622				{
623					// Cycling through all alignment modes by pressing the "Space" key
624					if (Input.Keyboard.SpaceReleased)
625					{
626						ITextDesign textDesign = (ITextDesign)testLabel.CustomDesign;
627						textDesign.TextFont = new Font(textDesign.TextFont,
628							textDesign.TextFont.HorizontalAlignment.NextValue());
629						testLabel.Text = textDesign.TextFont.HorizontalAlignment + " text";
630					}
631				});
632			}
633			#endregion
634
635			#region DisplayMultilineText (Static)
636			/// <summary>
637			/// Display multiline text
638			/// </summary>
639			[Test]
640			public static void DisplayMultilineText()
641			{
642				Screen testScene = new Screen();
643
644				Label singleLineLabel = new Label
645				{
646					LocalArea = Rectangle.FromCenter(0.25f, 0.5f, 0.3f, 0.2f),
647					Text = "Single line text",
648					CustomDesign = TestLabelDesign,
649				};
650				testScene.Add(singleLineLabel);
651
652				Label multiLineLabel = new Label
653				{
654					LocalArea = Rectangle.FromCenter(0.75f, 0.5f, 0.3f, 0.2f),
655					Text = "Multi-\r\n" + "Line-\n" + "Text",
656					CustomDesign = TestLabelDesign,
657				};
658				testScene.Add(multiLineLabel);
659
660				// Open now the scene to "activate" for the test
661				testScene.Open();
662
663				Application.Start(delegate
664				{
665					// Cycling through all alignment modes by pressing the "Space" key
666					if (Input.Keyboard.SpaceReleased)
667					{
668						// Grab the fonts
669						ITextDesign singleTextDesign =
670							singleLineLabel.CustomDesign as ITextDesign;
671						ITextDesign multiTextDesign =
672							multiLineLabel.CustomDesign as ITextDesign;
673
674						// determine the next text alignment mode
675						HorizontalAlignment newTextAlignment =
676							singleTextDesign.TextFont.HorizontalAlignment.NextValue();
677
678						// and set it
679						singleTextDesign.TextFont =
680							new Font(singleTextDesign.TextFont, newTextAlignment);
681						multiTextDesign.TextFont =
682							new Font(multiTextDesign.TextFont, newTextAlignment);
683					}
684				});
685			}
686			#endregion
687
688			#region Docking (Static)
689			/// <summary>
690			/// Docking
691			/// </summary>
692			[Test]
693			public static void Docking()
694			{
695				//  // The used UI screen for the unit test
696				//  UserScreen testScene = new UserScreen();
697
698				//  Label testLabel = new Label
699				//  {
700				//    LocalArea = new Rectangle(0.15f, 0.3f, 0.4f, 0.15f),
701				//    Design = TestLabelDesign,
702				//    Size = new Size(0.1f, 0.02f),
703				//    //Docking
704				//    AnchorPoint = AnchorType.Middle,
705				//  };
706				//  testScene.Add(testLabel);
707				//  //testImage.Text = "Alignment=" + testImage.Alignment;
708
709				//  // Open now the scene to "activate" for the test
710				//  testScene.Open();
711
712				//  Application.Start(delegate
713				//  {
714				//    // Cycling through all alignment modes by pressing the "Space" key
715				//    if (Input.Keyboard.SpaceReleased)
716				//    {
717				//      testLabel.Alignment = EnumHelper.NextValue(testLabel.Alignment);
718				//      //testLabel.Text = testLabel.Alignment.ToString();
719				//      //testImage.Text = "Alignment=" + testImage.Alignment
720				//      testLabel.Text = "Alignment=" + testLabel.Alignment +
721				//        ", AnchorPoint= " + testLabel.AnchorPoint;
722				//      ;
723				//    }
724
725				//    // Cycling through all alignment modes by pressing the "Space" key
726				//    if (Input.Keyboard.EnterReleased)
727				//    {
728				//      testLabel.AnchorPoint =
729				//        EnumHelper.NextValue(testLabel.AnchorPoint);
730				//      //testLabel.Text = testLabel.Alignment.ToString();
731				//      testLabel.Text = "Alignment=" + testLabel.Alignment +
732				//        ", AnchorPoint= " + testLabel.AnchorPoint;
733				//    }
734
735				//    // By pressing the "Ctrl" key we change the scaling of the control to
736				//    // if the alignment still works
737				//    testLabel.Scaling = Input.Keyboard.IsPressed(InputButton.LeftControl) ?
738				//      0.5f : 1.0f;
739				//  });
740			}
741			#endregion
742
743			#region Alignment (Static)
744			/// <summary>
745			/// Alignment
746			/// </summary>
747			[Test]
748			public static void Alignment()
749			{
750				//  // The used UI scene for the unit test
751				//  UIScene testScene = new UIScene();
752
753				//  Label testLabel = new Label
754				//  {
755				//    LocalArea = new Rectangle(0.15f, 0.3f, 0.4f, 0.15f),
756				//    Design = TestLabelDesign,
757				//    //Scaling = 0.5f,
758				//    Size = new Size(0.1f, 0.02f),
759				//    AnchorPoint = AnchorType.Middle,
760				//  };
761				//  testScene.Add(testLabel);
762				//  //testImage.Text = "Alignment=" + testImage.Alignment;
763
764				//  // Open now the scene to "activate" for the test
765				//  testScene.Open();
766
767				//  Application.Start(delegate
768				//  {
769				//    // Cycling through all alignment modes by pressing the "Space" key
770				//    if (Input.Keyboard.SpaceReleased)
771				//    {
772				//      testLabel.Alignment = EnumHelper.NextValue(testLabel.Alignment);
773				//      //testLabel.Text = testLabel.Alignment.ToString();
774				//      //testImage.Text = "Alignment=" + testImage.Alignment
775				//      testLabel.Text = "Alignment=" + testLabel.Alignment +
776				//        ", AnchorPoint= " + testLabel.AnchorPoint; ;
777				//    }
778
779				//    // Cycling through all alignment modes by pressing the "Space" key
780				//    if (Input.Keyboard.EnterReleased)
781				//    {
782				//      testLabel.AnchorPoint =
783				//        EnumHelper.NextValue(testLabel.AnchorPoint);
784				//      //testLabel.Text = testLabel.Alignment.ToString();
785				//      testLabel.Text = "Alignment=" + testLabel.Alignment +
786				//        ", AnchorPoint= " + testLabel.AnchorPoint;
787				//    }
788
789				//    // By pressing the "Ctrl" key we change the scaling of the control to
790				//    // if the alignment still works
791				//    testLabel.Scaling = Input.Keyboard.IsPressed(InputButton.LeftControl) ?
792				//      0.5f : 1.0f;
793				//  });
794			}
795			#endregion
796
797			#region ChildAlignment (Static)
798			/// <summary>
799			/// Child alignment
800			/// </summary>
801			[Test]
802			public static void ChildAlignment()
803			{
804				//  // The used UI scene for the unit test
805				//  UIScene testScene = new UIScene();
806
807				//  Label parentLabel = new Label
808				//  {
809				//    LocalArea = new Rectangle(0.2f, 0.2f, 0.6f, 0.5f),
810				//    Design = TestLabelDesign,
811				//    //Scaling = 0.5f,
812				//    //Text = "No AutoSize", -> no text because of child control text
813				//  };
814
815				//  Label testLabel = new Label
816				//  {
817				//    //LocalArea = new Rectangle(0.15f, 0.3f, 0.4f, 0.15f),
818				//    LocalPosition = new Point(0.15f, 0.3f),
819				//    Size = new Size(0.1f, 0.02f),
820				//    AnchorPoint = AnchorType.TopRight,
821				//    Design = TestLabelDesign,
822				//    //Scaling = 0.5f,
823
824				//  };
825				//  parentLabel.Add(testLabel);
826				//  testScene.Add(parentLabel);
827				//  //testImage.Text = "Alignment=" + testImage.Alignment;
828
829				//  // Open now the scene to "activate" for the test
830				//  testScene.Open();
831
832				//  Application.Start(delegate
833				//  {
834				//    // Cycling through all alignment modes by pressing the "Space" key
835				//    if (Input.Keyboard.SpaceReleased)
836				//    {
837				//      testLabel.Alignment = EnumHelper.NextValue(testLabel.Alignment);
838				//      //testLabel.Text = testLabel.Alignment.ToString();
839				//      //testImage.Text = "Alignment=" + testImage.Alignment
840				//      testLabel.Text = "Alignment=" + testLabel.Alignment +
841				//        ", AnchorPoint= " + testLabel.AnchorPoint; ;
842				//    }
843
844				//    // Cycling through all alignment modes by pressing the "Space" key
845				//    if (Input.Keyboard.EnterReleased)
846				//    {
847				//      testLabel.AnchorPoint =
848				//        EnumHelper.NextValue(testLabel.AnchorPoint);
849				//      //testLabel.Text = testLabel.Alignment.ToString();
850				//      testLabel.Text = "Alignment=" + testLabel.Alignment +
851				//        ", AnchorPoint= " + testLabel.AnchorPoint;
852				//    }
853
854				//    // By pressing the "Ctrl" key we change the scaling of the control to
855				//    // if the alignment still works
856				//    testLabel.Scaling = Input.Keyboard.IsPressed(InputButton.LeftControl) ?
857				//      0.5f : 1.0f;
858				//  });
859			}
860			#endregion
861
862			#region DrawLabelDepthTest (Static)
863			/// <summary>
864			/// Draw Label Depth Test
865			/// </summary>
866			[Test]
867			public static void DrawLabelDepthTest()
868			{
869				//  // The used UI scene for the unit test
870				//  UIScene uiScene = Base.GameScreen.OverlayScreen.UIScene;
871
872				//  Label frontLabel = null;
873				//  Label backLabel = null;
874
875				//  Base.StartTest("Display Label", delegate
876				//  {
877				//    if (frontLabel == null)
878				//    {
879				//      frontLabel = new Label
880				//      {
881				//        LocalArea = new Rectangle(0.3f, 0.46f, 0.4f, 0.08f),
882				//        IsAutoSizing = false,
883				//        Text = "I AM IN FRONT!!! :D",
884				//        TextColor = Color.Red,
885				//        TextFont = Graphic.InfoFont,//new Font("Arial", 13),
886				//        DepthLayer = 2,
887				//      };
888				//      uiScene.Add(frontLabel);
889
890				//      backLabel = new Label
891				//      {
892				//        LocalArea = new Rectangle(0.27f, 0.415f, 0.4f, 0.08f),
893				//        IsAutoSizing = false,
894				//        Text = "I AM IN THE BACK :(",
895				//        TextColor = Color.Red,
896				//        TextFont = Graphic.InfoFont,//new Font("Arial", 13),
897				//        DepthLayer = 8,
898				//      };
899				//      uiScene.Add(backLabel);
900
901				//    }
902				//  });
903			}
904			#endregion
905		}
906	}
907}