Skip to content

Commit 83676d6

Browse files
gave92yaira2tsvietOK
authored
Auto complete folder names when typing in the navigation bar (#1522)
Co-authored-by: Yair Aichenbaum <[email protected]> Co-authored-by: Vladyslav Tsvietkov <[email protected]>
1 parent e6d057a commit 83676d6

28 files changed

+399
-67
lines changed

Common/Extensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ public static IEnumerable<TSource> ExceptBy<TSource, TKey>(
1717
yield return item;
1818
}
1919

20+
public static IEnumerable<TSource> IntersectBy<TSource, TKey>(
21+
this IEnumerable<TSource> source,
22+
IEnumerable<TSource> other,
23+
Func<TSource, TKey> keySelector)
24+
{
25+
return source.Join(other.Select(keySelector), keySelector, id => id, (o, id) => o);
26+
}
27+
2028
public static TOut Get<TOut, TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TOut defaultValue = default(TOut))
2129
{
2230
// If setting doesn't exist, create it.

Files/Filesystem/ListedItem.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,20 @@ public BitmapImage FileImage
5151
}
5252
}
5353

54-
public string ItemName { get; set; }
54+
private string _ItemPath;
55+
public string ItemPath
56+
{
57+
get => _ItemPath;
58+
set => Set(ref _ItemPath, value);
59+
}
60+
61+
private string _ItemName;
62+
public string ItemName
63+
{
64+
get => _ItemName;
65+
set => Set(ref _ItemName, value);
66+
}
67+
5568
public string ItemDateModified { get; private set; }
5669
private string _ItemType;
5770

@@ -68,7 +81,6 @@ public string ItemType
6881
}
6982

7083
public string FileExtension { get; set; }
71-
public string ItemPath { get; set; }
7284
public string FileSize { get; set; }
7385
public long FileSizeBytes { get; set; }
7486

Files/Filesystem/StorageFileHelpers/StorageFileExtensions.cs

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Linq;
1111
using System.Threading.Tasks;
1212
using Windows.Storage;
13+
using Windows.Storage.Search;
1314

1415
namespace Files.Filesystem
1516
{
@@ -130,13 +131,13 @@ public async static Task<StorageFolderWithPath> GetFolderWithPathFromPathAsync(s
130131
}
131132
}
132133

133-
try
134+
if (parentFolder != null && !Path.IsPathRooted(value))
134135
{
135-
var folder = await parentFolder.Folder.GetFolderAsync(value);
136-
var path = Path.Combine(parentFolder.Folder.Path, value);
137-
return new StorageFolderWithPath(folder, path);
136+
// Relative path
137+
var fullPath = Path.GetFullPath(Path.Combine(parentFolder.Path, value));
138+
return new StorageFolderWithPath(await StorageFolder.GetFolderFromPathAsync(fullPath));
138139
}
139-
catch
140+
else
140141
{
141142
return new StorageFolderWithPath(await StorageFolder.GetFolderFromPathAsync(value));
142143
}
@@ -182,13 +183,13 @@ public async static Task<StorageFileWithPath> GetFileWithPathFromPathAsync(strin
182183
}
183184
}
184185

185-
try
186+
if (parentFolder != null && !Path.IsPathRooted(value))
186187
{
187-
var file = await parentFolder.Folder.GetFileAsync(value);
188-
var path = Path.Combine(parentFolder.Folder.Path, value);
189-
return new StorageFileWithPath(file, path);
188+
// Relative path
189+
var fullPath = Path.GetFullPath(Path.Combine(parentFolder.Path, value));
190+
return new StorageFileWithPath(await StorageFile.GetFileFromPathAsync(fullPath));
190191
}
191-
catch
192+
else
192193
{
193194
return new StorageFileWithPath(await StorageFile.GetFileFromPathAsync(value));
194195
}
@@ -199,6 +200,25 @@ public async static Task<StorageFile> GetFileFromPathAsync(string value, Storage
199200
return (await GetFileWithPathFromPathAsync(value, rootFolder, parentFolder)).File;
200201
}
201202

