private async void TblErrorFiles_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            IList <ErrorFilePair> pairs = (IList <ErrorFilePair>)((FrameworkElement)sender).DataContext;

            if (pairs.Count == 0)
            {
                await DialogUtils.ShowSafeAsync("<none>", "Errors");

                return;
            }

            int i = 0;

            while (true)
            {
                ErrorFilePair errorPair = pairs[i];
                string        title     = $"Error: {i + 1} / {pairs.Count}";
                string        message   = $"{errorPair.Pair.RelativePath}\r\n{errorPair.Exception}";

                ContentDialogResult result = await DialogUtils.ShowContentAsync(message, title, "Cancel", "Previous", "Next", ContentDialogButton.Secondary);

                if (result == ContentDialogResult.Primary)
                {
                    i = StdUtils.OffsetIndex(i, pairs.Count, -1).index;
                }
                else if (result == ContentDialogResult.Secondary)
                {
                    i = StdUtils.OffsetIndex(i, pairs.Count, 1).index;
                }
                else
                {
                    break;
                }
            }
        }
Esempio n. 2
0
        private void TbxSearch_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            IAudioService service = viewModel.AudioServiceUI;

            if (service == null)
            {
                return;
            }

            e.Handled = true;

            switch (e.Key)
            {
            case Key.Enter:
                if (lbxSongs.SelectedItem is Song)
                {
                    bool prepend = Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl);
                    Song addSong = (Song)lbxSongs.SelectedItem;
                    viewModel.AudioServiceUI.AddSongsToFirstPlaylist(new Song[] { addSong }, prepend);
                    service.PlayState = PlaybackState.Playing;
                }
                break;

            case Key.Escape:
                service.SearchKey = string.Empty;
                break;

            case Key.Up:
                if (lbxSongs.Items.Count > 0 && viewModel.AudioServiceUI?.IsSearching == true)
                {
                    isChangingSelectedSongIndex = true;
                    lbxSongs.SelectedIndex      =
                        StdUtils.OffsetIndex(lbxSongs.SelectedIndex, lbxSongs.Items.Count, -1).index;
                    isChangingSelectedSongIndex = false;
                }
                break;

            case Key.Down:
                if (lbxSongs.Items.Count > 0 && viewModel.AudioServiceUI?.IsSearching == true)
                {
                    isChangingSelectedSongIndex = true;
                    lbxSongs.SelectedIndex      =
                        StdUtils.OffsetIndex(lbxSongs.SelectedIndex, lbxSongs.Items.Count, 1).index;
                    isChangingSelectedSongIndex = false;
                }
                break;

            default:
                e.Handled = false;
                break;
            }
        }
        private static void Move <T>(ObservableCollection <T> collection, T item, int offset)
        {
            int oldIndex = collection.IndexOf(item);

            if (oldIndex == -1)
            {
                return;
            }

            int newIndex = StdUtils.OffsetIndex(oldIndex, collection.Count, offset).index;

            collection.Move(oldIndex, newIndex);
        }