Beispiel #1
0
        private async void MfiDelete_Click(object sender, RoutedEventArgs e)
        {
            FileSystemItem item = UwpUtils.GetDataContext <FileSystemItem>(sender);

            if (item.IsFile)
            {
                bool delete = await DialogUtils.ShowTwoOptionsAsync(item.Name, "Delete File?", "Yes", "No");

                if (!delete)
                {
                    return;
                }

                await viewModel.Api.DeleteFile(item.FullPath);

                await UiUtils.TryAgain("Try again?", "Delete file error",
                                       () => viewModel.Api.DeleteFile(item.FullPath),
                                       viewModel.BackgroundOperations, "Delete file...");
            }
            else
            {
                bool delete = await DialogUtils.ShowTwoOptionsAsync(item.Name, "Delete Folder?", "Yes", "No");

                if (!delete)
                {
                    return;
                }

                await UiUtils.TryAgain("Try again?", "Delete folder error",
                                       () => viewModel.Api.DeleteFolder(item.FullPath, true),
                                       viewModel.BackgroundOperations, "Delete folder...");
            }

            await pcView.UpdateContent();
        }
Beispiel #2
0
        private void MfiDetails_Click(object sender, RoutedEventArgs e)
        {
            viewModel.CurrentFolderPath = pcView.CurrentFolder?.FullPath;

            FileSystemItem item = UwpUtils.GetDataContext <FileSystemItem>(sender);

            Frame.Navigate(typeof(FileSystemItemInfoPage), (item, viewModel.Api));
        }
 private async void MfiReloadSongs_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         viewModel.IsUpdatingPlaylists = true;
         await UwpUtils.GetDataContext <ISourcePlaylist>(sender).Reload();
     }
     catch (Exception exc)
     {
         await DialogUtils.ShowSafeAsync(exc.Message, "Reload songs error");
     }
     finally
     {
         viewModel.IsUpdatingPlaylists = false;
     }
 }
        private void MfiRemovePlaylist_Click(object sender, RoutedEventArgs e)
        {
            IPlaylist     playlist = UwpUtils.GetDataContext <IPlaylist>(sender);
            IAudioService service  = viewModel.Service.Audio;

            if (service.CurrentPlaylist == playlist)
            {
                service.CurrentPlaylist = service.GetAllPlaylists().Where(p => p != playlist).Any() ?
                                          service.GetAllPlaylists().Next(playlist).next : null;
            }

            if (playlist is ISourcePlaylist)
            {
                service.SourcePlaylists.Remove((ISourcePlaylist)playlist);
            }
            else
            {
                service.Playlists.Remove(playlist);
            }
        }
Beispiel #5
0
        private async void MfiDownload_Click(object sender, RoutedEventArgs e)
        {
            FileSystemItem item = UwpUtils.GetDataContext <FileSystemItem>(sender);

            if (item.IsFolder)
            {
                await DialogUtils.ShowSafeAsync("Downloading a folder is not implemented");

                return;
            }

            FileSavePicker picker = new FileSavePicker()
            {
                SuggestedFileName    = item.Name,
                DefaultFileExtension = item.Extension,
            };

            picker.FileTypeChoices.Add(item.Extension, new string[] { item.Extension });

            StorageFile file = await picker.PickSaveFileAsync();

            if (file == null)
            {
                return;
            }

            await UiUtils.TryAgain("Try again?", "Download file error", async() =>
            {
                try
                {
                    await viewModel.Api.DownloadFile(item.FullPath, file);
                    return(true);
                }
                catch { }
                return(false);
            }, viewModel.BackgroundOperations, "Download file...");
        }
Beispiel #6
0
        private async void MfiRunWIthModeItem_Click(object sender, RoutedEventArgs e, SyncMode mode)
        {
            SyncPair sync = UwpUtils.GetDataContext <SyncPair>(sender);

            await BackgroundTaskHelper.Current.Start(sync, viewModel.Api, mode : mode);
        }
        private void MfiRemixSongs_Click(object sender, RoutedEventArgs e)
        {
            IPlaylist playlist = UwpUtils.GetDataContext <IPlaylist>(sender);

            playlist.Songs = playlist.Songs.Shuffle().ToArray();
        }