/// <summary> /// Gets the collection of /// <strong><see cref="CoreInteractionFramework.ListBoxStateMachineItem"/></strong> objects that /// are partially or completely visible. /// </summary> /// <returns>The list box items that are visible in the viewport.</returns> /// <example> /// <para> /// In this code example, the <strong>GetVisibleItems</strong> method retrieves the /// collection of visible list box items and iterates over them to determine their /// respective selected states and take appropriate action. /// </para> /// <code source="Core\Framework\StarshipArsenal\MainGameFrame.cs" /// region="Button 2" title="Button 2" lang="cs" /> /// </example> public ListBoxStateMachineItemCollection GetVisibleItems() { ListBoxStateMachineItemCollection visibleItems = new ListBoxStateMachineItemCollection(this); foreach (ListBoxStateMachineItem item in items) { if (item.IsVisible) { visibleItems.Add(item); } } return visibleItems; }
/// <summary> /// Creates an initialized instance of a /// <strong><see cref="ListBoxStateMachine"/></strong> object with the specified parameters. /// </summary> /// <param name="controller">The <strong>UIController</strong> object that dispatches hit testing.</param> /// <param name="numberOfPixelsInHorizontalAxis"> /// The number of pixels that this control occupies horizontally. /// For more information, see <strong><see cref="P:CoreInteractionFramework.UIElementStateMachine.NumberOfPixelsInHorizontalAxis"> /// NumberOfPixelsInHorizontalAxis</see></strong>. /// </param> /// <param name="numberOfPixelsInVerticalAxis"> /// The number of pixels that this control occupies vertically. /// For more information, see <strong><see cref="P:CoreInteractionFramework.UIElementStateMachine.NumberOfPixelsInVerticalAxis"> /// NumberOfPixelsInVerticalAxis</see></strong>. /// </param> public ListBoxStateMachine(UIController controller, int numberOfPixelsInHorizontalAxis, int numberOfPixelsInVerticalAxis) : base(controller, numberOfPixelsInHorizontalAxis, numberOfPixelsInVerticalAxis) { scrollAdapter = new ScrollAdapter(controller, this); scrollAdapter.ViewportChanged += OnScrollAdapterViewportChanged; ListBoxMode = ListBoxMode.Selection; // Create container objects. items = new ListBoxStateMachineItemCollection(this); selectedItems = new ListBoxStateMachineItemCollection(this); contactTargetEventContactIds = new Dictionary<int, ContactTargetEvent>(); capturedItemContactIds = new Dictionary<int, ListBoxStateMachineItem>(); items.ListBoxItemRemoved += OnListBoxItemRemoved; items.ListBoxItemAdded += OnListBoxItemAdded; selectedItems.ListBoxItemAdded += OnSelectedItemsListBoxItemAdded; selectedItems.ListBoxItemRemoved += OnSelectedItemsListBoxItemRemoved; }