/Scenes/UserInterfaces/Screen.cs
C# | 88 lines | 51 code | 8 blank | 29 comment | 9 complexity | 8435a78ea7ac2f0c15b79c6527bbc972 MD5 | raw file
Possible License(s): Apache-2.0
- using System;
- using System.Collections.Generic;
- using Delta.Scenes.UserInterfaces.Controls;
-
- namespace Delta.Scenes.UserInterfaces
- {
- /// <summary>
- /// The first concrete implementation of an UI screen which can keep all
- /// required UI controls for the interaction with and navigation for the
- /// user. It also provides background image which is drawn based on the given
- /// screen area.
- /// </summary>
- public class Screen : BaseScreen
- {
- #region Constructors
- /// <summary>
- /// Creates a custom screen to be filled with UI by the caller. Note: This
- /// is usually just used for unit-testing, but games and applications will
- /// also use it when they are not loading scenes and screens via content.
- /// </summary>
- public Screen()
- : this("<DynamicCreated>", false)
- {
- }
-
- /// <summary>
- /// Creates an user interface screen from the content file with all stored
- /// controls. Note: If the 'screenContentName' value is empty or null or
- /// starts with ">" (like ">DummyScreen<"), then the new screen
- /// will be empty and has to be filled and opened by the caller
- /// (automaticallyOpenScreen will be ignored).
- /// </summary>
- /// <param name="screenContentName">
- /// Scene name to load. Use the empty constructor to create scenes
- /// dynamically without content!
- /// </param>
- /// <param name="automaticallyOpenScreen"></param>
- public Screen(string screenContentName,
- bool automaticallyOpenScreen = true)
- : base(screenContentName)
- {
- if (automaticallyOpenScreen &&
- String.IsNullOrEmpty(screenContentName) == false &&
- screenContentName.StartsWith("<") == false)
- {
- Open();
- }
- }
- #endregion
-
- #region Methods (Private)
-
- #region GetRadioButtons
- /// <summary>
- /// Get all RadioButton's which have the same (given) "GroupControl".
- /// Currently only needed in the RadioButton class.
- /// </summary>
- /// <param name="searchingGroupTag">Searching group tag</param>
- /// <returns>Array of radio buttons for this group tag</returns>
- internal RadioButton[] GetRadioButtons(object searchingGroupTag)
- {
- List<RadioButton> foundButtons = new List<RadioButton>();
-
- for (int index = 0; index < Controls.Count; index++)
- {
- Panel panel = Controls[index] as Panel;
- if (panel != null)
- {
- foundButtons.AddRange(panel.GetChildrenOfType<RadioButton>());
- continue;
- } // if
-
- RadioButton radioButton = Controls[index] as RadioButton;
- if (radioButton != null &&
- radioButton.GroupObject == searchingGroupTag)
- {
- foundButtons.Add(radioButton);
- continue;
- } // if
- } // for
-
- return foundButtons.ToArray();
- }
- #endregion
-
- #endregion
- }
- }