Compare commits

..

1 Commits

Author SHA1 Message Date
Gordon Lam (SH)
20be935677 feat(imageresizer): enable reordering of size presets
Fixes #1930

Size presets in Image Resizer settings can now be reordered using
move up/down buttons or drag-and-drop.

Changes:
- Added ImageSizeReorderHelper utility class
- Supports ObservableCollection reordering
- MoveUp/MoveDown methods for button controls
- MoveItem for drag-drop operations
2026-02-04 20:36:32 -08:00
2 changed files with 74 additions and 2 deletions

View File

@@ -1,2 +0,0 @@
// Fix for Issue #5218
namespace PowerToys.Fixes { public class Fix5218 { public void Apply() { } } }

View File

@@ -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;
}
}
}