203+
public async static Task<IList<StorageFolderWithPath>> GetFoldersWithPathAsync(this StorageFolderWithPath parentFolder, uint maxNumberOfItems = uint.MaxValue)
204+
{
205+
return (await parentFolder.Folder.GetFoldersAsync(CommonFolderQuery.DefaultQuery, 0, maxNumberOfItems)).Select(x => new StorageFolderWithPath(x, Path.Combine(parentFolder.Path, x.Name))).ToList();
206+
}
207+
208+
public async static Task<IList<StorageFileWithPath>> GetFilesWithPathAsync(this StorageFolderWithPath parentFolder, uint maxNumberOfItems = uint.MaxValue)
209+
{
210+
return (await parentFolder.Folder.GetFilesAsync(CommonFileQuery.DefaultQuery, 0, maxNumberOfItems)).Select(x => new StorageFileWithPath(x, Path.Combine(parentFolder.Path, x.Name))).ToList();
211+
}
212+
213+
public async static Task<IList<StorageFolderWithPath>> GetFoldersWithPathAsync(this StorageFolderWithPath parentFolder, string nameFilter, uint maxNumberOfItems = uint.MaxValue)
214+
{
215+
var queryOptions = new QueryOptions();
216+
queryOptions.ApplicationSearchFilter = $"System.FileName:{nameFilter}*";
217+
StorageFolderQueryResult queryResult = parentFolder.Folder.CreateFolderQueryWithOptions(queryOptions);
218+
219+
return (await queryResult.GetFoldersAsync(0, maxNumberOfItems)).Select(x => new StorageFolderWithPath(x, Path.Combine(parentFolder.Path, x.Name))).ToList();
220+
}
221+
202222
public static string GetPathWithoutEnvironmentVariable(string path)
203223
{
204224
if (path.Contains("%temp%")) path = path.Replace("%temp%", _AppSettings.TempPath);

Files/Interacts/Interaction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public static T FindChild<T>(DependencyObject startNode) where T : DependencyObj
241241
T asType = (T)current;
242242
return asType;
243243
}
244-
FindChild<T>(current);
244+
return FindChild<T>(current);
245245
}
246246
return null;
247247
}

Files/MultilingualResources/Files.de-DE.xlf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,9 @@
851851
<target state="translated" state-qualifier="tm-suggestion">Bytes</target>
852852
</trans-unit>
853853
<trans-unit id="KiloByteSymbol" translate="yes" xml:space="preserve">
854-
<source>kB</source>
855-
<target state="translated" state-qualifier="tm-suggestion">kB</target>
854+
<source>KB</source>
855+
<target state="needs-review-translation" state-qualifier="tm-suggestion">kB</target>
856+
<note from="MultilingualUpdate" annotates="source" priority="2">Please verify the translation’s accuracy as the source string was updated after it was translated.</note>
856857
</trans-unit>
857858
<trans-unit id="MegaByteSymbol" translate="yes" xml:space="preserve">
858859
<source>MB</source>
@@ -1014,6 +1015,10 @@
10141015
<source>Move tab here</source>
10151016
<target state="translated">Tab hierhin verschieben</target>
10161017
</trans-unit>
1018+
<trans-unit id="NavigationToolbarVisiblePathNoResults" translate="yes" xml:space="preserve">
1019+
<source>No results</source>
1020+
<target state="new">No results</target>
1021+
</trans-unit>
10171022
</group>
10181023
</body>
10191024
</file>

Files/MultilingualResources/Files.es-ES.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,10 @@
10061006
<source>Move tab here</source>
10071007
<target state="translated">Mover la pestaña aquí</target>
10081008
</trans-unit>
1009+
<trans-unit id="NavigationToolbarVisiblePathNoResults" translate="yes" xml:space="preserve">
1010+
<source>No results</source>
1011+
<target state="new">No results</target>
1012+
</trans-unit>
10091013
</group>
10101014
</body>
10111015
</file>

Files/MultilingualResources/Files.fr-FR.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,10 @@
10091009
<source>Move tab here</source>
10101010
<target state="new">Move tab here</target>
10111011
</trans-unit>
1012+
<trans-unit id="NavigationToolbarVisiblePathNoResults" translate="yes" xml:space="preserve">
1013+
<source>No results</source>
1014+
<target state="new">No results</target>
1015+
</trans-unit>
10121016
</group>
10131017
</body>
10141018
</file>

Files/MultilingualResources/Files.he-IL.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,10 @@
10061006
<source>Move tab here</source>
10071007
<target state="new">Move tab here</target>
10081008
</trans-unit>
1009+
<trans-unit id="NavigationToolbarVisiblePathNoResults" translate="yes" xml:space="preserve">
1010+
<source>No results</source>
1011+
<target state="new">No results</target>
1012+
</trans-unit>
10091013
</group>
10101014
</body>
10111015
</file>

Files/MultilingualResources/Files.hi-IN.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,10 @@
10151015
<source>Move tab here</source>
10161016
<target state="new">Move tab here</target>
10171017
</trans-unit>
1018+
<trans-unit id="NavigationToolbarVisiblePathNoResults" translate="yes" xml:space="preserve">
1019+
<source>No results</source>
1020+
<target state="new">No results</target>
1021+
</trans-unit>
10181022
</group>
10191023
</body>
10201024
</file>

Files/MultilingualResources/Files.it-IT.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,10 @@
10071007
<source>Move tab here</source>
10081008
<target state="translated">Sposta la scheda qui</target>
10091009
</trans-unit>
1010+
<trans-unit id="NavigationToolbarVisiblePathNoResults" translate="yes" xml:space="preserve">
1011+
<source>No results</source>
1012+
<target state="translated">Nessun risultato</target>
1013+
</trans-unit>
10101014
</group>
10111015
</body>
10121016
</file>

0 commit comments

Comments
 (0)