From 912e8423fbf63a025dac977d5749e60d4c57df68 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Tue, 24 Mar 2020 18:31:31 +0200 Subject: Working on storage. --- .../Tango.FileSystem/FileSystemManager.cs | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs') diff --git a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs index c18df97c9..f72785f81 100644 --- a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs +++ b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs @@ -73,15 +73,18 @@ namespace Tango.FileSystem }); } - foreach (var file in Directory.GetFiles(request.Path)) + if (!request.FoldersOnly) { - items.Add(new FileSystemItemDTO() + foreach (var file in Directory.GetFiles(request.Path, request.Filter != null ? request.Filter : "*.*")) { - Path = file, - Type = FileSystemItemType.File, - DateModified = File.GetLastWriteTimeUtc(file), - Size = new FileInfo(file).Length - }); + items.Add(new FileSystemItemDTO() + { + Path = file, + Type = FileSystemItemType.File, + DateModified = File.GetLastWriteTimeUtc(file), + Size = new FileInfo(file).Length + }); + } } return new FileSystemItemDTO() @@ -92,24 +95,28 @@ namespace Tango.FileSystem }; } - public Task GetFolder(String path) + public Task GetFolder(String path, bool foldersOnly = false, String filter = "*.*") { return Task.Factory.StartNew(() => { return FileSystemItem.FromDTO(GetFolder(new GetFileSystemItemRequest() { Path = path, + FoldersOnly = foldersOnly, + Filter = filter, })); }); } - public Task GetFolder(Environment.SpecialFolder specialFolder) + public Task GetFolder(Environment.SpecialFolder specialFolder, bool foldersOnly = false, String filter = "*.*") { return Task.Factory.StartNew(() => { return FileSystemItem.FromDTO(GetFolder(new GetFileSystemItemRequest() { - SpecialFolder = specialFolder + SpecialFolder = specialFolder, + FoldersOnly = foldersOnly, + Filter = filter, })); }); } -- cgit v1.3.1 From 42c06402ff6648c356fba8315958283762ed2542 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 25 Mar 2020 00:26:47 +0200 Subject: Added Download menu implementation to file system. Added several stun and turn servers to web rtc. --- .../ViewModels/FileSystemViewVM.cs | 53 ++++++++++++++++++++++ .../Tango.FSE.PPCConsole/Views/FileSystemView.xaml | 17 ++++++- .../Controls/FileSystemControl.xaml | 11 ++++- .../FileSystem/IFileSystemProvider.cs | 1 + .../FileSystem/DefaultFileSystemProvider.cs | 11 +++++ .../Tango.FSE.UI/Storage/DefaultStorageProvider.cs | 2 +- .../FSE/Tango.FSE.UI/ViewModels/LoginViewVM.cs | 4 +- .../FileSystem/DefaultFileSystemService.cs | 14 ++++++ .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- .../Tango.FileSystem/FileExplorerControl.cs | 53 ++++++++++++++++++++-- .../Tango.FileSystem/FileSystemManager.cs | 17 +++++++ .../Network/CreateFolderRequest.cs | 14 ++++++ .../Network/CreateFolderResponse.cs | 13 ++++++ .../Tango.FileSystem/Tango.FileSystem.csproj | 2 + .../Visual_Studio/Tango.WebRTC/WebRtcClient.cs | 17 +++++++ 15 files changed, 219 insertions(+), 12 deletions(-) create mode 100644 Software/Visual_Studio/Tango.FileSystem/Network/CreateFolderRequest.cs create mode 100644 Software/Visual_Studio/Tango.FileSystem/Network/CreateFolderResponse.cs (limited to 'Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs index 4e2ca1882..e10cc0ad1 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs @@ -58,6 +58,7 @@ namespace Tango.FSE.PPCConsole.ViewModels public RelayCommand> CutPasteCommand { get; set; } public RelayCommand> DownloadCommand { get; set; } public RelayCommand RenameCommand { get; set; } + public RelayCommand NewFolderCommand { get; set; } public FileSystemViewVM() @@ -78,6 +79,7 @@ namespace Tango.FSE.PPCConsole.ViewModels CutPasteCommand = new RelayCommand>((items) => PasteItems(items, true)); DownloadCommand = new RelayCommand>(DownloadSelectedItems); RenameCommand = new RelayCommand(RenameFileSystemItem); + NewFolderCommand = new RelayCommand(CreateNewFolder); } private async void NavigateBack() @@ -341,7 +343,24 @@ namespace Tango.FSE.PPCConsole.ViewModels var result = await StorageProvider.SelectFolder("Select download destination folder"); if (result) { + + String destination = result.SelectedItem; + Debug.WriteLine($"Download to {result.SelectedItem}"); + + foreach (var item in items.Where(x => x.Type != FileSystemItemType.Drive)) + { + if (File.Exists(Path.Combine(destination, item.Name)) || Directory.Exists(Path.Combine(destination, item.Name))) + { + if (!await NotificationProvider.ShowWarningQuestion($"'{item.Name}' already exists on '{Path.GetDirectoryName(destination)}'. Do you want to overwrite?")) + { + continue; + } + } + + var handler = await FileSystemProvider.Download(item, destination); + FileSystemHandlers.Insert(0, handler); + } } } @@ -376,6 +395,40 @@ namespace Tango.FSE.PPCConsole.ViewModels } } + private async void CreateNewFolder() + { + if (CurrentItem == null) return; + if (CurrentItem is FolderItem) + { + if ((CurrentItem as FolderItem).IsRoot) return; + } + + var result = await NotificationProvider.ShowInputBox( + "New Folder", + $"Please enter a folder name and press 'ENTER'.", + PackIconKind.FolderAdd, "untitled", + "folder name", + 100, + "CREATE"); + + if (result.Confirmed) + { + try + { + using (NotificationProvider.PushTaskItem("Creating new folder...")) + { + var folderItem = await FileSystemProvider.CreateFolder(CurrentItem, result.Input); + NavigateToCurrentPath(); //Instead of inserting folder item just refresh the current path... + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"Error creating new folder '{Path.Combine(CurrentItem.Path,result.Input)}."); + await NotificationProvider.ShowError($"Error creating folder '{result.Input}'.\n{ex.FlattenMessage()}"); + } + } + } + private void OnCurrentItemChanged() { CurrentPath = CurrentItem.Path; diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/FileSystemView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/FileSystemView.xaml index d1143ede4..67f1dc1c5 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/FileSystemView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/FileSystemView.xaml @@ -121,6 +121,7 @@ + RenameCommand="{Binding RenameCommand}" + NewFolderCommand="{Binding NewFolderCommand}"/> @@ -163,7 +165,18 @@ - + + + + + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FileSystemControl.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FileSystemControl.xaml index eb1007609..5bc75ca54 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FileSystemControl.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FileSystemControl.xaml @@ -49,6 +49,13 @@ + + + + + + + @@ -93,7 +100,7 @@ - + - +