ImageresizerSizes.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Collections.ObjectModel; 6 using System.Text.Json; 7 using System.Text.Json.Serialization; 8 9 namespace Microsoft.PowerToys.Settings.UI.Library 10 { 11 public class ImageResizerSizes 12 { 13 private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions 14 { 15 WriteIndented = true, 16 }; 17 18 // Suppressing this warning because removing the setter breaks 19 // deserialization with System.Text.Json. This affects the UI display. 20 // See: https://github.com/dotnet/runtime/issues/30258 21 [JsonPropertyName("value")] 22 public ObservableCollection<ImageSize> Value { get; set; } 23 24 public ImageResizerSizes() 25 { 26 Value = new ObservableCollection<ImageSize>(); 27 } 28 29 public ImageResizerSizes(ObservableCollection<ImageSize> value) 30 { 31 Value = value; 32 } 33 34 public string ToJsonString() 35 { 36 var options = _serializerOptions; 37 return JsonSerializer.Serialize(this, options); 38 } 39 } 40 }