private void ButtonCharacterAdd_Click(object sender, RoutedEventArgs e) { var csIndex = _csManager.IndexOf(ListBoxCharacterData.ItemsSource as CharacterSet); var cIndex = _csManager[csIndex].IndexOf(ListBoxCharacterData.SelectedItem as Character); Character newCharacter; if (ListBoxCharacterData.SelectedItems.Count == 0) { var nextNumber = _csManager[csIndex].Count > 0 ? _csManager[csIndex].Select(character => character.Number).Max() + 1 : 0; newCharacter = new Character(_csManager[csIndex], nextNumber, 'X', "CHARACTER"); _csManager[csIndex].Add(newCharacter); } else { newCharacter = _csManager[csIndex].IndexOf(character => character.Number == _csManager[csIndex][cIndex].Number + 1) > -1 ? new Character(_csManager[csIndex], _csManager[csIndex].Select(character => character.Number).Max() + 1, 'X', "CHARACTER") : new Character(_csManager[csIndex], _csManager[csIndex][cIndex].Number + 1, 'X', "CHARACTER"); _csManager[csIndex].Insert(cIndex + 1, newCharacter); } ListBoxCharacterData.SelectedIndex = _csManager[csIndex].IndexOf(newCharacter); ListBoxCharacterData.ScrollIntoView(ListBoxCharacterData.SelectedItem); e.Handled = true; }
private void CharacterInfo_EntryComplete(object sender, RoutedEventArgs e) { ListBoxCharacterData.Focus(); if (ListBoxCharacterData.SelectedIndex < ListBoxCharacterData.Items.Count - 1) { ListBoxCharacterData.SelectedIndex++; } else { ListBoxCharacterData.SelectedIndex = 0; } ListBoxCharacterData.ScrollIntoView(ListBoxCharacterData.SelectedItem); e.Handled = true; }
private void ButtonCharacterRemove_Click(object sender, RoutedEventArgs e) { var csIndex = _csManager.IndexOf(ListBoxCharacterData.ItemsSource as CharacterSet); var cIndex = _csManager[csIndex].IndexOf(ListBoxCharacterData.SelectedItem as Character); while (ListBoxCharacterData.SelectedItems.Count > 0) { _csManager[csIndex].Remove(ListBoxCharacterData.SelectedItems[0] as Character); } ListBoxCharacterData.SelectedIndex = _csManager[csIndex].Count > 0 ? cIndex > 0 ? cIndex - 1 : 0 : -1; ListBoxCharacterData.ScrollIntoView(ListBoxCharacterData.SelectedItem); e.Handled = true; }