mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[fxcop] image resizer ui (#6841)
* adjustments * Settings fixed * Getting resizing tests operational again * fixed default vs loading from settings * one small tewak
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
// This class sets the visibility property of Advanced settings based on the OS Version
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ImageResizer.Models
|
||||
{
|
||||
public class AdvancedSettings
|
||||
public static class AdvancedSettings
|
||||
{
|
||||
public static bool UseNewSettings()
|
||||
{
|
||||
|
||||
@@ -24,12 +24,15 @@ namespace ImageResizer.Models
|
||||
|
||||
// NB: We read these from stdin since there are limits on the number of args you can have
|
||||
string file;
|
||||
while ((file = standardInput.ReadLine()) != null)
|
||||
if (standardInput != null)
|
||||
{
|
||||
batch.Files.Add(file);
|
||||
while ((file = standardInput.ReadLine()) != null)
|
||||
{
|
||||
batch.Files.Add(file);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
for (var i = 0; i < args?.Length; i++)
|
||||
{
|
||||
if (args[i] == "/d")
|
||||
{
|
||||
@@ -43,9 +46,7 @@ namespace ImageResizer.Models
|
||||
return batch;
|
||||
}
|
||||
|
||||
public IEnumerable<ResizeError> Process(
|
||||
CancellationToken cancellationToken,
|
||||
Action<int, double> reportProgress)
|
||||
public IEnumerable<ResizeError> Process(Action<int, double> reportProgress, CancellationToken cancellationToken)
|
||||
{
|
||||
double total = Files.Count;
|
||||
var completed = 0;
|
||||
@@ -66,7 +67,9 @@ namespace ImageResizer.Models
|
||||
{
|
||||
Execute(file);
|
||||
}
|
||||
#pragma warning disable CA1031 // Do not catch general exception types
|
||||
catch (Exception ex)
|
||||
#pragma warning restore CA1031 // Do not catch general exception types
|
||||
{
|
||||
errors.Add(new ResizeError { File = Path.GetFileName(file), Error = ex.Message });
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
@@ -175,6 +176,7 @@ namespace ImageResizer.Models
|
||||
}
|
||||
|
||||
var fileName = string.Format(
|
||||
CultureInfo.CurrentCulture,
|
||||
_settings.FileNameFormat,
|
||||
originalFileName,
|
||||
_settings.SelectedSize.Name,
|
||||
|
||||
@@ -13,7 +13,13 @@ namespace ImageResizer.Models
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class ResizeSize : ObservableObject
|
||||
{
|
||||
private static readonly IDictionary<string, string> _tokens;
|
||||
private static readonly IDictionary<string, string> _tokens = new Dictionary<string, string>
|
||||
{
|
||||
["$small$"] = Resources.Small,
|
||||
["$medium$"] = Resources.Medium,
|
||||
["$large$"] = Resources.Large,
|
||||
["$phone$"] = Resources.Phone,
|
||||
};
|
||||
|
||||
private string _name;
|
||||
private ResizeFit _fit = ResizeFit.Fit;
|
||||
@@ -22,15 +28,6 @@ namespace ImageResizer.Models
|
||||
private bool _showHeight = true;
|
||||
private ResizeUnit _unit = ResizeUnit.Pixel;
|
||||
|
||||
static ResizeSize()
|
||||
=> _tokens = new Dictionary<string, string>
|
||||
{
|
||||
["$small$"] = Resources.Small,
|
||||
["$medium$"] = Resources.Medium,
|
||||
["$large$"] = Resources.Large,
|
||||
["$phone$"] = Resources.Phone,
|
||||
};
|
||||
|
||||
public ResizeSize(string name, ResizeFit fit, double width, double height, ResizeUnit unit)
|
||||
{
|
||||
Name = name;
|
||||
|
||||
Reference in New Issue
Block a user