/ src / settings-ui / Settings.UI.Library / AdvancedPastePasteAsFileAction.cs
AdvancedPastePasteAsFileAction.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.Generic;
 6  using System.Text.Json.Serialization;
 7  
 8  using Microsoft.PowerToys.Settings.UI.Library.Helpers;
 9  
10  namespace Microsoft.PowerToys.Settings.UI.Library;
11  
12  public sealed class AdvancedPastePasteAsFileAction : Observable, IAdvancedPasteAction
13  {
14      public static class PropertyNames
15      {
16          public const string PasteAsTxtFile = "paste-as-txt-file";
17          public const string PasteAsPngFile = "paste-as-png-file";
18          public const string PasteAsHtmlFile = "paste-as-html-file";
19      }
20  
21      private AdvancedPasteAdditionalAction _pasteAsTxtFile = new();
22      private AdvancedPasteAdditionalAction _pasteAsPngFile = new();
23      private AdvancedPasteAdditionalAction _pasteAsHtmlFile = new();
24      private bool _isShown = true;
25  
26      [JsonPropertyName("isShown")]
27      public bool IsShown
28      {
29          get => _isShown;
30          set => Set(ref _isShown, value);
31      }
32  
33      [JsonPropertyName(PropertyNames.PasteAsTxtFile)]
34      public AdvancedPasteAdditionalAction PasteAsTxtFile
35      {
36          get => _pasteAsTxtFile;
37          init => Set(ref _pasteAsTxtFile, value ?? new());
38      }
39  
40      [JsonPropertyName(PropertyNames.PasteAsPngFile)]
41      public AdvancedPasteAdditionalAction PasteAsPngFile
42      {
43          get => _pasteAsPngFile;
44          init => Set(ref _pasteAsPngFile, value ?? new());
45      }
46  
47      [JsonPropertyName(PropertyNames.PasteAsHtmlFile)]
48      public AdvancedPasteAdditionalAction PasteAsHtmlFile
49      {
50          get => _pasteAsHtmlFile;
51          init => Set(ref _pasteAsHtmlFile, value ?? new());
52      }
53  
54      [JsonIgnore]
55      public IEnumerable<IAdvancedPasteAction> SubActions => [PasteAsTxtFile, PasteAsPngFile, PasteAsHtmlFile];
56  }