@@ -22,143 +22,76 @@ namespace Files.Filesystem
2222{
2323 public class ItemViewModel
2424 {
25- public static ObservableCollection < Classic_ListedFolderItem > classicFolderList = new ObservableCollection < Classic_ListedFolderItem > ( ) ;
26- public static ObservableCollection < Classic_ListedFolderItem > ClassicFolderList { get { return classicFolderList ; } }
27-
28- public static ObservableCollection < ListedItem > classicFileList = new ObservableCollection < ListedItem > ( ) ;
29- public static ObservableCollection < ListedItem > ClassicFileList { get { return classicFileList ; } }
30-
31- public static ObservableCollection < ListedItem > filesAndFolders = new ObservableCollection < ListedItem > ( ) ;
32- public static ObservableCollection < ListedItem > FilesAndFolders { get { return filesAndFolders ; } }
33-
34- StorageFolder folder ;
35- static string gotName ;
36- static string gotDate ;
37- static string gotType ;
38- static string gotPath ;
39- static string gotFolName ;
40- static string gotFolDate ;
41- static string gotFolPath ;
42- static string gotDotFileExtension ;
43- static string gotFolType ;
44- static Visibility gotFileImgVis ;
45- static Visibility gotEmptyImgVis ;
46- static Visibility gotFolImg ;
47- static StorageItemThumbnail gotFileImg ;
48- public static ObservableCollection < Classic_ListedFolderItem > ChildrenList ;
49- public static IReadOnlyList < StorageFolder > folderList ;
50- public static IReadOnlyList < StorageFile > fileList ;
51- public static bool isPhotoAlbumMode ;
52- public static string pageName ;
53-
54- public static ItemViewModel vm ;
55- public static ItemViewModel ViewModel { get { return vm ; } set { } }
56-
57- public static BackState bs = new BackState ( ) ;
58- public static BackState BS
59- {
60- get
61- {
62- return bs ;
63- }
64- }
65-
66- public static ForwardState fs = new ForwardState ( ) ;
67- public static ForwardState FS
25+ public ObservableCollection < Classic_ListedFolderItem > ClassicFolderList { get ; set ; } = new ObservableCollection < Classic_ListedFolderItem > ( ) ;
26+ public ObservableCollection < ListedItem > ClassicFileList { get ; set ; } = new ObservableCollection < ListedItem > ( ) ;
27+ public ObservableCollection < ListedItem > FilesAndFolders { get ; set ; } = new ObservableCollection < ListedItem > ( ) ;
28+ public ObservableCollection < Classic_ListedFolderItem > ChildrenList ;
29+ public ListedItem LI { get ; } = new ListedItem ( ) ;
30+ public UniversalPath Universal { get ; } = new UniversalPath ( ) ;
31+ public EmptyFolderTextState TextState { get ; set ; } = new EmptyFolderTextState ( ) ;
32+ public BackState BS { get ; set ; } = new BackState ( ) ;
33+ public ForwardState FS { get ; set ; } = new ForwardState ( ) ;
34+ public ProgressUIVisibility PVIS { get ; set ; } = new ProgressUIVisibility ( ) ;
35+ private StorageFolder folder ;
36+ private string gotName ;
37+ private string gotDate ;
38+ private string gotType ;
39+ private string gotPath ;
40+ private string gotFolName ;
41+ private string gotFolDate ;
42+ private string gotFolPath ;
43+ private string gotDotFileExtension ;
44+ private string gotFolType ;
45+ private Visibility gotFileImgVis ;
46+ private Visibility gotEmptyImgVis ;
47+ private Visibility gotFolImg ;
48+ private StorageItemThumbnail gotFileImg ;
49+ private bool isPhotoAlbumMode ;
50+ public string pageName ;
51+ private StorageFileQueryResult fileQueryResult ;
52+ private StorageFolderQueryResult folderQueryResult ;
53+ public CancellationTokenSource tokenSource ;
54+
55+
56+ public ItemViewModel ( )
6857 {
69- get
70- {
71- return fs ;
72- }
58+
7359 }
7460
75- public static ProgressUIVisibility pvis = new ProgressUIVisibility ( ) ;
76- public static ProgressUIVisibility PVIS
61+ private async void DisplayConsentDialog ( )
7762 {
78- get
79- {
80- return pvis ;
81- }
63+ await MainPage . permissionBox . ShowAsync ( ) ;
8264 }
83-
84- private ListedItem li = new ListedItem ( ) ;
85- public ListedItem LI { get { return this . li ; } }
86-
87- private static ProgressUIHeader pUIh = new ProgressUIHeader ( ) ;
88- public static ProgressUIHeader PUIH { get { return ItemViewModel . pUIh ; } }
89-
90- private static ProgressUIPath pUIp = new ProgressUIPath ( ) ;
91- public static ProgressUIPath PUIP { get { return ItemViewModel . pUIp ; } }
92-
93- private static EmptyFolderTextState textState = new EmptyFolderTextState ( ) ;
94- public static EmptyFolderTextState TextState { get { return textState ; } }
95-
96- public static int NumOfItems ;
97- public static int NumItemsRead ;
98- public static int NumOfFiles ;
99- public static int NumOfFolders ;
100- StorageFileQueryResult fileQueryResult ;
101- StorageFolderQueryResult folderQueryResult ;
102- public static CancellationToken token ;
103- public static CancellationTokenSource tokenSource ;
104-
105- public ItemViewModel ( string viewPath , Page p )
65+ public async void MemoryFriendlyGetItemsAsync ( string path , Page passedPage )
10666 {
107-
108- pageName = p . Name ;
67+ TextState . isVisible = Visibility . Collapsed ;
68+ tokenSource = new CancellationTokenSource ( ) ;
69+ CancellationToken token = App . ViewModel . tokenSource . Token ;
70+ pageName = passedPage . Name ;
71+ Universal . path = path ;
10972 // Personalize retrieved items for view they are displayed in
110- if ( p . Name == "GenericItemView" || p . Name == "ClassicModePage" )
73+ switch ( pageName )
11174 {
112- isPhotoAlbumMode = false ;
113- }
114- else if ( p . Name == "PhotoAlbumViewer" )
115- {
116- isPhotoAlbumMode = true ;
75+ case "GenericItemView" :
76+ isPhotoAlbumMode = false ;
77+ break ;
78+ case "PhotoAlbumViewer" :
79+ isPhotoAlbumMode = true ;
80+ break ;
81+ case "ClassicModePage" :
82+ isPhotoAlbumMode = false ;
83+ break ;
11784 }
11885
11986 if ( pageName != "ClassicModePage" )
12087 {
121- GenericFileBrowser . P . path = viewPath ;
12288 FilesAndFolders . Clear ( ) ;
12389 }
12490
125- tokenSource = new CancellationTokenSource ( ) ;
126- token = tokenSource . Token ;
127- MemoryFriendlyGetItemsAsync ( viewPath , token ) ;
128-
129- if ( pageName != "ClassicModePage" )
130- {
131- History . AddToHistory ( viewPath ) ;
132-
133- if ( History . HistoryList . Count == 1 )
134- {
135- BS . isEnabled = false ;
136- //Debug.WriteLine("Disabled Property");
137-
138-
139- }
140- else if ( History . HistoryList . Count > 1 )
141- {
142- BS . isEnabled = true ;
143- //Debug.WriteLine("Enabled Property");
144- }
145- }
146-
147-
148- }
149-
150- private async void DisplayConsentDialog ( )
151- {
152- await MainPage . permissionBox . ShowAsync ( ) ;
153- }
154- string sort = "By_Name" ;
155- SortEntry entry ;
156- public async void MemoryFriendlyGetItemsAsync ( string path , CancellationToken token )
157- {
15891 Stopwatch stopwatch = new Stopwatch ( ) ;
15992 stopwatch . Start ( ) ;
16093
161- PUIP . Path = path ;
94+ Universal . path = path ; // Set visible path to reflect new navigation
16295 try
16396 {
16497
@@ -170,16 +103,16 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
170103 FolderDepth = FolderDepth . Shallow ,
171104 IndexerOption = IndexerOption . UseIndexerWhenAvailable
172105 } ;
173-
106+ string sort = "By_Name" ;
174107 if ( sort == "By_Name" )
175108 {
176- entry = new SortEntry ( )
109+ SortEntry entry = new SortEntry ( )
177110 {
178111 AscendingOrder = true ,
179112 PropertyName = "System.FileName"
180113 } ;
114+ options . SortOrder . Add ( entry ) ;
181115 }
182- options . SortOrder . Add ( entry ) ;
183116
184117 uint index = 0 ;
185118 const uint step = 250 ;
@@ -360,27 +293,19 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
360293 rootFrame . Navigate ( typeof ( MainPage ) , new SuppressNavigationTransitionInfo ( ) ) ;
361294 }
362295
363- }
364-
365- public static ProgressPercentage progressPER = new ProgressPercentage ( ) ;
296+ History . AddToHistory ( Universal . path ) ;
366297
367- public static ProgressPercentage PROGRESSPER
368- {
369- get
298+ if ( History . HistoryList . Count == 1 )
370299 {
371- return progressPER ;
300+ BS . isEnabled = false ;
372301 }
373- set
302+ else if ( History . HistoryList . Count > 1 )
374303 {
375-
304+ BS . isEnabled = true ;
376305 }
306+ tokenSource = null ;
377307 }
378308
379- public static int UpdateProgUI ( int level )
380- {
381- PROGRESSPER . prog = level ;
382- return ( int ) level ;
383- }
384309
385310 public static async void FillTreeNode ( object item , TreeView EntireControl )
386311 {
0 commit comments