Skip to content

Fix: Update thumbnail when rotating image #11635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@
<Grid
x:Name="HeaderGrid"
Height="40"
Padding="16,0,0,0"
Margin="0"
Padding="16,0,0,0"
BorderBrush="{ThemeResource ControlStrokeColorDefault}"
BorderThickness="0,0,0,1"
PointerPressed="Grid_PointerPressed">
Expand Down Expand Up @@ -566,9 +566,9 @@
<CheckBox
x:Name="SelectionCheckbox"
Width="20"
AutomationProperties.AccessibilityView="Raw"
MinWidth="0"
HorizontalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
Checked="ItemSelected_Checked"
Unchecked="ItemSelected_Unchecked"
Visibility="Collapsed" />
Expand Down Expand Up @@ -620,6 +620,7 @@
x:Name="IconOverlay"
Width="16"
Height="16"
Margin="2"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
x:Load="True"
Expand Down
44 changes: 1 addition & 43 deletions src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Files.App.EventArguments;
using Files.App.Filesystem;
using Files.App.Helpers;
using Files.App.Interacts;
using Files.App.UserControls.Selection;
using Files.Shared.Enums;
using Microsoft.UI.Input;
Expand Down Expand Up @@ -47,23 +46,6 @@ public GridViewBrowser()
selectionRectangle.SelectionEnded += SelectionRectangle_SelectionEnded;
}

protected override void HookEvents()
{
base.HookEvents();
ItemManipulationModel.RefreshItemThumbnailInvoked += ItemManipulationModel_RefreshItemThumbnail;
ItemManipulationModel.RefreshItemsThumbnailInvoked += ItemManipulationModel_RefreshItemsThumbnail;
}

private void ItemManipulationModel_RefreshItemsThumbnail(object? sender, EventArgs e)
{
ReloadSelectedItemsIcon();
}

private void ItemManipulationModel_RefreshItemThumbnail(object? sender, EventArgs args)
{
ReloadSelectedItemIcon();
}

protected override void ItemManipulationModel_ScrollIntoViewInvoked(object? sender, ListedItem e)
{
FileList.ScrollIntoView(e);
Expand Down Expand Up @@ -92,13 +74,6 @@ protected override void ItemManipulationModel_RemoveSelectedItemInvoked(object?
FileList.SelectedItems.Remove(e);
}

protected override void UnhookEvents()
{
base.UnhookEvents();
ItemManipulationModel.RefreshItemThumbnailInvoked -= ItemManipulationModel_RefreshItemThumbnail;
ItemManipulationModel.RefreshItemsThumbnailInvoked -= ItemManipulationModel_RefreshItemsThumbnail;
}

protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
{
if (eventArgs.Parameter is NavigationArguments navArgs)
Expand Down Expand Up @@ -372,24 +347,6 @@ private async void ReloadItemIcons()
}
}

private async void ReloadSelectedItemIcon()
{
ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading();
ParentShellPageInstance.SlimContentPage.SelectedItem.ItemPropertiesInitialized = false;
await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemProperties(ParentShellPageInstance.SlimContentPage.SelectedItem, currentIconSize);
}

private async void ReloadSelectedItemsIcon()
{
ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading();

foreach (var selectedItem in ParentShellPageInstance.SlimContentPage.SelectedItems)
{
selectedItem.ItemPropertiesInitialized = false;
await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemProperties(selectedItem, currentIconSize);
}
}

private async void FileList_ItemTapped(object sender, TappedRoutedEventArgs e)
{
var clickedItem = e.OriginalSource as FrameworkElement;
Expand Down Expand Up @@ -460,6 +417,7 @@ private void FileList_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
}
ResetRenameDoubleClick();
}

private void ItemSelected_Checked(object sender, RoutedEventArgs e)
{
if (sender is CheckBox checkBox && checkBox.DataContext is ListedItem item && !FileList.SelectedItems.Contains(item))
Expand Down
32 changes: 32 additions & 0 deletions src/Files.App/Views/LayoutModes/StandardLayoutMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ protected override void HookEvents()
ItemManipulationModel.FocusSelectedItemsInvoked += ItemManipulationModel_FocusSelectedItemsInvoked;
ItemManipulationModel.StartRenameItemInvoked += ItemManipulationModel_StartRenameItemInvoked;
ItemManipulationModel.ScrollIntoViewInvoked += ItemManipulationModel_ScrollIntoViewInvoked;
ItemManipulationModel.RefreshItemThumbnailInvoked += ItemManipulationModel_RefreshItemThumbnail;
ItemManipulationModel.RefreshItemsThumbnailInvoked += ItemManipulationModel_RefreshItemsThumbnail;
}

protected override void UnhookEvents()
Expand All @@ -76,6 +78,36 @@ protected override void UnhookEvents()
ItemManipulationModel.FocusSelectedItemsInvoked -= ItemManipulationModel_FocusSelectedItemsInvoked;
ItemManipulationModel.StartRenameItemInvoked -= ItemManipulationModel_StartRenameItemInvoked;
ItemManipulationModel.ScrollIntoViewInvoked -= ItemManipulationModel_ScrollIntoViewInvoked;
ItemManipulationModel.RefreshItemThumbnailInvoked -= ItemManipulationModel_RefreshItemThumbnail;
ItemManipulationModel.RefreshItemsThumbnailInvoked -= ItemManipulationModel_RefreshItemsThumbnail;
}

protected virtual void ItemManipulationModel_RefreshItemsThumbnail(object? sender, EventArgs e)
{
ReloadSelectedItemsIcon();
}

protected virtual void ItemManipulationModel_RefreshItemThumbnail(object? sender, EventArgs args)
{
ReloadSelectedItemIcon();
}

protected virtual async void ReloadSelectedItemIcon()
{
ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading();
ParentShellPageInstance.SlimContentPage.SelectedItem.ItemPropertiesInitialized = false;
await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemProperties(ParentShellPageInstance.SlimContentPage.SelectedItem, IconSize);
}

protected virtual async void ReloadSelectedItemsIcon()
{
ParentShellPageInstance.FilesystemViewModel.CancelExtendedPropertiesLoading();

foreach (var selectedItem in ParentShellPageInstance.SlimContentPage.SelectedItems)
{
selectedItem.ItemPropertiesInitialized = false;
await ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemProperties(selectedItem, IconSize);
}
}

protected virtual void ItemManipulationModel_FocusFileListInvoked(object? sender, EventArgs e)
Expand Down