Implement the function to move files and folders
This commit is contained in:
Родитель
752e35fd81
Коммит
74c9eee8b1
|
@ -0,0 +1,9 @@
|
||||||
|
using NextcloudClient.Types;
|
||||||
|
|
||||||
|
namespace NextcloudApp.Models
|
||||||
|
{
|
||||||
|
public class MoveFileOrFolderPageParameters : PageParameters<MoveFileOrFolderPageParameters>
|
||||||
|
{
|
||||||
|
public ResourceInfo ResourceInfo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -114,6 +114,7 @@
|
||||||
<Compile Include="Converter\AddSlashToPathConverter.cs" />
|
<Compile Include="Converter\AddSlashToPathConverter.cs" />
|
||||||
<Compile Include="Converter\IsSortingToSelectionModeConverter.cs" />
|
<Compile Include="Converter\IsSortingToSelectionModeConverter.cs" />
|
||||||
<Compile Include="Converter\EmptyPathToSlashConverter.cs" />
|
<Compile Include="Converter\EmptyPathToSlashConverter.cs" />
|
||||||
|
<Compile Include="Models\MoveFileOrFolderPageParameters.cs" />
|
||||||
<Compile Include="Models\PageParameters.cs" />
|
<Compile Include="Models\PageParameters.cs" />
|
||||||
<Compile Include="Models\SingleFileDownloadPageParameters.cs" />
|
<Compile Include="Models\SingleFileDownloadPageParameters.cs" />
|
||||||
<Compile Include="Models\FileUploadPageParameters.cs" />
|
<Compile Include="Models\FileUploadPageParameters.cs" />
|
||||||
|
@ -149,6 +150,7 @@
|
||||||
<Compile Include="Utils\ObservableGroupingCollection.cs" />
|
<Compile Include="Utils\ObservableGroupingCollection.cs" />
|
||||||
<Compile Include="Utils\SortMode.cs" />
|
<Compile Include="Utils\SortMode.cs" />
|
||||||
<Compile Include="ViewModels\FileUploadPageViewModel.cs" />
|
<Compile Include="ViewModels\FileUploadPageViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\MoveFileOrFolderPageViewModel.cs" />
|
||||||
<Compile Include="ViewModels\SingleFileDownloadPageViewModel.cs" />
|
<Compile Include="ViewModels\SingleFileDownloadPageViewModel.cs" />
|
||||||
<Compile Include="ViewModels\FileInfoPageViewModel.cs" />
|
<Compile Include="ViewModels\FileInfoPageViewModel.cs" />
|
||||||
<Compile Include="ViewModels\SettingsPageViewModel.cs" />
|
<Compile Include="ViewModels\SettingsPageViewModel.cs" />
|
||||||
|
@ -157,6 +159,9 @@
|
||||||
<Compile Include="Views\FileUploadPage.xaml.cs">
|
<Compile Include="Views\FileUploadPage.xaml.cs">
|
||||||
<DependentUpon>FileUploadPage.xaml</DependentUpon>
|
<DependentUpon>FileUploadPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Views\MoveFileOrFolder.xaml.cs">
|
||||||
|
<DependentUpon>MoveFileOrFolder.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\SingleFileDownloadPage.xaml.cs">
|
<Compile Include="Views\SingleFileDownloadPage.xaml.cs">
|
||||||
<DependentUpon>SingleFileDownloadPage.xaml</DependentUpon>
|
<DependentUpon>SingleFileDownloadPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -225,6 +230,10 @@
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\MoveFileOrFolder.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\SingleFileDownloadPage.xaml">
|
<Page Include="Views\SingleFileDownloadPage.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
Settings,
|
Settings,
|
||||||
SingleFileDownload,
|
SingleFileDownload,
|
||||||
BulkFileDownload,
|
BulkFileDownload,
|
||||||
FileUpload
|
FileUpload,
|
||||||
|
MoveFileOrFolder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,5 +318,33 @@ namespace NextcloudApp.Services
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> Move(string oldPath, string newPath)
|
||||||
|
{
|
||||||
|
var client = ClientService.GetClient();
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var success = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
success = await client.Move(oldPath, newPath);
|
||||||
|
}
|
||||||
|
catch (ResponseError e)
|
||||||
|
{
|
||||||
|
if (e.StatusCode != "400") // ProtocolError
|
||||||
|
{
|
||||||
|
ResponseErrorHandlerService.HandleException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
await StartDirectoryListing();
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,4 +347,19 @@ Möchten Sie die Anwendungsentwickler informieren und den vorbereiteten Fehlerbe
|
||||||
<data name="Rename_Text.Text" xml:space="preserve">
|
<data name="Rename_Text.Text" xml:space="preserve">
|
||||||
<value>Umbenennen</value>
|
<value>Umbenennen</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MoveTo_Label.Label" xml:space="preserve">
|
||||||
|
<value>Verschieben nach</value>
|
||||||
|
</data>
|
||||||
|
<data name="MoveTo_Text.Text" xml:space="preserve">
|
||||||
|
<value>Verschieben nach</value>
|
||||||
|
</data>
|
||||||
|
<data name="AppBarCancel.Label" xml:space="preserve">
|
||||||
|
<value>Abbrechen</value>
|
||||||
|
</data>
|
||||||
|
<data name="AppBarDone.Label" xml:space="preserve">
|
||||||
|
<value>Fertig</value>
|
||||||
|
</data>
|
||||||
|
<data name="ChooseFolderListView_Header.Header" xml:space="preserve">
|
||||||
|
<value>Ordner auswählen</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -347,4 +347,19 @@ Would you like to inform the application developers and submit the prepared erro
|
||||||
<data name="Rename_Text.Text" xml:space="preserve">
|
<data name="Rename_Text.Text" xml:space="preserve">
|
||||||
<value>Rename</value>
|
<value>Rename</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MoveTo_Label.Label" xml:space="preserve">
|
||||||
|
<value>Move to</value>
|
||||||
|
</data>
|
||||||
|
<data name="MoveTo_Text.Text" xml:space="preserve">
|
||||||
|
<value>Move to</value>
|
||||||
|
</data>
|
||||||
|
<data name="AppBarCancel.Label" xml:space="preserve">
|
||||||
|
<value>Cancel</value>
|
||||||
|
</data>
|
||||||
|
<data name="AppBarDone.Label" xml:space="preserve">
|
||||||
|
<value>Done</value>
|
||||||
|
</data>
|
||||||
|
<data name="ChooseFolderListView_Header.Header" xml:space="preserve">
|
||||||
|
<value>Choose folder</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -37,6 +37,7 @@ namespace NextcloudApp.ViewModels
|
||||||
public ICommand UploadPhotosCommand { get; private set; }
|
public ICommand UploadPhotosCommand { get; private set; }
|
||||||
public ICommand DeleteResourceCommand { get; private set; }
|
public ICommand DeleteResourceCommand { get; private set; }
|
||||||
public ICommand RenameResourceCommand { get; private set; }
|
public ICommand RenameResourceCommand { get; private set; }
|
||||||
|
public ICommand MoveResourceCommand { get; private set; }
|
||||||
|
|
||||||
public DirectoryListPageViewModel(INavigationService navigationService, IResourceLoader resourceLoader, DialogService dialogService)
|
public DirectoryListPageViewModel(INavigationService navigationService, IResourceLoader resourceLoader, DialogService dialogService)
|
||||||
{
|
{
|
||||||
|
@ -85,6 +86,7 @@ namespace NextcloudApp.ViewModels
|
||||||
UploadPhotosCommand = new DelegateCommand(UploadPhotos);
|
UploadPhotosCommand = new DelegateCommand(UploadPhotos);
|
||||||
DeleteResourceCommand = new RelayCommand(DeleteResource);
|
DeleteResourceCommand = new RelayCommand(DeleteResource);
|
||||||
RenameResourceCommand = new RelayCommand(RenameResource);
|
RenameResourceCommand = new RelayCommand(RenameResource);
|
||||||
|
MoveResourceCommand = new RelayCommand(MoveResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary<string, object> viewModelState)
|
public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary<string, object> viewModelState)
|
||||||
|
@ -107,6 +109,20 @@ namespace NextcloudApp.ViewModels
|
||||||
base.OnNavigatingFrom(e, viewModelState, suspending);
|
base.OnNavigatingFrom(e, viewModelState, suspending);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MoveResource(object parameter)
|
||||||
|
{
|
||||||
|
var resourceInfo = parameter as ResourceInfo;
|
||||||
|
if (resourceInfo == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var parameters = new MoveFileOrFolderPageParameters
|
||||||
|
{
|
||||||
|
ResourceInfo = resourceInfo
|
||||||
|
};
|
||||||
|
_navigationService.Navigate(PageTokens.MoveFileOrFolder.ToString(), parameters.Serialize());
|
||||||
|
}
|
||||||
|
|
||||||
private async void DeleteResource(object parameter)
|
private async void DeleteResource(object parameter)
|
||||||
{
|
{
|
||||||
var resourceInfo = parameter as ResourceInfo;
|
var resourceInfo = parameter as ResourceInfo;
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace NextcloudApp.ViewModels
|
||||||
public ICommand DownloadCommand { get; private set; }
|
public ICommand DownloadCommand { get; private set; }
|
||||||
public ICommand DeleteResourceCommand { get; private set; }
|
public ICommand DeleteResourceCommand { get; private set; }
|
||||||
public ICommand RenameResourceCommand { get; private set; }
|
public ICommand RenameResourceCommand { get; private set; }
|
||||||
|
public ICommand MoveResourceCommand { get; private set; }
|
||||||
|
|
||||||
public FileInfoPageViewModel(INavigationService navigationService, IResourceLoader resourceLoader, DialogService dialogService)
|
public FileInfoPageViewModel(INavigationService navigationService, IResourceLoader resourceLoader, DialogService dialogService)
|
||||||
{
|
{
|
||||||
|
@ -56,6 +57,7 @@ namespace NextcloudApp.ViewModels
|
||||||
});
|
});
|
||||||
DeleteResourceCommand = new DelegateCommand(DeleteResource);
|
DeleteResourceCommand = new DelegateCommand(DeleteResource);
|
||||||
RenameResourceCommand = new DelegateCommand(RenameResource);
|
RenameResourceCommand = new DelegateCommand(RenameResource);
|
||||||
|
MoveResourceCommand = new RelayCommand(MoveResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary<string, object> viewModelState)
|
public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary<string, object> viewModelState)
|
||||||
|
@ -300,5 +302,19 @@ namespace NextcloudApp.ViewModels
|
||||||
_navigationService.GoBack();
|
_navigationService.GoBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MoveResource(object obj)
|
||||||
|
{
|
||||||
|
if (ResourceInfo == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var parameters = new MoveFileOrFolderPageParameters
|
||||||
|
{
|
||||||
|
ResourceInfo = ResourceInfo
|
||||||
|
};
|
||||||
|
_navigationService.Navigate(PageTokens.MoveFileOrFolder.ToString(), parameters.Serialize());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,317 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Controls;
|
||||||
|
using NextcloudApp.Models;
|
||||||
|
using NextcloudApp.Services;
|
||||||
|
using NextcloudClient.Types;
|
||||||
|
using Prism.Commands;
|
||||||
|
using Prism.Windows.AppModel;
|
||||||
|
using Prism.Windows.Navigation;
|
||||||
|
|
||||||
|
namespace NextcloudApp.ViewModels
|
||||||
|
{
|
||||||
|
public class MoveFileOrFolderPageViewModel : ViewModel
|
||||||
|
{
|
||||||
|
private Settings _settngs;
|
||||||
|
private DirectoryService _directoryService;
|
||||||
|
private ResourceInfo _selectedFileOrFolder;
|
||||||
|
private int _selectedPathIndex = -1;
|
||||||
|
private readonly INavigationService _navigationService;
|
||||||
|
private readonly IResourceLoader _resourceLoader;
|
||||||
|
private readonly DialogService _dialogService;
|
||||||
|
private bool _isNavigatingBack;
|
||||||
|
|
||||||
|
public ICommand GroupByNameAscendingCommand { get; private set; }
|
||||||
|
public ICommand GroupByNameDescendingCommand { get; private set; }
|
||||||
|
public ICommand GroupByDateAscendingCommand { get; private set; }
|
||||||
|
public ICommand GroupByDateDescendingCommand { get; private set; }
|
||||||
|
public ICommand GroupBySizeAscendingCommand { get; private set; }
|
||||||
|
public ICommand GroupBySizeDescendingCommand { get; private set; }
|
||||||
|
public ICommand RefreshCommand { get; private set; }
|
||||||
|
public ICommand CreateDirectoryCommand { get; private set; }
|
||||||
|
public object CancelFolderSelectionCommand { get; private set; }
|
||||||
|
public object MoveToSelectedFolderCommand { get; private set; }
|
||||||
|
|
||||||
|
public MoveFileOrFolderPageViewModel(INavigationService navigationService, IResourceLoader resourceLoader, DialogService dialogService)
|
||||||
|
{
|
||||||
|
_navigationService = navigationService;
|
||||||
|
_resourceLoader = resourceLoader;
|
||||||
|
_dialogService = dialogService;
|
||||||
|
Settings = SettingsService.Instance.Settings;
|
||||||
|
GroupByNameAscendingCommand = new DelegateCommand(() =>
|
||||||
|
{
|
||||||
|
Directory.GroupByNameAscending();
|
||||||
|
SelectedFileOrFolder = null;
|
||||||
|
});
|
||||||
|
GroupByNameDescendingCommand = new DelegateCommand(() =>
|
||||||
|
{
|
||||||
|
Directory.GroupByNameDescending();
|
||||||
|
SelectedFileOrFolder = null;
|
||||||
|
});
|
||||||
|
GroupByDateAscendingCommand = new DelegateCommand(() =>
|
||||||
|
{
|
||||||
|
Directory.GroupByDateAscending();
|
||||||
|
SelectedFileOrFolder = null;
|
||||||
|
});
|
||||||
|
GroupByDateDescendingCommand = new DelegateCommand(() =>
|
||||||
|
{
|
||||||
|
Directory.GroupByDateDescending();
|
||||||
|
SelectedFileOrFolder = null;
|
||||||
|
});
|
||||||
|
GroupBySizeAscendingCommand = new DelegateCommand(() =>
|
||||||
|
{
|
||||||
|
Directory.GroupBySizeAscending();
|
||||||
|
SelectedFileOrFolder = null;
|
||||||
|
});
|
||||||
|
GroupBySizeDescendingCommand = new DelegateCommand(() =>
|
||||||
|
{
|
||||||
|
Directory.GroupBySizeDescending();
|
||||||
|
SelectedFileOrFolder = null;
|
||||||
|
});
|
||||||
|
RefreshCommand = new DelegateCommand(async () =>
|
||||||
|
{
|
||||||
|
ShowProgressIndicator();
|
||||||
|
await Directory.Refresh();
|
||||||
|
HideProgressIndicator();
|
||||||
|
});
|
||||||
|
CreateDirectoryCommand = new DelegateCommand(CreateDirectory);
|
||||||
|
MoveToSelectedFolderCommand = new DelegateCommand(MoveToSelectedFolder);
|
||||||
|
CancelFolderSelectionCommand = new DelegateCommand(CancelFolderSelection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary<string, object> viewModelState)
|
||||||
|
{
|
||||||
|
base.OnNavigatedTo(e, viewModelState);
|
||||||
|
base.OnNavigatedTo(e, viewModelState);
|
||||||
|
var parameters = MoveFileOrFolderPageParameters.Deserialize(e.Parameter);
|
||||||
|
var resourceInfo = parameters?.ResourceInfo;
|
||||||
|
if (resourceInfo == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ResourceInfo = resourceInfo;
|
||||||
|
Directory = DirectoryService.Instance;
|
||||||
|
StartDirectoryListing();
|
||||||
|
_isNavigatingBack = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceInfo ResourceInfo { get; private set; }
|
||||||
|
|
||||||
|
public override void OnNavigatingFrom(NavigatingFromEventArgs e, Dictionary<string, object> viewModelState, bool suspending)
|
||||||
|
{
|
||||||
|
_isNavigatingBack = true;
|
||||||
|
if (!suspending)
|
||||||
|
{
|
||||||
|
Directory.StopDirectoryListing();
|
||||||
|
Directory = null;
|
||||||
|
_selectedFileOrFolder = null;
|
||||||
|
}
|
||||||
|
base.OnNavigatingFrom(e, viewModelState, suspending);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CancelFolderSelection()
|
||||||
|
{
|
||||||
|
_navigationService.GoBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void MoveToSelectedFolder()
|
||||||
|
{
|
||||||
|
ShowProgressIndicator();
|
||||||
|
var currentFolderResourceInfo = Directory.PathStack.Count > 0
|
||||||
|
? Directory.PathStack[Directory.PathStack.Count - 1].ResourceInfo
|
||||||
|
: new ResourceInfo();
|
||||||
|
|
||||||
|
var oldPath = string.IsNullOrEmpty(ResourceInfo.Path) ? "/" : ResourceInfo.Path;
|
||||||
|
oldPath = oldPath.TrimEnd('/');
|
||||||
|
|
||||||
|
if (!ResourceInfo.ContentType.Equals("dav/directory"))
|
||||||
|
{
|
||||||
|
oldPath = oldPath + "/" + ResourceInfo.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
var newPath = string.IsNullOrEmpty(currentFolderResourceInfo.Path) ? "/" : currentFolderResourceInfo.Path;
|
||||||
|
newPath = newPath.TrimEnd('/');
|
||||||
|
newPath = newPath + "/" + ResourceInfo.Name;
|
||||||
|
|
||||||
|
var success = await Directory.Move(oldPath, newPath);
|
||||||
|
|
||||||
|
HideProgressIndicator();
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
_navigationService.GoBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void CreateDirectory()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var dialog = new ContentDialog
|
||||||
|
{
|
||||||
|
Title = _resourceLoader.GetString("CreateNewFolder"),
|
||||||
|
Content = new TextBox()
|
||||||
|
{
|
||||||
|
Header = _resourceLoader.GetString("FolderName"),
|
||||||
|
PlaceholderText = _resourceLoader.GetString("NewFolder"),
|
||||||
|
Margin = new Thickness(0, 20, 0, 0)
|
||||||
|
},
|
||||||
|
PrimaryButtonText = _resourceLoader.GetString("Create"),
|
||||||
|
SecondaryButtonText = _resourceLoader.GetString("Cancel")
|
||||||
|
};
|
||||||
|
var dialogResult = await _dialogService.ShowAsync(dialog);
|
||||||
|
if (dialogResult != ContentDialogResult.Primary)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var textBox = dialog.Content as TextBox;
|
||||||
|
if (textBox == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var folderName = textBox.Text;
|
||||||
|
if (string.IsNullOrEmpty(folderName))
|
||||||
|
{
|
||||||
|
folderName = _resourceLoader.GetString("NewFolder");
|
||||||
|
}
|
||||||
|
ShowProgressIndicator();
|
||||||
|
var success = await Directory.CreateDirectory(folderName);
|
||||||
|
HideProgressIndicator();
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog = new ContentDialog
|
||||||
|
{
|
||||||
|
Title = _resourceLoader.GetString("CanNotCreateFolder"),
|
||||||
|
Content = new TextBlock
|
||||||
|
{
|
||||||
|
Text = _resourceLoader.GetString("SpecifyDifferentName"),
|
||||||
|
TextWrapping = TextWrapping.WrapWholeWords,
|
||||||
|
Margin = new Thickness(0, 20, 0, 0)
|
||||||
|
},
|
||||||
|
PrimaryButtonText = _resourceLoader.GetString("Retry"),
|
||||||
|
SecondaryButtonText = _resourceLoader.GetString("Cancel")
|
||||||
|
};
|
||||||
|
dialogResult = await _dialogService.ShowAsync(dialog);
|
||||||
|
if (dialogResult != ContentDialogResult.Primary)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DirectoryService Directory
|
||||||
|
{
|
||||||
|
get { return _directoryService; }
|
||||||
|
private set { SetProperty(ref _directoryService, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Settings Settings
|
||||||
|
{
|
||||||
|
get { return _settngs; }
|
||||||
|
private set { SetProperty(ref _settngs, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceInfo SelectedFileOrFolder
|
||||||
|
{
|
||||||
|
get { return _selectedFileOrFolder; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_isNavigatingBack)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!SetProperty(ref _selectedFileOrFolder, value))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_selectedPathIndex = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory?.PathStack == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.IsSorting)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (value.IsDirectory())
|
||||||
|
{
|
||||||
|
Directory.PathStack.Add(new PathInfo
|
||||||
|
{
|
||||||
|
ResourceInfo = value
|
||||||
|
});
|
||||||
|
SelectedPathIndex = Directory.PathStack.Count - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int SelectedPathIndex
|
||||||
|
{
|
||||||
|
get { return _selectedPathIndex; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!SetProperty(ref _selectedPathIndex, value))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_selectedPathIndex = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory?.PathStack == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (Directory.PathStack.Count > 0 && Directory.PathStack.Count > _selectedPathIndex + 1)
|
||||||
|
{
|
||||||
|
Directory.PathStack.RemoveAt(Directory.PathStack.Count - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
StartDirectoryListing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void StartDirectoryListing()
|
||||||
|
{
|
||||||
|
ShowProgressIndicator();
|
||||||
|
|
||||||
|
await Directory.StartDirectoryListing();
|
||||||
|
|
||||||
|
HideProgressIndicator();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool CanRevertState()
|
||||||
|
{
|
||||||
|
return SelectedPathIndex > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void RevertState()
|
||||||
|
{
|
||||||
|
SelectedPathIndex--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -250,6 +250,13 @@
|
||||||
Command="{Binding DataContext.RenameResourceCommand, ElementName=Page}"
|
Command="{Binding DataContext.RenameResourceCommand, ElementName=Page}"
|
||||||
CommandParameter="{Binding}"
|
CommandParameter="{Binding}"
|
||||||
Style="{StaticResource MenuFlyoutIconItemStyle}"/>
|
Style="{StaticResource MenuFlyoutIconItemStyle}"/>
|
||||||
|
<MenuFlyoutItem
|
||||||
|
Tag="MoveToFolder"
|
||||||
|
x:Uid="MoveTo_Text"
|
||||||
|
Text="Move to"
|
||||||
|
Command="{Binding DataContext.MoveResourceCommand, ElementName=Page}"
|
||||||
|
CommandParameter="{Binding}"
|
||||||
|
Style="{StaticResource MenuFlyoutIconItemStyle}"/>
|
||||||
<MenuFlyoutItem
|
<MenuFlyoutItem
|
||||||
Tag="Delete"
|
Tag="Delete"
|
||||||
x:Uid="Delete_Text"
|
x:Uid="Delete_Text"
|
||||||
|
|
|
@ -272,6 +272,11 @@
|
||||||
Label="Rename"
|
Label="Rename"
|
||||||
x:Uid="Rename_Label"
|
x:Uid="Rename_Label"
|
||||||
Command="{Binding RenameResourceCommand}"/>
|
Command="{Binding RenameResourceCommand}"/>
|
||||||
|
<AppBarButton
|
||||||
|
Icon="MoveToFolder"
|
||||||
|
Label="Move to"
|
||||||
|
x:Uid="MoveTo_Label"
|
||||||
|
Command="{Binding MoveResourceCommand}"/>
|
||||||
<AppBarButton
|
<AppBarButton
|
||||||
Icon="Delete"
|
Icon="Delete"
|
||||||
Label="Delete"
|
Label="Delete"
|
||||||
|
|
|
@ -0,0 +1,296 @@
|
||||||
|
<prismMvvm:SessionStateAwarePage
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:prismMvvm="using:Prism.Windows.Mvvm"
|
||||||
|
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||||
|
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
|
||||||
|
xmlns:behaviors="using:NextcloudApp.Behaviors"
|
||||||
|
xmlns:actions="using:NextcloudApp.Actions"
|
||||||
|
x:Class="NextcloudApp.Views.MoveFileOrFolderPage"
|
||||||
|
x:Name="Page"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
prismMvvm:ViewModelLocator.AutoWireViewModel="True"
|
||||||
|
NavigationCacheMode="Enabled">
|
||||||
|
|
||||||
|
<Page.Resources>
|
||||||
|
<CollectionViewSource
|
||||||
|
x:Key="GroupedFilesAndFolders"
|
||||||
|
Source="{Binding Directory.GroupedFilesAndFolders}"
|
||||||
|
IsSourceGrouped="{Binding Settings.ShowFileAndFolderGroupingHeader}" />
|
||||||
|
</Page.Resources>
|
||||||
|
|
||||||
|
<Grid Background="{ThemeResource SystemControlBackgroundChromeMediumBrush}">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="48" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<ListBox
|
||||||
|
x:Name="PathList"
|
||||||
|
ItemsSource="{Binding Directory.PathStack}"
|
||||||
|
SelectionMode="Single"
|
||||||
|
SelectedIndex="{Binding SelectedPathIndex, Mode=TwoWay}"
|
||||||
|
Margin="48,0,0,0">
|
||||||
|
|
||||||
|
<ListBox.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<VirtualizingStackPanel Orientation="Horizontal"/>
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ListBox.ItemsPanel>
|
||||||
|
|
||||||
|
<ListBox.Template>
|
||||||
|
<ControlTemplate TargetType="ItemsControl">
|
||||||
|
<ScrollViewer HorizontalScrollBarVisibility="Visible">
|
||||||
|
<ItemsPresenter/>
|
||||||
|
</ScrollViewer>
|
||||||
|
</ControlTemplate>
|
||||||
|
</ListBox.Template>
|
||||||
|
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBlock Text="{Binding ResourceInfo.Name}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
|
||||||
|
<ListBox.ItemContainerStyle>
|
||||||
|
<Style TargetType="ListBoxItem">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ListBoxItem">
|
||||||
|
<StackPanel
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Height="48">
|
||||||
|
<FontIcon
|
||||||
|
Glyph=""
|
||||||
|
FontSize="8"
|
||||||
|
Margin="0,0,8,0"
|
||||||
|
Foreground="{StaticResource SystemControlHighlightAccentBrush}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Visibility="{Binding IsRoot, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=true}"/>
|
||||||
|
<FontIcon
|
||||||
|
Glyph="{StaticResource NextclousLogo}"
|
||||||
|
FontFamily="{StaticResource NextcloudIcons}"
|
||||||
|
Margin="8,0,8,0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Visibility="{Binding IsRoot, Converter={StaticResource BooleanToVisibilityConverter}}"/>
|
||||||
|
<ContentPresenter
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Margin="0,0,8,0"
|
||||||
|
Visibility="{Binding IsRoot, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=true}" />
|
||||||
|
</StackPanel>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</ListBox.ItemContainerStyle>
|
||||||
|
|
||||||
|
<interactivity:Interaction.Behaviors>
|
||||||
|
<behaviors:ScrollListBoxToEndBehavior/>
|
||||||
|
</interactivity:Interaction.Behaviors>
|
||||||
|
</ListBox>
|
||||||
|
|
||||||
|
<SemanticZoom
|
||||||
|
Grid.Row="1"
|
||||||
|
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||||
|
<SemanticZoom.ZoomedInView>
|
||||||
|
<ListView
|
||||||
|
x:Uid="ChooseFolderListView_Header"
|
||||||
|
Name="ChooseFolderListView"
|
||||||
|
SelectedIndex="-1"
|
||||||
|
IsHoldingEnabled="True"
|
||||||
|
ItemsSource="{Binding Source={StaticResource GroupedFilesAndFolders}}"
|
||||||
|
SelectedItem="{Binding SelectedFileOrFolder, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
SelectionMode="{Binding Directory.IsSorting, Converter={StaticResource IsSortingToSelectionModeConverter}}"
|
||||||
|
Padding="0,2,0,2"
|
||||||
|
ContinuumNavigationTransitionInfo.ExitElementContainer="True"
|
||||||
|
Header="Choose folder">
|
||||||
|
<ListView.HeaderTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Border Background="{ThemeResource SystemControlHighlightAccentBrush}">
|
||||||
|
<TextBlock
|
||||||
|
Text="{Binding}"
|
||||||
|
Padding="14,8,14,8"/>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.HeaderTemplate>
|
||||||
|
<ListView.Resources>
|
||||||
|
<Style x:Key="FileOrFolderHeaderItemStyle" TargetType="ListViewHeaderItem">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="ListViewHeaderItem">
|
||||||
|
<ContentPresenter
|
||||||
|
x:Name="ContentPresenter"
|
||||||
|
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||||
|
ContentTransitions="{TemplateBinding ContentTransitions}"
|
||||||
|
Content="{TemplateBinding Content}"
|
||||||
|
Background="#00000000"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
VerticalContentAlignment="Center"/>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</ListView.Resources>
|
||||||
|
<ListView.ItemContainerStyle>
|
||||||
|
<Style TargetType="ListViewItem">
|
||||||
|
<Setter Property="Padding" Value="4,2,4,2"/>
|
||||||
|
</Style>
|
||||||
|
</ListView.ItemContainerStyle>
|
||||||
|
<ListView.GroupStyle>
|
||||||
|
<GroupStyle HeaderContainerStyle="{StaticResource FileOrFolderHeaderItemStyle}">
|
||||||
|
<GroupStyle.ContainerStyle>
|
||||||
|
<Style TargetType="GroupItem">
|
||||||
|
<Setter Property="IsTabStop" Value="False"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="GroupItem">
|
||||||
|
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<ContentControl
|
||||||
|
x:Name="HeaderContent"
|
||||||
|
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||||
|
HorizontalContentAlignment="Stretch"
|
||||||
|
ContentTransitions="{TemplateBinding ContentTransitions}"
|
||||||
|
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
|
||||||
|
Content="{TemplateBinding Content}"
|
||||||
|
IsTabStop="False"
|
||||||
|
Margin="0"
|
||||||
|
TabIndex="0"/>
|
||||||
|
<ItemsControl x:Name="ItemsControl" IsTabStop="False" ItemsSource="{Binding GroupItems}" Grid.Row="1" TabIndex="1" TabNavigation="Once">
|
||||||
|
<ItemsControl.ItemContainerTransitions>
|
||||||
|
<TransitionCollection>
|
||||||
|
<AddDeleteThemeTransition/>
|
||||||
|
<ContentThemeTransition/>
|
||||||
|
<ReorderThemeTransition/>
|
||||||
|
<EntranceThemeTransition IsStaggeringEnabled="False"/>
|
||||||
|
</TransitionCollection>
|
||||||
|
</ItemsControl.ItemContainerTransitions>
|
||||||
|
</ItemsControl>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</GroupStyle.ContainerStyle>
|
||||||
|
<GroupStyle.HeaderTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBlock
|
||||||
|
Style="{StaticResource TitleTextBlockStyle}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Padding="4,0,0,0"
|
||||||
|
TextWrapping="NoWrap"
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
Text="{Binding Key}"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</GroupStyle.HeaderTemplate>
|
||||||
|
</GroupStyle>
|
||||||
|
</ListView.GroupStyle>
|
||||||
|
<ListView.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Grid
|
||||||
|
Grid.RowSpan="2"
|
||||||
|
Height="40"
|
||||||
|
Width="40"
|
||||||
|
Margin="0,0,4,0"
|
||||||
|
Background="{StaticResource SystemControlHighlightAccentBrush}">
|
||||||
|
<FontIcon
|
||||||
|
Glyph="{Binding Converter={StaticResource ContentTypeToIconConverter}}"
|
||||||
|
FontFamily="Segoe MDL2 Assets"
|
||||||
|
FontSize="28"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Foreground="White"/>
|
||||||
|
<Border
|
||||||
|
Background="#808080"
|
||||||
|
Visibility="{Binding Thumbnail, Converter={StaticResource NullToVisibilityConverter}}">
|
||||||
|
<Image
|
||||||
|
Source="{Binding Thumbnail}"
|
||||||
|
Stretch="UniformToFill"/>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Text="{Binding Name}"
|
||||||
|
TextWrapping="NoWrap"
|
||||||
|
TextTrimming="CharacterEllipsis" />
|
||||||
|
<StackPanel
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<TextBlock
|
||||||
|
Text="{Binding Size, Converter={StaticResource BytesToHumanReadableConverter}}"
|
||||||
|
Foreground="{StaticResource SystemControlForegroundBaseMediumBrush}"
|
||||||
|
Margin="0,0,8,0"
|
||||||
|
Visibility="{Binding Converter={StaticResource IsFileAndNotFolderToVisibilityConverter}}"/>
|
||||||
|
<TextBlock
|
||||||
|
Text="{Binding LastModified, Converter={StaticResource DateTimeToStringConverter}}"
|
||||||
|
Foreground="{StaticResource SystemControlForegroundBaseMediumBrush}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
</SemanticZoom.ZoomedInView>
|
||||||
|
<SemanticZoom.ZoomedOutView>
|
||||||
|
<GridView
|
||||||
|
ItemsSource="{Binding Source={StaticResource GroupedFilesAndFolders}, Path=CollectionGroups}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
|
HorizontalContentAlignment="Center">
|
||||||
|
<GridView.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Border
|
||||||
|
Background="Transparent"
|
||||||
|
MinWidth="52"
|
||||||
|
MinHeight="52"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center">
|
||||||
|
<TextBlock
|
||||||
|
Text="{Binding Group.Key}"
|
||||||
|
Style="{StaticResource TitleTextBlockStyle}"
|
||||||
|
TextWrapping="NoWrap"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Margin="8"/>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</GridView.ItemTemplate>
|
||||||
|
</GridView>
|
||||||
|
</SemanticZoom.ZoomedOutView>
|
||||||
|
</SemanticZoom>
|
||||||
|
<CommandBar Grid.Row="2" VerticalAlignment="Bottom">
|
||||||
|
<CommandBar.SecondaryCommands>
|
||||||
|
<AppBarButton
|
||||||
|
Icon="Sync"
|
||||||
|
Label="Refresh"
|
||||||
|
x:Uid="AppBarRefresh"
|
||||||
|
Command="{Binding RefreshCommand}"/>
|
||||||
|
</CommandBar.SecondaryCommands>
|
||||||
|
<AppBarButton Icon="Accept" Label="Done" x:Uid="AppBarDone" Command="{Binding MoveToSelectedFolderCommand}"/>
|
||||||
|
<AppBarButton Icon="Clear" Label="Cancel" x:Uid="AppBarCancel" Command="{Binding CancelFolderSelectionCommand}"/>
|
||||||
|
</CommandBar>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
</prismMvvm:SessionStateAwarePage>
|
|
@ -0,0 +1,12 @@
|
||||||
|
using Prism.Windows.Mvvm;
|
||||||
|
|
||||||
|
namespace NextcloudApp.Views
|
||||||
|
{
|
||||||
|
public sealed partial class MoveFileOrFolderPage : SessionStateAwarePage
|
||||||
|
{
|
||||||
|
public MoveFileOrFolderPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче