Skip to content

Commit 8cf5dd0

Browse files
authored
Properties: Show item location instead of full path (#1153)
1 parent 8244e8a commit 8cf5dd0

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

Files/Helpers/StringExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public static string Right([NotNull] this string value, int length)
7373
{ "GiB", ResourceController.GetTranslation("GigaByteSymbol") },
7474
{ "TiB", ResourceController.GetTranslation("TeraByteSymbol") },
7575
{ "PiB", ResourceController.GetTranslation("PetaByteSymbol") },
76-
{ "B", ResourceController.GetTranslation("ByteSymbol") }
76+
{ "B", ResourceController.GetTranslation("ByteSymbol") },
77+
{ "b", ResourceController.GetTranslation("ByteSymbol") }
7778
};
7879

7980
public static string ConvertSizeAbbreviation(this string value)

Files/View Models/SelectedItemsPropertiesViewModel.cs

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
using Files.DataModels;
21
using Files.Filesystem;
32
using GalaSoft.MvvmLight;
4-
using Windows.UI.Xaml.Controls;
53
using System;
64
using System.Collections.Generic;
7-
using System.Linq;
85
using System.Threading;
96
using System.Threading.Tasks;
107
using Windows.Security.Cryptography.Core;
118
using Windows.Storage;
129
using Windows.Storage.FileProperties;
13-
using Windows.Storage.Search;
1410
using Windows.UI.Xaml;
1511
using Windows.UI.Xaml.Media;
16-
using Windows.UI.Xaml.Media.Imaging;
1712
using System.IO;
1813
using Windows.UI.Core;
1914
using FileAttributes = System.IO.FileAttributes;
@@ -24,71 +19,88 @@ namespace Files.View_Models
2419
{
2520
public class SelectedItemsPropertiesViewModel : ViewModelBase
2621
{
27-
#region ItemProperties
2822
private string _ItemName;
23+
2924
public string ItemName
3025
{
3126
get => _ItemName;
3227
set => Set(ref _ItemName, value);
3328
}
29+
3430
private string _ItemType;
31+
3532
public string ItemType
3633
{
3734
get => _ItemType;
3835
set => Set(ref _ItemType, value);
3936
}
37+
4038
private string _ItemPath;
39+
4140
public string ItemPath
4241
{
4342
get => _ItemPath;
4443
set => Set(ref _ItemPath, value);
4544
}
45+
4646
private long _ItemSizeReal;
4747

4848
public long ItemSizeReal
4949
{
5050
get => _ItemSizeReal;
5151
set => Set(ref _ItemSizeReal, value);
5252
}
53+
5354
private Visibility _ItemSizeProgressVisibility = Visibility.Collapsed;
5455

5556
public Visibility ItemSizeProgressVisibility
5657
{
5758
get => _ItemSizeProgressVisibility;
5859
set => Set(ref _ItemSizeProgressVisibility, value);
5960
}
61+
6062
private bool _SizeCalcError;
6163

6264
public bool SizeCalcError
6365
{
6466
get => _SizeCalcError;
6567
set => Set(ref _SizeCalcError, value);
6668
}
69+
6770
private string _ItemModifiedTimestamp;
71+
6872
public string ItemModifiedTimestamp
6973
{
7074
get => _ItemModifiedTimestamp;
7175
set => Set(ref _ItemModifiedTimestamp, value);
7276
}
77+
7378
private ImageSource _FileIconSource;
79+
7480
public ImageSource FileIconSource
7581
{
7682
get => _FileIconSource;
7783
set => Set(ref _FileIconSource, value);
7884
}
85+
7986
private bool _LoadFolderGlyph;
87+
8088
public bool LoadFolderGlyph
8189
{
8290
get => _LoadFolderGlyph;
8391
set => Set(ref _LoadFolderGlyph, value);
8492
}
93+
8594
private bool _LoadUnknownTypeGlyph;
95+
8696
public bool LoadUnknownTypeGlyph
8797
{
8898
get => _LoadUnknownTypeGlyph;
8999
set => Set(ref _LoadUnknownTypeGlyph, value);
90100
}
101+
91102
private bool _LoadFileIcon;
103+
92104
public bool LoadFileIcon
93105
{
94106
get => _LoadFileIcon;
@@ -118,26 +130,33 @@ public bool IsItemSelected
118130
get => _IsItemSelected;
119131
set => Set(ref _IsItemSelected, value);
120132
}
133+
121134
private string _ItemCreatedTimestamp;
122135

123136
public string ItemCreatedTimestamp
124137
{
125138
get => _ItemCreatedTimestamp;
126139
set => Set(ref _ItemCreatedTimestamp, value);
127140
}
141+
128142
public string _ItemAccessedTimestamp;
143+
129144
public string ItemAccessedTimestamp
130145
{
131146
get => _ItemAccessedTimestamp;
132147
set => Set(ref _ItemAccessedTimestamp, value);
133148
}
149+
134150
public string _ItemFileOwner;
151+
135152
public string ItemFileOwner
136153
{
137154
get => _ItemFileOwner;
138155
set => Set(ref _ItemFileOwner, value);
139156
}
157+
140158
public string _ItemMD5Hash;
159+
141160
public string ItemMD5Hash
142161
{
143162
get => _ItemMD5Hash;
@@ -150,7 +169,9 @@ public string ItemMD5Hash
150169
}
151170
}
152171
}
172+
153173
private bool _ItemMD5HashCalcError;
174+
154175
public bool ItemMD5HashCalcError
155176
{
156177
get => _ItemMD5HashCalcError;
@@ -164,38 +185,35 @@ public Visibility ItemMD5HashVisibility
164185
get => _ItemMD5HashVisibility;
165186
set => Set(ref _ItemMD5HashVisibility, value);
166187
}
188+
167189
public Visibility _ItemMD5HashProgressVisibiity = Visibility.Collapsed;
168190

