private void Lyrics_ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.LastOrDefault() is Lyric currentLyric) { Lyrics_ListView.ScrollIntoView(currentLyric); LyricsContent_TextBox.Text = currentLyric.Content; } if (e.RemovedItems.Any()) { foreach (Lyric item in e.RemovedItems) { item.IsSelected = false; } } if (Lyrics_ListView.SelectedItems.LastOrDefault() is Lyric selectedLyric) { if (_backLyric != null) { _backLyric.IsSelected = false; } _backLyric = selectedLyric; selectedLyric.IsSelected = true; InputSubmitOperations_ComboBox.SelectedItem = ModifyLyrics_ComboBoxItem; } else { LyricsContent_TextBox.Text = String.Empty; InputSubmitOperations_ComboBox.SelectedItem = AddLyrics_ComboBoxItem; } }
private void LyricTime_Button_Click(object sender, RoutedEventArgs e) { Lyric lyric = (sender as Button).DataContext as Lyric; if (Lyrics_ListView.SelectionMode == ListViewSelectionMode.Multiple || Lyrics_ListView.SelectionMode == ListViewSelectionMode.Extended) { var range = new ItemIndexRange(Lyrics_ListView.Items.IndexOf(lyric), 1); if (Lyrics_ListView.SelectedItems.Contains(lyric)) { Lyrics_ListView.DeselectRange(range); } else { Lyrics_ListView.SelectRange(range); } } else if (Lyrics_ListView.SelectionMode != ListViewSelectionMode.None) { Lyrics_ListView.SelectedItem = lyric; } GoToLyricTime(lyric); }
private void Select_Paragraph_MenuFlyoutItem_Click(object sender, RoutedEventArgs e) { int selectedIndex = Lyrics_ListView.SelectedIndex; int paragraphStart = 0; int paragraphLength = -1; var lyrics = _viewModel.LyricItems.ToList(); foreach (var lyric in lyrics.Where(l => String.IsNullOrEmpty(l.Content))) { int currentId = lyrics.IndexOf(lyric); if (currentId <= selectedIndex) { paragraphStart = currentId + 1; } else { paragraphLength = currentId - paragraphStart; break; } } if (paragraphLength == -1) { paragraphLength = lyrics.Count - paragraphStart; } Lyrics_ListView.SelectedItem = null; Lyrics_ListView.SelectRange(new ItemIndexRange(paragraphStart, (uint)paragraphLength)); }
private void Select_Reverse_MenuFlyoutItem_Click(object sender, RoutedEventArgs e) { var selectedRanges = Lyrics_ListView.SelectedRanges.ToList(); Lyrics_ListView.SelectAll(); foreach (ItemIndexRange range in selectedRanges) { Lyrics_ListView.DeselectRange(range); } }
private void Select_BeforeItem_MenuFlyoutItem_Click(object sender, RoutedEventArgs e) { int selectedIndex = Lyrics_ListView.SelectedIndex; if (selectedIndex != -1) { Lyrics_ListView.SelectedIndex = -1; Lyrics_ListView.SelectRange(new ItemIndexRange(0, (uint)(selectedIndex + 1))); } else { Lyrics_ListView.SelectAll(); } }
private void Select_AfterItem_MenuFlyoutItem_Click(object sender, RoutedEventArgs e) { if (Lyrics_ListView.SelectedIndex == -1) { Lyrics_ListView.SelectAll(); return; } int itemsCount = Lyrics_ListView.Items.Count; int selectIndex = Lyrics_ListView.SelectedIndex; uint selectCount = (uint)(itemsCount - selectIndex); Lyrics_ListView.SelectedItem = null; Lyrics_ListView.SelectRange(new ItemIndexRange(selectIndex, selectCount)); }