Skip to content

Commit e6172ac

Browse files
committed
Bug fixes for UniversalPath, NavigationActions
1 parent b7f746a commit e6172ac

File tree

5 files changed

+66
-67
lines changed

5 files changed

+66
-67
lines changed

Files UWP/Filesystem/ItemViewModel.cs

+40-13
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,44 @@ public async void MemoryFriendlyGetItemsAsync(string path, Page passedPage)
9797

9898
PVIS.isVisible = Visibility.Visible;
9999
TextState.isVisible = Visibility.Collapsed;
100-
folder = await StorageFolder.GetFolderFromPathAsync(path);
100+
switch (Universal.path)
101+
{
102+
case "Desktop":
103+
Universal.path = MainPage.DesktopPath;
104+
break;
105+
case "Downloads":
106+
Universal.path = MainPage.DownloadsPath;
107+
break;
108+
case "Documents":
109+
Universal.path = MainPage.DocumentsPath;
110+
break;
111+
case "Pictures":
112+
Universal.path = MainPage.PicturesPath;
113+
break;
114+
case "Music":
115+
Universal.path = MainPage.MusicPath;
116+
break;
117+
case "Videos":
118+
Universal.path = MainPage.VideosPath;
119+
break;
120+
case "OneDrive":
121+
Universal.path = MainPage.OneDrivePath;
122+
break;
123+
}
124+
125+
folder = await StorageFolder.GetFolderFromPathAsync(Universal.path);
126+
127+
History.AddToHistory(Universal.path);
128+
129+
if (History.HistoryList.Count == 1)
130+
{
131+
BS.isEnabled = false;
132+
}
133+
else if (History.HistoryList.Count > 1)
134+
{
135+
BS.isEnabled = true;
136+
}
137+
101138
QueryOptions options = new QueryOptions()
102139
{
103140
FolderDepth = FolderDepth.Shallow,
@@ -281,28 +318,18 @@ public async void MemoryFriendlyGetItemsAsync(string path, Page passedPage)
281318
await unsupportedDevice.ShowAsync();
282319
}
283320
stopwatch.Stop();
284-
Debug.WriteLine("Loading of: " + path + " failed in " + stopwatch.ElapsedMilliseconds + " Milliseconds.");
321+
Debug.WriteLine("Loading of: " + Universal.path + " failed in " + stopwatch.ElapsedMilliseconds + " Milliseconds.");
285322
}
286323
catch (COMException e)
287324
{
288325
stopwatch.Stop();
289-
Debug.WriteLine("Loading of: " + path + " failed in " + stopwatch.ElapsedMilliseconds + " Milliseconds.");
326+
Debug.WriteLine("Loading of: " + Universal.path + " failed in " + stopwatch.ElapsedMilliseconds + " Milliseconds.");
290327
Frame rootFrame = Window.Current.Content as Frame;
291328
MessageDialog driveGone = new MessageDialog(e.Message, "Drive Unplugged");
292329
await driveGone.ShowAsync();
293330
rootFrame.Navigate(typeof(MainPage), new SuppressNavigationTransitionInfo());
294331
}
295332

296-
History.AddToHistory(Universal.path);
297-
298-
if (History.HistoryList.Count == 1)
299-
{
300-
BS.isEnabled = false;
301-
}
302-
else if (History.HistoryList.Count > 1)
303-
{
304-
BS.isEnabled = true;
305-
}
306333
tokenSource = null;
307334
}
308335

Files UWP/Interacts/Interaction.cs

