[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:
Clint Rutkas
2020-10-01 11:33:23 -07:00
committed by GitHub
parent 19b519638f
commit c219fe0d1d
21 changed files with 141 additions and 112 deletions

View File

@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Threading;
using System.Windows.Media.Imaging;
@@ -18,7 +19,7 @@ using Newtonsoft.Json.Serialization;
namespace ImageResizer.Properties
{
[JsonObject(MemberSerialization.OptIn)]
public partial class Settings : IDataErrorInfo, INotifyPropertyChanged
public sealed partial class Settings : IDataErrorInfo, INotifyPropertyChanged
{
// Used to synchronize access to the settings.json file
private static Mutex _jsonMutex = new Mutex();
@@ -32,7 +33,6 @@ namespace ImageResizer.Properties
private PngInterlaceOption _pngInterlaceOption;
private TiffCompressOption _tiffCompressOption;
private string _fileName;
private ObservableCollection<ImageResizer.Models.ResizeSize> _sizes;
private bool _keepDateModified;
private System.Guid _fallbackEncoder;
private CustomSize _customSize;
@@ -92,7 +92,12 @@ namespace ImageResizer.Properties
}
string IDataErrorInfo.Error
=> string.Empty;
{
get
{
return string.Empty;
}
}
string IDataErrorInfo.this[string columnName]
{
@@ -105,7 +110,7 @@ namespace ImageResizer.Properties
if (JpegQualityLevel < 1 || JpegQualityLevel > 100)
{
return string.Format(Resources.ValueMustBeBetween, 1, 100);
return string.Format(CultureInfo.CurrentCulture, Resources.ValueMustBeBetween, 1, 100);
}
return string.Empty;
@@ -306,7 +311,7 @@ namespace ImageResizer.Properties
{
if (string.IsNullOrWhiteSpace(value))
{
throw new System.ArgumentNullException();
throw new System.ArgumentNullException(nameof(FileName));
}
_fileName = value;
@@ -315,15 +320,7 @@ namespace ImageResizer.Properties
}
[JsonProperty(PropertyName = "imageresizer_sizes")]
public ObservableCollection<ResizeSize> Sizes
{
get => _sizes;
set
{
_sizes = value;
NotifyPropertyChanged();
}
}
public ObservableCollection<ResizeSize> Sizes { get; private set; }
[JsonProperty(PropertyName = "imageresizer_keepDateModified")]
public bool KeepDateModified
@@ -423,12 +420,18 @@ namespace ImageResizer.Properties
PngInterlaceOption = jsonSettings.PngInterlaceOption;
TiffCompressOption = jsonSettings.TiffCompressOption;
FileName = jsonSettings.FileName;
Sizes = jsonSettings.Sizes;
KeepDateModified = jsonSettings.KeepDateModified;
FallbackEncoder = jsonSettings.FallbackEncoder;
CustomSize = jsonSettings.CustomSize;
SelectedSizeIndex = jsonSettings.SelectedSizeIndex;
if (jsonSettings.Sizes.Count > 0)
{
Sizes.Clear();
Sizes.AddRange(jsonSettings.Sizes);
}
});
_jsonMutex.ReleaseMutex();
}
}