ImageResizerSettings.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; 6 using System.Text.Json; 7 using System.Text.Json.Serialization; 8 9 using Microsoft.PowerToys.Settings.UI.Library.Interfaces; 10 11 namespace Microsoft.PowerToys.Settings.UI.Library 12 { 13 public class ImageResizerSettings : BasePTModuleSettings, ISettingsConfig 14 { 15 public const string ModuleName = "Image Resizer"; 16 17 private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions 18 { 19 WriteIndented = true, 20 }; 21 22 [JsonPropertyName("properties")] 23 public ImageResizerProperties Properties { get; set; } 24 25 public ImageResizerSettings() 26 { 27 Version = "1"; 28 Name = ModuleName; 29 Properties = new ImageResizerProperties(); 30 } 31 32 public ImageResizerSettings(Func<string, string> resourceLoader) 33 : this() 34 { 35 Properties = new ImageResizerProperties(resourceLoader); 36 } 37 38 public override string ToJsonString() 39 { 40 return JsonSerializer.Serialize(this, SettingsSerializationContext.Default.ImageResizerSettings); 41 } 42 43 public string GetModuleName() 44 { 45 return Name; 46 } 47 48 // This can be utilized in the future if the settings.json file is to be modified/deleted. 49 public bool UpgradeSettingsConfiguration() 50 { 51 return false; 52 } 53 } 54 }