Skip to content

Commit 11fabe8

Browse files
committed
Remove outdated code from FileLoader
1 parent f3fdc5c commit 11fabe8

File tree

4 files changed

+27
-176
lines changed

4 files changed

+27
-176
lines changed

FileLoader.cs

+17-162
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,13 @@ public class ItemViewModel
4747
{
4848
public static ObservableCollection<Classic_ListedFolderItem> classicFolderList = new ObservableCollection<Classic_ListedFolderItem>();
4949
public static ObservableCollection<Classic_ListedFolderItem> ClassicFolderList { get { return classicFolderList; } }
50+
5051
public static ObservableCollection<ListedItem> classicFileList = new ObservableCollection<ListedItem>();
5152
public static ObservableCollection<ListedItem> ClassicFileList { get { return classicFileList; } }
5253

5354
public static ObservableCollection<ListedItem> filesAndFolders = new ObservableCollection<ListedItem>();
5455
public static ObservableCollection<ListedItem> FilesAndFolders { get { return filesAndFolders; } }
5556

56-
string DesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
57-
string DocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
58-
string DownloadsPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads";
59-
string OneDrivePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\OneDrive";
60-
string PicturesPath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
61-
string MusicPath = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
62-
string VideosPath = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos);
63-
6457
StorageFolder folder;
6558
static string gotName;
6659
static string gotDate;
@@ -163,6 +156,7 @@ public static ProgressUIVisibility PVIS
163156

