@@ -22,143 +22,76 @@ namespace Files.Filesystem
22
22
{
23
23
public class ItemViewModel
24
24
{
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 ( )
68
57
{
69
- get
70
- {
71
- return fs ;
72
- }
58
+
73
59
}
74
60
75
- public static ProgressUIVisibility pvis = new ProgressUIVisibility ( ) ;
76
- public static ProgressUIVisibility PVIS
61
+ private async void DisplayConsentDialog ( )
77
62
{
78
- get
79
- {
80
- return pvis ;
81
- }
63
+ await MainPage . permissionBox . ShowAsync ( ) ;
82
64
}
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 )
106
66
{
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 ;
109
72
// Personalize retrieved items for view they are displayed in
110
- if ( p . Name == "GenericItemView" || p . Name == "ClassicModePage" )
73
+ switch ( pageName )
111
74
{
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 ;
117
84
}
118
85
119
86
if ( pageName != "ClassicModePage" )
120
87
{
121
- GenericFileBrowser . P . path = viewPath ;
122
88
FilesAndFolders . Clear ( ) ;
123
89
}
124
90
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
- {
158
91
Stopwatch stopwatch = new Stopwatch ( ) ;
159
92
stopwatch . Start ( ) ;
160
93
161
- PUIP . Path = path ;
94
+ Universal . path = path ; // Set visible path to reflect new navigation
162
95
try
163
96
{
164
97
@@ -170,16 +103,16 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
170
103
FolderDepth = FolderDepth . Shallow ,
171
104
IndexerOption = IndexerOption . UseIndexerWhenAvailable
172
105
} ;
173
-
106
+ string sort = "By_Name" ;
174
107
if ( sort == "By_Name" )
175
108
{
176
- entry = new SortEntry ( )
109
+ SortEntry entry = new SortEntry ( )
177
110
{
178
111
AscendingOrder = true ,
179
112
PropertyName = "System.FileName"
180
113
} ;
114
+ options . SortOrder . Add ( entry ) ;
181
115
}
182
- options . SortOrder . Add ( entry ) ;
183
116
184
117
uint index = 0 ;
185
118
const uint step = 250 ;
@@ -309,7 +242,7 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
309
242
}
310
243
else
311
244
{
312
- FilesAndFolders . Add ( new ListedItem ( ) { EmptyImgVis = gotEmptyImgVis , FileImg = icon , FileIconVis = gotFileImgVis , FolderImg = gotFolImg , FileName = gotName , FileDate = gotDate , FileExtension = gotType , FilePath = gotPath } ) ;
245
+ FilesAndFolders . Add ( new ListedItem ( ) { DotFileExtension = gotDotFileExtension , EmptyImgVis = gotEmptyImgVis , FileImg = icon , FileIconVis = gotFileImgVis , FolderImg = gotFolImg , FileName = gotName , FileDate = gotDate , FileExtension = gotType , FilePath = gotPath } ) ;
313
246
}
314
247
}
315
248
catch
@@ -360,27 +293,19 @@ public async void MemoryFriendlyGetItemsAsync(string path, CancellationToken tok
360
293
rootFrame . Navigate ( typeof ( MainPage ) , new SuppressNavigationTransitionInfo ( ) ) ;
361
294
}
362
295
363
- }
364
-
365
- public static ProgressPercentage progressPER = new ProgressPercentage ( ) ;
296
+ History . AddToHistory ( Universal . path ) ;
366
297
367
- public static ProgressPercentage PROGRESSPER
368
- {
369
- get
298
+ if ( History . HistoryList . Count == 1 )
370
299
{
371
- return progressPER ;
300
+ BS . isEnabled = false ;
372
301
}
373
- set
302
+ else if ( History . HistoryList . Count > 1 )
374
303
{
375
-
304
+ BS . isEnabled = true ;
376
305
}
306
+ tokenSource = null ;
377
307
}
378
308
379
- public static int UpdateProgUI ( int level )
380
- {
381
- PROGRESSPER . prog = level ;
382
- return ( int ) level ;
383
- }
384
309
385
310
public static async void FillTreeNode ( object item , TreeView EntireControl )
386
311
{
0 commit comments