private async Task CreateFolderAsync() { var dialog = new ContentDialog(); dialog.Title = App.ResourceLoader.GetString("CreateNewFolder"); var box = new TextBox() { Header = App.ResourceLoader.GetString("FolderName"), AcceptsReturn = false, SelectedText = App.ResourceLoader.GetString("NewFolderName") }; dialog.Content = box; dialog.PrimaryButtonText = App.ResourceLoader.GetString("OK"); dialog.SecondaryButtonText = App.ResourceLoader.GetString("Cancel"); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { IndicatorService.GetDefault().ShowBar(); await WebDavItemService.GetDefault().CreateFolder(WebDavNavigationService.CurrentItem, box.Text); await WebDavNavigationService.ReloadAsync(); IndicatorService.GetDefault().HideBar(); } }
private async Task Move() { try { IndicatorService.GetDefault().ShowBar(); foreach (var davItem in _itemsToMove) { await WebDavItemService.GetDefault().MoveToFolder(davItem, WebDavNavigationService.CurrentItem); } } finally { IndicatorService.GetDefault().HideBar(); await WebDavNavigationService.ReloadAsync(); await NavigationService.NavigateAsync(typeof(FilesPage), WebDavNavigationService.CurrentItem, new SuppressNavigationTransitionInfo()); } for (int i = 0; i < NavigationService.Frame.BackStackDepth; i++) { if (NavigationService.Frame.BackStack[i].SourcePageType == typeof(SelectFolderPage)) { NavigationService.Frame.BackStack.RemoveAt(i); } } }
public override async Task OnNavigatedFromAsync(IDictionary <string, object> pageState, bool suspending) { var service = await WebDavNavigationService.InintializeAsync(); await service.ReloadAsync(); await base.OnNavigatedFromAsync(pageState, suspending); }
private async Task UploadFilesAsync() { FileOpenPicker picker = new FileOpenPicker(); picker.FileTypeFilter.Add("*"); picker.SuggestedStartLocation = PickerLocationId.ComputerFolder; var files = await picker.PickMultipleFilesAsync(); _tokenSource = new CancellationTokenSource(); var button = new Button(); button.Content = App.ResourceLoader.GetString("Cancel"); button.HorizontalAlignment = HorizontalAlignment.Center; button.Command = new DelegateCommand(() => { _tokenSource.Cancel(false); IndicatorService.GetDefault().HideBar(); }); _executionSession = await RequestExtendedExecutionAsync(); try { foreach (var file in files) { if (!_tokenSource.IsCancellationRequested) { var progress = new Progress <HttpProgress>(async httpProgress => { if (_tokenSource.IsCancellationRequested) { return; } await Dispatcher.DispatchAsync(() => { var text = string.Format(App.ResourceLoader.GetString("UploadingFile"), file.DisplayName); text += Environment.NewLine + new BytesToSuffixConverter().Convert(httpProgress.BytesSent, null, null, null) + " - " + new ProgressToPercentConverter().Convert(httpProgress, null, null, null); IndicatorService.GetDefault().ShowBar(text, button); if (httpProgress.BytesSent == httpProgress.TotalBytesToSend && files.Count - 1 == files.ToList().IndexOf(file)) { IndicatorService.GetDefault().HideBar(); SelectionMode = ListViewSelectionMode.Single; } }); }); await WebDavItemService.GetDefault().UploadAsync(WebDavNavigationService.CurrentItem, file, _tokenSource.Token, progress); } } } catch (TaskCanceledException) { } finally { ClearExecutionSession(_executionSession); IndicatorService.GetDefault().HideBar(); await WebDavNavigationService.ReloadAsync(); } }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { await base.OnNavigatedToAsync(parameter, mode, state); WebDavNavigationService = await WebDavNavigationService.InintializeAsync(); WebDavNavigationService.PropertyChanged += WebDavNavigationServiceOnPropertyChanged; await Task.Run(() => LoadThumbnails()); }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { await base.OnNavigatedToAsync(parameter, mode, state); Windows.UI.Core.SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.Visible; WebDavNavigationService = await WebDavNavigationService.InintializeAsync(); WebDavNavigationService.PropertyChanged += WebDavNavigationServiceOnPropertyChanged; await Task.Run(() => LoadThumbnails()); await ShowCameraUploadInfo(); }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { WebDavNavigationService = await WebDavNavigationService.InintializeAsync(); WebDavNavigationService.PropertyChanged += WebDavNavigationServiceOnPropertyChanged; if (parameter is List <DavItem> ) { _itemsToMove = parameter as List <DavItem>; } HideItemsToMove(); await base.OnNavigatedToAsync(parameter, mode, state); }
public SelectFolderPageViewModel() { HomeCommand = new DelegateCommand(async() => await WebDavNavigationService.NavigateAsync(new DavItem { EntityId = Configuration.ServerUrl })); AcceptCommand = new DelegateCommand(async() => await AcceptSelection()); CancelCommand = new DelegateCommand(async() => { await WebDavNavigationService.ReloadAsync(); await NavigationService.NavigateAsync(typeof(FilesPage), SelectedItem, new SuppressNavigationTransitionInfo()); }); CreateFolderCommand = new DelegateCommand(async() => await CreateFolderAsync()); }
private async Task DeleteItems(List <DavItem> items) { ContentDialog dialog = new ContentDialog(); if (items.Count == 1) { var item = items.First(); dialog.Title = App.ResourceLoader.GetString("deleteFileConfirmation"); if (item.IsCollection) { dialog.Title = App.ResourceLoader.GetString("deleteFolderConfirmation"); } dialog.Content = item.DisplayName; } else { dialog.Title = App.ResourceLoader.GetString("deleteMultipleConfirmation"); int i = 0; foreach (var item in items) { if (i < 3) { dialog.Content += item.DisplayName + Environment.NewLine; i++; } else { dialog.Content += "..."; break; } } } dialog.PrimaryButtonText = App.ResourceLoader.GetString("yes"); dialog.SecondaryButtonText = App.ResourceLoader.GetString("no"); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { IndicatorService.GetDefault().ShowBar(); await WebDavItemService.GetDefault().DeleteItemAsync(items.Cast <DavItem>().ToList()); SelectionMode = ListViewSelectionMode.Single; await WebDavNavigationService.ReloadAsync(); IndicatorService.GetDefault().HideBar(); } }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { WebDavNavigationService = await WebDavNavigationService.InintializeAsync(); WebDavNavigationService.PropertyChanged += WebDavNavigationServiceOnPropertyChanged; //items should be moved if (parameter is List <DavItem> ) { _itemsToMove = parameter as List <DavItem>; HideItemsToMove(); } //just a folder has to be selected (nothing to move), the parameter is the default folder if (parameter is DavItem item) { await WebDavNavigationService.NavigateAsync(item); } await base.OnNavigatedToAsync(parameter, mode, state); }
public FilesPageViewModel() { _syncedFolderService = new SyncedFoldersService(); UploadItemCommand = new DelegateCommand(async() => await UploadFilesAsync()); RefreshCommand = new DelegateCommand(async() => await WebDavNavigationService.ReloadAsync()); AddToSyncCommand = new DelegateCommand <object>(async parameter => await RegisterFolderForSync(parameter)); DownloadCommand = new DelegateCommand <DavItem>(async item => await DownloadFilesAsync(FilesPage.GetSelectedItems(item))); DeleteCommand = new DelegateCommand <DavItem>(async item => await DeleteItems(FilesPage.GetSelectedItems(item))); SwitchSelectionModeCommand = new DelegateCommand(() => SelectionMode = SelectionMode == ListViewSelectionMode.Multiple ? ListViewSelectionMode.Single : ListViewSelectionMode.Multiple); ShowPropertiesCommand = new DelegateCommand <DavItem>(async item => await NavigationService.NavigateAsync(typeof(DetailsPage), item, new SuppressNavigationTransitionInfo())); AddFolderCommand = new DelegateCommand(async() => await CreateFolderAsync()); HomeCommand = new DelegateCommand(async() => await WebDavNavigationService.NavigateAsync(new DavItem { EntityId = Configuration.ServerUrl })); MoveCommand = new DelegateCommand <DavItem>(async item => await NavigationService.NavigateAsync(typeof(SelectFolderPage), FilesPage.GetSelectedItems(item), new SuppressNavigationTransitionInfo())); RenameCommand = new DelegateCommand <DavItem>(async item => await Rename(item)); OpenCommand = new DelegateCommand <DavItem>(async item => await OpenFileAsync(item)); }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { Windows.UI.Core.SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.Visible; WebDavNavigationService = await WebDavNavigationService.InintializeAsync(); WebDavNavigationService.PropertyChanged += WebDavNavigationServiceOnPropertyChanged; //items should be moved if (parameter is List <DavItem> ) { _itemsToMove = parameter as List <DavItem>; HideItemsToMove(); } //just a folder has to be selected (nothing to move), the parameter is the default folder if (parameter is DavItem item) { await WebDavNavigationService.NavigateAsync(item); } await base.OnNavigatedToAsync(parameter, mode, state); }
private async Task <List <DavItem> > LoadItems() { var service = await WebDavNavigationService.InintializeAsync(); var serverUrl = Configuration.ServerUrl.Substring(0, Configuration.ServerUrl.IndexOf("remote.php", StringComparison.OrdinalIgnoreCase)); foreach (var davItem in service.Items) { if (!davItem.IsCollection && davItem.ContentType.StartsWith("image", StringComparison.OrdinalIgnoreCase)) { var url = new Uri(davItem.EntityId, UriKind.RelativeOrAbsolute); if (!url.IsAbsoluteUri) { url = new Uri(new Uri(serverUrl), url); } //var itemPath = davItem.EntityId.Substring(davItem.EntityId.IndexOf("remote.php/webdav", StringComparison.OrdinalIgnoreCase) + 17); //var url = serverUrl + "index.php/apps/files/api/v1/thumbnail/" + 2000 + "/" + 2000 + itemPath; davItem.ThumbnailUrl = url.ToString(); } } return(service.Items.Where(i => i.ContentType.StartsWith("image") || i.ContentType.StartsWith("video")).ToList()); }
private async Task Rename(DavItem item) { var dialog = new ContentDialog(); dialog.Title = App.ResourceLoader.GetString("RenameTitle"); var box = new TextBox(); box.Header = App.ResourceLoader.GetString("NewName"); box.AcceptsReturn = false; try { box.Text = Path.GetExtension(item.DisplayName); box.SelectedText = Path.GetFileNameWithoutExtension(item.DisplayName); } catch (ArgumentException) { box.Text = item.DisplayName; } dialog.Content = box; dialog.PrimaryButtonText = App.ResourceLoader.GetString("OK"); dialog.SecondaryButtonText = App.ResourceLoader.GetString("Cancel"); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { if (string.IsNullOrWhiteSpace(box.Text)) { return; } IndicatorService.GetDefault().ShowBar(); await WebDavItemService.GetDefault().Rename(item, box.Text); await WebDavNavigationService.ReloadAsync(); IndicatorService.GetDefault().HideBar(); } }