1- using Files . Interacts ;
1+ using Files . Filesystem ;
2+ using Files . Interacts ;
3+ using GalaSoft . MvvmLight ;
24using System ;
35using Windows . Foundation . Metadata ;
46using Windows . Storage ;
57using Windows . UI . WindowManagement ;
68using Windows . UI . Xaml . Controls ;
9+ using Windows . UI . Xaml . Media ;
710using Windows . UI . Xaml . Media . Imaging ;
811
912namespace Files
@@ -12,7 +15,7 @@ namespace Files
1215 public sealed partial class Properties : Page
1316 {
1417 public AppWindow propWindow ;
15-
18+ public ItemPropertiesViewModel itemProperties { get ; } = new ItemPropertiesViewModel ( ) ;
1619 public Properties ( )
1720 {
1821 this . InitializeComponent ( ) ;
@@ -26,34 +29,55 @@ public Properties()
2629 }
2730 }
2831
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 )
3033 {
3134 // Collect AppWindow-specific info
3235 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 )
3837 {
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+
3959 if ( App . CurrentInstance . ContentPage . SelectedItem . FolderImg != Windows . UI . Xaml . Visibility . Visible )
4060 {
4161 var thumbnail = await ( await StorageFile . GetFileFromPathAsync ( App . CurrentInstance . ContentPage . SelectedItem . FilePath ) ) . GetThumbnailAsync ( Windows . Storage . FileProperties . ThumbnailMode . SingleItem , 40 , Windows . Storage . FileProperties . ThumbnailOptions . ResizeThumbnail ) ;
4262 var bitmap = new BitmapImage ( ) ;
4363 await bitmap . SetSourceAsync ( thumbnail ) ;
44- itemIcon . Source = bitmap ;
45- }
46- else
47- {
48- EmptyImageIcon . Visibility = Windows . UI . Xaml . Visibility . Collapsed ;
64+ itemProperties . FileIconSource = bitmap ;
4965 }
5066 }
5167 else
5268 {
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 ) ;
5480 }
55-
56-
5781 }
5882
5983 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
6488 }
6589 }
6690 }
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+ }
67156}
0 commit comments