Skip to content

Commit c88067e

Browse files
Luke BlevinsLuke Blevins
authored andcommitted
Fixed Item Load Bug
1 parent 62c5555 commit c88067e

File tree

6 files changed

+35
-49
lines changed

6 files changed

+35
-49
lines changed

FileLoader.cs

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -112,29 +112,27 @@ public static ProgressUIVisibility PVIS
112112
}
113113
}
114114

115-
public ItemViewModel(string ViewPath, bool isInPhotoMode)
115+
public ItemViewModel(string ViewPath)
116116
{
117-
isPhotoAlbumMode = isInPhotoMode;
118117
GenericFileBrowser.P.path = ViewPath;
118+
119119
FilesAndFolders.Clear();
120-
121-
GetItemsAsync(ViewPath);
122-
120+
GetItemsAsync(ViewPath);
123121
History.AddToHistory(ViewPath);
124122

125123

126124

127125
if (History.HistoryList.Count == 1)
128126
{
129127
BS.isEnabled = false;
130-
Debug.WriteLine("Disabled Property");
128+
//Debug.WriteLine("Disabled Property");
131129

132130

133131
}
134132
else if (History.HistoryList.Count > 1)
135133
{
136134
BS.isEnabled = true;
137-
Debug.WriteLine("Enabled Property");
135+
//Debug.WriteLine("Enabled Property");
138136
}
139137

140138
}
@@ -172,40 +170,17 @@ public async void GetItemsAsync(string path)
172170
try
173171
{
174172
folder = await StorageFolder.GetFolderFromPathAsync(path); // Set location to the current directory specified in path
175-
176-
177-
QueryOptions options = new QueryOptions()
178-
{
179-
FolderDepth = FolderDepth.Shallow,
180-
IndexerOption = IndexerOption.UseIndexerWhenAvailable
181-
182-
};
183-
string[] otherProperties = new string[]
184-
{
185-
SystemProperties.Title
186-
};
187-
188-
options.SetPropertyPrefetch(PropertyPrefetchOptions.None, otherProperties);
189-
SortEntry sort = new SortEntry()
190-
{
191-
AscendingOrder = true,
192-
PropertyName = "System.ItemNameDisplay"
193-
};
194-
options.SortOrder.Add(sort);
195-
196-
StorageFileQueryResult fileQueryResult = folder.CreateFileQueryWithOptions(options);
197-
StorageFolderQueryResult folderQueryResult = folder.CreateFolderQueryWithOptions(options);
198-
folderList = await folder.GetFoldersAsync(); // Create a read-only list of all folders in location
199-
fileList = await folder.GetFilesAsync(); // Create a read-only list of all files in location
200-
int NumOfFolders = folderList.Count; // How many folders are in the list
201-
int NumOfFiles = fileList.Count; // How many files are in the list
173+
folderList = await folder.GetFoldersAsync(); // Create a read-only list of all folders in location
174+
fileList = await folder.GetFilesAsync(); // Create a read-only list of all files in location
175+
int NumOfFolders = folderList.Count; // How many folders are in the list
176+
int NumOfFiles = fileList.Count; // How many files are in the list
202177
int NumOfItems = NumOfFiles + NumOfFolders;
203178
int NumItemsRead = 0;
204179

205180
if (NumOfItems == 0)
206181
{
207182
TextState.isVisible = Visibility.Visible;
208-
return;
183+
//return;
209184
}
210185

211186
PUIH.Header = "Loading " + NumOfItems + " items";

GenericFileBrowser.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
8989
{
9090
base.OnNavigatedTo(eventArgs);
9191
var parameters = (string)eventArgs.Parameter;
92-
ItemViewModel.ViewModel = new ItemViewModel(parameters, false);
92+
ItemViewModel.FilesAndFolders.Clear();
93+
ItemViewModel.ViewModel = new ItemViewModel(parameters);
9394
if (parameters.Equals(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)))
9495
{
9596
P.path = "Desktop";

ItemInteractions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
6666
History.ForwardList.Clear();
6767
ItemViewModel.FS.isEnabled = false;
6868
ItemViewModel.FilesAndFolders.Clear();
69-
ItemViewModel.ViewModel = new ItemViewModel(clickedOnItem.FilePath, false);
69+
ItemViewModel.ViewModel = new ItemViewModel(clickedOnItem.FilePath);
7070
GenericFileBrowser.P.path = clickedOnItem.FilePath;
7171
GenericFileBrowser.UpdateAllBindings();
7272
}
@@ -124,7 +124,7 @@ public static async void PhotoAlbumItemList_ClickAsync(object sender, ItemClickE
124124
History.ForwardList.Clear();
125125
ItemViewModel.FS.isEnabled = false;
126126
ItemViewModel.FilesAndFolders.Clear();
127-
ItemViewModel.ViewModel = new ItemViewModel(clickedOnItem.FilePath, true);
127+
ItemViewModel.ViewModel = new ItemViewModel(clickedOnItem.FilePath);
128128
GenericFileBrowser.P.path = clickedOnItem.FilePath;
129129
GenericFileBrowser.UpdateAllBindings();
130130

@@ -199,7 +199,7 @@ public static async void OpenItem_Click(object sender, RoutedEventArgs e)
199199
History.ForwardList.Clear();
200200
ItemViewModel.FS.isEnabled = false;
201201
ItemViewModel.FilesAndFolders.Clear();
202-
ItemViewModel.ViewModel = new ItemViewModel(RowData.FilePath, false);
202+
ItemViewModel.ViewModel = new ItemViewModel(RowData.FilePath);
203203
GenericFileBrowser.P.path = RowData.FilePath;
204204
GenericFileBrowser.UpdateAllBindings();
205205
}

MainPage.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515

1616

17+
using ItemListPresenter;
1718
using System;
1819
using System.ComponentModel;
1920
using System.Diagnostics;
@@ -66,41 +67,49 @@ private void navView_ItemSelected(NavigationView sender, NavigationViewSelection
6667
}
6768
else if (item.Name == "DesktopIC")
6869
{
70+
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
6971
ContentFrame.Navigate(typeof(GenericFileBrowser), DesktopPath);
7072
auto_suggest.PlaceholderText = "Search Desktop";
7173
}
7274
else if (item.Name == "DocumentsIC")
7375
{
76+
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
7477
ContentFrame.Navigate(typeof(GenericFileBrowser), DocumentsPath);
7578
auto_suggest.PlaceholderText = "Search Documents";
7679
}
7780
else if (item.Name == "DownloadsIC")
7881
{
82+
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
7983
ContentFrame.Navigate(typeof(GenericFileBrowser), DownloadsPath);
8084
auto_suggest.PlaceholderText = "Search Downloads";
8185
}
8286
else if (item.Name == "PicturesIC")
8387
{
88+
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
8489
ContentFrame.Navigate(typeof(PhotoAlbum), PicturesPath);
8590
auto_suggest.PlaceholderText = "Search Pictures";
8691
}
8792
else if (item.Name == "MusicIC")
8893
{
94+
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
8995
ContentFrame.Navigate(typeof(GenericFileBrowser), MusicPath);
9096
auto_suggest.PlaceholderText = "Search Music";
9197
}
9298
else if (item.Name == "VideosIC")
9399
{
100+
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
94101
ContentFrame.Navigate(typeof(GenericFileBrowser), VideosPath);
95102
auto_suggest.PlaceholderText = "Search Videos";
96103
}
97104
else if (item.Name == "LocD_IC")
98105
{
106+
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
99107
ContentFrame.Navigate(typeof(GenericFileBrowser), @"C:\");
100108
auto_suggest.PlaceholderText = "Search";
101109
}
102110
else if (item.Name == "OneD_IC")
103111
{
112+
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
104113
ContentFrame.Navigate(typeof(GenericFileBrowser), OneDrivePath);
105114
auto_suggest.PlaceholderText = "Search OneDrive";
106115
}

NavigationSystem.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,14 @@ public static void Back_Click(object sender, RoutedEventArgs e)
170170
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
171171
//Debug.WriteLine("\nBefore Removals");
172172
//ArrayDiag.DumpArray();
173-
History.AddToForwardList(History.HistoryList[History.HistoryList.Count() - 1]);
174-
History.HistoryList.RemoveAt(History.HistoryList.Count() - 1);
173+
History.AddToForwardList(History.HistoryList[History.HistoryList.Count - 1]);
174+
History.HistoryList.RemoveAt(History.HistoryList.Count - 1);
175175
//Debug.WriteLine("\nAfter Removals");
176176
//ArrayDiag.DumpArray();
177-
ItemViewModel.ViewModel = new ItemViewModel(History.HistoryList[History.HistoryList.Count() - 1], false); // To take into account the correct index without interference from the folder being navigated to
178177
ItemViewModel.FilesAndFolders.Clear();
179-
GenericFileBrowser.P.path = History.HistoryList[History.HistoryList.Count() - 1];
178+
ItemViewModel.ViewModel = new ItemViewModel(History.HistoryList[History.HistoryList.Count - 1]); // To take into account the correct index without interference from the folder being navigated to
179+
//ItemViewModel.FilesAndFolders.Clear();
180+
GenericFileBrowser.P.path = History.HistoryList[History.HistoryList.Count - 1];
180181
GenericFileBrowser.UpdateAllBindings();
181182

182183
if (History.ForwardList.Count == 0)
@@ -203,8 +204,8 @@ public static void Forward_Click(object sender, RoutedEventArgs e)
203204
if (History.ForwardList.Count() > 0)
204205
{
205206
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
206-
ItemViewModel.ViewModel = new ItemViewModel(History.ForwardList[History.ForwardList.Count() - 1], false); // To take into account the correct index without interference from the folder being navigated to
207207
ItemViewModel.FilesAndFolders.Clear();
208+
ItemViewModel.ViewModel = new ItemViewModel(History.ForwardList[History.ForwardList.Count() - 1]); // To take into account the correct index without interference from the folder being navigated to
208209
GenericFileBrowser.P.path = History.ForwardList[History.ForwardList.Count() - 1];
209210
History.ForwardList.RemoveAt(History.ForwardList.Count() - 1);
210211
GenericFileBrowser.UpdateAllBindings();
@@ -226,7 +227,7 @@ public static void Refresh_Click(object sender, RoutedEventArgs e)
226227
{
227228
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
228229
ItemViewModel.FilesAndFolders.Clear();
229-
ItemViewModel.ViewModel = new ItemViewModel(ItemViewModel.PUIP.Path, false);
230+
ItemViewModel.ViewModel = new ItemViewModel(ItemViewModel.PUIP.Path);
230231
GenericFileBrowser.P.path = ItemViewModel.PUIP.Path;
231232
GenericFileBrowser.UpdateAllBindings();
232233
}
@@ -250,8 +251,8 @@ public static void Back_Click(object sender, RoutedEventArgs e)
250251
History.HistoryList.RemoveAt(History.HistoryList.Count() - 1);
251252
Debug.WriteLine("\nAfter Removals");
252253
ArrayDiag.DumpArray();
253-
ItemViewModel.ViewModel = new ItemViewModel(History.HistoryList[History.HistoryList.Count() - 1], true); // To take into account the correct index without interference from the folder being navigated to
254254
ItemViewModel.FilesAndFolders.Clear();
255+
ItemViewModel.ViewModel = new ItemViewModel(History.HistoryList[History.HistoryList.Count() - 1]); // To take into account the correct index without interference from the folder being navigated to
255256
GenericFileBrowser.P.path = History.HistoryList[History.HistoryList.Count() - 1];
256257
GenericFileBrowser.UpdateAllBindings();
257258

@@ -279,8 +280,8 @@ public static void Forward_Click(object sender, RoutedEventArgs e)
279280
if (History.ForwardList.Count() > 0)
280281
{
281282
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
282-
ItemViewModel.ViewModel = new ItemViewModel(History.ForwardList[History.ForwardList.Count() - 1], true); // To take into account the correct index without interference from the folder being navigated to
283283
ItemViewModel.FilesAndFolders.Clear();
284+
ItemViewModel.ViewModel = new ItemViewModel(History.ForwardList[History.ForwardList.Count() - 1]); // To take into account the correct index without interference from the folder being navigated to
284285
GenericFileBrowser.P.path = History.ForwardList[History.ForwardList.Count() - 1];
285286
History.ForwardList.RemoveAt(History.ForwardList.Count() - 1);
286287
GenericFileBrowser.UpdateAllBindings();
@@ -302,7 +303,7 @@ public static void Refresh_Click(object sender, RoutedEventArgs e)
302303
{
303304
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
304305
ItemViewModel.FilesAndFolders.Clear();
305-
ItemViewModel.ViewModel = new ItemViewModel(ItemViewModel.PUIP.Path, true);
306+
ItemViewModel.ViewModel = new ItemViewModel(ItemViewModel.PUIP.Path);
306307
GenericFileBrowser.P.path = ItemViewModel.PUIP.Path;
307308
GenericFileBrowser.UpdateAllBindings();
308309
}

PhotoAlbum.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
3838
{
3939
base.OnNavigatedTo(eventArgs);
4040
var parameters = eventArgs.Parameter.ToString();
41-
ItemViewModel.ViewModel = new ItemViewModel(parameters, true);
41+
ItemViewModel.ViewModel = new ItemViewModel(parameters);
4242
Interact.Interaction.page = this;
4343
FileList.ItemClick += Interact.Interaction.PhotoAlbumItemList_ClickAsync;
4444
Back.Click += Navigation.PhotoAlbumNavActions.Back_Click;

0 commit comments

Comments
 (0)