Skip to content

5275 set multiple images as desktop background #9712

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
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
2 changes: 1 addition & 1 deletion src/Files.Uwp/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ private async Task LoadMenuItemsAsync()
}
shellContextMenuItemCancellationToken?.Cancel();
shellContextMenuItemCancellationToken = new CancellationTokenSource();
SelectedItemsPropertiesViewModel.CheckFileExtension(SelectedItem?.FileExtension);
SelectedItemsPropertiesViewModel.CheckAllFileExtensions(this.SelectedItems.Select(selectedItem => selectedItem?.FileExtension).ToList());
var shiftPressed = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);
var items = ContextFlyoutItemHelper.GetItemContextCommandsWithoutShellItems(currentInstanceViewModel: InstanceViewModel, workingDir: ParentShellPageInstance.FilesystemViewModel.WorkingDirectory, selectedItems: SelectedItems, selectedItemsPropertiesViewModel: SelectedItemsPropertiesViewModel, commandsViewModel: CommandsViewModel, shiftPressed: shiftPressed, showOpenMenu: false);
ItemContextMenuFlyout.PrimaryCommands.Clear();
Expand Down
11 changes: 11 additions & 0 deletions src/Files.Uwp/Helpers/ContextFlyoutItemHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
Glyph = "\uE91B",
Command = commandsViewModel.SetAsDesktopBackgroundItemCommand,
ShowInSearchPage = true,
ShowItem = (selectedItemsPropertiesViewModel.SelectedItemsCount == 1)
},
new ContextMenuFlyoutItemViewModel()
{
Expand All @@ -735,6 +736,16 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(BaseLayo
GlyphFontFamilyName = "CustomGlyph",
Command = commandsViewModel.SetAsLockscreenBackgroundItemCommand,
ShowInSearchPage = true,
ShowItem = (selectedItemsPropertiesViewModel.SelectedItemsCount == 1)
},
new ContextMenuFlyoutItemViewModel()
{
Text = "SetAsSlideshow".GetLocalized(),
Glyph = "\uE91B",
GlyphFontFamilyName = "CustomGlyph",
Command = commandsViewModel.SetAsDesktopBackgroundItemCommand,
ShowInSearchPage = true,
ShowItem = (selectedItemsPropertiesViewModel.SelectedItemsCount > 1)
},
}
},
Expand Down
17 changes: 17 additions & 0 deletions src/Files.Uwp/Helpers/FileExtensionHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,22 @@ public static bool IsFontFile(string fileExtensionToCheck)
fileExtensionToCheck.Equals(".ttc", StringComparison.OrdinalIgnoreCase) ||
fileExtensionToCheck.Equals(".ttf", StringComparison.OrdinalIgnoreCase);
}

/// <summary>
/// Check if the file extension is a shortcut file.
/// </summary>
/// <param name="fileExtensionToCheck">The file extension to check.</param>
/// <returns><c>true</c> if the fileExtensionToCheck is a shortcute file;
/// otherwise <c>false</c>.</returns>
/// <remarks>Font file type is .lnkf</remarks>
public static bool IsShortcutFile(string fileExtensionToCheck)
{
if (string.IsNullOrEmpty(fileExtensionToCheck))
{
return false;
}

return fileExtensionToCheck.Equals(".lnk", StringComparison.OrdinalIgnoreCase);
}
}
}
29 changes: 7 additions & 22 deletions src/Files.Uwp/ViewModels/SelectedItemsPropertiesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System;
using System.Collections.ObjectModel;
using Windows.UI.Xaml;
using System.Collections.Generic;
using Files.Uwp.Helpers;

namespace Files.Uwp.ViewModels
{
Expand Down Expand Up @@ -537,29 +539,12 @@ public bool IsSelectedItemShortcut
set => SetProperty(ref isSelectedItemShortcut, value);
}

public void CheckFileExtension(string itemExtension)
public void CheckAllFileExtensions(List<string> itemExtensions)
{
// Set properties to false
IsSelectedItemImage = false;
IsSelectedItemShortcut = false;

//check if the selected item is an image file
if (!string.IsNullOrEmpty(itemExtension) && SelectedItemsCount == 1)
{
if (itemExtension.Equals(".png", StringComparison.OrdinalIgnoreCase)
|| itemExtension.Equals(".jpg", StringComparison.OrdinalIgnoreCase)
|| itemExtension.Equals(".bmp", StringComparison.OrdinalIgnoreCase)
|| itemExtension.Equals(".jpeg", StringComparison.OrdinalIgnoreCase))
{
// Since item is an image, set the IsSelectedItemImage property to true
IsSelectedItemImage = true;
}
else if (itemExtension.Equals(".lnk", StringComparison.OrdinalIgnoreCase))
{
// The selected item is a shortcut, so set the IsSelectedItemShortcut property to true
IsSelectedItemShortcut = true;
}
}
// Checks if all the item extensions are image extensions of some kind.
IsSelectedItemImage = itemExtensions.TrueForAll(itemExtension => FileExtensionHelpers.IsImageFile(itemExtension));
// Checks if there is only one selected item and if it's a shortcut.
IsSelectedItemShortcut = (itemExtensions.Count == 1) && (itemExtensions.TrueForAll(itemExtension => FileExtensionHelpers.IsShortcutFile(itemExtension)));
}

private string shortcutItemType;
Expand Down