+22-23
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ namespace Files.Interacts
2424
{
2525
public class Interaction
2626
{
27-
28-
private static PasteState ps = new PasteState();
29-
public static PasteState PS { get { return ps; } }
27+
public static PasteState PS { get; } = new PasteState();
3028

3129
public static Page page;
3230
public Interaction(Page p)
@@ -39,24 +37,24 @@ public Interaction(Page p)
3937
// Double-tap event for DataGrid
4038
public static async void List_ItemClick(object sender, DoubleTappedRoutedEventArgs e)
4139
{
40+
4241
if (page.Name == "GenericItemView")
4342
{
44-
4543
var index = GenericFileBrowser.data.SelectedIndex;
46-
4744
if (index > -1)
4845
{
4946
var clickedOnItem = App.ViewModel.FilesAndFolders[index];
50-
5147
if (clickedOnItem.FileExtension == "Folder")
5248
{
49+
App.ViewModel.Universal.path = clickedOnItem.FilePath;
50+
App.PathText.Text = clickedOnItem.FilePath;
5351
App.ViewModel.TextState.isVisible = Visibility.Collapsed;
5452
History.ForwardList.Clear();
5553
App.ViewModel.FS.isEnabled = false;
5654
App.ViewModel.FilesAndFolders.Clear();
5755
if (clickedOnItem.FilePath == Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
5856
{
59-
App.ViewModel.Universal.path = "Desktop";
57+
App.PathText.Text = "Desktop";
6058
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
6159
{
6260
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "DesktopIC")
@@ -70,7 +68,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
7068
}
7169
else if (clickedOnItem.FilePath == Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
7270
{
73-
App.ViewModel.Universal.path = "Documents";
71+
App.PathText.Text = "Documents";
7472
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
7573
{
7674
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "DocumentsIC")
@@ -84,7 +82,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
8482
}
8583
else if (clickedOnItem.FilePath == (Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads"))
8684
{
87-
App.ViewModel.Universal.path = "Downloads";
85+
App.PathText.Text = "Downloads";
8886
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
8987
{
9088
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "DownloadsIC")
@@ -108,11 +106,11 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
108106
}
109107
MainPage.accessibleContentFrame.Navigate(typeof(PhotoAlbum), YourHome.PicturesPath, new SuppressNavigationTransitionInfo());
110108
MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Pictures";
111-
App.ViewModel.Universal.path = "Pictures";
109+
App.PathText.Text = "Pictures";
112110
}
113111
else if (clickedOnItem.FilePath == Environment.GetFolderPath(Environment.SpecialFolder.MyMusic))
114112
{
115-
App.ViewModel.Universal.path = "Music";
113+
App.PathText.Text = "Music";
116114
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
117115
{
118116
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "MusicIC")
@@ -126,7 +124,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
126124
}
127125
else if (clickedOnItem.FilePath == (Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\OneDrive"))
128126
{
129-
App.ViewModel.Universal.path = "OneDrive";
127+
App.PathText.Text = "OneDrive";
130128
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
131129
{
132130
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "OneD_IC")
@@ -140,7 +138,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
140138
}
141139
else if (clickedOnItem.FilePath == Environment.GetFolderPath(Environment.SpecialFolder.MyVideos))
142140
{
143-
App.ViewModel.Universal.path = "Videos";
141+
App.PathText.Text = "Videos";
144142
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
145143
{
146144
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "VideosIC")
@@ -198,16 +196,17 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
198196
if (index > -1)
199197
{
200198
var clickedOnItem = App.ViewModel.FilesAndFolders[index];
201-
202199
if (clickedOnItem.FileExtension == "Folder")
203200
{
201+
App.ViewModel.Universal.path = clickedOnItem.FilePath;
202+
App.PathText.Text = clickedOnItem.FilePath;
204203
App.ViewModel.TextState.isVisible = Visibility.Collapsed;
205204
History.ForwardList.Clear();
206205
App.ViewModel.FS.isEnabled = false;
207206
App.ViewModel.FilesAndFolders.Clear();
208207
if (clickedOnItem.FilePath == Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
209208
{
210-
App.ViewModel.Universal.path = "Desktop";
209+
App.PathText.Text = "Desktop";
211210
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
212211
{
213212
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "DesktopIC")
@@ -221,7 +220,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
221220
}
222221
else if (clickedOnItem.FilePath == Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
223222
{
224-
App.ViewModel.Universal.path = "Documents";
223+
App.PathText.Text = "Documents";
225224
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
226225
{
227226
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "DocumentsIC")
@@ -235,7 +234,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
235234
}
236235
else if (clickedOnItem.FilePath == (Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads"))
237236
{
238-
App.ViewModel.Universal.path = "Downloads";
237+
App.PathText.Text = "Downloads";
239238
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
240239
{
241240
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "DownloadsIC")
@@ -259,11 +258,11 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
259258
}
260259
MainPage.accessibleContentFrame.Navigate(typeof(PhotoAlbum), YourHome.PicturesPath, new SuppressNavigationTransitionInfo());
261260
MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Pictures";
262-
App.ViewModel.Universal.path = "Pictures";
261+
App.PathText.Text = "Pictures";
263262
}
264263
else if (clickedOnItem.FilePath == Environment.GetFolderPath(Environment.SpecialFolder.MyMusic))
265264
{
266-
App.ViewModel.Universal.path = "Music";
265+
App.PathText.Text = "Music";
267266
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
268267
{
269268
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "MusicIC")
@@ -277,7 +276,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
277276
}
278277
else if (clickedOnItem.FilePath == (Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\OneDrive"))
279278
{
280-
App.ViewModel.Universal.path = "OneDrive";
279+
App.PathText.Text = "OneDrive";
281280
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
282281
{
283282
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "OneD_IC")
@@ -291,7 +290,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
291290
}
292291
else if (clickedOnItem.FilePath == Environment.GetFolderPath(Environment.SpecialFolder.MyVideos))
293292
{
294-
App.ViewModel.Universal.path = "Videos";
293+
App.PathText.Text = "Videos";
295294
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
296295
{
297296
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "VideosIC")
@@ -305,7 +304,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
305304
}
306305
else
307306
{
308-
App.ViewModel.Universal.path = clickedOnItem.FilePath;
307+
App.PathText.Text = clickedOnItem.FilePath;
309308
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
310309
{
311310
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "LocD_IC")
@@ -314,7 +313,7 @@ public static async void List_ItemClick(object sender, DoubleTappedRoutedEventAr
314313
break;
315314
}
316315
}
317-
App.ViewModel.MemoryFriendlyGetItemsAsync(App.ViewModel.Universal.path, PhotoAlbum.PAPageName);
316+
App.ViewModel.MemoryFriendlyGetItemsAsync(clickedOnItem.FilePath, PhotoAlbum.PAPageName);
318317
}
319318
}
320319
else if (clickedOnItem.FileExtension == "Executable")

Files UWP/Navigation/NavigationActions.cs

+1-8
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,18 @@ public class NavigationActions
1111
{
1212
public static void Back_Click(object sender, RoutedEventArgs e)
1313
{
14-
// NOTE: THIS CHECK WAS REMOVED, REVERT BACK IF THINGS BREAK
15-
//if (App.ViewModel.IsTerminated == false)
16-
//{
1714
if(App.ViewModel.tokenSource != null)
1815
{
1916
App.ViewModel.tokenSource.Cancel();
2017
}
2118
App.ViewModel.FilesAndFolders.Clear();
22-
//}
2319

2420
if (History.HistoryList.Count > 1)
2521
{
2622
App.ViewModel.TextState.isVisible = Visibility.Collapsed;
27-
//Debug.WriteLine("\nBefore Removals");
28-
//ArrayDiag.DumpArray();
23+
2924
History.AddToForwardList(History.HistoryList[History.HistoryList.Count - 1]);
3025
History.HistoryList.RemoveAt(History.HistoryList.Count - 1);
31-
//Debug.WriteLine("\nAfter Removals");
32-
//ArrayDiag.DumpArray();
3326

3427
App.ViewModel.FilesAndFolders.Clear();
3528

Files UWP/Navigation/PhotoAlbumNavActions.cs

+3-21
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,19 @@ public class PhotoAlbumNavActions
1313
{
1414
public static void Back_Click(object sender, RoutedEventArgs e)
1515
{
16-
//if (App.ViewModel.IsTerminated == false)
17-
//{
16+
1817
if(App.ViewModel.tokenSource != null)
1918
{
2019
App.ViewModel.tokenSource.Cancel();
2120
}
2221
App.ViewModel.FilesAndFolders.Clear();
23-
//}
22+
2423

2524
if (History.HistoryList.Count() > 1)
2625
{
2726
App.ViewModel.TextState.isVisible = Visibility.Collapsed;
28-
//Debug.WriteLine("\nBefore Removals");
29-
//ArrayDiag.DumpArray();
3027
History.AddToForwardList(History.HistoryList[History.HistoryList.Count() - 1]);
3128
History.HistoryList.RemoveAt(History.HistoryList.Count() - 1);
32-
//Debug.WriteLine("\nAfter Removals");
33-
//ArrayDiag.DumpArray();
3429
App.ViewModel.FilesAndFolders.Clear();
3530

3631
if ((History.HistoryList[History.HistoryList.Count - 1]) == Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
@@ -145,12 +140,6 @@ public static void Back_Click(object sender, RoutedEventArgs e)
145140
App.ViewModel.MemoryFriendlyGetItemsAsync(History.HistoryList[History.HistoryList.Count - 1], GenericFileBrowser.GFBPageName); // To take into account the correct index without interference from the folder being navigated to
146141
}
147142

148-
149-
150-
151-
//App.ViewModel.ViewModel = new ItemViewModel(History.HistoryList[History.HistoryList.Count() - 1], PhotoAlbum.PAPageName); // To take into account the correct index without interference from the folder being navigated to
152-
//App.PathText.Text = History.HistoryList[History.HistoryList.Count() - 1];
153-
154143
if (History.ForwardList.Count == 0)
155144
{
156145
App.ViewModel.FS.isEnabled = false;
@@ -159,22 +148,16 @@ public static void Back_Click(object sender, RoutedEventArgs e)
159148
{
160149
App.ViewModel.FS.isEnabled = true;
161150
}
162-
163-
164151
}
165-
166152
}
167153

168154
public static void Forward_Click(object sender, RoutedEventArgs e)
169155
{
170-
//if (App.ViewModel.IsTerminated == false)
171-
//{
172156
if(App.ViewModel.tokenSource != null)
173157
{
174158
App.ViewModel.tokenSource.Cancel();
175159
}
176160
App.ViewModel.FilesAndFolders.Clear();
177-
//}
178161

179162
if (History.ForwardList.Count() > 0)
180163
{
@@ -199,10 +182,9 @@ public static void Forward_Click(object sender, RoutedEventArgs e)
199182

200183
public async static void Refresh_Click(object sender, RoutedEventArgs e)
201184
{
202-
//App.ViewModel.IsStopRequested = true;
203185
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
204186
{
205-
if(App.ViewModel != null)
187+
if(App.ViewModel.tokenSource != null)
206188
{
207189
App.ViewModel.tokenSource.Cancel();
208190
}

Files UWP/Navigation/UniversalPath.cs

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ private void NotifyPropertyChanged(string info)
3434

3535
public class DisplayedPathText : INotifyPropertyChanged
3636
{
37-
38-
3937
private string text;
4038
public string Text
4139
{

0 commit comments

Comments
 (0)