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. --- .../Tango.FileSystem/FileExplorerControl.cs | 53 ++++++++++++++++++++-- .../Tango.FileSystem/FileSystemManager.cs | 17 +++++++ .../Network/CreateFolderRequest.cs | 14 ++++++ .../Network/CreateFolderResponse.cs | 13 ++++++ .../Tango.FileSystem/Tango.FileSystem.csproj | 2 + 5 files changed, 95 insertions(+), 4 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') diff --git a/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs b/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs index c624178a0..3660a18f0 100644 --- a/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs +++ b/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs @@ -105,6 +105,22 @@ namespace Tango.FileSystem public static readonly DependencyProperty DeleteCommandInternalProperty = DependencyProperty.Register("DeleteCommandInternal", typeof(ICommand), typeof(FileExplorerControl), new PropertyMetadata(null)); + public ICommand NewFolderCommandInternal + { + get { return (ICommand)GetValue(NewFolderCommandInternalProperty); } + set { SetValue(NewFolderCommandInternalProperty, value); } + } + public static readonly DependencyProperty NewFolderCommandInternalProperty = + DependencyProperty.Register("NewFolderCommandInternal", typeof(ICommand), typeof(FileExplorerControl), new PropertyMetadata(null)); + + public ICommand NewFolderCommand + { + get { return (ICommand)GetValue(NewFolderCommandProperty); } + set { SetValue(NewFolderCommandProperty, value); } + } + public static readonly DependencyProperty NewFolderCommandProperty = + DependencyProperty.Register("NewFolderCommand", typeof(ICommand), typeof(FileExplorerControl), new PropertyMetadata(null)); + public ICommand DropCommand { get { return (ICommand)GetValue(DropCommandProperty); } @@ -273,7 +289,6 @@ namespace Tango.FileSystem public static readonly DependencyProperty SelectionModeProperty = DependencyProperty.Register("SelectionMode", typeof(SelectionMode), typeof(FileExplorerControl), new PropertyMetadata(SelectionMode.Extended)); - static FileExplorerControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(FileExplorerControl), new FrameworkPropertyMetadata(typeof(FileExplorerControl))); @@ -343,21 +358,43 @@ namespace Tango.FileSystem OpenCommand = new RelayCommand(() => { ItemDoubleClickedCommand?.Execute(SelectedItems.FirstOrDefault()); - }, () => SelectedItems != null && SelectedItems.Count == 1); + }, () => + { + return SelectedItems != null && SelectedItems.Count == 1; + }); DeleteCommandInternal = new RelayCommand(() => { DeleteCommand?.Execute(SelectedItems.ToList()); - }, () => SelectedItems != null && SelectedItems.Count > 1 && SelectedItems.All(x => x.Type != FileSystemItemType.Drive)); + }, () => SelectedItems != null && SelectedItems.Count > 0 && SelectedItems.All(x => x.Type != FileSystemItemType.Drive)); - RenameCommandInternal = new RelayCommand(() => + RenameCommandInternal = new RelayCommand(() => { RenameCommand?.Execute(SelectedItems.FirstOrDefault()); }, () => SelectedItems != null && SelectedItems.Count == 1 && SelectedItems.All(x => x.Type != FileSystemItemType.Drive)); + + NewFolderCommandInternal = new RelayCommand(() => + { + NewFolderCommand?.Execute(null); + }, + () => + { + if (CurrentItem == null) return false; + + if (CurrentItem is FolderItem) + { + if ((CurrentItem as FolderItem).IsRoot) + { + return false; + } + } + + return true; + }); } private void OnIsContextMenuOpenedChanged() @@ -370,6 +407,7 @@ namespace Tango.FileSystem (OpenCommand as RelayCommand)?.RaiseCanExecuteChanged(); (DeleteCommandInternal as RelayCommand)?.RaiseCanExecuteChanged(); (RenameCommandInternal as RelayCommand)?.RaiseCanExecuteChanged(); + (NewFolderCommandInternal as RelayCommand)?.RaiseCanExecuteChanged(); if (IsContextMenuOpened) { @@ -479,6 +517,13 @@ namespace Tango.FileSystem DownloadCommandInternal.Execute(null); } } + else if (e.Key == Key.N && Keyboard.IsKeyDown(Key.LeftCtrl)) + { + if (NewFolderCommandInternal != null && NewFolderCommandInternal.CanExecute(null)) + { + DownloadCommandInternal.Execute(null); + } + } else if (e.Key == Key.F2) { if (RenameCommandInternal != null && RenameCommandInternal.CanExecute(null)) diff --git a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs index f72785f81..46ca080a2 100644 --- a/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs +++ b/Software/Visual_Studio/Tango.FileSystem/FileSystemManager.cs @@ -181,5 +181,22 @@ namespace Tango.FileSystem throw new FileNotFoundException("Could not locate the source file or folder."); } } + + public FileSystemItemDTO CreateFolder(String path, String folderName) + { + String fullPath = Path.Combine(path, folderName); + + if (Directory.Exists(fullPath)) + { + throw new IOException("The specified directory name already exists."); + } + + Directory.CreateDirectory(fullPath); + + return GetFolder(new GetFileSystemItemRequest() + { + Path = fullPath + }); + } } } diff --git a/Software/Visual_Studio/Tango.FileSystem/Network/CreateFolderRequest.cs b/Software/Visual_Studio/Tango.FileSystem/Network/CreateFolderRequest.cs new file mode 100644 index 000000000..77452dcdf --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Network/CreateFolderRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem.Network +{ + public class CreateFolderRequest + { + public String Path { get; set; } + public String FolderName { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Network/CreateFolderResponse.cs b/Software/Visual_Studio/Tango.FileSystem/Network/CreateFolderResponse.cs new file mode 100644 index 000000000..d52e52c47 --- /dev/null +++ b/Software/Visual_Studio/Tango.FileSystem/Network/CreateFolderResponse.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FileSystem.Network +{ + public class CreateFolderResponse + { + public FileSystemItemDTO FolderItem { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.FileSystem/Tango.FileSystem.csproj b/Software/Visual_Studio/Tango.FileSystem/Tango.FileSystem.csproj index a1218f12d..a31af216c 100644 --- a/Software/Visual_Studio/Tango.FileSystem/Tango.FileSystem.csproj +++ b/Software/Visual_Studio/Tango.FileSystem/Tango.FileSystem.csproj @@ -60,6 +60,8 @@ + + -- cgit v1.3.1