1
- using Files . DataModels ;
2
1
using Files . Filesystem ;
3
2
using GalaSoft . MvvmLight ;
4
- using Windows . UI . Xaml . Controls ;
5
3
using System ;
6
4
using System . Collections . Generic ;
7
- using System . Linq ;
8
5
using System . Threading ;
9
6
using System . Threading . Tasks ;
10
7
using Windows . Security . Cryptography . Core ;
11
8
using Windows . Storage ;
12
9
using Windows . Storage . FileProperties ;
13
- using Windows . Storage . Search ;
14
10
using Windows . UI . Xaml ;
15
11
using Windows . UI . Xaml . Media ;
16
- using Windows . UI . Xaml . Media . Imaging ;
17
12
using System . IO ;
18
13
using Windows . UI . Core ;
19
14
using FileAttributes = System . IO . FileAttributes ;
@@ -24,71 +19,88 @@ namespace Files.View_Models
24
19
{
25
20
public class SelectedItemsPropertiesViewModel : ViewModelBase
26
21
{
27
- #region ItemProperties
28
22
private string _ItemName ;
23
+
29
24
public string ItemName
30
25
{
31
26
get => _ItemName ;
32
27
set => Set ( ref _ItemName , value ) ;
33
28
}
29
+
34
30
private string _ItemType ;
31
+
35
32
public string ItemType
36
33
{
37
34
get => _ItemType ;
38
35
set => Set ( ref _ItemType , value ) ;
39
36
}
37
+
40
38
private string _ItemPath ;
39
+
41
40
public string ItemPath
42
41
{
43
42
get => _ItemPath ;
44
43
set => Set ( ref _ItemPath , value ) ;
45
44
}
45
+
46
46
private long _ItemSizeReal ;
47
47
48
48
public long ItemSizeReal
49
49
{
50
50
get => _ItemSizeReal ;
51
51
set => Set ( ref _ItemSizeReal , value ) ;
52
52
}
53
+
53
54
private Visibility _ItemSizeProgressVisibility = Visibility . Collapsed ;
54
55
55
56
public Visibility ItemSizeProgressVisibility
56
57
{
57
58
get => _ItemSizeProgressVisibility ;
58
59
set => Set ( ref _ItemSizeProgressVisibility , value ) ;
59
60
}
61
+
60
62
private bool _SizeCalcError ;
61
63
62
64
public bool SizeCalcError
63
65
{
64
66
get => _SizeCalcError ;
65
67
set => Set ( ref _SizeCalcError , value ) ;
66
68
}
69
+
67
70
private string _ItemModifiedTimestamp ;
71
+
68
72
public string ItemModifiedTimestamp
69
73
{
70
74
get => _ItemModifiedTimestamp ;
71
75
set => Set ( ref _ItemModifiedTimestamp , value ) ;
72
76
}
77
+
73
78
private ImageSource _FileIconSource ;
79
+
74
80
public ImageSource FileIconSource
75
81
{
76
82
get => _FileIconSource ;
77
83
set => Set ( ref _FileIconSource , value ) ;
78
84
}
85
+
79
86
private bool _LoadFolderGlyph ;
87
+
80
88
public bool LoadFolderGlyph
81
89
{
82
90
get => _LoadFolderGlyph ;
83
91
set => Set ( ref _LoadFolderGlyph , value ) ;
84
92
}
93
+
85
94
private bool _LoadUnknownTypeGlyph ;
95
+
86
96
public bool LoadUnknownTypeGlyph
87
97
{
88
98
get => _LoadUnknownTypeGlyph ;
89
99
set => Set ( ref _LoadUnknownTypeGlyph , value ) ;
90
100
}
101
+
91
102
private bool _LoadFileIcon ;
103
+
92
104
public bool LoadFileIcon
93
105
{
94
106
get => _LoadFileIcon ;
@@ -118,26 +130,33 @@ public bool IsItemSelected
118
130
get => _IsItemSelected ;
119
131
set => Set ( ref _IsItemSelected , value ) ;
120
132
}
133
+
121
134
private string _ItemCreatedTimestamp ;
122
135
123
136
public string ItemCreatedTimestamp
124
137
{
125
138
get => _ItemCreatedTimestamp ;
126
139
set => Set ( ref _ItemCreatedTimestamp , value ) ;
127
140
}
141
+
128
142
public string _ItemAccessedTimestamp ;
143
+
129
144
public string ItemAccessedTimestamp
130
145
{
131
146
get => _ItemAccessedTimestamp ;
132
147
set => Set ( ref _ItemAccessedTimestamp , value ) ;
133
148
}
149
+
134
150
public string _ItemFileOwner ;
151
+
135
152
public string ItemFileOwner
136
153
{
137
154
get => _ItemFileOwner ;
138
155
set => Set ( ref _ItemFileOwner , value ) ;
139
156
}
157
+
140
158
public string _ItemMD5Hash ;
159
+
141
160
public string ItemMD5Hash
142
161
{
143
162
get => _ItemMD5Hash ;
@@ -150,7 +169,9 @@ public string ItemMD5Hash
150
169
}
151
170
}
152
171
}
172
+
153
173
private bool _ItemMD5HashCalcError ;
174
+
154
175
public bool ItemMD5HashCalcError
155
176
{
156
177
get => _ItemMD5HashCalcError ;
@@ -164,38 +185,35 @@ public Visibility ItemMD5HashVisibility
164
185
get => _ItemMD5HashVisibility ;
165
186
set => Set ( ref _ItemMD5HashVisibility , value ) ;
166
187
}
188
+
167
189
public Visibility _ItemMD5HashProgressVisibiity = Visibility . Collapsed ;
168
190
169
191
public Visibility ItemMD5HashProgressVisibility
170
192
{
171
193
get => _ItemMD5HashProgressVisibiity ;
172
194
set => Set ( ref _ItemMD5HashProgressVisibiity , value ) ;
173
195
}
174
- #endregion
175
- #region Properties
176
196
177
197
public Microsoft . UI . Xaml . Controls . ProgressBar ItemMD5HashProgress { get ; set ; }
178
198
179
199
public ListedItem Item { get ; }
180
200
181
201
public CoreDispatcher Dispatcher { get ; set ; }
182
- #endregion
183
- #region Constructors
202
+
184
203
public SelectedItemsPropertiesViewModel ( ListedItem item )
185
204
{
186
205
Item = item ;
187
206
188
207
ItemName = Item ? . ItemName ;
189
208
ItemType = Item ? . ItemType ;
190
- ItemPath = Item ? . ItemPath ;
209
+ ItemPath = Path . GetDirectoryName ( Item ? . ItemPath ) ;
191
210
ItemModifiedTimestamp = Item ? . ItemDateModified ;
192
211
FileIconSource = Item ? . FileImage ;
193
212
LoadFolderGlyph = Item != null ? Item . LoadFolderGlyph : false ;
194
213
LoadUnknownTypeGlyph = Item != null ? Item . LoadUnknownTypeGlyph : false ;
195
214
LoadFileIcon = Item != null ? Item . LoadFileIcon : false ;
196
215
}
197
- #endregion
198
- #region Methods
216
+
199
217
public async void GetOtherPropeties ( StorageItemContentProperties properties )
200
218
{
201
219
string dateAccessedProperty = "System.DateAccessed" ;
@@ -207,6 +225,7 @@ public async void GetOtherPropeties(StorageItemContentProperties properties)
207
225
ItemAccessedTimestamp = ListedItem . GetFriendlyDate ( ( DateTimeOffset ) extraProperties [ dateAccessedProperty ] ) ;
208
226
ItemFileOwner = extraProperties [ fileOwnerProperty ] . ToString ( ) ;
209
227
}
228
+
210
229
private async void GetFolderSize ( StorageFolder storageFolder , CancellationToken token )
211
230
{
212
231
ItemSizeProgressVisibility = Visibility . Visible ;
@@ -230,6 +249,7 @@ private async void GetFolderSize(StorageFolder storageFolder, CancellationToken
230
249
}
231
250
ItemSizeProgressVisibility = Visibility . Collapsed ;
232
251
}
252
+
233
253
public async Task < long > CalculateFolderSizeAsync ( string path , CancellationToken token )
234
254
{
235
255
long size = 0 ;
@@ -359,6 +379,5 @@ public async Task GetPropertiesAsync(CancellationTokenSource _tokenSource)
359
379
GetFolderSize ( storageFolder , _tokenSource . Token ) ;
360
380
}
361
381
}
362
- #endregion
363
382
}
364
383
}
0 commit comments