Skip to content

Commit 8b67f35

Browse files
committed
Ensure Ribbon Shadow Isn't Stored When Not Available
1 parent 5df3d57 commit 8b67f35

File tree

4 files changed

+54
-6
lines changed

4 files changed

+54
-6
lines changed

Files UWP/GenericFileBrowser.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@
287287
<controls:DataGridTemplateColumn IsReadOnly="True">
288288
<controls:DataGridTemplateColumn.CellTemplate>
289289
<DataTemplate>
290-
<Grid Name="Icon" Margin="15, 0, 0, 0">
290+
<Grid Name="Icon" Margin="0, 0, 0, 0">
291291
<Rectangle Visibility="Collapsed" Name="CutIndicator" Opacity="0.1" Fill="LightGray"/>
292292
<FontIcon Visibility="{Binding FolderImg}" Glyph="&#xE8D5;" FontFamily="Segoe MDL2 Assets" Foreground="#ffe793"/>
293293
<FontIcon Visibility="{Binding EmptyImgVis}" Glyph="&#xE7C3;" FontFamily="Segoe MDL2 Assets"/>

Files UWP/PhotoAlbum.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,10 @@
400400
<ProgressBar Name="ProgBar" Height="10" VerticalAlignment="Top" IsIndeterminate="True"/>
401401
<TextBlock Visibility="{x:Bind TextState.isVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Name="EmptyText" HorizontalAlignment="Center" Text="This folder is empty." TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,125,0,0" Grid.Row="3" Canvas.ZIndex="0"/>
402402

403-
<controls:AdaptiveGridView StretchContentForSingleRow="False" DesiredWidth="150" VerticalContentAlignment="Stretch" ItemHeight="150" animations:ReorderGridAnimation.Duration="300" ShowsScrollingPlaceholders="True" Margin="24,24,24,0" Grid.Row="3" SelectionMode="Extended" IsRightTapEnabled="True" IsDoubleTapEnabled="True" Name="FileList" Padding="0, 0, 0, 0" >
403+
<controls:AdaptiveGridView RightTapped="FileList_RightTapped" StretchContentForSingleRow="False" DesiredWidth="150" VerticalContentAlignment="Stretch" ItemHeight="150" animations:ReorderGridAnimation.Duration="300" ShowsScrollingPlaceholders="True" Margin="24,24,24,0" Grid.Row="3" SelectionMode="Extended" IsRightTapEnabled="True" IsDoubleTapEnabled="True" Name="FileList" Padding="0, 0, 0, 0" >
404404
<controls:AdaptiveGridView.ItemTemplate>
405405
<DataTemplate>
406-
<StackPanel Orientation="Vertical" Padding="0" ToolTipService.ToolTip="{Binding FileName}" Background="Transparent" IsRightTapEnabled="True" Margin="0, 0, 0, 0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
406+
<StackPanel Tag="{Binding RowIndex}" RightTapped="StackPanel_RightTapped" Orientation="Vertical" Padding="0" ToolTipService.ToolTip="{Binding FileName}" Background="Transparent" IsRightTapEnabled="True" Margin="0, 0, 0, 0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
407407
<StackPanel.ContextFlyout>
408408
<MenuFlyout x:Name="RightClickContextMenu" MenuFlyoutPresenterStyle="{StaticResource MenuFlyoutFluentThemeResources}">
409409
<MenuFlyout.Items>

Files UWP/PhotoAlbum.xaml.cs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@
1515
using System.Diagnostics;
1616
using Windows.UI.Xaml.Media.Animation;
1717
using System.ComponentModel;
18+
using System.Collections.ObjectModel;
19+
using System.Collections.Generic;
20+
using Windows.UI.Xaml.Data;
1821

1922
namespace Files
2023
{
2124

2225
public sealed partial class PhotoAlbum : Page
2326
{
24-
public GridView gv;
27+
public AdaptiveGridView gv;
2528
public Image largeImg;
2629
public MenuFlyout context;
2730
public MenuFlyout gridContext;
@@ -213,5 +216,46 @@ internal void TextState_PropertyChanged(object sender, PropertyChangedEventArgs
213216
{
214217
TextState.isVisible = ItemViewModel<PhotoAlbum>.GetCurrentSelectedTabInstance<ProHome>().TextState.isVisible;
215218
}
219+
220+
221+
private void StackPanel_RightTapped(object sender, RightTappedRoutedEventArgs e)
222+
{
223+
//ObjectPressed = ((ReadOnlyObservableCollection<ListedItem>)FileList.ItemsSource)[(int)(sender as StackPanel).Tag];
224+
}
225+
226+
private void FileList_RightTapped(object sender, RightTappedRoutedEventArgs e)
227+
{
228+
var ItemPressed = Interaction<PhotoAlbum>.FindParent<GridViewItem>(e.OriginalSource as DependencyObject);
229+
List<StackPanel> stackPanels = new List<StackPanel>();
230+
Interaction<PhotoAlbum>.FindChildren<StackPanel>(stackPanels, ItemPressed);
231+
var ObjectPressed = ((ReadOnlyObservableCollection<ListedItem>)FileList.ItemsSource)[(int) stackPanels[0].Tag];
232+
//List<int> indexes = new List<int>();
233+
//foreach (ItemIndexRange range in FileList.SelectedRanges)
234+
//{
235+
// for (int x = range.FirstIndex; x <= range.LastIndex; x++) { indexes.Add(x); }
236+
//}
237+
List<GridViewItem> items = new List<GridViewItem>();
238+
List<GridViewItem> selitems = new List<GridViewItem>();
239+
Interaction<PhotoAlbum>.FindChildren<GridViewItem>(items, FileList);
240+
foreach (GridViewItem gvi in items)
241+
{
242+
if (gvi.IsSelected)
243+
{
244+
selitems.Add(gvi);
245+
}
246+
}
247+
248+
foreach (GridViewItem selectedItem in selitems)
249+
{
250+
if (FileList.IndexFromContainer(FileList.ContainerFromItem(selectedItem)) == FileList.IndexFromContainer(FileList.ContainerFromItem(ItemPressed)))
251+
{
252+
return;
253+
}
254+
}
255+
256+
// The following code is only reachable when a user RightTapped an unselected row
257+
FileList.SelectedItems.Clear();
258+
FileList.SelectedItems.Add(ObjectPressed);
259+
}
216260
}
217261
}

Files UWP/ProHome.xaml.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,12 @@ public ProHome()
9090
BackButton.Click += NavigationActions.Back_Click;
9191
ForwardButton.Click += NavigationActions.Forward_Click;
9292
RefreshButton.Click += NavigationActions.Refresh_Click;
93-
ribbonShadow.Receivers.Add(RibbonShadowSurface);
94-
Ribbon.Translation += new System.Numerics.Vector3(0, 0, 4);
93+
if(ribbonShadow != null)
94+
{
95+
ribbonShadow.Receivers.Add(RibbonShadowSurface);
96+
Ribbon.Translation += new System.Numerics.Vector3(0, 0, 4);
97+
}
98+
9599

96100
}
97101

0 commit comments

Comments
 (0)