From d48b2d23515d06a21ad241380986bf8f31773195 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 22 Mar 2020 00:04:44 +0200 Subject: Implemented WebRtcTransportAdapter. Implemented FileSystem via WebRTC. Improved FileSystemControl keyboard control. Implemented FileSystemControl context menu. Improved Transported custom request handler registration. Implemented FS copy/move/delete. Implemented InputBox. --- .../Tango.FileSystem/FileSystemManager.cs | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) (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 44c8f1901..b8e59c322 100644 --- a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs +++ b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +using Tango.Core.Helpers; using Tango.FileSystem.Network; namespace Tango.FileSystem @@ -106,5 +107,50 @@ namespace Tango.FileSystem throw new FileNotFoundException("Could not locate the specified file or directory."); } } + + public void Move(MoveRequest request) + { + if (Directory.Exists(request.Destination)) + { + throw new IOException($"'{Path.GetFileName(request.Destination)}' already exists on the target folder."); + } + + if (File.Exists(request.Source)) + { + File.Move(request.Source, request.Destination); + } + else if (Directory.Exists(request.Source)) + { + Directory.Move(request.Source, request.Destination); + } + else + { + throw new FileNotFoundException("Could not locate the source file or folder."); + } + } + + public void Copy(CopyRequest request) + { + if (File.Exists(request.Source)) + { + if (request.Source == request.Destination) + { + while (File.Exists(request.Destination)) + { + request.Destination = Path.Combine(Path.GetDirectoryName(request.Destination), Path.GetFileNameWithoutExtension(request.Destination)) + " copy" + Path.GetExtension(request.Destination); + } + } + File.Copy(request.Source, request.Destination, true); + } + else if (Directory.Exists(request.Source)) + { + Directory.CreateDirectory(Path.GetDirectoryName(request.Destination)); + PathHelper.CopyDirectory(request.Source, request.Destination, true); + } + else + { + throw new FileNotFoundException("Could not locate the source file or folder."); + } + } } } -- cgit v1.3.1 From 5a5b63afd5c4ff1d6a1dbd6996ed0a5a494387d0 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 22 Mar 2020 14:53:04 +0200 Subject: Working on storage provider. --- .../ViewModels/FileSystemViewVM.cs | 8 +- .../Controls/FileSystemControl.xaml | 4 +- .../FSE/Tango.FSE.Common/FSEViewModel.cs | 7 + .../Tango.FSE.Common/Storage/IStorageProvider.cs | 36 ++ .../FSE/Tango.FSE.Common/Storage/IStorageResult.cs | 13 + .../Tango.FSE.Common/Storage/MultiStorageResult.cs | 24 ++ .../Storage/SingleStorageResult.cs | 19 + .../FSE/Tango.FSE.Common/Tango.FSE.Common.csproj | 4 + .../Tango.FSE.UI/Storage/DefaultStorageProvider.cs | 389 +++++++++++++++++++++ .../FSE/Tango.FSE.UI/Tango.FSE.UI.csproj | 8 + .../FSE/Tango.FSE.UI/ViewModelLocator.cs | 4 + .../FSE/Tango.FSE.UI/ViewModels/LoginViewVM.cs | 5 + .../FSE/Tango.FSE.UI/Views/MainView.xaml | 178 ++++++++++ .../FSE/Tango.FSE.UI/Views/MainView.xaml.cs | 13 + .../Visual_Studio/FSE/Tango.FSE.UI/packages.config | 2 + .../Tango.FileSystem/FileSystemManager.cs | 22 ++ 16 files changed, 732 insertions(+), 4 deletions(-) create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Storage/IStorageProvider.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Storage/IStorageResult.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Storage/MultiStorageResult.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/Storage/SingleStorageResult.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/Storage/DefaultStorageProvider.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 f074294b2..4e2ca1882 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 @@ -336,9 +336,13 @@ namespace Tango.FSE.PPCConsole.ViewModels } } - private void DownloadSelectedItems(List items) + private async void DownloadSelectedItems(List items) { - + var result = await StorageProvider.SelectFolder("Select download destination folder"); + if (result) + { + Debug.WriteLine($"Download to {result.SelectedItem}"); + } } private async void RenameFileSystemItem(FileSystemItem item) 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 62de7cf48..fcea26001 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FileSystemControl.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Controls/FileSystemControl.xaml @@ -93,7 +93,7 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Devices + + + + + + + + + + + Computer + + Desktop + Documents + Application Data + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml.cs index 3d29032b1..b98ad1a52 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Views/MainView.xaml.cs @@ -21,6 +21,7 @@ namespace Tango.FSE.UI.Views public partial class MainView : UserControl { private UIElement _previousFocusedElement; + private object _lastSelectedItem; public static MainView Instance { get; set; } @@ -105,5 +106,17 @@ namespace Tango.FSE.UI.Views e.Handled = true; } } + + private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (listView.SelectedItem != null) + { + _lastSelectedItem = listView.SelectedItem; + } + else + { + listView.SelectedItem = _lastSelectedItem; + } + } } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/packages.config b/Software/Visual_Studio/FSE/Tango.FSE.UI/packages.config index c795da787..fda2f4d3f 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/packages.config +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/packages.config @@ -14,4 +14,6 @@ + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs index b8e59c322..c18df97c9 100644 --- a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs +++ b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs @@ -92,6 +92,28 @@ namespace Tango.FileSystem }; } + public Task GetFolder(String path) + { + return Task.Factory.StartNew(() => + { + return FileSystemItem.FromDTO(GetFolder(new GetFileSystemItemRequest() + { + Path = path, + })); + }); + } + + public Task GetFolder(Environment.SpecialFolder specialFolder) + { + return Task.Factory.StartNew(() => + { + return FileSystemItem.FromDTO(GetFolder(new GetFileSystemItemRequest() + { + SpecialFolder = specialFolder + })); + }); + } + public void Delete(String path) { if (Directory.Exists(path)) -- cgit v1.3.1