diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-24 18:31:31 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-24 18:31:31 +0200 |
| commit | 912e8423fbf63a025dac977d5749e60d4c57df68 (patch) | |
| tree | f7bf2901f49cc2d970a8e5c2fb79069b03798ae2 /Software/Visual_Studio/Tango.FileSystem | |
| parent | 74090438f4bbd60ad561c35b63b351a54014e4d2 (diff) | |
| download | Tango-912e8423fbf63a025dac977d5749e60d4c57df68.tar.gz Tango-912e8423fbf63a025dac977d5749e60d4c57df68.zip | |
Working on storage.
Diffstat (limited to 'Software/Visual_Studio/Tango.FileSystem')
3 files changed, 52 insertions, 28 deletions
diff --git a/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs b/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs index 60061780b..c624178a0 100644 --- a/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs +++ b/Software/Visual_Studio/Tango.FileSystem/FileExplorerControl.cs @@ -265,6 +265,15 @@ namespace Tango.FileSystem public static readonly DependencyProperty AllowDragProperty = DependencyProperty.Register("AllowDrag", typeof(bool), typeof(FileExplorerControl), new PropertyMetadata(null)); + public SelectionMode SelectionMode + { + get { return (SelectionMode)GetValue(SelectionModeProperty); } + set { SetValue(SelectionModeProperty, value); } + } + 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))); @@ -492,39 +501,45 @@ namespace Tango.FileSystem private void _datagrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { - if (!_preventSynchronization) + if (SelectionMode == SelectionMode.Extended) { - _preventSynchronization = true; + if (!_preventSynchronization) + { + _preventSynchronization = true; - _listBox.SelectedItems.Clear(); + _listBox.SelectedItems.Clear(); - foreach (var item in _datagrid.SelectedItems) - { - _listBox.SelectedItems.Add(item); - } + foreach (var item in _datagrid.SelectedItems) + { + _listBox.SelectedItems.Add(item); + } - SynchronizeSelectedItems(_listBox.SelectedItems); + SynchronizeSelectedItems(_listBox.SelectedItems); - _preventSynchronization = false; + _preventSynchronization = false; + } } } private void _listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { - if (!_preventSynchronization) + if (SelectionMode == SelectionMode.Extended) { - _preventSynchronization = true; + if (!_preventSynchronization) + { + _preventSynchronization = true; - _datagrid.SelectedItems.Clear(); + _datagrid.SelectedItems.Clear(); - foreach (var item in _listBox.SelectedItems) - { - _datagrid.SelectedItems.Add(item); - } + foreach (var item in _listBox.SelectedItems) + { + _datagrid.SelectedItems.Add(item); + } - SynchronizeSelectedItems(_listBox.SelectedItems); + SynchronizeSelectedItems(_listBox.SelectedItems); - _preventSynchronization = false; + _preventSynchronization = false; + } } } 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<FileSystemItem> GetFolder(String path) + public Task<FileSystemItem> GetFolder(String path, bool foldersOnly = false, String filter = "*.*") { return Task.Factory.StartNew<FileSystemItem>(() => { return FileSystemItem.FromDTO(GetFolder(new GetFileSystemItemRequest() { Path = path, + FoldersOnly = foldersOnly, + Filter = filter, })); }); } - public Task<FileSystemItem> GetFolder(Environment.SpecialFolder specialFolder) + public Task<FileSystemItem> GetFolder(Environment.SpecialFolder specialFolder, bool foldersOnly = false, String filter = "*.*") { return Task.Factory.StartNew<FileSystemItem>(() => { return FileSystemItem.FromDTO(GetFolder(new GetFileSystemItemRequest() { - SpecialFolder = specialFolder + SpecialFolder = specialFolder, + FoldersOnly = foldersOnly, + Filter = filter, })); }); } diff --git a/Software/Visual_Studio/Tango.FileSystem/Network/GetFileSystemItemRequest.cs b/Software/Visual_Studio/Tango.FileSystem/Network/GetFileSystemItemRequest.cs index 1ed6c19e4..3cf91e869 100644 --- a/Software/Visual_Studio/Tango.FileSystem/Network/GetFileSystemItemRequest.cs +++ b/Software/Visual_Studio/Tango.FileSystem/Network/GetFileSystemItemRequest.cs @@ -11,5 +11,7 @@ namespace Tango.FileSystem.Network { public String Path { get; set; } public SpecialFolder? SpecialFolder { get; set; } + public bool FoldersOnly { get; set; } + public String Filter { get; set; } = "*.*"; } } |
