Skip to content

Commit dfd0488

Browse files
winston-deyaira2
andauthored
Added a details page to the properties dialog (#1962)
Co-authored-by: Yair Aichenbaum <[email protected]>
1 parent 0bce9fc commit dfd0488

19 files changed

+1207
-6
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Windows.UI.Xaml.Data;
7+
8+
namespace Files.Converters
9+
{
10+
class DateTimeOffsetToString : IValueConverter
11+
{
12+
public object Convert(object value, Type targetType, object parameter, string language)
13+
{
14+
if (value != null)
15+
return ((DateTimeOffset)value).ToLocalTime().ToString();
16+
return "";
17+
}
18+
19+
public object ConvertBack(object value, Type targetType, object parameter, string language)
20+
{
21+
try
22+
{
23+
return DateTimeOffset.Parse(value as string);
24+
}
25+
catch (FormatException e)
26+
{
27+
return null;
28+
}
29+
}
30+
}
31+
}

Files/Converters/DoubleToString.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Windows.UI.Xaml.Data;
7+
8+
namespace Files.Converters
9+
{
10+
class DoubleToString : IValueConverter
11+
{
12+
public object Convert(object value, Type targetType, object parameter, string language)
13+
{
14+
if (value != null)
15+
return value.ToString();
16+
return "";
17+
}
18+
19+
public object ConvertBack(object value, Type targetType, object parameter, string language)
20+
{
21+
try
22+
{
23+
return Double.Parse(value as string);
24+
}
25+
catch (FormatException e)
26+
{
27+
return null;
28+
}
29+
}
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Windows.UI.Xaml.Data;
7+
8+
namespace Files.Converters
9+
{
10+
class StringArrayToString : IValueConverter
11+
{
12+
public object Convert(object value, Type targetType, object parameter, string language)
13+
{
14+
var array = value as string[];
15+
16+
if (array == null || !(array is string[]))
17+
return "";
18+
19+
var str = "";
20+
foreach (var i in array as string[])
21+
str += string.Format("{0}; ", i);
22+
23+
return str;
24+
}
25+
26+
public object ConvertBack(object value, Type targetType, object parameter, string language)
27+
{
28+
return (value as string).Split("; ");
29+
}
30+
}
31+
}

Files/Converters/UInt32ToString.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Windows.UI.Xaml.Data;
7+
8+
namespace Files.Converters
9+
{
10+
class UInt32ToString : IValueConverter
11+
{
12+
public object Convert(object value, Type targetType, object parameter, string language)
13+
{
14+
if(value != null)
15+
return value.ToString();
16+
return "";
17+
}
18+
19+
public object ConvertBack(object value, Type targetType, object parameter, string language)
20+
{
21+
try
22+
{
23+
return UInt32.Parse(value as string);
24+
}
25+
catch (FormatException e)
26+
{
27+
return null;
28+
}
29+
}
30+
}
31+
}

Files/Files.csproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,12 @@
158158
<Compile Include="Commands\Paste.cs" />
159159
<Compile Include="Controllers\IJson.cs" />
160160
<Compile Include="Controllers\SidebarPinnedController.cs" />
161+
<Compile Include="Converters\DateTimeOffsetToString.cs" />
162+
<Compile Include="Converters\DoubleToString.cs" />
161163
<Compile Include="Converters\MultiBooleanConverter.cs" />
162164
<Compile Include="Converters\StorageDeleteOptionToBooleanConverter.cs" />
165+
<Compile Include="Converters\StringArrayToString.cs" />
166+
<Compile Include="Converters\UInt32ToString.cs" />
163167
<Compile Include="DataModels\DefaultLanguageModel.cs" />
164168
<Compile Include="DataModels\SidebarPinnedModel.cs" />
165169
<Compile Include="Controllers\TerminalController.cs" />
@@ -173,6 +177,7 @@
173177
<DependentUpon>RestartDialog.xaml</DependentUpon>
174178
</Compile>
175179
<Compile Include="Filesystem\CloudDriveSyncStatus.cs" />
180+
<Compile Include="Filesystem\PropertiesData.cs" />
176181
<Compile Include="Filesystem\StorageFileHelpers\StorageFileExtensions.cs" />
177182
<Compile Include="Filesystem\StorageFileHelpers\IStorageItemWithPath.cs" />
178183
<Compile Include="Filesystem\StorageFileHelpers\StorageFileWithPath.cs" />
@@ -234,6 +239,9 @@
234239
<Compile Include="Enums\WallpaperType.cs" />
235240
<Compile Include="Filesystem\DriveItem.cs" />
236241
<Compile Include="Filesystem\Drives.cs" />
242+
<Compile Include="UserControls\PropertyListItem.xaml.cs">
243+
<DependentUpon>PropertyListItem.xaml</DependentUpon>
244+
</Compile>
237245
<Compile Include="UserControls\SidebarControl.xaml.cs">
238246
<DependentUpon>SidebarControl.xaml</DependentUpon>
239247
</Compile>
@@ -279,6 +287,9 @@
279287
<Compile Include="Views\LayoutModes\GridViewBrowser.xaml.cs">
280288
<DependentUpon>GridViewBrowser.xaml</DependentUpon>
281289
</Compile>
290+
<Compile Include="Views\Pages\PropertiesDetails.xaml.cs">
291+
<DependentUpon>PropertiesDetails.xaml</DependentUpon>
292+
</Compile>
282293
<Compile Include="Views\MainPage.xaml.cs">
283294
<DependentUpon>MainPage.xaml</DependentUpon>
284295
</Compile>
@@ -356,6 +367,7 @@
356367
<None Include="Assets\terminal\terminal.json">
357368
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
358369
</None>
370+
<Content Include="Resources\BingMapsKey.txt" />
359371
<None Include="NLog.config">
360372
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
361373
</None>
@@ -502,6 +514,10 @@
502514
<SubType>Designer</SubType>
503515
<Generator>MSBuild:Compile</Generator>
504516
</Page>
517+
<Page Include="UserControls\PropertyListItem.xaml">
518+
<SubType>Designer</SubType>
519+
<Generator>MSBuild:Compile</Generator>
520+
</Page>
505521
<Page Include="UserControls\SidebarControl.xaml">
506522
<SubType>Designer</SubType>
507523
<Generator>MSBuild:Compile</Generator>
@@ -538,6 +554,10 @@
538554
<SubType>Designer</SubType>
539555
<Generator>MSBuild:Compile</Generator>
540556
</Page>
557+
<Page Include="Views\Pages\PropertiesDetails.xaml">
558+
<Generator>MSBuild:Compile</Generator>
559+
<SubType>Designer</SubType>
560+
</Page>
541561
<Page Include="Views\MainPage.xaml">
542562
<SubType>Designer</SubType>
543563
<Generator>MSBuild:Compile</Generator>

Files/Filesystem/ListedItem.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ public DateTimeOffset ItemDateAccessedReal
150150

151151
private DateTimeOffset _itemDateAccessedReal;
152152

153+
public bool IsImage()
154+
{
155+
if (FileExtension != null)
156+
{
157+
string lower = FileExtension.ToLower();
158+
return lower.Contains("png") || lower.Contains("jpg") || lower.Contains("gif") || lower.Contains("jpeg");
159+
}
160+
return false;
161+
}
162+
153163
public ListedItem(string folderRelativeId)
154164
{
155165
FolderRelativeId = folderRelativeId;
@@ -225,4 +235,4 @@ public ShortcutItem(string folderRelativeId) : base(folderRelativeId)
225235
public bool RunAsAdmin { get; set; }
226236
public bool IsUrl { get; set; }
227237
}
228-
}
238+
}

Files/Filesystem/PropertiesData.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Windows.UI.Xaml;
7+
8+
namespace Files.Filesystem
9+
{
10+
public class PropertiesData
11+
{
12+
public string Text { get; set; } = "Test:";
13+
public string Property { get; set; }
14+
public object Data { get; set; }
15+
public Visibility Visibility { get; set; } = Visibility.Visible;
16+
17+
public PropertiesData(string property, string text)
18+
{
19+
Property = property;
20+
Text = text;
21+
}
22+
23+
public PropertiesData(string property, object data)
24+
{
25+
Property = property;
26+
Data = data;
27+
}
28+
}
29+
}

Files/ResourceDictionaries/PropertiesStyles.xaml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
2+
xmlns:usercontrols="using:Files.UserControls" xmlns:converters="using:Files.Converters">
23

34
<Style x:Key="PropertiesTab" TargetType="StackPanel">
45
<Setter Property="Padding" Value="14,0,14,14" />
@@ -12,6 +13,7 @@
1213
<Style x:Key="PropertyName" TargetType="TextBlock">
1314
<Setter Property="Margin" Value="{StaticResource PropertyNameMargin}" />
1415
<Setter Property="FontWeight" Value="SemiBold" />
16+
<Setter Property="Margin" Value="0,7"/>
1517
</Style>
1618

1719
<Style x:Key="PropertyValueGrid" TargetType="Grid">
@@ -28,6 +30,7 @@
2830
<Setter Property="Margin" Value="{StaticResource PropertyValueMargin}" />
2931
<Setter Property="VerticalAlignment" Value="{StaticResource PropertyValueVerticalAlignment}" />
3032
<Setter Property="IsTextSelectionEnabled" Value="True" />
33+
<Setter Property="Margin" Value="20,0,0,0"/>
3134
</Style>
3235

3336
<Style
@@ -38,5 +41,40 @@
3841
<Setter Property="VerticalAlignment" Value="{StaticResource PropertyValueVerticalAlignment}" />
3942
<Setter Property="HorizontalAlignment" Value="Stretch" />
4043
<Setter Property="BorderThickness" Value="1" />
44+
<Setter Property="Margin" Value="20,0,0,0"/>
45+
<Setter Property="BorderBrush">
46+
<Setter.Value>
47+
<SolidColorBrush Color="Transparent"/>
48+
</Setter.Value>
49+
</Setter>
50+
51+
<Setter Property="Background">
52+
<Setter.Value>
53+
<SolidColorBrush Color="Transparent"/>
54+
</Setter.Value>
55+
</Setter>
56+
</Style>
57+
58+
<converters:StringArrayToString x:Key="StringArrayToString"/>
59+
<converters:UInt32ToString x:Key="UInt32ToString"/>
60+
<converters:DoubleToString x:Key="DoubleToString"/>
61+
<converters:DateTimeOffsetToString x:Key="DateTimeOffsetToString"/>
62+
63+
64+
65+
<Style TargetType="MenuFlyoutSeparator" x:Key="Separator">
66+
<Setter Property="Grid.Column" Value="0"/>
67+
<Setter Property="Grid.ColumnSpan" Value="2"/>
68+
<Setter Property="Margin" Value="-12, 0"/>
69+
<Setter Property="HorizontalAlignment" Value="Stretch"/>
70+
</Style>
71+
72+
<Style TargetType="TextBlock" x:Key="SeparatorText">
73+
<Setter Property="Grid.Column" Value="0"/>
74+
<Setter Property="FontSize" Value="22"/>
75+
</Style>
76+
77+
<Style TargetType="usercontrols:PropertyListItem">
78+
<Setter Property="ColumnWidth" Value="110"/>
4179
</Style>
4280
</ResourceDictionary>

Files/Resources/BingMapsKey.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<UserControl
2+
x:Class="Files.UserControls.PropertyListItem"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:Files.UserControls"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
mc:Ignorable="d"
9+
d:DesignHeight="300"
10+
d:DesignWidth="400">
11+
12+
<UserControl.Resources>
13+
<ResourceDictionary>
14+
<ResourceDictionary.MergedDictionaries>
15+
<ResourceDictionary Source="ms-appx:///ResourceDictionaries/PropertiesStyles.xaml" />
16+
</ResourceDictionary.MergedDictionaries>
17+
</ResourceDictionary>
18+
19+
</UserControl.Resources>
20+
<Grid>
21+
<Grid.RowDefinitions>
22+
<RowDefinition Height="Auto"/>
23+
</Grid.RowDefinitions>
24+
<Grid.ColumnDefinitions>
25+
<ColumnDefinition Width="{x:Bind ColumnWidth}" />
26+
<ColumnDefinition Width="*" />
27+
</Grid.ColumnDefinitions>
28+
29+
<TextBlock Grid.Row ="0" Text="{x:Bind Text}" Style="{StaticResource PropertyName}"/>
30+
<TextBox Grid.Row ="0" Text="{x:Bind ValueText, Mode=TwoWay}" IsReadOnly="{x:Bind IsReadOnly, Mode=OneWay}" TextChanged="TextBox_TextChanged" Style="{StaticResource PropertyValueTextBox}" Grid.Column="1"/>
31+
32+
</Grid>
33+
</UserControl>

0 commit comments

Comments
 (0)