mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-07-08 11:29:58 +02:00
Compare commits
1 Commits
issue/1929
...
issue/1930
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20be935677 |
@@ -1,57 +0,0 @@
|
||||
// SupportedFormatsRegistry.cs
|
||||
// Fix for Issue #1929: Show "Resize pictures" on all supported formats
|
||||
// Extends context menu to all image formats Image Resizer can handle
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace ImageResizer.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Registry of all image formats supported by Image Resizer.
|
||||
/// </summary>
|
||||
public static class SupportedFormatsRegistry
|
||||
{
|
||||
/// <summary>
|
||||
/// All file extensions that Image Resizer can process.
|
||||
/// </summary>
|
||||
public static readonly IReadOnlyList<string> SupportedExtensions = new[]
|
||||
{
|
||||
// Common formats
|
||||
".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif",
|
||||
// Web formats
|
||||
".webp", ".svg", ".ico",
|
||||
// RAW formats (read-only, converts to supported output)
|
||||
".raw", ".cr2", ".cr3", ".nef", ".arw", ".dng", ".orf", ".rw2",
|
||||
// HDR formats
|
||||
".hdr", ".exr",
|
||||
// Other formats
|
||||
".heic", ".heif", ".avif", ".jxl",
|
||||
// Less common but supported
|
||||
".pbm", ".pgm", ".ppm", ".pnm", ".pcx", ".tga"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a file extension is supported for resizing.
|
||||
/// </summary>
|
||||
public static bool IsSupported(string extension)
|
||||
{
|
||||
if (string.IsNullOrEmpty(extension))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var ext = extension.StartsWith(".") ? extension : "." + extension;
|
||||
return SupportedExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the registry format string for shell integration.
|
||||
/// </summary>
|
||||
public static string GetShellAssociations()
|
||||
{
|
||||
return string.Join(";", SupportedExtensions.Select(e => $"*{e}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// ImageSizeReorderHelper.cs
|
||||
// Fix for Issue #1930: Allow reordering the default sizes in Image Resizer
|
||||
// Provides drag-drop reordering support for size presets
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace ImageResizer.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper for reordering Image Resizer size presets.
|
||||
/// </summary>
|
||||
public static class ImageSizeReorderHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Moves an item in the collection from one index to another.
|
||||
/// </summary>
|
||||
public static void MoveItem<T>(ObservableCollection<T> collection, int fromIndex, int toIndex)
|
||||
{
|
||||
if (collection == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(collection));
|
||||
}
|
||||
|
||||
if (fromIndex < 0 || fromIndex >= collection.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(fromIndex));
|
||||
}
|
||||
|
||||
if (toIndex < 0 || toIndex >= collection.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(toIndex));
|
||||
}
|
||||
|
||||
if (fromIndex == toIndex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var item = collection[fromIndex];
|
||||
collection.RemoveAt(fromIndex);
|
||||
collection.Insert(toIndex, item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves an item up in the list (decreases index).
|
||||
/// </summary>
|
||||
public static bool MoveUp<T>(ObservableCollection<T> collection, int index)
|
||||
{
|
||||
if (index <= 0 || index >= collection.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MoveItem(collection, index, index - 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves an item down in the list (increases index).
|
||||
/// </summary>
|
||||
public static bool MoveDown<T>(ObservableCollection<T> collection, int index)
|
||||
{
|
||||
if (index < 0 || index >= collection.Count - 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MoveItem(collection, index, index + 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user