1
- using Files . Interacts ;
1
+ using Files . Filesystem ;
2
+ using Files . Interacts ;
3
+ using GalaSoft . MvvmLight ;
2
4
using System ;
3
5
using Windows . Foundation . Metadata ;
4
6
using Windows . Storage ;
5
7
using Windows . UI . WindowManagement ;
6
8
using Windows . UI . Xaml . Controls ;
9
+ using Windows . UI . Xaml . Media ;
7
10
using Windows . UI . Xaml . Media . Imaging ;
8
11
9
12
namespace Files
@@ -12,7 +15,7 @@ namespace Files
12
15
public sealed partial class Properties : Page
13
16
{
14
17
public AppWindow propWindow ;
15
-
18
+ public ItemPropertiesViewModel itemProperties { get ; } = new ItemPropertiesViewModel ( ) ;
16
19
public Properties ( )
17
20
{
18
21
this . InitializeComponent ( ) ;
@@ -26,34 +29,55 @@ public Properties()
26
29
}
27
30
}
28
31
29
- private void Properties_Loaded ( object sender , Windows . UI . Xaml . RoutedEventArgs e )
32
+ private async void Properties_Loaded ( object sender , Windows . UI . Xaml . RoutedEventArgs e )
30
33
{
31
34
// Collect AppWindow-specific info
32
35
propWindow = Interaction . AppWindows [ this . UIContext ] ;
33
- }
34
-
35
- private async void itemIcon_Loading ( Windows . UI . Xaml . FrameworkElement sender , object args )
36
- {
37
- if ( App . CurrentInstance . ContentPage . SelectedItem != null )
36
+ if ( App . CurrentInstance . ContentPage . IsItemSelected )
38
37
{
38
+ var selectedItem = App . CurrentInstance . ContentPage . SelectedItem ;
39
+ IStorageItem selectedStorageItem ;
40
+ try
41
+ {
42
+ selectedStorageItem = await StorageFolder . GetFolderFromPathAsync ( selectedItem . FilePath ) ;
43
+ }
44
+ catch ( Exception )
45
+ {
46
+ // Not a folder, so attempt to get as StorageFile
47
+ selectedStorageItem = await StorageFile . GetFileFromPathAsync ( selectedItem . FilePath ) ;
48
+ }
49
+ itemProperties . ItemName = selectedItem . FileName ;
50
+ itemProperties . ItemType = selectedItem . FileType ;
51
+ itemProperties . ItemPath = selectedItem . FilePath ;
52
+ itemProperties . ItemSize = selectedItem . FileSize ;
53
+ itemProperties . LoadFileIcon = selectedItem . FileIconVis == Windows . UI . Xaml . Visibility . Visible ? true : false ;
54
+ itemProperties . LoadFolderGlyph = selectedItem . FolderImg == Windows . UI . Xaml . Visibility . Visible ? true : false ;
55
+ itemProperties . LoadUnknownTypeGlyph = selectedItem . EmptyImgVis == Windows . UI . Xaml . Visibility . Visible ? true : false ;
56
+ itemProperties . ItemModifiedTimestamp = selectedItem . FileDate ;
57
+ itemProperties . ItemCreatedTimestamp = ListedItem . GetFriendlyDate ( selectedStorageItem . DateCreated ) ;
58
+
39
59
if ( App . CurrentInstance . ContentPage . SelectedItem . FolderImg != Windows . UI . Xaml . Visibility . Visible )
40
60
{
41
61
var thumbnail = await ( await StorageFile . GetFileFromPathAsync ( App . CurrentInstance . ContentPage . SelectedItem . FilePath ) ) . GetThumbnailAsync ( Windows . Storage . FileProperties . ThumbnailMode . SingleItem , 40 , Windows . Storage . FileProperties . ThumbnailOptions . ResizeThumbnail ) ;
42
62
var bitmap = new BitmapImage ( ) ;
43
63
await bitmap . SetSourceAsync ( thumbnail ) ;
44
- itemIcon . Source = bitmap ;
45
- }
46
- else
47
- {
48
- EmptyImageIcon . Visibility = Windows . UI . Xaml . Visibility . Collapsed ;
64
+ itemProperties . FileIconSource = bitmap ;
49
65
}
50
66
}
51
67
else
52
68
{
53
- EmptyImageIcon . Visibility = Windows . UI . Xaml . Visibility . Collapsed ;
69
+ var parentDirectory = App . CurrentInstance . ViewModel . currentFolder ;
70
+ var parentDirectoryStorageItem = await StorageFolder . GetFolderFromPathAsync ( parentDirectory . FilePath ) ;
71
+ itemProperties . ItemName = parentDirectory . FileName ;
72
+ itemProperties . ItemType = parentDirectory . FileType ;
73
+ itemProperties . ItemPath = parentDirectory . FilePath ;
74
+ itemProperties . ItemSize = parentDirectory . FileSize ;
75
+ itemProperties . LoadFileIcon = false ;
76
+ itemProperties . LoadFolderGlyph = true ;
77
+ itemProperties . LoadUnknownTypeGlyph = false ;
78
+ itemProperties . ItemModifiedTimestamp = parentDirectory . FileDate ;
79
+ itemProperties . ItemCreatedTimestamp = ListedItem . GetFriendlyDate ( parentDirectoryStorageItem . DateCreated ) ;
54
80
}
55
-
56
-
57
81
}
58
82
59
83
private async void Button_Click ( object sender , Windows . UI . Xaml . RoutedEventArgs e )
@@ -64,4 +88,69 @@ private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e
64
88
}
65
89
}
66
90
}
91
+
92
+ public class ItemPropertiesViewModel : ViewModelBase
93
+ {
94
+ private string _ItemName ;
95
+ private string _ItemType ;
96
+ private string _ItemPath ;
97
+ private string _ItemSize ;
98
+ private string _ItemCreatedTimestamp ;
99
+ private string _ItemModifiedTimestamp ;
100
+ private ImageSource _FileIconSource ;
101
+ private bool _LoadFolderGlyph ;
102
+ private bool _LoadUnknownTypeGlyph ;
103
+ private bool _LoadFileIcon ;
104
+
105
+ public string ItemName
106
+ {
107
+ get => _ItemName ;
108
+ set => Set ( ref _ItemName , value ) ;
109
+ }
110
+ public string ItemType
111
+ {
112
+ get => _ItemType ;
113
+ set => Set ( ref _ItemType , value ) ;
114
+ }
115
+ public string ItemPath
116
+ {
117
+ get => _ItemPath ;
118
+ set => Set ( ref _ItemPath , value ) ;
119
+ }
120
+ public string ItemSize
121
+ {
122
+ get => _ItemSize ;
123
+ set => Set ( ref _ItemSize , value ) ;
124
+ }
125
+ public string ItemCreatedTimestamp
126
+ {
127
+ get => _ItemCreatedTimestamp ;
128
+ set => Set ( ref _ItemCreatedTimestamp , value ) ;
129
+ }
130
+ public string ItemModifiedTimestamp
131
+ {
132
+ get => _ItemModifiedTimestamp ;
133
+ set => Set ( ref _ItemModifiedTimestamp , value ) ;
134
+ }
135
+ public ImageSource FileIconSource
136
+ {
137
+ get => _FileIconSource ;
138
+ set => Set ( ref _FileIconSource , value ) ;
139
+ }
140
+ public bool LoadFolderGlyph
141
+ {
142
+ get => _LoadFolderGlyph ;
143
+ set => Set ( ref _LoadFolderGlyph , value ) ;
144
+ }
145
+ public bool LoadUnknownTypeGlyph
146
+ {
147
+ get => _LoadUnknownTypeGlyph ;
148
+ set => Set ( ref _LoadUnknownTypeGlyph , value ) ;
149
+ }
150
+ public bool LoadFileIcon
151
+ {
152
+ get => _LoadFileIcon ;
153
+ set => Set ( ref _LoadFileIcon , value ) ;
154
+ }
155
+ }
67
156
}
0 commit comments