/// <summary> /// Called when a ListBoxStateMachineItem is removed from the items collection. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnListBoxItemRemoved(object sender, ListBoxStateMachineItemEventArgs e) { if (e.Item != null) { e.Item.ResetItem(); e.Item.ItemStateChanged -= OnItemStateChanged; UpdateLayout(); } }
/// <summary> /// Called when a ListBoxStateMachineItem is added to the items collection. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnListBoxItemAdded(object sender, ListBoxStateMachineItemEventArgs e) { if (e.Item != null) { e.Item.Parent = this; e.Item.ItemStateChanged += OnItemStateChanged; UpdateLayout(); } }
/// <summary> /// Handles the ItemStateChanged event for all items in the list box. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnItemStateChanged(object sender, ListBoxStateMachineItemEventArgs e) { OnItemStateChanged(e.Item); }
/// <summary> /// Called when a ListBoxStateMachineItem is removed to the selectedItems collection. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnSelectedItemsListBoxItemRemoved(object sender, ListBoxStateMachineItemEventArgs e) { e.Item.IsSelected = false; }
/// <summary> /// Called when a ListBoxStateMachineItem is added to the selectedItems collection. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnSelectedItemsListBoxItemAdded(object sender, ListBoxStateMachineItemEventArgs e) { if (items.Contains(e.Item)) { if (selectionMode == SelectionMode.Single && selectedItems.Count > 1) { if (!selectedItems.Remove(e.Item)) { e.Item.IsSelected = false; } } else { e.Item.IsSelected = true; } } else { throw SurfaceCoreFrameworkExceptions.ItemIsNotInListBoxItemsCollection("Items"); } }
/// <summary> /// Handles updating the flag texture on the selected cloth when the ListBox item selected changes. /// </summary> private void OnItemStateChanged(object sender, ListBoxStateMachineItemEventArgs e) { ListBoxItem item = e.Item as ListBoxItem; if (item != null && item.IsSelected) { textiles.CurrentTheme = item.Theme; } }