Skip to content

Commit

Permalink
Adjusting settings to leverage base class (#5127)
Browse files Browse the repository at this point in the history
* renaming / deleting file

* adding in base class

Co-authored-by: Clint Rutkas <crutkas@microsoft.com>
  • Loading branch information
crutkas and Clint Rutkas committed Jul 21, 2020
1 parent d01b93a commit 398991f
Show file tree
Hide file tree
Showing 30 changed files with 202 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
// See the LICENSE file in the project root for more information.

using System.Text.Json;
using System.Text.Json.Serialization;

namespace Microsoft.PowerToys.Settings.UI.Lib
{
public abstract class BasePTModuleSettings
{
// Gets or sets name of the powertoy module.
public string name { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }

// Gets or sets the powertoys version.
public string version { get; set; }
[JsonPropertyName("version")]
public string Version { get; set; }

// converts the current to a json string.
public virtual string ToJsonString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,22 @@
// See the LICENSE file in the project root for more information.

using System.Text.Json;
using System.Text.Json.Serialization;

namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class ColorPickerSettings : BasePTModuleSettings
{
public const string ModuleName = "ColorPicker";

public ColorPickerProperties properties { get; set; }
[JsonPropertyName("properties")]
public ColorPickerProperties Properties { get; set; }

public ColorPickerSettings()
{
properties = new ColorPickerProperties();
version = "1";
name = ModuleName;
}

public override string ToJsonString()
{
return JsonSerializer.Serialize(this);
Properties = new ColorPickerProperties();
Version = "1";
Name = ModuleName;
}

public virtual void Save()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public FZConfigProperties()
this.FancyzonesShowOnAllMonitors = new BoolProperty();
this.FancyzonesZoneHighlightColor = new StringProperty(ConfigDefaults.DefaultFancyZonesZoneHighlightColor);
this.FancyzonesHighlightOpacity = new IntProperty(50);
this.FancyzonesEditorHotkey = new KeyBoardKeysProperty(
this.FancyzonesEditorHotkey = new KeyboardKeysProperty(
new HotkeySettings()
{
Win = true,
Expand Down Expand Up @@ -82,7 +82,7 @@ public FZConfigProperties()
public IntProperty FancyzonesHighlightOpacity { get; set; }

[JsonPropertyName("fancyzones_editor_hotkey")]
public KeyBoardKeysProperty FancyzonesEditorHotkey { get; set; }
public KeyboardKeysProperty FancyzonesEditorHotkey { get; set; }

[JsonPropertyName("fancyzones_excluded_apps")]
public StringProperty FancyzonesExcludedApps { get; set; }
Expand Down
23 changes: 4 additions & 19 deletions src/core/Microsoft.PowerToys.Settings.UI.Lib/FancyZonesSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,20 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class FancyZonesSettings
public class FancyZonesSettings : BasePTModuleSettings
{
public FancyZonesSettings()
{
this.Version = string.Empty;
this.Name = string.Empty;
this.Properties = new FZConfigProperties();
Version = string.Empty;
Name = string.Empty;
Properties = new FZConfigProperties();
}

[JsonPropertyName("version")]
public string Version { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("properties")]
public FZConfigProperties Properties { get; set; }

public string ToJsonString()
{
return JsonSerializer.Serialize(this);
}
}
}
19 changes: 0 additions & 19 deletions src/core/Microsoft.PowerToys.Settings.UI.Lib/IPowerToySettings.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ImageResizerProperties()
ImageresizerTiffCompressOption = new IntProperty();
ImageresizerFileName = new StringProperty("%1 (%2)");

ImageresizerSizes = new ImageresizerSizes(new ObservableCollection<ImageSize>()
ImageresizerSizes = new ImageResizerSizes(new ObservableCollection<ImageSize>()
{
new ImageSize(0, "Small", ResizeFit.Fit, 854, 480, ResizeUnit.Pixel),
new ImageSize(1, "Medium", ResizeFit.Fit, 1366, 768, ResizeUnit.Pixel),
Expand All @@ -32,7 +32,7 @@ public ImageResizerProperties()

ImageresizerKeepDateModified = new BoolProperty();
ImageresizerFallbackEncoder = new StringProperty(new System.Guid("19e4a5aa-5662-4fc5-a0c0-1758028e1057").ToString());
ImageresizerCustomSize = new ImageresizerCustomSizeProperty(new ImageSize(4, "custom", ResizeFit.Fit, 1024, 640, ResizeUnit.Pixel));
ImageresizerCustomSize = new ImageResizerCustomSizeProperty(new ImageSize(4, "custom", ResizeFit.Fit, 1024, 640, ResizeUnit.Pixel));
}

[JsonPropertyName("imageresizer_selectedSizeIndex")]
Expand Down Expand Up @@ -60,7 +60,7 @@ public ImageResizerProperties()
public StringProperty ImageresizerFileName { get; set; }

[JsonPropertyName("imageresizer_sizes")]
public ImageresizerSizes ImageresizerSizes { get; set; }
public ImageResizerSizes ImageresizerSizes { get; set; }

[JsonPropertyName("imageresizer_keepDateModified")]
public BoolProperty ImageresizerKeepDateModified { get; set; }
Expand All @@ -69,7 +69,7 @@ public ImageResizerProperties()
public StringProperty ImageresizerFallbackEncoder { get; set; }

[JsonPropertyName("imageresizer_customSize")]
public ImageresizerCustomSizeProperty ImageresizerCustomSize { get; set; }
public ImageResizerCustomSizeProperty ImageresizerCustomSize { get; set; }

public string ToJsonString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,26 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class ImageResizerSettings
public class ImageResizerSettings : BasePTModuleSettings
{
[JsonPropertyName("version")]
public string Version { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }
public const string ModuleName = "Image Resizer";

[JsonPropertyName("properties")]
public ImageResizerProperties Properties { get; set; }

public ImageResizerSettings()
{
this.Version = "1";
this.Name = "Image Resizer";
this.Properties = new ImageResizerProperties();
Version = "1";
Name = ModuleName;
Properties = new ImageResizerProperties();
}

public string ToJsonString()
public override string ToJsonString()
{
var options = new JsonSerializerOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Text.Json.Serialization;

namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class ImagerResizerKeepDateModified
{
[JsonPropertyName("value")]
public bool Value { get; set; }

public ImagerResizerKeepDateModified()
{
Value = false;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Text.Json.Serialization;

namespace Microsoft.PowerToys.Settings.UI.Lib
{

public class ImageresizerCustomSizeProperty
public class ImageResizerCustomSizeProperty
{
[JsonPropertyName("value")]
public ImageSize Value { get; set; }

public ImageresizerCustomSizeProperty()
public ImageResizerCustomSizeProperty()
{
this.Value = new ImageSize();
Value = new ImageSize();
}

public ImageresizerCustomSizeProperty(ImageSize value)
public ImageResizerCustomSizeProperty(ImageSize value)
{
Value = value;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Text.Json.Serialization;

namespace Microsoft.PowerToys.Settings.UI.Lib
{

public class ImageresizerFallbackEncoder
public class ImageResizerFallbackEncoder
{
[JsonPropertyName("value")]
public string Value { get; set; }

public ImageresizerFallbackEncoder()
public ImageResizerFallbackEncoder()
{
this.Value = string.Empty;
Value = string.Empty;
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Microsoft.PowerToys.Settings.UI.Lib
{

public class ImageresizerSizes
public class ImageResizerSizes
{
[JsonPropertyName("value")]
public ObservableCollection<ImageSize> Value { get; set; }

public ImageresizerSizes()
public ImageResizerSizes()
{
this.Value = new ObservableCollection<ImageSize>();
Value = new ObservableCollection<ImageSize>();
}

public ImageresizerSizes(ObservableCollection<ImageSize> value)
public ImageResizerSizes(ObservableCollection<ImageSize> value)
{
Value = value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;

namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class KeyBoardKeysProperty
public class KeyboardKeysProperty
{
public KeyBoardKeysProperty()
public KeyboardKeysProperty()
{
this.Value = new HotkeySettings();
Value = new HotkeySettings();
}

public KeyBoardKeysProperty(HotkeySettings hkSettings)
public KeyboardKeysProperty(HotkeySettings hkSettings)
{
this.Value = hkSettings;
Value = hkSettings;
}

[JsonPropertyName("value")]
Expand Down

0 comments on commit 398991f

Please sign in to comment.