164157
public ItemViewModel(string ViewPath, Page p)
165158
{
159+
166160
pageName = p.Name;
167161
// Personalize retrieved items for view they are displayed in
168162
if(p.Name == "GenericItemView" || p.Name == "ClassicModePage")
@@ -222,6 +216,9 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
222216
PUIP.Path = path;
223217
try
224218
{
219+
220+
PVIS.isVisible = Visibility.Visible;
221+
TextState.isVisible = Visibility.Collapsed;
225222
folder = await StorageFolder.GetFolderFromPathAsync(path);
226223
QueryOptions options = new QueryOptions()
227224
{
@@ -248,16 +245,16 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
248245

249246
StorageFolderQueryResult folderQueryResult = folder.CreateFolderQueryWithOptions(options);
250247
IReadOnlyList<StorageFolder> folders = await folderQueryResult.GetFoldersAsync(index, step);
251-
while(folders.Count != 0)
248+
int foldersCountSnapshot = folders.Count;
249+
while (folders.Count != 0)
252250
{
253251
foreach(StorageFolder folder in folders)
254252
{
255253
if (token.IsCancellationRequested)
256254
{
257255
return;
258256
}
259-
//int ProgressReported = (NumItemsRead * 100 / NumOfItems);
260-
//UpdateProgUI(ProgressReported);
257+
261258
gotFolName = folder.Name.ToString();
262259
gotFolDate = folder.DateCreated.ToString();
263260
gotFolPath = folder.Path.ToString();
@@ -282,7 +279,7 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
282279
index = 0;
283280
StorageFileQueryResult fileQueryResult = folder.CreateFileQueryWithOptions(options);
284281
IReadOnlyList<StorageFile> files = await fileQueryResult.GetFilesAsync(index, step);
285-
282+
int filesCountSnapshot = files.Count;
286283
while (files.Count != 0)
287284
{
288285
foreach (StorageFile file in files)
@@ -291,8 +288,7 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
291288
{
292289
return;
293290
}
294-
//int ProgressReported = (NumItemsRead * 100 / NumOfItems);
295-
//UpdateProgUI(ProgressReported);
291+
296292
gotName = file.Name.ToString();
297293
gotDate = file.DateCreated.ToString(); // In the future, parse date to human readable format
298294
if (file.FileType.ToString() == ".exe")
@@ -339,11 +335,15 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
339335
index += step;
340336
files = await fileQueryResult.GetFilesAsync(index, step);
341337
}
338+
if(foldersCountSnapshot + filesCountSnapshot == 0)
339+
{
340+
TextState.isVisible = Visibility.Visible;
341+
}
342342
if (pageName != "ClassicModePage")
343343
{
344344
PVIS.isVisible = Visibility.Collapsed;
345345
}
346-
346+
PVIS.isVisible = Visibility.Collapsed;
347347
}
348348
catch (UnauthorizedAccessException)
349349
{
@@ -352,158 +352,15 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
352352
catch (System.Runtime.InteropServices.COMException e)
353353
{
354354
Frame rootFrame = Window.Current.Content as Frame;
355-
MessageDialog driveGone = new MessageDialog(e.Message, "Drive Not Found");
355+
MessageDialog driveGone = new MessageDialog(e.Message, "Drive Unplugged");
356356
await driveGone.ShowAsync();
357357
rootFrame.Navigate(typeof(MainPage), new SuppressNavigationTransitionInfo());
358358
}
359359
stopwatch.Stop();
360360
Debug.WriteLine("Loading of: " + path + " completed in " + stopwatch.ElapsedMilliseconds + " Milliseconds.");
361361
}
362362

363-
//public async void GetItemsAsync(string path, CancellationToken token)
364-
//{
365-
// Stopwatch stopwatch = new Stopwatch();
366-
// stopwatch.Start();
367-
368-
// PUIP.Path = path;
369-
// try
370-
// {
371-
// folder = await StorageFolder.GetFolderFromPathAsync(path); // Set location to the current directory specified in path
372-
// folderList = await folder.GetFoldersAsync(); // Create a read-only list of all folders in location
373-
// if (token.IsCancellationRequested == true)
374-
// {
375-
// return;
376-
// }
377-
// fileList = await folder.GetFilesAsync(); // Create a read-only list of all files in location
378-
// NumOfFolders = folderList.Count; // How many folders are in the list
379-
// NumOfFiles = fileList.Count; // How many files are in the list
380-
// NumOfItems = NumOfFiles + NumOfFolders;
381-
// NumItemsRead = 0;
382-
383-
// if (NumOfItems == 0)
384-
// {
385-
// TextState.isVisible = Visibility.Visible;
386-
// }
387-
388-
// PUIH.Header = "Loading " + NumOfItems + " items";
389-
// ButtonText.buttonText = "Hide";
390-
391-
// if (NumOfItems >= 250)
392-
// {
393-
// PVIS.isVisible = Visibility.Visible;
394-
// }
395-
// if (NumOfFolders > 0)
396-
// {
397-
// foreach (StorageFolder fol in folderList)
398-
// {
399-
// if (token.IsCancellationRequested == true)
400-
// {
401-
// return;
402-
// }
403-
// int ProgressReported = (NumItemsRead * 100 / NumOfItems);
404-
// UpdateProgUI(ProgressReported);
405-
// gotFolName = fol.Name.ToString();
406-
// gotFolDate = fol.DateCreated.ToString();
407-
// gotFolPath = fol.Path.ToString();
408-
// gotFolType = "Folder";
409-
// gotFolImg = Visibility.Visible;
410-
// gotFileImgVis = Visibility.Collapsed;
411-
412-
413-
// if (pageName == "ClassicModePage")
414-
// {
415-
// ClassicFolderList.Add(new Classic_ListedFolderItem() { FileName = gotFolName, FileDate = gotFolDate, FileExtension = gotFolType, FilePath = gotFolPath });
416-
// }
417-
// else
418-
// {
419-
// FilesAndFolders.Add(new ListedItem() { ItemIndex = FilesAndFolders.Count, FileImg = null, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotFolName, FileDate = gotFolDate, FileExtension = gotFolType, FilePath = gotFolPath });
420-
// }
421-
422-
423-
// NumItemsRead++;
424-
// }
425-
426-
// }
427-
428-
// if (NumOfFiles > 0)
429-
// {
430-
// foreach (StorageFile f in fileList)
431-
// {
432-
// if (token.IsCancellationRequested == true)
433-
// {
434-
// return;
435-
// }
436-
// int ProgressReported = (NumItemsRead * 100 / NumOfItems);
437-
// UpdateProgUI(ProgressReported);
438-
// gotName = f.Name.ToString();
439-
// gotDate = f.DateCreated.ToString(); // In the future, parse date to human readable format
440-
// if (f.FileType.ToString() == ".exe")
441-
// {
442-
// gotType = "Executable";
443-
// }
444-
// else
445-
// {
446-
// gotType = f.DisplayType;
447-
// }
448-
// gotPath = f.Path.ToString();
449-
// gotFolImg = Visibility.Collapsed;
450-
// if (isPhotoAlbumMode == false)
451-
// {
452-
// const uint requestedSize = 20;
453-
// const ThumbnailMode thumbnailMode = ThumbnailMode.ListView;
454-
// const ThumbnailOptions thumbnailOptions = ThumbnailOptions.UseCurrentScale;
455-
// gotFileImg = await f.GetThumbnailAsync(thumbnailMode, requestedSize, thumbnailOptions);
456-
// }
457-
// else
458-
// {
459-
// const uint requestedSize = 275;
460-
// const ThumbnailMode thumbnailMode = ThumbnailMode.PicturesView;
461-
// const ThumbnailOptions thumbnailOptions = ThumbnailOptions.ResizeThumbnail;
462-
// gotFileImg = await f.GetThumbnailAsync(thumbnailMode, requestedSize, thumbnailOptions);
463-
// }
464-
465-
// BitmapImage icon = new BitmapImage();
466-
// if (gotFileImg != null)
467-
// {
468-
// icon.SetSource(gotFileImg.CloneStream());
469-
// }
470-
// gotFileImgVis = Visibility.Visible;
471-
472-
// if (pageName == "ClassicModePage")
473-
// {
474-
// ClassicFileList.Add(new ListedItem() { FileImg = icon, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotName, FileDate = gotDate, FileExtension = gotType, FilePath = gotPath });
475-
// }
476-
// else
477-
// {
478-
// FilesAndFolders.Add(new ListedItem() { FileImg = icon, FileIconVis = gotFileImgVis, FolderImg = gotFolImg, FileName = gotName, FileDate = gotDate, FileExtension = gotType, FilePath = gotPath });
479-
// }
480-
// NumItemsRead++;
481-
// }
482-
483-
484-
// }
485-
// if (pageName != "ClassicModePage")
486-
// {
487-
// PVIS.isVisible = Visibility.Collapsed;
488-
// }
489-
490-
491-
// }
492-
// catch (UnauthorizedAccessException)
493-
// {
494-
// DisplayConsentDialog();
495-
// }
496-
// catch (System.Runtime.InteropServices.COMException e)
497-
// {
498-
// Frame rootFrame = Window.Current.Content as Frame;
499-
// MessageDialog driveGone = new MessageDialog(e.Message, "Drive Not Found");
500-
// await driveGone.ShowAsync();
501-
// rootFrame.Navigate(typeof(MainPage), new SuppressNavigationTransitionInfo());
502-
// }
503-
// stopwatch.Stop();
504-
// Debug.WriteLine("Loading of: " + path + " completed in " + stopwatch.ElapsedMilliseconds + " Milliseconds.");
505-
506-
//}
363+
507364

508365
public static ProgressPercentage progressPER = new ProgressPercentage();
509366

@@ -530,15 +387,13 @@ public static async void DisplayCollisionUIWithArgs(string header, string subHea
530387
CollisionBoxHeader.Header = header;
531388
CollisionBoxSubHeader.SubHeader = subHeader;
532389
await GenericFileBrowser.collisionBox.ShowAsync();
533-
//CollisionUIVisibility.isVisible = Visibility.Visible;
534390
}
535391

536392
public static async void DisplayReviewUIWithArgs(string header, string subHeader)
537393
{
538394
ConflictBoxHeader.Header = header;
539395
ConflictBoxSubHeader.SubHeader = subHeader;
540396
await GenericFileBrowser.reviewBox.ShowAsync();
541-
//ConflictUIVisibility.isVisible = Visibility.Visible;
542397
}
543398

544399
public static async void FillTreeNode(object item, Microsoft.UI.Xaml.Controls.TreeView EntireControl)

Files.csproj

+6-6
Original file line numberDiff line numberDiff line change
@@ -256,22 +256,22 @@
256256
<Version>6.1.9</Version>
257257
</PackageReference>
258258
<PackageReference Include="Microsoft.Toolkit.Uwp">
259-
<Version>5.0.0</Version>
259+
<Version>5.1.0</Version>
260260
</PackageReference>
261261
<PackageReference Include="Microsoft.Toolkit.Uwp.DeveloperTools">
262-
<Version>5.0.0</Version>
262+
<Version>5.1.0</Version>
263263
</PackageReference>
264264
<PackageReference Include="Microsoft.Toolkit.Uwp.UI">
265-
<Version>5.0.0</Version>
265+
<Version>5.1.0</Version>
266266
</PackageReference>
267267
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Animations">
268-
<Version>5.0.0</Version>
268+
<Version>5.1.0</Version>
269269
</PackageReference>
270270
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
271-
<Version>5.0.0</Version>
271+
<Version>5.1.0</Version>
272272
</PackageReference>
273273
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.DataGrid">
274-
<Version>5.0.0</Version>
274+
<Version>5.1.0</Version>
275275
</PackageReference>
276276
<PackageReference Include="Microsoft.UI.Xaml">
277277
<Version>2.1.190131001-prerelease</Version>

GenericFileBrowser.xaml

+2-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<RowDefinition Height="35"/>
2020
<RowDefinition Height="Auto"/>
2121
<RowDefinition Height="Auto"/>
22-
<RowDefinition Height="80*"/>
22+
<RowDefinition Height="*"/>
2323
</Grid.RowDefinitions>
2424
<TextBlock Name="EmptyText" Visibility="{x:Bind local2:ItemViewModel.TextState.isVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" Text="This folder is empty." TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,125,0,0" Grid.Row="3" Canvas.ZIndex="0"/>
2525

@@ -187,14 +187,10 @@
187187

188188
</controls:DataGrid>
189189

190-
191-
192-
193-
194190
<ContentDialog BorderThickness="0" Name="AddDialog" PrimaryButtonText="Cancel" Loaded="ContentDialog_Loaded" Grid.RowSpan="4">
195191
<Frame Width="450" Name="AddDialogFrame"/>
196192
</ContentDialog>
197-
193+
198194
<ContentDialog PrimaryButtonText="Replace" SecondaryButtonText="Skip" Title="{x:Bind local2:ItemViewModel.ConflictBoxHeader.Header, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Name="ReviewBox" Grid.RowSpan="4">
199195
<Grid>
200196
<TextBlock Name="ConflictSmallHeader" TextWrapping="WrapWholeWords" Text="{x:Bind local2:ItemViewModel.ConflictBoxSubHeader.SubHeader, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" VerticalAlignment="Center"/>

PhotoAlbum.xaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@
246246
<RowDefinition Height="35"/>
247247
<RowDefinition Height="Auto"/>
248248
<RowDefinition Height="Auto"/>
249-
<RowDefinition Height="80*"/>
249+
<RowDefinition Height="*"/>
250250
</Grid.RowDefinitions>
251251
<TextBlock Name="EmptyText" Visibility="{x:Bind local2:ItemViewModel.TextState.isVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" Text="This folder is empty." TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,125,0,0" Grid.Row="3" Canvas.ZIndex="0"/>
252252

@@ -318,7 +318,7 @@
318318
<ProgressBar Visibility="{x:Bind local2:ItemViewModel.PVIS.isVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Value="{x:Bind local2:ItemViewModel.PROGRESSPER.prog, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Stretch"/>
319319
</StackPanel>
320320

321-
<GridView Margin="24,0,24,0" Grid.Row="3" IsTapEnabled="True" Tapped="FileList_Tapped" SelectionMode="Extended" IsDoubleTapEnabled="True" IsRightTapEnabled="True" ItemsSource="{x:Bind local2:ItemViewModel.FilesAndFolders}" Name="FileList" Padding="0, 0, 0, 0" >
321+
<GridView ShowsScrollingPlaceholders="True" Margin="24,0,24,0" Grid.Row="3" IsTapEnabled="True" Tapped="FileList_Tapped" SelectionMode="Extended" IsDoubleTapEnabled="True" IsRightTapEnabled="True" ItemsSource="{x:Bind local2:ItemViewModel.FilesAndFolders}" Name="FileList" Padding="0, 0, 0, 0" >
322322
<GridView.Resources>
323323
<MenuFlyout x:Name="RightClickContextMenu" x:Key="RightClickFlyout">
324324
<MenuFlyout.Items>

0 commit comments

Comments
 (0)