Skip to content

Commit 74fcba7

Browse files
authored
Improve codebase quality in properties (#1854)
1 parent b743fc2 commit 74fcba7

File tree

9 files changed

+275
-298
lines changed

9 files changed

+275
-298
lines changed

Files/Files.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@
188188
<Compile Include="Program.cs" />
189189
<Compile Include="ResourceController.cs" />
190190
<Compile Include="INavigationToolbar.cs" />
191+
<Compile Include="UserControls\FileIcon.xaml.cs">
192+
<DependentUpon>FileIcon.xaml</DependentUpon>
193+
</Compile>
191194
<Compile Include="UserControls\MenuFlyoutItemWithImage.xaml.cs">
192195
<DependentUpon>MenuFlyoutItemWithImage.xaml</DependentUpon>
193196
</Compile>
@@ -257,6 +260,7 @@
257260
<Compile Include="View Models\Properties\DriveProperties.cs" />
258261
<Compile Include="View Models\Properties\FileProperties.cs" />
259262
<Compile Include="View Models\Properties\FolderProperties.cs" />
263+
<Compile Include="View Models\Properties\PropertiesTab.cs" />
260264
<Compile Include="Views\LayoutModes\GenericFileBrowser.xaml.cs">
261265
<DependentUpon>GenericFileBrowser.xaml</DependentUpon>
262266
</Compile>
@@ -437,10 +441,18 @@
437441
<Generator>MSBuild:Compile</Generator>
438442
<SubType>Designer</SubType>
439443
</Page>
444+
<Page Include="ResourceDictionaries\PropertiesStyles.xaml">
445+
<SubType>Designer</SubType>
446+
<Generator>MSBuild:Compile</Generator>
447+
</Page>
440448
<Page Include="ResourceDictionaries\TabView_themeresources.xaml">
441449
<Generator>MSBuild:Compile</Generator>
442450
<SubType>Designer</SubType>
443451
</Page>
452+
<Page Include="UserControls\FileIcon.xaml">
453+
<SubType>Designer</SubType>
454+
<Generator>MSBuild:Compile</Generator>
455+
</Page>
444456
<Page Include="UserControls\MenuFlyoutItemWithImage.xaml">
445457
<SubType>Designer</SubType>
446458
<Generator>MSBuild:Compile</Generator>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<ResourceDictionary
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
4+
5+
<Style TargetType="StackPanel" x:Key="PropertiesTab">
6+
<Setter Property="Padding" Value="14,0,14,14"/>
7+
<Setter Property="VerticalAlignment" Value="Top"/>
8+
</Style>
9+
10+
<Thickness x:Key="PropertyNameMargin">0,7</Thickness>
11+
<Thickness x:Key="PropertyValueMargin">20,0,0,0</Thickness>
12+
<VerticalAlignment x:Key="PropertyValueVerticalAlignment">Center</VerticalAlignment>
13+
14+
<Style TargetType="TextBlock" x:Key="PropertyName">
15+
<Setter Property="Margin" Value="{StaticResource PropertyNameMargin}"/>
16+
<Setter Property="FontWeight" Value="SemiBold"/>
17+
</Style>
18+
19+
<Style TargetType="Grid" x:Key="PropertyValueGrid">
20+
<Setter Property="Margin" Value="{StaticResource PropertyValueMargin}"/>
21+
<Setter Property="VerticalAlignment" Value="{StaticResource PropertyValueVerticalAlignment}"/>
22+
</Style>
23+
24+
<Style TargetType="Grid" x:Key="PropertyValueStackPanel">
25+
<Setter Property="Margin" Value="{StaticResource PropertyValueMargin}"/>
26+
<Setter Property="VerticalAlignment" Value="{StaticResource PropertyValueVerticalAlignment}"/>
27+
</Style>
28+
29+
<Style TargetType="TextBlock" x:Key="PropertyValueTextBlock">
30+
<Setter Property="Margin" Value="{StaticResource PropertyValueMargin}"/>
31+
<Setter Property="VerticalAlignment" Value="{StaticResource PropertyValueVerticalAlignment}"/>
32+
<Setter Property="IsTextSelectionEnabled" Value="True"/>
33+
</Style>
34+
35+
<Style TargetType="TextBox" BasedOn="{StaticResource DefaultTextBoxStyle}" x:Key="PropertyValueTextBox">
36+
<Setter Property="Margin" Value="{StaticResource PropertyValueMargin}"/>
37+
<Setter Property="VerticalAlignment" Value="{StaticResource PropertyValueVerticalAlignment}"/>
38+
<Setter Property="HorizontalAlignment" Value="Stretch"/>
39+
<Setter Property="BorderThickness" Value="1"/>
40+
</Style>
41+
</ResourceDictionary>

Files/UserControls/FileIcon.xaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<UserControl
2+
x:Class="Files.UserControls.FileIcon"
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+
<StackPanel>
13+
<Image
14+
x:Name="FolderGlyphIcon"
15+
Width="{x:Bind ItemSize}"
16+
Height="{x:Bind ItemSize}"
17+
HorizontalAlignment="Stretch"
18+
VerticalAlignment="Stretch"
19+
x:Load="{x:Bind ViewModel.LoadFolderGlyph}"
20+
Stretch="Uniform">
21+
<Image.Source>
22+
<SvgImageSource
23+
RasterizePixelHeight="128"
24+
RasterizePixelWidth="128"
25+
UriSource="{x:Bind ViewModel.FolderIconSource}" />
26+
</Image.Source>
27+
</Image>
28+
<FontIcon
29+
x:Name="EmptyImageIcon"
30+
HorizontalAlignment="Left"
31+
VerticalAlignment="Stretch"
32+
x:Load="{x:Bind ViewModel.LoadUnknownTypeGlyph, Mode=OneWay}"
33+
FontFamily="{StaticResource FluentUIGlyphs}"
34+
FontSize="{x:Bind ItemSize}"
35+
Glyph="&#xea00;" />
36+
<FontIcon
37+
x:Name="CombinedItemsIcon"
38+
HorizontalAlignment="Left"
39+
VerticalAlignment="Stretch"
40+
x:Load="{x:Bind ViewModel.LoadCombinedItemsGlyph, Mode=OneWay}"
41+
FontFamily="{StaticResource CustomGlyph}"
42+
FontSize="{x:Bind LargerItemSize}"
43+
Glyph="&#xF109;" />
44+
<FontIcon
45+
x:Name="DriveItemIcon"
46+
HorizontalAlignment="Center"
47+
VerticalAlignment="Stretch"
48+
x:Load="{x:Bind ViewModel.LoadDriveItemGlyph, Mode=OneWay}"
49+
FontFamily="{StaticResource FluentUIGlyphs}"
50+
FontSize="{x:Bind LargerItemSize}"
51+
Glyph="{x:Bind ViewModel.DriveItemGlyphSource, Mode=OneWay}" />
52+
<FontIcon
53+
x:Name="WebShortcutGlyph"
54+
HorizontalAlignment="Left"
55+
VerticalAlignment="Stretch"
56+
x:Load="{x:Bind ViewModel.LoadLinkIcon, Mode=OneWay}"
57+
FontFamily="{StaticResource FluentUIGlyphs}"
58+
FontSize="{x:Bind ItemSize}"
59+
Glyph="&#xEAAB;" />
60+
<Image
61+
x:Name="ItemIcon"
62+
HorizontalAlignment="Stretch"
63+
VerticalAlignment="Stretch"
64+
x:Load="{x:Bind ViewModel.LoadFileIcon, Mode=OneWay}"
65+
Source="{x:Bind ViewModel.FileIconSource, Mode=OneWay}" />
66+
</StackPanel>
67+
</UserControl>

Files/UserControls/FileIcon.xaml.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Files.View_Models;
2+
using Windows.UI.Xaml.Controls;
3+
4+
namespace Files.UserControls
5+
{
6+
public sealed partial class FileIcon : UserControl
7+
{
8+
public SelectedItemsPropertiesViewModel ViewModel { get; set; }
9+
10+
private double itemSize;
11+
public double ItemSize
12+
{
13+
get => itemSize;
14+
set
15+
{
16+
itemSize = value;
17+
LargerItemSize = itemSize + 2.0;
18+
}
19+
}
20+
private double LargerItemSize { get; set; }
21+
22+
public FileIcon()
23+
{
24+
this.InitializeComponent();
25+
}
26+
}
27+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using Files.Filesystem;
2+
using System.Collections.Generic;
3+
using Windows.Storage;
4+
using Windows.UI.Xaml;
5+
using Windows.UI.Xaml.Controls;
6+
using Windows.UI.Xaml.Navigation;
7+
8+
namespace Files.View_Models.Properties
9+
{
10+
public abstract class PropertiesTab : Page
11+
{
12+
public BaseProperties BaseProperties { get; set; }
13+
14+
public SelectedItemsPropertiesViewModel ViewModel { get; set; }
15+
16+
protected Microsoft.UI.Xaml.Controls.ProgressBar ItemMD5HashProgress = null;
17+
18+
protected void Properties_Loaded(object sender, RoutedEventArgs e)
19+
{
20+
if (BaseProperties != null)
21+
{
22+
BaseProperties.GetSpecialProperties();
23+
}
24+
}
25+
26+
protected override void OnNavigatedTo(NavigationEventArgs e)
27+
{
28+
ViewModel = new SelectedItemsPropertiesViewModel();
29+
var np = e.Parameter as Files.Properties.PropertyNavParam;
30+
31+
if (np.navParameter is ListedItem)
32+
{
33+
var listedItem = np.navParameter as ListedItem;
34+
if (listedItem.PrimaryItemAttribute == StorageItemTypes.File)
35+
{
36+
BaseProperties = new FileProperties(ViewModel, np.tokenSource, Dispatcher, ItemMD5HashProgress, listedItem);
37+
}
38+
else if (listedItem.PrimaryItemAttribute == StorageItemTypes.Folder)
39+
{
40+
BaseProperties = new FolderProperties(ViewModel, np.tokenSource, Dispatcher, listedItem);
41+
}
42+
}
43+
else if (np.navParameter is List<ListedItem>)
44+
{
45+
BaseProperties = new CombinedProperties(ViewModel, np.tokenSource, Dispatcher, np.navParameter as List<ListedItem>);
46+
}
47+
else if (np.navParameter is DriveItem)
48+
{
49+
BaseProperties = new DriveProperties(ViewModel, np.navParameter as DriveItem);
50+
}
51+
52+
base.OnNavigatedTo(e);
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)