Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/files-community/Files into …
Browse files Browse the repository at this point in the history
…main
  • Loading branch information
yaira2 committed Mar 31, 2021
2 parents 2783631 + c489c48 commit e94244e
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 187 deletions.
2 changes: 1 addition & 1 deletion Files/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1953,4 +1953,4 @@
<data name="BaseLayoutContextFlyoutColumn.Text" xml:space="preserve">
<value>Column View</value>
</data>
</root>
</root>
13 changes: 6 additions & 7 deletions Files/Views/ColumnShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,7 @@ private async void ItemDisplayFrame_Navigated(object sender, NavigationEventArgs
{
ContentPage = await GetContentOrNullAsync();
NavigationToolbar.ClearSearchBoxQueryText(true);
if (ItemDisplayFrame.CurrentSourcePageType == typeof(GenericFileBrowser)
|| ItemDisplayFrame.CurrentSourcePageType == typeof(GridViewBrowser))
if (ItemDisplayFrame.CurrentSourcePageType == typeof(ColumnViewBase))
{
// Reset DataGrid Rows that may be in "cut" command mode
ContentPage.ResetItemOpacity();
Expand Down Expand Up @@ -930,7 +929,7 @@ private async void KeyboardAccelerator_Invoked(KeyboardAccelerator sender, Keybo
var alt = args.KeyboardAccelerator.Modifiers.HasFlag(VirtualKeyModifiers.Menu);
var shift = args.KeyboardAccelerator.Modifiers.HasFlag(VirtualKeyModifiers.Shift);
var tabInstance = CurrentPageType == typeof(GenericFileBrowser)
|| CurrentPageType == typeof(GridViewBrowser);
|| CurrentPageType == typeof(GridViewBrowser) || CurrentPageType == typeof(ColumnViewBrowser) || CurrentPageType == typeof(ColumnViewBase);

switch (c: ctrl, s: shift, a: alt, t: tabInstance, k: args.KeyboardAccelerator.Key)
{
Expand Down Expand Up @@ -1053,7 +1052,8 @@ await FilesystemHelpers.DeleteItemsAsync(
switch (args.KeyboardAccelerator.Key)
{
case VirtualKey.F2: //F2, rename
if (CurrentPageType == typeof(GenericFileBrowser) || CurrentPageType == typeof(GridViewBrowser))
if (CurrentPageType == typeof(GenericFileBrowser) || CurrentPageType == typeof(GridViewBrowser) || CurrentPageType == typeof(ColumnViewBrowser) || CurrentPageType == typeof(ColumnViewBase))

{
if (ContentPage.IsItemSelected)
{
Expand Down Expand Up @@ -1340,7 +1340,7 @@ public void NavigateToPath(string navigationPath, Type sourcePageType, Navigatio
if (navArgs != null && navArgs.AssociatedTabInstance != null)
{
ItemDisplayFrame.Navigate(
sourcePageType == null ? typeof(ColumnViewBase) : sourcePageType,
sourcePageType = typeof(ColumnViewBase),
navArgs,
new SuppressNavigationTransitionInfo());
}
Expand All @@ -1355,8 +1355,7 @@ public void NavigateToPath(string navigationPath, Type sourcePageType, Navigatio
return;
}

ItemDisplayFrame.Navigate(
sourcePageType == null ? typeof(ColumnViewBase) : sourcePageType,
ItemDisplayFrame.Navigate(sourcePageType = typeof(ColumnViewBase),
new NavigationArguments()
{
NavPathParam = navigationPath,
Expand Down
142 changes: 1 addition & 141 deletions Files/Views/LayoutModes/ColumnViewBase.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,7 @@
x:Name="PageRoot"
mc:Ignorable="d">
<local:BaseLayout.Resources>
<Style x:Key="ListViewItemStandardContextFlyout" TargetType="ListViewItem">
<Setter Property="ContextFlyout" Value="{StaticResource BaseLayoutItemContextFlyout}" />
<Setter Property="Padding" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<Style x:Key="ListViewItemRecycleBinContextFlyout" TargetType="ListViewItem">
<Setter Property="ContextFlyout" Value="{StaticResource BaseLayoutRecycleBinItemContextFlyout}" />
<Setter Property="Padding" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
<converters:BoolToVisibilityConverter
x:Key="NegatedBoolToVisibilityConverter"
FalseValue="Visible"
Expand All @@ -43,134 +31,6 @@
<Setter Property="TitleBarVisibility" Value="Collapsed"></Setter>
<Setter Property="BorderThickness" Value="0,0,1,0"></Setter>
</Style>
<!--<DataTemplate x:Name="ListViewBrowserTemplate" x:DataType="local2:ListedItem">
<Grid Margin="10,0"
Height="32"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="Transparent"
IsRightTapEnabled="True"
RightTapped="StackPanel_RightTapped"
ToolTipService.ToolTip="{x:Bind ItemName, Mode=OneWay}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="24" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
Width="24"
Height="24"
Opacity="{x:Bind Opacity, Mode=OneWay}"
Tag="ItemImage">
<Image
x:Name="Picture"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
x:Load="{x:Bind LoadFileIcon, Mode=OneWay}"
x:Phase="1"
Source="{x:Bind FileImage, Mode=OneWay}"
Stretch="Uniform" />
<Image
x:Name="FolderGlyph"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
x:Load="{x:Bind LoadFolderGlyph, Mode=OneWay}"
x:Phase="1"
Stretch="Uniform">
<Image.Source>
<SvgImageSource
RasterizePixelHeight="256"
RasterizePixelWidth="256"
UriSource="{x:Bind FolderIconSourceLarge}" />
</Image.Source>
</Image>
<Viewbox
x:Name="TypeUnknownGlyph"
MaxWidth="24"
MaxHeight="24"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
x:Load="{x:Bind LoadUnknownTypeGlyph, Mode=OneWay}"
x:Phase="1">
<FontIcon Glyph="&#xE7C3;" />
</Viewbox>
<Image
x:Name="IconOverlay"
Width="16"
Height="16"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
x:Load="True"
x:Phase="1"
Source="{x:Bind IconOverlay, Mode=OneWay}"
Stretch="Uniform" />
<Viewbox
x:Name="WebShortcutGlyph"
MaxWidth="24"
MaxHeight="24"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
x:Load="{x:Bind LoadWebShortcutGlyph, Mode=OneWay}"
x:Phase="1">
<FontIcon FontSize="20" Glyph="&#xE71B;" />
</Viewbox>
<Border
x:Name="ShortcutGlyphElement"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
x:Load="{x:Bind IsShortcutItem}"
x:Phase="1"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
BorderBrush="{ThemeResource ApplicationForegroundThemeBrush}"
BorderThickness="1">
<FontIcon
FontFamily="{StaticResource CustomGlyph}"
FontSize="14"
Glyph="&#xF10A;" />
</Border>
</Grid>
<Grid
Grid.Column="1"
Margin="5,0,5,0"
HorizontalAlignment="Left">
<TextBlock
x:Name="ItemName"
Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Text="{x:Bind ItemName, Mode=OneWay}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap" />
</Grid>
<Popup
x:Name="EditPopup"
Grid.Column="1"
x:Load="False">
<TextBox
x:Name="ListViewTextBoxItemName"
Margin="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Text="{x:Bind ItemName, Mode=OneWay}"
TextAlignment="Center"
TextChanged="ListViewTextBoxItemName_TextChanged"
TextWrapping="Wrap" />
</Popup>
<Grid Grid.Column="2">
<FontIcon
x:Name="CloudDriveSyncStatusGlyph"
Margin="0,0,0,0"
VerticalAlignment="Center" HorizontalAlignment="Center"
x:Load="{x:Bind ((local3:CloudDriveSyncStatusUI)SyncStatusUI).LoadSyncStatus, Mode=OneWay}"
x:Phase="2"
FontSize="18"
Foreground="{x:Bind ((local3:CloudDriveSyncStatusUI)SyncStatusUI).Foreground, Mode=OneWay}"
Glyph="{x:Bind ((local3:CloudDriveSyncStatusUI)SyncStatusUI).Glyph, Mode=OneWay}" />
</Grid>
</Grid>
</DataTemplate>-->
</local:BaseLayout.Resources>
<Grid
x:Name="RootGrid"
Expand Down
30 changes: 14 additions & 16 deletions Files/Views/LayoutModes/ColumnViewBase.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ public sealed partial class ColumnViewBase : BaseLayout
private ListedItem renamingItem;
private string oldItemName;
private TextBlock textBlock;
private ListViewItem navigatedfolder;

public ColumnViewBase() : base()
{
this.InitializeComponent();
//this.DataContext = this;
//base.BaseLayoutContextFlyout = BaseLayoutContextFlyout;
//base.BaseLayoutItemContextFlyout = BaseLayoutItemContextFlyout;
var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged);
tapDebounceTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
}
Expand All @@ -65,9 +63,8 @@ private void ListViewTextBoxItemName_TextChanged(object sender, TextChangedEvent
}
public static event EventHandler ItemInvoked;

protected override async void OnNavigatedTo(NavigationEventArgs eventArgs)
{
base.OnNavigatedTo(eventArgs);
protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
{ base.OnNavigatedTo(eventArgs);
var param = (eventArgs.Parameter as NavigationArguments);
//NavParam = param.NavPathParam;
//var viewmodel = new ItemViewModel(FolderSettings);
Expand All @@ -79,6 +76,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs eventArgs)
{
FileList.ItemsSource = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders;
ParentShellPageInstance.IsCurrentInstance = true;
ColumnViewBrowser.columnparent.UpdatePathUIToWorkingDirectory(param.NavPathParam);
}
var parameters = (NavigationArguments)eventArgs.Parameter;
if (parameters.IsLayoutSwitch)
Expand Down Expand Up @@ -513,6 +511,16 @@ private void FileListListItem_PointerPressed(object sender, PointerRoutedEventAr
}
}
}
private void Grid_Loaded(object sender, RoutedEventArgs e)
{
// This is the best way I could find to set the context flyout, as doing it in the styles isn't possible
// because you can't use bindings in the setters
DependencyObject item = VisualTreeHelper.GetParent(sender as Grid);
while (!(item is ListViewItem))
item = VisualTreeHelper.GetParent(item);
var itemContainer = item as ListViewItem;
itemContainer.ContextFlyout = ItemContextMenuFlyout;
}
private async void FileList_ChoosingItemContainer(ListViewBase sender, ChoosingItemContainerEventArgs args)
{
if (args.ItemContainer == null)
Expand All @@ -532,15 +540,5 @@ private async void FileList_ChoosingItemContainer(ListViewBase sender, ChoosingI
await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemProperties(item, 24);
}
}
private void Grid_Loaded(object sender, RoutedEventArgs e)
{
// This is the best way I could find to set the context flyout, as doing it in the styles isn't possible
// because you can't use bindings in the setters
DependencyObject item = VisualTreeHelper.GetParent(sender as Grid);
while (!(item is ListViewItem))
item = VisualTreeHelper.GetParent(item);
var itemContainer = item as ListViewItem;
itemContainer.ContextFlyout = ItemContextMenuFlyout;
}
}
}
18 changes: 3 additions & 15 deletions Files/Views/LayoutModes/ColumnViewBrowser.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<local:BaseLayout
<local:BaseLayout
x:Class="Files.Views.LayoutModes.ColumnViewBrowser"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand All @@ -21,18 +21,6 @@
x:Name="PageRoot"
mc:Ignorable="d">
<local:BaseLayout.Resources>
<Style x:Key="ListViewItemStandardContextFlyout" TargetType="ListViewItem">
<Setter Property="ContextFlyout" Value="{StaticResource BaseLayoutItemContextFlyout}" />
<Setter Property="Padding" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<Style x:Key="ListViewItemRecycleBinContextFlyout" TargetType="ListViewItem">
<Setter Property="ContextFlyout" Value="{StaticResource BaseLayoutRecycleBinItemContextFlyout}" />
<Setter Property="Padding" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
<converters:BoolToVisibilityConverter
x:Key="NegatedBoolToVisibilityConverter"
Expand All @@ -44,6 +32,7 @@
<Setter Property="Background" Value="Transparent"/>
<Setter Property="TitleBarVisibility" Value="Collapsed"></Setter>
<Setter Property="BorderThickness" Value="0,0,1,0"></Setter>
<Setter Property="Width" Value="300"/>
</Style>
</local:BaseLayout.Resources>
<Grid
Expand Down Expand Up @@ -81,8 +70,7 @@
Background="Transparent"
IsRightTapEnabled="True"
RightTapped="StackPanel_RightTapped"
ToolTipService.ToolTip="{x:Bind ItemName, Mode=OneWay}"
Loaded="Grid_Loaded">
ToolTipService.ToolTip="{x:Bind ItemName, Mode=OneWay}" Loaded="Grid_Loaded">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="24" />
<ColumnDefinition Width="*" />
Expand Down
10 changes: 6 additions & 4 deletions Files/Views/LayoutModes/ColumnViewBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ public sealed partial class ColumnViewBrowser : BaseLayout
private ListedItem renamingItem;
private string oldItemName;
private TextBlock textBlock;
public static IShellPage columnparent;
private NavigationArguments parameters;
private ListViewItem navigatedfolder;

public ColumnViewBrowser() : base()
{
this.InitializeComponent();
ColumnViewBase.ItemInvoked += ColumnViewBase_ItemInvoked;
//this.DataContext = this;
//base.BaseLayoutContextFlyout = BaseLayoutContextFlyout;
//base.BaseLayoutItemContextFlyout = BaseLayoutItemContextFlyout;
var selectionRectangle = RectangleSelection.Create(FileList, SelectionRectangle, FileList_SelectionChanged);
tapDebounceTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
}
Expand Down Expand Up @@ -123,7 +124,8 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
{
FileList.ItemsSource = ParentShellPageInstance.FilesystemViewModel.FilesAndFolders;
}
var parameters = (NavigationArguments)eventArgs.Parameter;
columnparent = ParentShellPageInstance;
parameters = (NavigationArguments)eventArgs.Parameter;
if (parameters.IsLayoutSwitch)
{
ReloadItemIcons();
Expand Down Expand Up @@ -358,7 +360,6 @@ public override void Dispose()

private void FileList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{

if (e != null)
{
// Do not commit rename if SelectionChanged is due to selction rectangle (#3660)
Expand Down Expand Up @@ -421,6 +422,7 @@ private void FileList_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
{
if (!IsRenamingItem && !ParentShellPageInstance.NavigationToolbar.IsEditModeEnabled)
{

if (App.InteractionViewModel.IsQuickLookEnabled)
{
QuickLookHelpers.ToggleQuickLook(ParentShellPageInstance);
Expand Down
2 changes: 1 addition & 1 deletion Files/Views/LayoutModes/GenericFileBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,4 @@
StrokeThickness="1" />
</Canvas>
</Grid>
</local:BaseLayout>
</local:BaseLayout>
2 changes: 1 addition & 1 deletion Files/Views/LayoutModes/GridViewBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
x:Key="NegatedBoolToVisibilityConverter"
FalseValue="Visible"
TrueValue="Collapsed" />

<converters1:BoolToSelectionMode x:Key="BoolToSelectionModeConverter" />

<DataTemplate x:Name="GridViewBrowserTemplate" x:DataType="local2:ListedItem">
Expand Down
2 changes: 1 addition & 1 deletion Files/Views/LayoutModes/GridViewBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private void StackPanel_RightTapped(object sender, RightTappedRoutedEventArgs e)
var parentContainer = DependencyObjectHelpers.FindParent<GridViewItem>(e.OriginalSource as DependencyObject);
if (!parentContainer.IsSelected)
{
SetSelectedItemOnUi(FileList.ItemFromContainer(parentContainer) as ListedItem);
SetSelectedItemOnUi(FileList.ItemFromContainer(parentContainer) as ListedItem);
}
}

Expand Down

0 comments on commit e94244e

Please sign in to comment.