169191
public Visibility ItemMD5HashProgressVisibility
170192
{
171193
get => _ItemMD5HashProgressVisibiity;
172194
set => Set(ref _ItemMD5HashProgressVisibiity, value);
173195
}
174-
#endregion
175-
#region Properties
176196

177197
public Microsoft.UI.Xaml.Controls.ProgressBar ItemMD5HashProgress { get; set; }
178198

179199
public ListedItem Item { get; }
180200

181201
public CoreDispatcher Dispatcher { get; set; }
182-
#endregion
183-
#region Constructors
202+
184203
public SelectedItemsPropertiesViewModel(ListedItem item)
185204
{
186205
Item = item;
187206

188207
ItemName = Item?.ItemName;
189208
ItemType = Item?.ItemType;
190-
ItemPath = Item?.ItemPath;
209+
ItemPath = Path.GetDirectoryName(Item?.ItemPath);
191210
ItemModifiedTimestamp = Item?.ItemDateModified;
192211
FileIconSource = Item?.FileImage;
193212
LoadFolderGlyph = Item != null ? Item.LoadFolderGlyph : false;
194213
LoadUnknownTypeGlyph = Item != null ? Item.LoadUnknownTypeGlyph : false;
195214
LoadFileIcon = Item != null ? Item.LoadFileIcon : false;
196215
}
197-
#endregion
198-
#region Methods
216+
199217
public async void GetOtherPropeties(StorageItemContentProperties properties)
200218
{
201219
string dateAccessedProperty = "System.DateAccessed";
@@ -207,6 +225,7 @@ public async void GetOtherPropeties(StorageItemContentProperties properties)
207225
ItemAccessedTimestamp = ListedItem.GetFriendlyDate((DateTimeOffset)extraProperties[dateAccessedProperty]);
208226
ItemFileOwner = extraProperties[fileOwnerProperty].ToString();
209227
}
228+
210229
private async void GetFolderSize(StorageFolder storageFolder, CancellationToken token)
211230
{
212231
ItemSizeProgressVisibility = Visibility.Visible;
@@ -230,6 +249,7 @@ private async void GetFolderSize(StorageFolder storageFolder, CancellationToken
230249
}
231250
ItemSizeProgressVisibility = Visibility.Collapsed;
232251
}
252+
233253
public async Task<long> CalculateFolderSizeAsync(string path, CancellationToken token)
234254
{
235255
long size = 0;
@@ -359,6 +379,5 @@ public async Task GetPropertiesAsync(CancellationTokenSource _tokenSource)
359379
GetFolderSize(storageFolder, _tokenSource.Token);
360380
}
361381
}
362-
#endregion
363382
}
364383
}

0 commit comments

Comments
 (0)