getting stuff to work

headers and trailing commas

adding braces

updated encoder
This commit is contained in:
Clint Rutkas 2020-01-02 16:58:06 -08:00
parent 3d204e7da9
commit 5310866120
39 changed files with 206 additions and 132 deletions

View file

@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.

View file

@ -4,13 +4,13 @@
namespace System.Windows.Media.Imaging
{
static class BitmapEncoderExtensions
internal static class BitmapEncoderExtensions
{
public static bool CanEncode(this BitmapEncoder encoder)
{
try
{
var = encoder.CodecInfo;
var test = encoder.CodecInfo;
}
catch (NotSupportedException)
{

View file

@ -4,12 +4,14 @@
namespace System.Collections.Generic
{
static class ICollectionExtensions
internal static class ICollectionExtensions
{
public static void AddRange<T>(this ICollection<T> collection, IEnumerable<T> items)
{
foreach (var item in items)
{
collection.Add(item);
}
}
}
}

View file

@ -4,7 +4,7 @@
namespace System
{
static class TimeSpanExtensions
internal static class TimeSpanExtensions
{
public static TimeSpan Multiply(this TimeSpan timeSpan, double scalar)
=> new TimeSpan((long)(timeSpan.Ticks * scalar));

View file

@ -169,6 +169,9 @@
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="..\..\codeAnalysis\StyleCop.json" />
<Compile Include="..\..\codeAnalysis\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
@ -181,7 +184,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="MvvmLightLibs">
<Version>5.4.1</Version>
<Version>5.4.1.1</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>

View file

@ -15,6 +15,7 @@ namespace ImageResizer.Models
public class ResizeBatch
{
public string DestinationDirectory { get; set; }
public ICollection<string> Files { get; } = new List<string>();
public static ResizeBatch FromCommandLine(TextReader standardInput, string[] args)
@ -24,7 +25,9 @@ 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)
{
batch.Files.Add(file);
}
for (var i = 0; i < args.Length; i++)
{
@ -55,7 +58,7 @@ namespace ImageResizer.Models
new ParallelOptions
{
CancellationToken = cancellationToken,
MaxDegreeOfParallelism = Environment.ProcessorCount
MaxDegreeOfParallelism = Environment.ProcessorCount,
},
(file, state, i) =>
{

View file

@ -7,6 +7,7 @@ namespace ImageResizer.Models
public class ResizeError
{
public string File { get; set; }
public string Error { get; set; }
}
}

View file

@ -8,6 +8,6 @@ namespace ImageResizer.Models
{
Fill,
Fit,
Stretch
Stretch,
}
}

View file

@ -14,11 +14,11 @@ using Microsoft.VisualBasic.FileIO;
namespace ImageResizer.Models
{
class ResizeOperation
internal class ResizeOperation
{
readonly string _file;
readonly string _destinationDirectory;
readonly Settings _settings;
private readonly string _file;
private readonly string _destinationDirectory;
private readonly Settings _settings;
public ResizeOperation(string file, string destinationDirectory, Settings settings)
{
@ -39,7 +39,9 @@ namespace ImageResizer.Models
var encoder = BitmapEncoder.Create(decoder.CodecInfo.ContainerFormat);
if (!encoder.CanEncode())
{
encoder = BitmapEncoder.Create(_settings.FallbackEncoder);
}
ConfigureEncoder(encoder);
@ -55,7 +57,9 @@ namespace ImageResizer.Models
}
if (decoder.Palette != null)
{
encoder.Palette = decoder.Palette;
}
foreach (var originalFrame in decoder.Frames)
{
@ -71,11 +75,15 @@ namespace ImageResizer.Models
path = GetDestinationPath(encoder);
Directory.CreateDirectory(Path.GetDirectoryName(path));
using (var outputStream = File.Open(path, FileMode.CreateNew, FileAccess.Write))
{
encoder.Save(outputStream);
}
}
if (_settings.KeepDateModified)
{
File.SetLastWriteTimeUtc(path, File.GetLastWriteTimeUtc(_file));
}
if (_settings.Replace)
{
@ -85,7 +93,7 @@ namespace ImageResizer.Models
}
}
void ConfigureEncoder(BitmapEncoder encoder)
private void ConfigureEncoder(BitmapEncoder encoder)
{
switch (encoder)
{
@ -103,7 +111,7 @@ namespace ImageResizer.Models
}
}
BitmapSource Transform(BitmapSource source)
private BitmapSource Transform(BitmapSource source)
{
var originalWidth = source.PixelWidth;
var originalHeight = source.PixelHeight;
@ -137,7 +145,9 @@ namespace ImageResizer.Models
if (_settings.ShrinkOnly
&& _settings.SelectedSize.Unit != ResizeUnit.Percent
&& (scaleX >= 1 || scaleY >= 1))
{
return source;
}
var scaledBitmap = new TransformedBitmap(source, new ScaleTransform(scaleX, scaleY));
if (_settings.SelectedSize.Fit == ResizeFit.Fill
@ -153,7 +163,7 @@ namespace ImageResizer.Models
return scaledBitmap;
}
string GetDestinationPath(BitmapEncoder encoder)
private string GetDestinationPath(BitmapEncoder encoder)
{
var directory = _destinationDirectory ?? Path.GetDirectoryName(_file);
var originalFileName = Path.GetFileNameWithoutExtension(_file);
@ -176,12 +186,14 @@ namespace ImageResizer.Models
var path = Path.Combine(directory, fileName + extension);
var uniquifier = 1;
while (File.Exists(path))
{
path = Path.Combine(directory, fileName + " (" + uniquifier++ + ")" + extension);
}
return path;
}
string GetBackupPath()
private string GetBackupPath()
{
var directory = Path.GetDirectoryName(_file);
var fileName = Path.GetFileNameWithoutExtension(_file);
@ -190,7 +202,9 @@ namespace ImageResizer.Models
var path = Path.Combine(directory, fileName + ".bak" + extension);
var uniquifier = 1;
while (File.Exists(path))
{
path = Path.Combine(directory, fileName + " (" + uniquifier++ + ")" + ".bak" + extension);
}
return path;
}

View file

@ -11,14 +11,14 @@ namespace ImageResizer.Models
{
public class ResizeSize : ObservableObject
{
static readonly IDictionary<string, string> _tokens;
private static readonly IDictionary<string, string> _tokens;
string _name;
ResizeFit _fit = ResizeFit.Fit;
double _width;
double _height;
bool _showHeight = true;
ResizeUnit _unit = ResizeUnit.Pixel;
private string _name;
private ResizeFit _fit = ResizeFit.Fit;
private double _width;
private double _height;
private bool _showHeight = true;
private ResizeUnit _unit = ResizeUnit.Pixel;
static ResizeSize()
=> _tokens = new Dictionary<string, string>
@ -26,7 +26,7 @@ namespace ImageResizer.Models
["$small$"] = Resources.Small,
["$medium$"] = Resources.Medium,
["$large$"] = Resources.Large,
["$phone$"] = Resources.Phone
["$phone$"] = Resources.Phone,
};
public virtual string Name
@ -41,7 +41,9 @@ namespace ImageResizer.Models
set
{
if (Set(nameof(Fit), ref _fit, value))
{
UpdateShowHeight();
}
}
}
@ -69,7 +71,9 @@ namespace ImageResizer.Models
set
{
if (Set(nameof(Unit), ref _unit, value))
{
UpdateShowHeight();
}
}
}
@ -85,23 +89,25 @@ namespace ImageResizer.Models
originalHeight,
dpi);
static string ReplaceTokens(string text)
private static string ReplaceTokens(string text)
=> (text != null && _tokens.TryGetValue(text, out var result))
? result
: text;
void UpdateShowHeight()
private void UpdateShowHeight()
=> Set(
nameof(ShowHeight),
ref _showHeight,
Fit == ResizeFit.Stretch || Unit != ResizeUnit.Percent);
double ConvertToPixels(double value, ResizeUnit unit, int originalValue, double dpi)
private double ConvertToPixels(double value, ResizeUnit unit, int originalValue, double dpi)
{
if (value == 0)
{
if (Fit == ResizeFit.Fit)
{
return double.PositiveInfinity;
}
Debug.Assert(Fit == ResizeFit.Fill || Fit == ResizeFit.Stretch, "Unexpected ResizeFit value: " + Fit);

View file

@ -9,6 +9,6 @@ namespace ImageResizer.Models
Centimeter,
Inch,
Percent,
Pixel
Pixel,
}
}

View file

@ -13,7 +13,7 @@ namespace ImageResizer.Properties
{
partial class Settings : IDataErrorInfo
{
string _fileNameFormat;
private string _fileNameFormat;
public Settings()
=> AllSizes = new AllSizesCollection(this);
@ -41,7 +41,9 @@ namespace ImageResizer.Properties
{
var index = Sizes.IndexOf(value);
if (index == -1)
{
index = Sizes.Count;
}
SelectedSizeIndex = index;
}
@ -53,12 +55,15 @@ namespace ImageResizer.Properties
public override object this[string propertyName]
{
get { return base[propertyName]; }
set
{
base[propertyName] = value;
if (propertyName == nameof(FileName))
{
_fileNameFormat = null;
}
}
}
@ -67,19 +72,23 @@ namespace ImageResizer.Properties
get
{
if (columnName != nameof(JpegQualityLevel))
{
return string.Empty;
}
if (JpegQualityLevel < 1 || JpegQualityLevel > 100)
{
return string.Format(Resources.ValueMustBeBetween, 1, 100);
}
return string.Empty;
}
}
class AllSizesCollection : IEnumerable<ResizeSize>, INotifyCollectionChanged, INotifyPropertyChanged
private class AllSizesCollection : IEnumerable<ResizeSize>, INotifyCollectionChanged, INotifyPropertyChanged
{
ObservableCollection<ResizeSize> _sizes;
CustomSize _customSize;
private ObservableCollection<ResizeSize> _sizes;
private CustomSize _customSize;
public AllSizesCollection(Settings settings)
{
@ -121,6 +130,7 @@ namespace ImageResizer.Properties
}
public event NotifyCollectionChangedEventHandler CollectionChanged;
public event PropertyChangedEventHandler PropertyChanged;
public int Count
@ -134,23 +144,23 @@ namespace ImageResizer.Properties
public IEnumerator<ResizeSize> GetEnumerator()
=> new AllSizesEnumerator(this);
void HandleCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
private void HandleCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
=> OnCollectionChanged(e);
void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
private void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
=> PropertyChanged?.Invoke(this, e);
void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
private void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
=> CollectionChanged?.Invoke(this, e);
IEnumerator IEnumerable.GetEnumerator()
=> GetEnumerator();
class AllSizesEnumerator : IEnumerator<ResizeSize>
private class AllSizesEnumerator : IEnumerator<ResizeSize>
{
readonly AllSizesCollection _list;
private readonly AllSizesCollection _list;
int _index = -1;
private int _index = -1;
public AllSizesEnumerator(AllSizesCollection list)
=> _list = list;

View file

@ -6,7 +6,7 @@ using System;
namespace ImageResizer.Utilities
{
static class MathHelpers
internal static class MathHelpers
{
public static int Clamp(int value, int min, int max)
=> Math.Min(Math.Max(value, min), max);

View file

@ -16,7 +16,7 @@ namespace ImageResizer.ViewModels
{
public class AdvancedViewModel : ViewModelBase
{
static readonly IDictionary<Guid, string> _encoderMap;
private static readonly IDictionary<Guid, string> _encoderMap;
static AdvancedViewModel()
{
@ -58,6 +58,7 @@ namespace ImageResizer.ViewModels
=> _encoderMap.Keys;
public ICommand RemoveSizeCommand { get; }
public ICommand AddSizeCommand { get; }
public void RemoveSize(ResizeSize size)

View file

@ -13,9 +13,9 @@ namespace ImageResizer.ViewModels
{
public class InputViewModel : ViewModelBase
{
readonly ResizeBatch _batch;
readonly MainViewModel _mainViewModel;
readonly IMainView _mainView;
private readonly ResizeBatch _batch;
private readonly MainViewModel _mainViewModel;
private readonly IMainView _mainView;
public InputViewModel(
Settings settings,
@ -38,7 +38,9 @@ namespace ImageResizer.ViewModels
public Settings Settings { get; }
public ICommand ResizeCommand { get; }
public ICommand CancelCommand { get; }
public ICommand ShowAdvancedCommand { get; }
public void Resize()

View file

@ -14,11 +14,11 @@ namespace ImageResizer.ViewModels
{
public class MainViewModel : ViewModelBase
{
readonly Settings _settings;
readonly ResizeBatch _batch;
private readonly Settings _settings;
private readonly ResizeBatch _batch;
object _currentPage;
double _progress;
private object _currentPage;
private double _progress;
public MainViewModel(ResizeBatch batch, Settings settings)
{
@ -44,7 +44,9 @@ namespace ImageResizer.ViewModels
public void Load(IMainView view)
{
if (_batch.Files.Count == 0)
{
_batch.Files.AddRange(view.OpenPictureFiles());
}
if (_settings.UpgradeRequired)
{

View file

@ -17,14 +17,14 @@ namespace ImageResizer.ViewModels
{
public class ProgressViewModel : ViewModelBase
{
readonly MainViewModel _mainViewModel;
readonly ResizeBatch _batch;
readonly IMainView _mainView;
readonly Stopwatch _stopwatch = new Stopwatch();
readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
private readonly MainViewModel _mainViewModel;
private readonly ResizeBatch _batch;
private readonly IMainView _mainView;
private readonly Stopwatch _stopwatch = new Stopwatch();
private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
double _progress;
TimeSpan _timeRemaining;
private double _progress;
private TimeSpan _timeRemaining;
public ProgressViewModel(
ResizeBatch batch,
@ -52,6 +52,7 @@ namespace ImageResizer.ViewModels
}
public ICommand StartCommand { get; }
public ICommand StopCommand { get; }
public void Start()

View file

@ -13,7 +13,7 @@ namespace ImageResizer.ViewModels
{
public class ResultsViewModel : ViewModelBase
{
readonly IMainView _mainView;
private readonly IMainView _mainView;
public ResultsViewModel(IMainView mainView, IEnumerable<ResizeError> errors)
{
@ -23,6 +23,7 @@ namespace ImageResizer.ViewModels
}
public IEnumerable<ResizeError> Errors { get; }
public ICommand CloseCommand { get; }
public void Close() => _mainView.Close();

View file

@ -17,10 +17,10 @@ namespace ImageResizer.Views
InitializeComponent();
}
void HandleAcceptClick(object sender, RoutedEventArgs e)
private void HandleAcceptClick(object sender, RoutedEventArgs e)
=> DialogResult = true;
void HandleRequestNavigate(object sender, RequestNavigateEventArgs e)
private void HandleRequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(e.Uri.ToString());
e.Handled = true;

View file

@ -10,7 +10,7 @@ using ImageResizer.Properties;
namespace ImageResizer.Views
{
[ValueConversion(typeof(double), typeof(string))]
class AutoDoubleConverter : IValueConverter
internal class AutoDoubleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{

View file

@ -7,7 +7,7 @@ using System.Windows.Controls;
namespace ImageResizer.Views
{
class AutoDoubleValidationRule : ValidationRule
internal class AutoDoubleValidationRule : ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{

View file

@ -10,7 +10,7 @@ using System.Windows.Data;
namespace ImageResizer.Views
{
[ValueConversion(typeof(Enum), typeof(string))]
class BoolValueConverter : IValueConverter
internal class BoolValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
=> (bool)value ? Visibility.Visible : Visibility.Collapsed;

View file

@ -38,7 +38,9 @@ namespace ImageResizer.Views
var targetValue = Resources.ResourceManager.GetString(builder.ToString());
if (toLower)
{
targetValue = targetValue.ToLower();
}
return targetValue;
}

View file

@ -10,7 +10,9 @@ namespace ImageResizer.Views
public interface IMainView
{
void Close();
void ShowAdvanced(AdvancedViewModel viewModel);
IEnumerable<string> OpenPictureFiles();
}
}

View file

@ -28,11 +28,13 @@ namespace ImageResizer.Views
"|*.bmp;*.dib;*.exif;*.gif;*.jfif;*.jpe;*.jpeg;*.jpg;*.jxr;*.png;*.rle;*.tif;*.tiff;*.wdp|" +
AppResources.AllFilesFilter + "|*.*",
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
Multiselect = true
Multiselect = true,
};
if (openFileDialog.ShowDialog() != true)
{
return Enumerable.Empty<string>();
}
return openFileDialog.FileNames;
}

View file

@ -11,7 +11,7 @@ using ImageResizer.Properties;
namespace ImageResizer.Views
{
[ValueConversion(typeof(ResizeUnit), typeof(string))]
class ResizeUnitConverter : IValueConverter
internal class ResizeUnitConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{

View file

@ -11,7 +11,7 @@ using ImageResizer.Properties;
namespace ImageResizer.Views
{
[ValueConversion(typeof(TiffCompressOption), typeof(string))]
class TiffCompressOptionConverter : IValueConverter
internal class TiffCompressOptionConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
=> Resources.ResourceManager.GetString(

View file

@ -11,7 +11,7 @@ using ImageResizer.Properties;
namespace ImageResizer.Views
{
[ValueConversion(typeof(TimeSpan), typeof(string))]
class TimeRemainingConverter : IValueConverter
internal class TimeRemainingConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
@ -23,10 +23,12 @@ namespace ImageResizer.Views
{
builder.Append(timeRemaining.Hours == 1 ? "Hour" : "Hours");
}
if (timeRemaining.Hours != 0 || timeRemaining.Minutes > 0)
{
builder.Append(timeRemaining.Minutes == 1 ? "Minute" : "Minutes");
}
if (timeRemaining.Hours == 0)
{
builder.Append(timeRemaining.Seconds == 1 ? "Second" : "Seconds");

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>

View file

@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ImageResizer</RootNamespace>
<AssemblyName>ImageResizer.Test</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -21,6 +22,8 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>..\..\codeAnalysis\Rules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@ -29,6 +32,8 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>..\..\codeAnalysis\Rules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
@ -75,8 +80,22 @@
</Content>
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="..\..\codeAnalysis\StyleCop.json" />
<Compile Include="..\..\codeAnalysis\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
<Version>2.9.8</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Moq">
<Version>4.2.1510.2205</Version>
<Version>4.13.1</Version>
</PackageReference>
<PackageReference Include="MvvmLightLibs">
<Version>5.4.1.1</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>
@ -84,10 +103,10 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.ValueTuple">
<Version>4.4.0</Version>
<Version>4.5.0</Version>
</PackageReference>
<PackageReference Include="xunit.extensions">
<Version>1.9.2</Version>
<PackageReference Include="xunit">
<Version>2.4.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>

View file

@ -1,6 +1,6 @@
// <copyright file="CustomSizeTests.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
// Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
using ImageResizer.Properties;
using Xunit;

View file

@ -1,6 +1,6 @@
// <copyright file="ResizeBatchTests.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
// Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license.
// 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.Collections.Concurrent;
@ -17,7 +17,7 @@ namespace ImageResizer.Models
{
public class ResizeBatchTests
{
static readonly string EOL = Environment.NewLine;
private static readonly string EOL = Environment.NewLine;
[Fact]
public void FromCommandLine_works()
@ -28,7 +28,7 @@ namespace ImageResizer.Models
var args = new[]
{
"/d", "OutputDir",
"Image3.jpg"
"Image3.jpg",
};
var result = ResizeBatch.FromCommandLine(
@ -97,7 +97,7 @@ namespace ImageResizer.Models
Assert.True(calls.Any(c => c.i == 2 && c.count == 2));
}
static ResizeBatch CreateBatch(Action<string> executeAction)
private static ResizeBatch CreateBatch(Action<string> executeAction)
{
var mock = new Mock<ResizeBatch> { CallBase = true };
mock.Protected().Setup("Execute", ItExpr.IsAny<string>()).Callback(executeAction);

View file

@ -1,6 +1,6 @@
// <copyright file="ResizeOperationTests.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
// Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license.
// 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.Collections.ObjectModel;
@ -15,7 +15,7 @@ namespace ImageResizer.Models
{
public class ResizeOperationTests : IDisposable
{
readonly TestDirectory _directory = new TestDirectory();
private readonly TestDirectory _directory = new TestDirectory();
[Fact]
public void Execute_copies_frame_metadata()
@ -430,7 +430,7 @@ namespace ImageResizer.Models
public void Dispose()
=> _directory.Dispose();
Settings Settings(Action<Settings> action = null)
private Settings Settings(Action<Settings> action = null)
{
var settings = new Settings
{
@ -440,10 +440,10 @@ namespace ImageResizer.Models
{
Name = "Test",
Width = 96,
Height = 96
}
Height = 96,
},
},
SelectedSizeIndex = 0
SelectedSizeIndex = 0,
};
action?.Invoke(settings);

View file

@ -1,6 +1,6 @@
// <copyright file="ResizeSizeTests.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
// Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
using System.Collections.Generic;
using System.ComponentModel;
@ -35,7 +35,7 @@ namespace ImageResizer.Models
("$small$", Resources.Small),
("$medium$", Resources.Medium),
("$large$", Resources.Large),
("$phone$", Resources.Phone)
("$phone$", Resources.Phone),
};
foreach (var (name, expected) in args)
{
@ -95,7 +95,7 @@ namespace ImageResizer.Models
var size = new ResizeSize
{
Width = 0,
Height = 42
Height = 42,
};
Assert.True(size.HasAuto);
@ -107,7 +107,7 @@ namespace ImageResizer.Models
var size = new ResizeSize
{
Width = 42,
Height = 0
Height = 0,
};
Assert.True(size.HasAuto);
@ -119,7 +119,7 @@ namespace ImageResizer.Models
var size = new ResizeSize
{
Width = 42,
Height = 42
Height = 42,
};
Assert.False(size.HasAuto);
@ -145,7 +145,7 @@ namespace ImageResizer.Models
var size = new ResizeSize
{
Width = 1,
Unit = ResizeUnit.Inch
Unit = ResizeUnit.Inch,
};
var result = size.GetPixelWidth(100, 96);
@ -159,7 +159,7 @@ namespace ImageResizer.Models
var size = new ResizeSize
{
Height = 1,
Unit = ResizeUnit.Inch
Unit = ResizeUnit.Inch,
};
var result = size.GetPixelHeight(100, 96);
@ -191,7 +191,7 @@ namespace ImageResizer.Models
var size = new ResizeSize
{
Width = 0,
Fit = ResizeFit.Fit
Fit = ResizeFit.Fit,
};
var result = size.GetPixelWidth(100, 96);
@ -205,7 +205,7 @@ namespace ImageResizer.Models
var size = new ResizeSize
{
Width = 0,
Fit = ResizeFit.Fill
Fit = ResizeFit.Fill,
};
var result = size.GetPixelWidth(100, 96);
@ -219,7 +219,7 @@ namespace ImageResizer.Models
var size = new ResizeSize
{
Width = 0.5,
Unit = ResizeUnit.Inch
Unit = ResizeUnit.Inch,
};
var result = size.GetPixelWidth(100, 96);
@ -233,7 +233,7 @@ namespace ImageResizer.Models
var size = new ResizeSize
{
Width = 1,
Unit = ResizeUnit.Centimeter
Unit = ResizeUnit.Centimeter,
};
var result = size.GetPixelWidth(100, 96);
@ -247,7 +247,7 @@ namespace ImageResizer.Models
var size = new ResizeSize
{
Width = 50,
Unit = ResizeUnit.Percent
Unit = ResizeUnit.Percent,
};
var result = size.GetPixelWidth(200, 96);
@ -261,7 +261,7 @@ namespace ImageResizer.Models
var size = new ResizeSize
{
Width = 50,
Unit = ResizeUnit.Pixel
Unit = ResizeUnit.Pixel,
};
var result = size.GetPixelWidth(100, 96);

View file

@ -1,6 +1,6 @@
// <copyright file="SettingsTests.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
// Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
using System.Collections.ObjectModel;
using System.Collections.Specialized;
@ -20,7 +20,7 @@ namespace ImageResizer.Properties
var settings = new Settings
{
Sizes = new ObservableCollection<ResizeSize>(),
CustomSize = new CustomSize()
CustomSize = new CustomSize(),
};
var ncc = (INotifyCollectionChanged)settings.AllSizes;
@ -38,7 +38,7 @@ namespace ImageResizer.Properties
var settings = new Settings
{
Sizes = new ObservableCollection<ResizeSize>(),
CustomSize = new CustomSize()
CustomSize = new CustomSize(),
};
Assert.PropertyChanged(
@ -53,7 +53,7 @@ namespace ImageResizer.Properties
var settings = new Settings
{
Sizes = new ObservableCollection<ResizeSize> { new ResizeSize() },
CustomSize = new CustomSize()
CustomSize = new CustomSize(),
};
Assert.Contains(settings.Sizes[0], settings.AllSizes);
@ -65,7 +65,7 @@ namespace ImageResizer.Properties
var settings = new Settings
{
Sizes = new ObservableCollection<ResizeSize>(),
CustomSize = new CustomSize()
CustomSize = new CustomSize(),
};
Assert.Contains(settings.CustomSize, settings.AllSizes);
@ -78,7 +78,7 @@ namespace ImageResizer.Properties
var settings = new Settings
{
Sizes = new ObservableCollection<ResizeSize>(),
CustomSize = originalCustomSize
CustomSize = originalCustomSize,
};
var ncc = (INotifyCollectionChanged)settings.AllSizes;
@ -116,7 +116,7 @@ namespace ImageResizer.Properties
{
SelectedSizeIndex = index,
Sizes = new ObservableCollection<ResizeSize>(),
CustomSize = new CustomSize()
CustomSize = new CustomSize(),
};
var result = settings.SelectedSize;
@ -132,8 +132,8 @@ namespace ImageResizer.Properties
SelectedSizeIndex = 0,
Sizes = new ObservableCollection<ResizeSize>
{
new ResizeSize()
}
new ResizeSize(),
},
};
var result = settings.SelectedSize;

View file

@ -1,6 +1,6 @@
// <copyright file="AssertEx.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
// Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license.
// 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.Collections.Generic;
@ -12,7 +12,7 @@ using Xunit;
namespace ImageResizer.Test
{
static class AssertEx
internal static class AssertEx
{
public static void All<T>(IEnumerable<T> collection, Action<T> action)
{
@ -80,6 +80,7 @@ namespace ImageResizer.Test
}
public object Sender { get; }
public TArgs Arguments { get; }
}
}

View file

@ -1,6 +1,6 @@
// <copyright file="BitmapSourceExtensions.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
// Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
using System.Windows;
using System.Windows.Media;
@ -8,7 +8,7 @@ using System.Windows.Media.Imaging;
namespace ImageResizer.Test
{
static class BitmapSourceExtensions
internal static class BitmapSourceExtensions
{
public static Color GetFirstPixel(this BitmapSource source)
{

View file

@ -1,6 +1,6 @@
// <copyright file="TestDirectory.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
// Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license.
// 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.Collections.Generic;
@ -15,7 +15,7 @@ namespace ImageResizer
{
public class TestDirectory : IDisposable
{
readonly string _path;
private readonly string _path;
public TestDirectory()
{
@ -25,7 +25,7 @@ namespace ImageResizer
Directory.CreateDirectory(_path);
}
IEnumerable<string> Files
private IEnumerable<string> Files
=> Directory.EnumerateFiles(_path);
public IEnumerable<string> FileNames

View file

@ -1,6 +1,6 @@
// <copyright file="TimeRemainingConverterTests.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
// Copyright (c) Brice Lambson
// The Brice Lambson licenses this file to you under the MIT license.
// 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;