Skip to content

Commit

Permalink
Details view improvements (#5061)
Browse files Browse the repository at this point in the history
  • Loading branch information
gave92 authored May 30, 2021
1 parent 4eb3979 commit 78b8f3c
Show file tree
Hide file tree
Showing 12 changed files with 386 additions and 732 deletions.
10 changes: 6 additions & 4 deletions Files/Files.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@
<Compile Include="UserControls\ArrangementOptions.xaml.cs">
<DependentUpon>ArrangementOptions.xaml</DependentUpon>
</Compile>
<Compile Include="UserControls\DataGridHeader.xaml.cs">
<DependentUpon>DataGridHeader.xaml</DependentUpon>
</Compile>
<Compile Include="UserControls\FilePreviews\CodePreview.xaml.cs">
<DependentUpon>CodePreview.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -448,7 +451,6 @@
<Compile Include="UserControls\MultitaskingControl\TabItem\ITabItem.cs" />
<Compile Include="UserControls\MultitaskingControl\TabItem\ITabItemControl.cs" />
<Compile Include="UserControls\Selection\RectangleSelection.cs" />
<Compile Include="UserControls\Selection\RectangleSelection_DataGrid.cs" />
<Compile Include="UserControls\Selection\RectangleSelection_ListViewBase.cs" />
<Compile Include="UserControls\SidebarControl.xaml.cs">
<DependentUpon>SidebarControl.xaml</DependentUpon>
Expand Down Expand Up @@ -830,15 +832,15 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControls\FilePreviews\CodePreview.xaml">
<Page Include="UserControls\DataGridHeader.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControls\RestartControl.xaml">
<Page Include="UserControls\FilePreviews\CodePreview.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ResourceDictionaries\CustomDataGridStyle.xaml">
<Page Include="UserControls\RestartControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down
325 changes: 0 additions & 325 deletions Files/ResourceDictionaries/CustomDataGridStyle.xaml

This file was deleted.

9 changes: 0 additions & 9 deletions Files/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -2118,15 +2118,6 @@
<data name="ConflictingItemsDialogOptionSkip.Text" xml:space="preserve">
<value>Skip</value>
</data>
<data name="FileBrowserSortOption_Name.Text" xml:space="preserve">
<value>Name</value>
</data>
<data name="FileBrowserSortOption_DateModified.Text" xml:space="preserve">
<value>Date modified</value>
</data>
<data name="FileBrowserSortOption_FileType.Text" xml:space="preserve">
<value>Type</value>
</data>
<data name="FileOperationsDialogDetailsExpander.Header" xml:space="preserve">
<value>Details</value>
</data>
Expand Down
90 changes: 90 additions & 0 deletions Files/UserControls/DataGridHeader.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<UserControl
x:Class="Files.UserControls.DataGridHeader"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ciao="using:Microsoft.Toolkit.Uwp.UI"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Files.UserControls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="300"
d:DesignWidth="400"
mc:Ignorable="d">
<UserControl.Resources>
<Style x:Name="HeaderButtonStyle" TargetType="Button">
<Setter Property="CornerRadius" Value="0" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Height" Value="34" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Opacity="0" />
</Setter.Value>
</Setter>
</Style>

<x:String x:Key="SortIconAscending">&#xE74A;</x:String>
</UserControl.Resources>

<Grid>
<Button
Command="{x:Bind Command}"
CommandParameter="{x:Bind CommandParameter}"
IsEnabled="{x:Bind CanBeSorted, Mode=OneWay}"
Style="{StaticResource HeaderButtonStyle}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Style="{ThemeResource NavigationViewItemHeaderTextStyle}" Text="{x:Bind Header, Mode=OneWay}" />
<FontIcon
x:Name="SortIcon"
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
FontSize="12"
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
Glyph="{StaticResource SortIconAscending}"
RenderTransformOrigin="0.5, 0.5"
Visibility="Collapsed">
<FontIcon.RenderTransform>
<RotateTransform />
</FontIcon.RenderTransform>
</FontIcon>
</Grid>
</Button>

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SortStates">
<VisualState x:Name="Unsorted" />
<VisualState x:Name="SortAscending">
<VisualState.Setters>
<Setter Target="SortIcon.Visibility" Value="Visible" />
</VisualState.Setters>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="SortIcon"
Storyboard.TargetProperty="(FontIcon.RenderTransform).(RotateTransform.Angle)"
To="0"
Duration="0:0:0.2" />
</Storyboard>
</VisualState>
<VisualState x:Name="SortDescending">
<VisualState.Setters>
<Setter Target="SortIcon.Visibility" Value="Visible" />
</VisualState.Setters>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="SortIcon"
Storyboard.TargetProperty="(FontIcon.RenderTransform).(RotateTransform.Angle)"
To="180"
Duration="0:0:0.2" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</UserControl>
97 changes: 97 additions & 0 deletions Files/UserControls/DataGridHeader.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using Microsoft.Toolkit.Uwp.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Windows.Input;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// Il modello di elemento Controllo utente è documentato all'indirizzo https://go.microsoft.com/fwlink/?LinkId=234236

namespace Files.UserControls
{
public sealed partial class DataGridHeader : UserControl, INotifyPropertyChanged
{
public ICommand Command { get; set; }
public object CommandParameter { get; set; }

private string header;

public string Header
{
get { return header; }
set
{
if (value != header)
{
header = value;
NotifyPropertyChanged(nameof(Header));
}
}
}

private bool canBeSorted = true;

public bool CanBeSorted
{
get { return canBeSorted; }
set
{
if (value != canBeSorted)
{
canBeSorted = value;
NotifyPropertyChanged(nameof(CanBeSorted));
}
}
}

private SortDirection? columnSortOption;

public SortDirection? ColumnSortOption
{
get { return columnSortOption; }
set
{
if (value != columnSortOption)
{
switch (value)
{
case SortDirection.Ascending:
VisualStateManager.GoToState(this, "SortAscending", true);
break;
case SortDirection.Descending:
VisualStateManager.GoToState(this, "SortDescending", true);
break;
default:
VisualStateManager.GoToState(this, "Unsorted", true);
break;
}
columnSortOption = value;
}
}
}

public DataGridHeader()
{
this.InitializeComponent();
}

public event PropertyChangedEventHandler PropertyChanged;

private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
4 changes: 0 additions & 4 deletions Files/UserControls/Selection/RectangleSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public static RectangleSelection Create(UIElement uiElement, Rectangle selection
{
return new RectangleSelection_ListViewBase(uiElement as ListViewBase, selectionRectangle, selectionChanged);
}
else if (uiElement is DataGrid)
{
return new RectangleSelection_DataGrid(uiElement as DataGrid, selectionRectangle, selectionChanged);
}
else
{
throw new ArgumentException("uiElement must derive from ListViewBase or DataGrid");
Expand Down
Loading

0 comments on commit 78b8f3c

Please sign in to comment.