diff --git a/PowerToys.sln b/PowerToys.sln
index 322e2eeb38..0fe9d331db 100644
--- a/PowerToys.sln
+++ b/PowerToys.sln
@@ -188,8 +188,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "powerpreviewTest", "src\mod
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{C3081D9A-1586-441A-B5F4-ED815B3719C1}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Settings.Test", "src\core\Microsoft.PowerToys.Settings.Test\Microsoft.PowerToys.Settings.Test.csproj", "{6F2B5799-36AE-4D10-9DCF-B19CD26A5DBC}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Settings.UI.Runner", "src\core\Microsoft.PowerToys.Settings.UI.Runner\Microsoft.PowerToys.Settings.UI.Runner.csproj", "{E4E0D2AE-B17D-4BD4-8BEE-AFC8CC464C5F}"
ProjectSection(ProjectDependencies) = postProject
{F88B6FD1-14BD-48DB-85C2-6C51B8045121} = {F88B6FD1-14BD-48DB-85C2-6C51B8045121}
@@ -209,6 +207,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.PowerToys.Settings.UI.Lib", "src\core\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj", "{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.PowerToys.Settings.UnitTest", "src\core\Microsoft.PowerToys.Settings.UnitTest\Microsoft.PowerToys.Settings.UnitTest.csproj", "{A80355C2-780D-4245-BD80-25B8DE698EE3}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -367,10 +367,6 @@ Global
{47310AB4-9034-4BD1-8D8B-E88AD21A171B}.Debug|x64.Build.0 = Debug|x64
{47310AB4-9034-4BD1-8D8B-E88AD21A171B}.Release|x64.ActiveCfg = Release|x64
{47310AB4-9034-4BD1-8D8B-E88AD21A171B}.Release|x64.Build.0 = Release|x64
- {6F2B5799-36AE-4D10-9DCF-B19CD26A5DBC}.Debug|x64.ActiveCfg = Debug|x64
- {6F2B5799-36AE-4D10-9DCF-B19CD26A5DBC}.Debug|x64.Build.0 = Debug|x64
- {6F2B5799-36AE-4D10-9DCF-B19CD26A5DBC}.Release|x64.ActiveCfg = Release|x64
- {6F2B5799-36AE-4D10-9DCF-B19CD26A5DBC}.Release|x64.Build.0 = Release|x64
{E4E0D2AE-B17D-4BD4-8BEE-AFC8CC464C5F}.Debug|x64.ActiveCfg = Debug|x64
{E4E0D2AE-B17D-4BD4-8BEE-AFC8CC464C5F}.Debug|x64.Build.0 = Debug|x64
{E4E0D2AE-B17D-4BD4-8BEE-AFC8CC464C5F}.Release|x64.ActiveCfg = Release|x64
@@ -389,8 +385,14 @@ Global
{C073B057-B157-40F0-8678-1DCD119D841C}.Release|x64.ActiveCfg = Release|x64
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|x64.ActiveCfg = Debug|x64
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|x64.Build.0 = Debug|x64
- {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x64.ActiveCfg = Release|Any CPU
- {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x64.Build.0 = Release|Any CPU
+ {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x64.ActiveCfg = Release|x64
+ {B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x64.Build.0 = Release|x64
+ {A80355C2-780D-4245-BD80-25B8DE698EE3}.Debug|x64.ActiveCfg = Debug|x64
+ {A80355C2-780D-4245-BD80-25B8DE698EE3}.Debug|x64.Build.0 = Debug|x64
+ {A80355C2-780D-4245-BD80-25B8DE698EE3}.Debug|x64.Deploy.0 = Debug|x64
+ {A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x64.ActiveCfg = Release|x64
+ {A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x64.Build.0 = Release|x64
+ {A80355C2-780D-4245-BD80-25B8DE698EE3}.Release|x64.Deploy.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -438,12 +440,12 @@ Global
{748417CA-F17E-487F-9411-CAFB6D3F4877} = {2F305555-C296-497E-AC20-5FA1B237996A}
{217DF501-135C-4E38-BFC8-99D4821032EA} = {2F305555-C296-497E-AC20-5FA1B237996A}
{47310AB4-9034-4BD1-8D8B-E88AD21A171B} = {2F305555-C296-497E-AC20-5FA1B237996A}
- {6F2B5799-36AE-4D10-9DCF-B19CD26A5DBC} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
{E4E0D2AE-B17D-4BD4-8BEE-AFC8CC464C5F} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
{F88B6FD1-14BD-48DB-85C2-6C51B8045121} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
{A7D5099E-F0FD-4BF3-8522-5A682759F915} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
{C073B057-B157-40F0-8678-1DCD119D841C} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
+ {A80355C2-780D-4245-BD80-25B8DE698EE3} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
diff --git a/src/core/Microsoft.PowerToys.Settings.Test/Microsoft.PowerToys.Settings.Test.csproj b/src/core/Microsoft.PowerToys.Settings.Test/Microsoft.PowerToys.Settings.Test.csproj
deleted file mode 100644
index dd59020c85..0000000000
--- a/src/core/Microsoft.PowerToys.Settings.Test/Microsoft.PowerToys.Settings.Test.csproj
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
- netcoreapp3.1
-
- false
-
- x64
-
-
-
-
-
-
-
-
-
-
diff --git a/src/core/Microsoft.PowerToys.Settings.Test/UnitTest1.cs b/src/core/Microsoft.PowerToys.Settings.Test/UnitTest1.cs
deleted file mode 100644
index 90cb7f0276..0000000000
--- a/src/core/Microsoft.PowerToys.Settings.Test/UnitTest1.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-
-namespace Microsoft.PowerToys.Settings.Test
-{
- [TestClass]
- public class UnitTest1
- {
- [TestMethod]
- public void TestMethod1()
- {
- }
- }
-}
diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/FZConfigProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/FZConfigProperties.cs
index 202a45f612..146a5b2ac3 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/FZConfigProperties.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/FZConfigProperties.cs
@@ -22,6 +22,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
this.FancyzonesHighlightOpacity = new IntProperty();
this.FancyzonesEditorHotkey = new KeyBoardKeysProperty();
this.FancyzonesExcludedApps = new StringProperty();
+ this.FancyzonesInActiveColor = new StringProperty();
+ this.FancyzonesBorderColor = new StringProperty();
}
[JsonPropertyName("fancyzones_shiftDrag")]
@@ -62,5 +64,11 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonPropertyName("fancyzones_excluded_apps")]
public StringProperty FancyzonesExcludedApps { get; set; }
+
+ [JsonPropertyName("fancyzones_zoneBorderColor")]
+ public StringProperty FancyzonesBorderColor { get; set; }
+
+ [JsonPropertyName("fancyzones_zoneColor")]
+ public StringProperty FancyzonesInActiveColor { get; set; }
}
}
diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameLocalProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameLocalProperties.cs
new file mode 100644
index 0000000000..4b38605576
--- /dev/null
+++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameLocalProperties.cs
@@ -0,0 +1,53 @@
+// 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;
+using System.Text.Json.Serialization;
+
+namespace Microsoft.PowerToys.Settings.UI.Lib
+{
+
+ public class PowerRenameLocalProperties
+ {
+ public PowerRenameLocalProperties()
+ {
+ PersistState = false;
+ MRUEnabled = false;
+ MaxMRUSize = 0;
+ ShowIcon = false;
+ ExtendedContextMenuOnly = false;
+ }
+
+ private int _maxSize;
+
+ public bool PersistState { get; set; }
+
+ public bool MRUEnabled { get; set; }
+
+ public int MaxMRUSize
+ {
+ get
+ {
+ return _maxSize;
+ }
+
+ set
+ {
+ if (value < 0)
+ {
+ _maxSize = 0;
+ }
+ }
+ }
+
+ public bool ShowIcon { get; set; }
+
+ public bool ExtendedContextMenuOnly { get; set; }
+
+ public string ToJsonString()
+ {
+ return JsonSerializer.Serialize(this);
+ }
+ }
+}
diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameProperties.cs
index 3f502b02d1..99bc3bd1f8 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameProperties.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameProperties.cs
@@ -10,26 +10,26 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{
public PowerRenameProperties()
{
- PersistInput = new BoolProperty();
- MruEnabled = new BoolProperty();
- MaxMruSize = new IntProperty();
- ShowIconInMenu = new BoolProperty();
- ShowExtendedMenu = new BoolProperty();
+ PersistState = new BoolProperty();
+ MRUEnabled = new BoolProperty();
+ MaxMRUSize = new IntProperty();
+ ShowIcon = new BoolProperty();
+ ExtendedContextMenuOnly = new BoolProperty();
}
[JsonPropertyName("bool_persist_input")]
- public BoolProperty PersistInput { get; set; }
+ public BoolProperty PersistState { get; set; }
[JsonPropertyName("bool_mru_enabled")]
- public BoolProperty MruEnabled { get; set; }
+ public BoolProperty MRUEnabled { get; set; }
[JsonPropertyName("int_max_mru_size")]
- public IntProperty MaxMruSize { get; set; }
+ public IntProperty MaxMRUSize { get; set; }
[JsonPropertyName("bool_show_icon_on_menu")]
- public BoolProperty ShowIconInMenu { get; set; }
+ public BoolProperty ShowIcon { get; set; }
[JsonPropertyName("bool_show_extended_menu")]
- public BoolProperty ShowExtendedMenu { get; set; }
+ public BoolProperty ExtendedContextMenuOnly { get; set; }
}
}
diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameSettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameSettings.cs
index ca18535027..cfeecf40c6 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameSettings.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/PowerRenameSettings.cs
@@ -15,7 +15,20 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{
properties = new PowerRenameProperties();
version = "1";
- name = "_unset_";
+ name = "PowerRename";
+ }
+
+ public PowerRenameSettings(PowerRenameLocalProperties localProperties)
+ {
+ properties = new PowerRenameProperties();
+ properties.PersistState.Value = localProperties.PersistState;
+ properties.MRUEnabled.Value = localProperties.MRUEnabled;
+ properties.MaxMRUSize.Value = localProperties.MaxMRUSize;
+ properties.ShowIcon.Value = localProperties.ShowIcon;
+ properties.ExtendedContextMenuOnly.Value = localProperties.ExtendedContextMenuOnly;
+
+ version = "1";
+ name = "PowerRename";
}
public PowerRenameSettings(string ptName)
diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SettingsUtils.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SettingsUtils.cs
index 2ed273cae5..5a60a913ff 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/SettingsUtils.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/SettingsUtils.cs
@@ -10,6 +10,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{
public static class SettingsUtils
{
+ private const string DefaultFileName = "settings.json";
+
public static bool SettingsFolderExists(string powertoy)
{
return Directory.Exists(Path.Combine(LocalApplicationDataFolder(), $"Microsoft\\PowerToys\\{powertoy}"));
@@ -24,50 +26,56 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
/// Get path to the json settings file.
///
/// string path.
- public static string GetSettingsPath(string powertoy)
+ public static string GetSettingsPath(string powertoy, string fileName = DefaultFileName)
{
if (string.IsNullOrWhiteSpace(powertoy))
{
return Path.Combine(
LocalApplicationDataFolder(),
- $"Microsoft\\PowerToys\\settings.json");
+ $"Microsoft\\PowerToys\\{fileName}");
}
return Path.Combine(
LocalApplicationDataFolder(),
- $"Microsoft\\PowerToys\\{powertoy}\\settings.json");
+ $"Microsoft\\PowerToys\\{powertoy}\\{fileName}");
}
- public static bool SettingsExists(string powertoy)
+ public static bool SettingsExists(string powertoy, string fileName = DefaultFileName)
{
- return File.Exists(GetSettingsPath(powertoy));
+ return File.Exists(GetSettingsPath(powertoy, fileName));
}
///
/// Get a Deserialized object of the json settings string.
///
/// Deserialized json settings object.
- public static T GetSettings(string powertoy)
+ public static T GetSettings(string powertoy, string fileName = DefaultFileName)
{
- var jsonSettingsString = File.ReadAllText(GetSettingsPath(powertoy));
+ var jsonSettingsString = File.ReadAllText(GetSettingsPath(powertoy, fileName));
return JsonSerializer.Deserialize(jsonSettingsString);
}
// Save settings to a json file.
- public static void SaveSettings(string jsonSettings, string powertoy)
+ public static void SaveSettings(string jsonSettings, string powertoy, string fileName = DefaultFileName)
{
- if (jsonSettings != null)
+ try
{
- if (!SettingsFolderExists(powertoy))
+ if (jsonSettings != null)
{
- CreateSettingsFolder(powertoy);
- }
+ if (!SettingsFolderExists(powertoy))
+ {
+ CreateSettingsFolder(powertoy);
+ }
- File.WriteAllText(GetSettingsPath(powertoy), jsonSettings);
+ File.WriteAllText(GetSettingsPath(powertoy, fileName), jsonSettings);
+ }
+ }
+ catch
+ {
}
}
- private static string LocalApplicationDataFolder()
+ public static string LocalApplicationDataFolder()
{
return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
}
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj b/src/core/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj
index f9952423e5..3bdd7f46a3 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj
+++ b/src/core/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj
@@ -72,6 +72,7 @@
+
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw b/src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw
index 87d0ed056f..0b49b12b8d 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw
+++ b/src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw
@@ -134,7 +134,7 @@
Navigation view item name for General
- PowerLauncher
+ PowerLauncher [Not Functional]
Navigation view item name for PowerLauncher
@@ -142,7 +142,7 @@
Navigation view item name for PowerRename
- Shortcut Guide
+ Shortcut Guide [Not Functional]
Navigation view item name for Shortcut Guide
@@ -154,7 +154,7 @@
Navigation view item name for FancyZones
- Image Resizer
+ Image Resizer [Not Functional]
Navigation view item name for Image Resizer
@@ -290,8 +290,8 @@
Override Windows Snap hotkeys (Win + arrow) to move windows between zones
-
- Save Color Choice
+
+ Save Zone Highlight Color Choice
Hold Shift key or any non-primary mouse button to enable zones while dragging
@@ -320,4 +320,94 @@
Module overview
+
+ Attribution
+
+
+ About PowerToys
+
+
+ Check for updates
+
+
+ Privacy statement
+
+
+ Dark
+
+
+ System default
+
+
+ Light
+
+
+ Report a bug
+
+
+ Request a feature
+
+
+ Restart as admin
+
+
+ Run at startup
+
+
+ Miscellaneous
+
+
+ A Windows Shell Extension for more advanced bulk renaming using search and replace or regular expressions.
+
+
+ Shell integration
+
+
+ Enable PowerRename
+
+
+ Theme
+
+
+ Show on default context menu
+
+
+ Only show on extended context menu (Shift + Right-click)
+
+
+ Maximum numbers of items to show in recently used list
+
+
+ Restore search, replace and flags values on launch from previous run
+
+
+ Markdown Preview Handler
+
+
+ Svg Preview Handler
+
+
+ These settings allow you to manage your Windows File Explorer custom preview handlers.
+
+
+ Miscellaneous
+
+
+ Open-source notice
+
+
+ Enable Auto Complete
+
+
+ Zone border color (Default #FFFFFF)
+
+
+ Zone inactive color (Default #F5FCFF)
+
+
+ Save Zone Border Color Choice
+
+
+ Save Zone Inactive Color Choice
+
\ No newline at end of file
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/FancyZonesViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/FancyZonesViewModel.cs
index 031b14f3c9..546deb025a 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/FancyZonesViewModel.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/FancyZonesViewModel.cs
@@ -20,11 +20,27 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public ButtonClickCommand LaunchEditorEventHandler { get; set; }
- public ICommand SaveColorChoiceEventHandler
+ public ICommand SaveZoneHighlightColorEventHandler
{
get
{
- return new RelayCommand(SaveColorChoice);
+ return new RelayCommand(SaveZoneHighlightColor);
+ }
+ }
+
+ public ICommand SaveBorderColorEventHandler
+ {
+ get
+ {
+ return new RelayCommand(SaveZoneBorderColor);
+ }
+ }
+
+ public ICommand SaveInActiveColorEventHandler
+ {
+ get
+ {
+ return new RelayCommand(SaveZoneInActiveColor);
}
}
@@ -32,9 +48,17 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public FancyZonesViewModel()
{
- Settings = SettingsUtils.GetSettings(ModuleName);
+ try
+ {
+ Settings = SettingsUtils.GetSettings(ModuleName);
+ }
+ catch
+ {
+ Settings = new FancyZonesSettings();
+ SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
+ }
+
this.LaunchEditorEventHandler = new ButtonClickCommand(LaunchEditor);
- // this.SaveColorChoiceEventHandler = new ButtonClickCommand(SaveColorChoice);
this._shiftDrag = Settings.Properties.FancyzonesShiftDrag.Value;
this._overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value;
@@ -49,8 +73,20 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
this._highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value;
this._excludedApps = Settings.Properties.FancyzonesExcludedApps.Value;
this._editorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value;
+ this._zoneBorderColor = Settings.Properties.FancyzonesBorderColor.Value;
+ this._zoneInActiveColor = Settings.Properties.FancyzonesInActiveColor.Value;
+
+ GeneralSettings generalSettings;
+ try
+ {
+ generalSettings = SettingsUtils.GetSettings(string.Empty);
+ }
+ catch
+ {
+ generalSettings = new GeneralSettings();
+ SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty);
+ }
- GeneralSettings generalSettings = SettingsUtils.GetSettings(string.Empty);
this._isEnabled = generalSettings.Enabled.FancyZones;
}
@@ -68,6 +104,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private int _highlightOpacity;
private string _excludedApps;
private HotkeySettings _editorHotkey;
+ private string _zoneBorderColor;
+ private string _zoneInActiveColor;
public bool IsEnabled
{
@@ -271,6 +309,42 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
+ public string ZoneBorderColor
+ {
+ get
+ {
+ return _zoneBorderColor;
+ }
+
+ set
+ {
+ if (value != _zoneBorderColor)
+ {
+ _zoneBorderColor = value;
+ Settings.Properties.FancyzonesBorderColor.Value = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ public string ZoneInActiveColor
+ {
+ get
+ {
+ return _zoneInActiveColor;
+ }
+
+ set
+ {
+ if (value != _zoneInActiveColor)
+ {
+ _zoneInActiveColor = value;
+ Settings.Properties.FancyzonesInActiveColor.Value = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
public int HighlightOpacity
{
get
@@ -351,11 +425,21 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
ShellPage.DefaultSndMSGCallback("{\"action\":{\"FancyZones\":{\"action_name\":\"ToggledFZEditor\", \"value\":\"\"}}}");
}
- private void SaveColorChoice(Color color)
+ private void SaveZoneHighlightColor(Color color)
{
ZoneHighlightColor = color.ToString();
}
+ private void SaveZoneBorderColor(Color color)
+ {
+ ZoneBorderColor = color.ToString();
+ }
+
+ private void SaveZoneInActiveColor(Color color)
+ {
+ ZoneInActiveColor = color.ToString();
+ }
+
public void RaisePropertyChanged([CallerMemberName] string propertyName = null)
{
OnPropertyChanged(propertyName);
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/GeneralViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/GeneralViewModel.cs
index 9a9dff010a..5ab16a997b 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/GeneralViewModel.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/GeneralViewModel.cs
@@ -2,14 +2,225 @@
// 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.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Text.Json;
using Microsoft.PowerToys.Settings.UI.Helpers;
+using Microsoft.PowerToys.Settings.UI.Lib;
+using Microsoft.PowerToys.Settings.UI.ViewModels.Commands;
+using Microsoft.PowerToys.Settings.UI.Views;
+using Windows.System;
+using Windows.UI.Popups;
+using Windows.UI.Xaml;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class GeneralViewModel : Observable
{
+ private GeneralSettings GeneralSettingsConfigs { get; set; }
+
+ public ButtonClickCommand CheckFoUpdatesEventHandler { get; set; }
+
+ public ButtonClickCommand RestartElevatedButtonEventHandler { get; set; }
+
public GeneralViewModel()
{
+ this.CheckFoUpdatesEventHandler = new ButtonClickCommand(CheckForUpdates_Click);
+ this.RestartElevatedButtonEventHandler = new ButtonClickCommand(Restart_Elevated);
+
+ try
+ {
+ GeneralSettingsConfigs = SettingsUtils.GetSettings(string.Empty);
+ }
+ catch
+ {
+ GeneralSettingsConfigs = new GeneralSettings();
+ SettingsUtils.SaveSettings(GeneralSettingsConfigs.ToJsonString(), string.Empty);
+ }
+
+ switch (GeneralSettingsConfigs.Theme.ToLower())
+ {
+ case "light":
+ _isLightThemeRadioButtonChecked = true;
+ ShellPage.ShellHandler.RequestedTheme = ElementTheme.Light;
+ break;
+ case "dark":
+ _isDarkThemeRadioButtonChecked = true;
+ ShellPage.ShellHandler.RequestedTheme = ElementTheme.Dark;
+ break;
+ case "system":
+ _isSystemThemeRadioButtonChecked = true;
+ ShellPage.ShellHandler.RequestedTheme = ElementTheme.Default;
+ break;
+ }
+
+ _startup = GeneralSettingsConfigs.Startup;
+ }
+
+ private bool _packaged = false;
+ private bool _startup = false;
+ private bool _isElevated = false;
+ private bool _runElevated = false;
+ private bool _isDarkThemeRadioButtonChecked = false;
+ private bool _isLightThemeRadioButtonChecked = false;
+ private bool _isSystemThemeRadioButtonChecked = false;
+
+ // Gets or sets a value indicating whether packaged.
+ public bool Packaged
+ {
+ get
+ {
+ return _packaged;
+ }
+
+ set
+ {
+ if (_packaged != value)
+ {
+ _packaged = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ // Gets or sets a value indicating whether run powertoys on start-up.
+ public bool Startup
+ {
+ get
+ {
+ return _startup;
+ }
+
+ set
+ {
+ if (_startup != value)
+ {
+ _startup = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ // Gets or sets a value indicating whether the powertoy elevated.
+ public bool IsElevated
+ {
+ get
+ {
+ return _isElevated;
+ }
+
+ set
+ {
+ if (_isElevated != value)
+ {
+ _isElevated = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ // Gets or sets a value indicating whether powertoys should run elevated.
+ public bool RunElevated
+ {
+ get
+ {
+ return _runElevated;
+ }
+
+ set
+ {
+ if (_runElevated != value)
+ {
+ _runElevated = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ public bool IsDarkThemeRadioButtonChecked
+ {
+ get
+ {
+ return _isDarkThemeRadioButtonChecked;
+ }
+
+ set
+ {
+ if (value == true)
+ {
+ GeneralSettingsConfigs.Theme = "dark";
+ _isDarkThemeRadioButtonChecked = value;
+ ShellPage.ShellHandler.RequestedTheme = ElementTheme.Dark;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ public bool IsLightThemeRadioButtonChecked
+ {
+ get
+ {
+ return _isLightThemeRadioButtonChecked;
+ }
+
+ set
+ {
+ if (value == true)
+ {
+ GeneralSettingsConfigs.Theme = "light";
+ _isLightThemeRadioButtonChecked = value;
+ ShellPage.ShellHandler.RequestedTheme = ElementTheme.Light;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ public bool IsSystemThemeRadioButtonChecked
+ {
+ get
+ {
+ return _isSystemThemeRadioButtonChecked;
+ }
+
+ set
+ {
+ if (value == true)
+ {
+ GeneralSettingsConfigs.Theme = "system";
+ _isSystemThemeRadioButtonChecked = value;
+ ShellPage.ShellHandler.RequestedTheme = ElementTheme.Default;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ public void RaisePropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ // Notify UI of property change
+ OnPropertyChanged(propertyName);
+
+ OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(GeneralSettingsConfigs);
+
+ ShellPage.DefaultSndMSGCallback(outsettings.ToString());
+ }
+
+ // callback function to launch the URL to check for updates.
+ private async void CheckForUpdates_Click()
+ {
+ await Launcher.LaunchUriAsync(new Uri("https://github.com/microsoft/PowerToys/releases"));
+ }
+
+ private void Restart_Elevated()
+ {
+ GeneralSettings settings = SettingsUtils.GetSettings(string.Empty);
+ settings.RunElevated = true;
+ OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
+
+ if (ShellPage.DefaultSndMSGCallback != null)
+ {
+ ShellPage.DefaultSndMSGCallback(outsettings.ToString());
+ }
}
}
}
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerPreviewViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerPreviewViewModel.cs
new file mode 100644
index 0000000000..b8014c7a53
--- /dev/null
+++ b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerPreviewViewModel.cs
@@ -0,0 +1,86 @@
+// 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.Runtime.CompilerServices;
+using Microsoft.PowerToys.Settings.UI.Helpers;
+using Microsoft.PowerToys.Settings.UI.Lib;
+using Microsoft.PowerToys.Settings.UI.Views;
+
+namespace Microsoft.PowerToys.Settings.UI.ViewModels
+{
+ public class PowerPreviewViewModel : Observable
+ {
+ private const string ModuleName = "File Explorer Preview";
+
+ private PowerPreviewSettings Settings { get; set; }
+
+ public PowerPreviewViewModel()
+ {
+ try
+ {
+ Settings = SettingsUtils.GetSettings(ModuleName);
+ }
+ catch
+ {
+ Settings = new PowerPreviewSettings();
+ SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
+ }
+
+ this._svgRenderIsEnabled = Settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.Value;
+ this._mdRenderIsEnabled = Settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.Value;
+ }
+
+ private bool _svgRenderIsEnabled = false;
+ private bool _mdRenderIsEnabled = false;
+
+ public bool SVGRenderIsEnebled
+ {
+ get
+ {
+ return _svgRenderIsEnabled;
+ }
+
+ set
+ {
+ if (value != _svgRenderIsEnabled)
+ {
+ _svgRenderIsEnabled = value;
+ Settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.Value = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ public bool MDRenderIsEnebled
+ {
+ get
+ {
+ return _mdRenderIsEnabled;
+ }
+
+ set
+ {
+ if (value != _mdRenderIsEnabled)
+ {
+ _mdRenderIsEnabled = value;
+ Settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.Value = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ private void RaisePropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ // Notify UI of property change
+ OnPropertyChanged(propertyName);
+
+ if (ShellPage.DefaultSndMSGCallback != null)
+ {
+ SndPowerPreviewSettings snd = new SndPowerPreviewSettings(Settings);
+ SndModuleSettings ipcMessage = new SndModuleSettings(snd);
+ ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
+ }
+ }
+ }
+}
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerRenameViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerRenameViewModel.cs
index dda10c1783..a1b9078c4a 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerRenameViewModel.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/PowerRenameViewModel.cs
@@ -2,14 +2,186 @@
// 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.Runtime.CompilerServices;
using Microsoft.PowerToys.Settings.UI.Helpers;
+using Microsoft.PowerToys.Settings.UI.Lib;
+using Microsoft.PowerToys.Settings.UI.Views;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class PowerRenameViewModel : Observable
{
+ private const string ModuleName = "PowerRename";
+
+ private PowerRenameSettings Settings { get; set; }
+
public PowerRenameViewModel()
{
+ try
+ {
+ PowerRenameLocalProperties localSettings = SettingsUtils.GetSettings(ModuleName, "power-rename-settings.json");
+ Settings = new PowerRenameSettings(localSettings);
+ }
+ catch
+ {
+ PowerRenameLocalProperties localSettings = new PowerRenameLocalProperties();
+ Settings = new PowerRenameSettings(localSettings);
+ SettingsUtils.SaveSettings(localSettings.ToJsonString(), ModuleName, "power-rename-settings.json");
+ }
+
+ _powerRenameEnabledOnContextMenu = Settings.properties.ShowIcon.Value;
+ _powerRenameEnabledOnContextExtendedMenu = Settings.properties.ExtendedContextMenuOnly.Value;
+ _powerRenameRestoreFlagsOnLaunch = Settings.properties.PersistState.Value;
+ _powerRenameMaxDispListNumValue = Settings.properties.MaxMRUSize.Value;
+ _autoComplete = Settings.properties.MRUEnabled.Value;
+
+ GeneralSettings generalSettings;
+ try
+ {
+ generalSettings = SettingsUtils.GetSettings(string.Empty);
+ }
+ catch
+ {
+ generalSettings = new GeneralSettings();
+ SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty);
+ }
+
+ _powerRenameEnabled = generalSettings.Enabled.PowerRename;
+ }
+
+ private bool _powerRenameEnabled = false;
+ private bool _powerRenameEnabledOnContextMenu = false;
+ private bool _powerRenameEnabledOnContextExtendedMenu = false;
+ private bool _powerRenameRestoreFlagsOnLaunch = false;
+ private int _powerRenameMaxDispListNumValue = 0;
+ private bool _autoComplete = false;
+
+ public bool IsEnabled
+ {
+ get
+ {
+ return _powerRenameEnabled;
+ }
+
+ set
+ {
+ if (value != _powerRenameEnabled)
+ {
+ if (ShellPage.DefaultSndMSGCallback != null)
+ {
+ GeneralSettings generalSettings = SettingsUtils.GetSettings(string.Empty);
+ generalSettings.Enabled.PowerRename = value;
+ OutGoingGeneralSettings snd = new OutGoingGeneralSettings(generalSettings);
+ ShellPage.DefaultSndMSGCallback(snd.ToString());
+
+ _powerRenameEnabled = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+ }
+
+ public bool MRUEnabled
+ {
+ get
+ {
+ return _autoComplete;
+ }
+
+ set
+ {
+ if (value != _autoComplete)
+ {
+ _autoComplete = value;
+ Settings.properties.MRUEnabled.Value = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ public bool EnabledOnContextMenu
+ {
+ get
+ {
+ return _powerRenameEnabledOnContextMenu;
+ }
+
+ set
+ {
+ if (value != _powerRenameEnabledOnContextMenu)
+ {
+ _powerRenameEnabledOnContextMenu = value;
+ Settings.properties.ShowIcon.Value = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ public bool EnabledOnContextExtendedMenu
+ {
+ get
+ {
+ return _powerRenameEnabledOnContextExtendedMenu;
+ }
+
+ set
+ {
+ if (value != _powerRenameEnabledOnContextExtendedMenu)
+ {
+ _powerRenameEnabledOnContextExtendedMenu = value;
+ Settings.properties.ExtendedContextMenuOnly.Value = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ public bool RestoreFlagsOnLaunch
+ {
+ get
+ {
+ return _powerRenameRestoreFlagsOnLaunch;
+ }
+
+ set
+ {
+ if (value != _powerRenameRestoreFlagsOnLaunch)
+ {
+ _powerRenameRestoreFlagsOnLaunch = value;
+ Settings.properties.PersistState.Value = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ public int MaxDispListNum
+ {
+ get
+ {
+ return _powerRenameMaxDispListNumValue;
+ }
+
+ set
+ {
+ if (value != _powerRenameMaxDispListNumValue)
+ {
+ _powerRenameMaxDispListNumValue = value;
+ Settings.properties.MaxMRUSize.Value = value;
+ RaisePropertyChanged();
+ }
+ }
+ }
+
+ private void RaisePropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ // Notify UI of property change
+ OnPropertyChanged(propertyName);
+
+ if (ShellPage.DefaultSndMSGCallback != null)
+ {
+ SndPowerRenameSettings snd = new SndPowerRenameSettings(Settings);
+ SndModuleSettings ipcMessage = new SndModuleSettings(snd);
+ ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
+ }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Views/FancyZonesPage.xaml b/src/core/Microsoft.PowerToys.Settings.UI/Views/FancyZonesPage.xaml
index be25f86ce4..49ba3bc672 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/Views/FancyZonesPage.xaml
+++ b/src/core/Microsoft.PowerToys.Settings.UI/Views/FancyZonesPage.xaml
@@ -130,12 +130,12 @@
HorizontalAlignment="Left"
Margin="{StaticResource SmallTopMargin}"
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
-
+
-
+ IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
+ DataContext="{Binding ZoneHighlightColor, Source={StaticResource eventViewModel}}"/>
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Views/GeneralPage.xaml b/src/core/Microsoft.PowerToys.Settings.UI/Views/GeneralPage.xaml
index dcb752dc66..9ca3684c49 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/Views/GeneralPage.xaml
+++ b/src/core/Microsoft.PowerToys.Settings.UI/Views/GeneralPage.xaml
@@ -1,14 +1,20 @@
-
+
+
+
+
+
@@ -40,76 +46,70 @@
-
-
+
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Views/GeneralPage.xaml.cs b/src/core/Microsoft.PowerToys.Settings.UI/Views/GeneralPage.xaml.cs
index 8227688c4e..f8c5d75062 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/Views/GeneralPage.xaml.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI/Views/GeneralPage.xaml.cs
@@ -3,9 +3,11 @@
// See the LICENSE file in the project root for more information.
using System;
+using System.IO;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Windows.System;
+using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
@@ -18,9 +20,9 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public sealed partial class GeneralPage : Page
{
///
- /// Gets view model.
+ /// Gets or sets view model.
///
- public GeneralViewModel ViewModel { get; } = new GeneralViewModel();
+ public GeneralViewModel ViewModel { get; set; }
///
/// Initializes a new instance of the class.
@@ -28,122 +30,10 @@ namespace Microsoft.PowerToys.Settings.UI.Views
///
public GeneralPage()
{
- InitializeComponent();
- }
+ this.InitializeComponent();
- ///
- protected override void OnNavigatedTo(NavigationEventArgs e)
- {
- base.OnNavigatedTo(e);
- GeneralSettings settings = null;
- try
- {
- // get settings file if they exist.
- settings = SettingsUtils.GetSettings(string.Empty);
-
- // load and apply theme settings
- ReLoadTheme(settings.Theme);
-
- // load run on start-up settings value and update the ui state.
- ToggleSwitch_RunAtStartUp.IsOn = settings.Startup;
- }
- catch
- {
- // create settings file if one is not found.
- settings = new GeneralSettings();
- SettingsUtils.SaveSettings(settings.ToJsonString(), string.Empty);
-
- // load and apply theme settings
- ReLoadTheme(settings.Theme);
-
- // load run on start up ui settings value and update the ui state.
- ToggleSwitch_RunAtStartUp.IsOn = settings.Startup;
- }
- }
-
- ///
- /// Update and save theme settings to json file.
- ///
- /// theme name.
- private void ReLoadTheme(string themeName)
- {
- switch (themeName.ToLower())
- {
- case "light":
- ShellPage.ShellHandler.RequestedTheme = ElementTheme.Light;
- Radio_Theme_Light.IsChecked = true;
- break;
- case "dark":
- ShellPage.ShellHandler.RequestedTheme = ElementTheme.Dark;
- Radio_Theme_Dark.IsChecked = true;
- break;
- case "system":
- ShellPage.ShellHandler.RequestedTheme = ElementTheme.Default;
- Radio_Theme_Default.IsChecked = true;
- break;
- }
- }
-
- private void ToggleSwitch_RunAtStartUp_Toggled(object sender, RoutedEventArgs e)
- {
- ToggleSwitch swt = sender as ToggleSwitch;
-
- if (swt != null)
- {
- GeneralSettings settings = SettingsUtils.GetSettings(string.Empty);
-
- string startup = swt.IsOn.ToString().ToLower();
- switch (startup)
- {
- case "true":
- settings.Startup = true;
- break;
- case "false":
- settings.Startup = false;
- break;
- }
-
- SettingsUtils.SaveSettings(settings.ToJsonString(), string.Empty);
- OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
-
- if (ShellPage.DefaultSndMSGCallback != null)
- {
- ShellPage.DefaultSndMSGCallback(outsettings.ToString());
- }
- }
- }
-
- private void Restart_Elevated(object sender, RoutedEventArgs e)
- {
- GeneralSettings settings = SettingsUtils.GetSettings(string.Empty);
- settings.RunElevated = true;
- OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
-
- if (ShellPage.DefaultSndMSGCallback != null)
- {
- ShellPage.DefaultSndMSGCallback(outsettings.ToString());
- }
- }
-
- private void Theme_Changed(object sender, RoutedEventArgs e)
- {
- RadioButton rb = sender as RadioButton;
-
- if (rb != null)
- {
- string themeName = rb.Tag.ToString();
- ReLoadTheme(themeName);
-
- // update and save settings to file.
- GeneralSettings settings = SettingsUtils.GetSettings(string.Empty);
- settings.Theme = themeName;
- SettingsUtils.SaveSettings(settings.ToJsonString(), string.Empty);
- }
- }
-
- private async void CheckForUpdates_Click(object sender, RoutedEventArgs e)
- {
- await Launcher.LaunchUriAsync(new Uri("https://github.com/microsoft/PowerToys/releases"));
+ this.ViewModel = new GeneralViewModel();
+ this.GeneralSettingsView.DataContext = this.ViewModel;
}
}
}
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerPreviewPage.xaml b/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerPreviewPage.xaml
index a95a8c15bf..791d43611e 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerPreviewPage.xaml
+++ b/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerPreviewPage.xaml
@@ -38,40 +38,36 @@
-
-
-
+
-
+
-
+
-
+
-
+
-
-
+
+
+
\ No newline at end of file
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerPreviewPage.xaml.cs b/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerPreviewPage.xaml.cs
index bf0929834b..cc82d9fa39 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerPreviewPage.xaml.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerPreviewPage.xaml.cs
@@ -2,7 +2,9 @@
// 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 Microsoft.PowerToys.Settings.UI.Lib;
+using Microsoft.PowerToys.Settings.UI.ViewModels;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
@@ -14,67 +16,13 @@ namespace Microsoft.PowerToys.Settings.UI.Views
///
public sealed partial class PowerPreviewPage : Page
{
- private const string PreviewPaneKey = "File Explorer Preview";
+ public PowerPreviewViewModel viewModel { get; set; }
public PowerPreviewPage()
{
- InitializeComponent();
- }
-
- ///
- protected override void OnNavigatedTo(NavigationEventArgs e)
- {
- PowerPreviewSettings settings;
- try
- {
- base.OnNavigatedTo(e);
- settings = SettingsUtils.GetSettings(PreviewPaneKey);
- ToggleSwitch_Preview_SVG.IsOn = settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.Value;
- ToggleSwitch_Preview_MD.IsOn = settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.Value;
- }
- catch
- {
- settings = new PowerPreviewSettings(PreviewPaneKey);
- SettingsUtils.SaveSettings(settings.ToJsonString(), PreviewPaneKey);
- ToggleSwitch_Preview_SVG.IsOn = settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.Value;
- ToggleSwitch_Preview_MD.IsOn = settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.Value;
- }
- }
-
- private void ToggleSwitch_Preview_SVG_Toggled(object sender, RoutedEventArgs e)
- {
- ToggleSwitch swt = sender as ToggleSwitch;
-
- if (swt != null)
- {
- PowerPreviewSettings settings = SettingsUtils.GetSettings(PreviewPaneKey);
- settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.Value = swt.IsOn;
-
- if (ShellPage.DefaultSndMSGCallback != null)
- {
- SndPowerPreviewSettings snd = new SndPowerPreviewSettings(settings);
- SndModuleSettings ipcMessage = new SndModuleSettings(snd);
- ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
- }
- }
- }
-
- private void ToggleSwitch_Preview_MD_Toggled(object sender, RoutedEventArgs e)
- {
- ToggleSwitch swt = sender as ToggleSwitch;
-
- if (swt != null)
- {
- PowerPreviewSettings settings = SettingsUtils.GetSettings(PreviewPaneKey);
- settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.Value = swt.IsOn;
-
- if (ShellPage.DefaultSndMSGCallback != null)
- {
- SndPowerPreviewSettings snd = new SndPowerPreviewSettings(settings);
- SndModuleSettings ipcMessage = new SndModuleSettings(snd);
- ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
- }
- }
+ this.InitializeComponent();
+ viewModel = new PowerPreviewViewModel();
+ this.PowerPreviewSettingsView.DataContext = viewModel;
}
}
}
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerRenamePage.xaml b/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerRenamePage.xaml
index a5d172d53b..9d9922b3b2 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerRenamePage.xaml
+++ b/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerRenamePage.xaml
@@ -39,74 +39,81 @@
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
\ No newline at end of file
diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerRenamePage.xaml.cs b/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerRenamePage.xaml.cs
index be6fd3dcf0..0f2a54f69e 100644
--- a/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerRenamePage.xaml.cs
+++ b/src/core/Microsoft.PowerToys.Settings.UI/Views/PowerRenamePage.xaml.cs
@@ -14,128 +14,14 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
public sealed partial class PowerRenamePage : Page
{
- public PowerRenameViewModel ViewModel { get; } = new PowerRenameViewModel();
-
- private const string POWERTOYNAME = "PowerRename";
+ public PowerRenameViewModel ViewModel { get; set; }
public PowerRenamePage()
{
- InitializeComponent();
- }
+ this.InitializeComponent();
- ///
- protected override void OnNavigatedTo(NavigationEventArgs e)
- {
- base.OnNavigatedTo(e);
- PowerRenameSettings settings;
- try
- {
- settings = SettingsUtils.GetSettings(POWERTOYNAME);
- UpdateView(settings);
- }
- catch
- {
- settings = new PowerRenameSettings(POWERTOYNAME);
- SettingsUtils.SaveSettings(settings.ToJsonString(), POWERTOYNAME);
- UpdateView(settings);
- }
- }
-
- private void UpdateView(PowerRenameSettings settings)
- {
- Toggle_PowerRename_Enable.IsOn = settings.properties.MruEnabled.Value;
- Toggle_PowerRename_EnableOnExtendedContextMenu.IsOn = settings.properties.ShowExtendedMenu.Value;
- Toggle_PowerRename_MaxDispListNum.Value = settings.properties.MaxMruSize.Value;
- Toggle_PowerRename_EnableOnContextMenu.IsOn = settings.properties.ShowIconInMenu.Value;
- Toggle_PowerRename_RestoreFlagsOnLaunch.IsOn = settings.properties.PersistInput.Value;
- }
-
- private void Toggle_PowerRename_Enable_Toggled(object sender, RoutedEventArgs e)
- {
- ToggleSwitch swt = sender as ToggleSwitch;
-
- if (swt != null)
- {
- PowerRenameSettings settings = SettingsUtils.GetSettings(POWERTOYNAME);
- settings.properties.MruEnabled.Value = swt.IsOn;
-
- if (ShellPage.DefaultSndMSGCallback != null)
- {
- SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
- SndModuleSettings ipcMessage = new SndModuleSettings(snd);
- ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
- }
- }
- }
-
- private void Toggle_PowerRename_EnableOnContextMenu_Toggled(object sender, RoutedEventArgs e)
- {
- ToggleSwitch swt = sender as ToggleSwitch;
-
- if (swt != null)
- {
- PowerRenameSettings settings = SettingsUtils.GetSettings(POWERTOYNAME);
- settings.properties.ShowIconInMenu.Value = swt.IsOn;
-
- if (ShellPage.DefaultSndMSGCallback != null)
- {
- SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
- SndModuleSettings ipcMessage = new SndModuleSettings(snd);
- ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
- }
- }
- }
-
- private void Toggle_PowerRename_EnableOnExtendedContextMenu_Toggled(object sender, RoutedEventArgs e)
- {
- ToggleSwitch swt = sender as ToggleSwitch;
-
- if (swt != null)
- {
- PowerRenameSettings settings = SettingsUtils.GetSettings(POWERTOYNAME);
- settings.properties.ShowExtendedMenu.Value = swt.IsOn;
-
- if (ShellPage.DefaultSndMSGCallback != null)
- {
- SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
- SndModuleSettings ipcMessage = new SndModuleSettings(snd);
- ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
- }
- }
- }
-
- private void Toggle_PowerRename_RestoreFlagsOnLaunch_Toggled(object sender, RoutedEventArgs e)
- {
- ToggleSwitch swt = sender as ToggleSwitch;
-
- if (swt != null)
- {
- PowerRenameSettings settings = SettingsUtils.GetSettings(POWERTOYNAME);
- settings.properties.PersistInput.Value = swt.IsOn;
-
- if (ShellPage.DefaultSndMSGCallback != null)
- {
- SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
- SndModuleSettings ipcMessage = new SndModuleSettings(snd);
- ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
- }
- }
- }
-
- private void Toggle_PowerRename_MaxDispListNum_ValueChanged(NumberBox sender, NumberBoxValueChangedEventArgs args)
- {
- if (sender != null)
- {
- PowerRenameSettings settings = SettingsUtils.GetSettings(POWERTOYNAME);
- settings.properties.MaxMruSize.Value = Convert.ToInt32(sender.Value);
-
- if (ShellPage.DefaultSndMSGCallback != null)
- {
- SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
- SndModuleSettings ipcMessage = new SndModuleSettings(snd);
- ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
- }
- }
+ ViewModel = new PowerRenameViewModel();
+ this.PowerRenameSettingsView.DataContext = ViewModel;
}
}
}
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/LockScreenLogo.scale-200.png b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/LockScreenLogo.scale-200.png
new file mode 100644
index 0000000000..735f57adb5
Binary files /dev/null and b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/LockScreenLogo.scale-200.png differ
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/SplashScreen.scale-200.png b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/SplashScreen.scale-200.png
new file mode 100644
index 0000000000..023e7f1fed
Binary files /dev/null and b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/SplashScreen.scale-200.png differ
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/Square150x150Logo.scale-200.png b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/Square150x150Logo.scale-200.png
new file mode 100644
index 0000000000..af49fec1a5
Binary files /dev/null and b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/Square150x150Logo.scale-200.png differ
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/Square44x44Logo.scale-200.png b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/Square44x44Logo.scale-200.png
new file mode 100644
index 0000000000..ce342a2ec8
Binary files /dev/null and b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/Square44x44Logo.scale-200.png differ
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
new file mode 100644
index 0000000000..f6c02ce97e
Binary files /dev/null and b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/StoreLogo.png b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/StoreLogo.png
new file mode 100644
index 0000000000..7385b56c0e
Binary files /dev/null and b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/StoreLogo.png differ
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/Wide310x150Logo.scale-200.png b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/Wide310x150Logo.scale-200.png
new file mode 100644
index 0000000000..288995b397
Binary files /dev/null and b/src/core/Microsoft.PowerToys.Settings.UnitTest/Assets/Wide310x150Logo.scale-200.png differ
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/Microsoft.PowerToys.Settings.UnitTest.csproj b/src/core/Microsoft.PowerToys.Settings.UnitTest/Microsoft.PowerToys.Settings.UnitTest.csproj
new file mode 100644
index 0000000000..d41e17e914
--- /dev/null
+++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/Microsoft.PowerToys.Settings.UnitTest.csproj
@@ -0,0 +1,184 @@
+
+
+
+
+ Debug
+ x86
+ {A80355C2-780D-4245-BD80-25B8DE698EE3}
+ AppContainerExe
+ Properties
+ Microsoft.PowerToys.Settings.UnitTest
+ Microsoft.PowerToys.Settings.UnitTest
+ en-US
+ UAP
+ 10.0.18362.0
+ 10.0.18362.0
+ 14
+ 512
+ {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ $(VisualStudioVersion)
+ false
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x86
+ false
+ prompt
+ true
+
+
+ bin\x86\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x86
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\ARM\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ ARM
+ false
+ prompt
+ true
+
+
+ bin\ARM\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ ARM
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\ARM64\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ ARM64
+ false
+ prompt
+ true
+ true
+
+
+ bin\ARM64\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ ARM64
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\x64\Debug\Test\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x64
+ false
+ prompt
+ true
+
+
+ bin\x64\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x64
+ false
+ prompt
+ true
+ true
+
+
+ PackageReference
+
+
+
+
+
+
+
+
+
+
+ UnitTestApp.xaml
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6.2.9
+
+
+ 1.4.0
+
+
+ 1.4.0
+
+
+
+
+ {b1bcc8c6-46b5-4bfa-8f22-20f32d99ec6a}
+ Microsoft.PowerToys.Settings.UI.Lib
+
+
+ {a7d5099e-f0fd-4bf3-8522-5a682759f915}
+ Microsoft.PowerToys.Settings.UI
+
+
+
+
+ 14.0
+
+
+
+
\ No newline at end of file
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/BasePTModuleSettingsTest.cs b/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/BasePTModuleSettingsTest.cs
new file mode 100644
index 0000000000..6cd4b1d552
--- /dev/null
+++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/BasePTModuleSettingsTest.cs
@@ -0,0 +1,48 @@
+using Microsoft.PowerToys.Settings.UI.Lib;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json.Schema;
+using System;
+
+namespace Microsoft.PowerToys.Settings.UnitTest
+{
+ [TestClass]
+ public class BasePTModuleSettingsTest
+ {
+ // Work around for System.JSON required properties:
+ // https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-migrate-from-newtonsoft-how-to.
+ // Test also failes when the attributes are not initiliazed i.e they have null values.
+ [TestMethod]
+ [Obsolete]
+ public void ToJsonString_ShouldReturnValidJSONOfModel_WhenSuccessful()
+ {
+ // Arrange
+ string file_name = "test\\BasePTModuleSettingsTest";
+ string expectedSchemaText = @"
+ {
+ '$schema': 'http://json-schema.org/draft-04/schema#',
+ 'type': 'object',
+ 'properties': {
+ 'name': {
+ 'type': 'string'
+ },
+ 'version': {
+ 'type': 'string'
+ }
+ },
+ 'additionalProperties': false
+ }";
+
+ string testSettingsConfigs = new BasePTSettingsTest().ToJsonString();
+ SettingsUtils.SaveSettings(testSettingsConfigs, file_name);
+ JsonSchema expectedSchema = JsonSchema.Parse(expectedSchemaText);
+
+ // Act
+ JObject actualSchema = JObject.Parse(SettingsUtils.GetSettings(file_name).ToJsonString());
+ bool valid = actualSchema.IsValid(expectedSchema);
+
+ // Assert
+ Assert.IsTrue(valid);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/BasePTSettingsTest.cs b/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/BasePTSettingsTest.cs
new file mode 100644
index 0000000000..87b412bb0c
--- /dev/null
+++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/BasePTSettingsTest.cs
@@ -0,0 +1,13 @@
+using Microsoft.PowerToys.Settings.UI.Lib;
+
+namespace Microsoft.PowerToys.Settings.UnitTest
+{
+ public class BasePTSettingsTest : BasePTModuleSettings
+ {
+ public BasePTSettingsTest()
+ {
+ this.name = string.Empty;
+ this.version = string.Empty;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/SettingsUtilsTests.cs b/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/SettingsUtilsTests.cs
new file mode 100644
index 0000000000..61a6aea3d7
--- /dev/null
+++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/ModelsTests/SettingsUtilsTests.cs
@@ -0,0 +1,119 @@
+using Microsoft.PowerToys.Settings.UI.Lib;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text.Json;
+using System.Threading.Tasks;
+
+namespace Microsoft.PowerToys.Settings.UnitTest
+{
+ [TestClass]
+ public class SettingsUtilsTests
+ {
+ public SettingsUtilsTests()
+ {
+ string file_name = "\\test";
+ if (SettingsUtils.SettingsFolderExists(file_name))
+ {
+ DeleteFolder(file_name);
+ }
+ }
+
+ [TestCleanup()]
+ public void Cleanup()
+ {
+ string file_name = "\\test";
+ if (SettingsUtils.SettingsFolderExists(file_name))
+ {
+ DeleteFolder(file_name);
+ }
+ }
+
+ [TestMethod]
+ public void SaveSettings_SaveSettingsToFile_WhenFilePathExists()
+ {
+ // Arrange
+ string file_name = "\\test";
+ string file_contents_correct_json_content = "{\"name\":\"powertoy module name\",\"version\":\"powertoy version\"}";
+
+ BasePTSettingsTest expected_json = JsonSerializer.Deserialize(file_contents_correct_json_content);
+
+ // Act
+ SettingsUtils.SaveSettings(file_contents_correct_json_content, file_name);
+ BasePTSettingsTest actual_json = SettingsUtils.GetSettings(file_name);
+
+ // Assert
+ Assert.IsTrue(actual_json.Equals(actual_json));
+ }
+
+ [TestMethod]
+ public async Task SaveSettings_ShouldCreateFile_WhenFilePathIsNotFoundAsync()
+ {
+ // Arrange
+ string file_name = "test\\Test Folder";
+ string file_contents_correct_json_content = "{\"name\":\"powertoy module name\",\"version\":\"powertoy version\"}";
+
+ BasePTSettingsTest expected_json = JsonSerializer.Deserialize(file_contents_correct_json_content);
+
+ // Act
+ if(SettingsUtils.SettingsFolderExists(file_name))
+ {
+ DeleteFolder(file_name);
+ }
+
+ SettingsUtils.SaveSettings(file_contents_correct_json_content, file_name);
+ BasePTSettingsTest actual_json = SettingsUtils.GetSettings(file_name);
+
+ // Assert
+ Assert.IsTrue(actual_json.Equals(actual_json));
+ }
+
+ [TestMethod]
+ public void SettingsFolderExists_ShouldReturnFalse_WhenFilePathIsNotFound()
+ {
+ // Arrange
+ string file_name_random = "test\\"+ RandomString();
+ string file_name_exists = "test\\exists";
+ string file_contents_correct_json_content = "{\"name\":\"powertoy module name\",\"version\":\"powertoy version\"}";
+
+ // Act
+ bool pathNotFound = SettingsUtils.SettingsFolderExists(file_name_random);
+
+ SettingsUtils.SaveSettings(file_contents_correct_json_content, file_name_exists);
+ bool pathFound = SettingsUtils.SettingsFolderExists(file_name_exists);
+
+ // Assert
+ Assert.IsFalse(pathNotFound);
+ Assert.IsTrue(pathFound);
+ }
+
+ [TestMethod]
+ public void CreateSettingsFolder_ShouldCreateFolder_WhenSuccessfull()
+ {
+ // Arrange
+ string file_name = "test\\" + RandomString();
+
+ // Act
+ SettingsUtils.CreateSettingsFolder(file_name);
+
+ // Assert
+ Assert.IsTrue(SettingsUtils.SettingsFolderExists(file_name));
+ }
+
+ public void DeleteFolder(string powertoy)
+ {
+ Directory.Delete(Path.Combine(SettingsUtils.LocalApplicationDataFolder(), $"Microsoft\\PowerToys\\{powertoy}"), true);
+ }
+
+ public static string RandomString()
+ {
+ Random random = new Random();
+ int length = 20;
+ const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ return new string(Enumerable.Repeat(chars, length)
+ .Select(s => s[random.Next(s.Length)]).ToArray());
+ }
+ }
+}
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/Package.appxmanifest b/src/core/Microsoft.PowerToys.Settings.UnitTest/Package.appxmanifest
new file mode 100644
index 0000000000..cc8fe316af
--- /dev/null
+++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/Package.appxmanifest
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+ Microsoft.PowerToys.Settings.UnitTest
+ lamotile
+ Assets\StoreLogo.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/Properties/AssemblyInfo.cs b/src/core/Microsoft.PowerToys.Settings.UnitTest/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..69a2c50ac1
--- /dev/null
+++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/Properties/AssemblyInfo.cs
@@ -0,0 +1,18 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Microsoft.PowerToys.Settings.UnitTest")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Microsoft.PowerToys.Settings.UnitTest")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: AssemblyMetadata("TargetPlatform","UAP")]
+
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: ComVisible(false)]
\ No newline at end of file
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/UnitTestApp.xaml b/src/core/Microsoft.PowerToys.Settings.UnitTest/UnitTestApp.xaml
new file mode 100644
index 0000000000..50ff71f962
--- /dev/null
+++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/UnitTestApp.xaml
@@ -0,0 +1,7 @@
+
+
+
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/UnitTestApp.xaml.cs b/src/core/Microsoft.PowerToys.Settings.UnitTest/UnitTestApp.xaml.cs
new file mode 100644
index 0000000000..8acaacca75
--- /dev/null
+++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/UnitTestApp.xaml.cs
@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.ApplicationModel;
+using Windows.ApplicationModel.Activation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+namespace Microsoft.PowerToys.Settings.UnitTest
+{
+ ///
+ /// Provides application-specific behavior to supplement the default Application class.
+ ///
+ sealed partial class App : Application
+ {
+ ///
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ ///
+ public App()
+ {
+ this.InitializeComponent();
+ this.Suspending += OnSuspending;
+ }
+
+ ///
+ /// Invoked when the application is launched normally by the end user. Other entry points
+ /// will be used such as when the application is launched to open a specific file.
+ ///
+ /// Details about the launch request and process.
+ protected override void OnLaunched(LaunchActivatedEventArgs e)
+ {
+
+#if DEBUG
+ if (System.Diagnostics.Debugger.IsAttached)
+ {
+ this.DebugSettings.EnableFrameRateCounter = true;
+ }
+#endif
+
+ Frame rootFrame = Window.Current.Content as Frame;
+
+ // Do not repeat app initialization when the Window already has content,
+ // just ensure that the window is active
+ if (rootFrame == null)
+ {
+ // Create a Frame to act as the navigation context and navigate to the first page
+ rootFrame = new Frame();
+
+ rootFrame.NavigationFailed += OnNavigationFailed;
+
+ if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
+ {
+ //TODO: Load state from previously suspended application
+ }
+
+ // Place the frame in the current Window
+ Window.Current.Content = rootFrame;
+ }
+
+ Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();
+
+ // Ensure the current window is active
+ Window.Current.Activate();
+
+ Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments);
+ }
+
+ ///
+ /// Invoked when Navigation to a certain page fails
+ ///
+ /// The Frame which failed navigation
+ /// Details about the navigation failure
+ void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
+ {
+ throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
+ }
+
+ ///
+ /// Invoked when application execution is being suspended. Application state is saved
+ /// without knowing whether the application will be terminated or resumed with the contents
+ /// of memory still intact.
+ ///
+ /// The source of the suspend request.
+ /// Details about the suspend request.
+ private void OnSuspending(object sender, SuspendingEventArgs e)
+ {
+ var deferral = e.SuspendingOperation.GetDeferral();
+ //TODO: Save application state and stop any background activity
+ deferral.Complete();
+ }
+ }
+}
diff --git a/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/GeneralSettingsViewModelTest.cs b/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/GeneralSettingsViewModelTest.cs
new file mode 100644
index 0000000000..257b86167a
--- /dev/null
+++ b/src/core/Microsoft.PowerToys.Settings.UnitTest/ViewModelTests/GeneralSettingsViewModelTest.cs
@@ -0,0 +1,22 @@
+using Microsoft.PowerToys.Settings.UI.Lib;
+using Microsoft.PowerToys.Settings.UI.ViewModels;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json.Schema;
+using System;
+using System.Diagnostics;
+
+namespace Microsoft.PowerToys.Settings.UnitTest.ViewModelTests
+{
+ [TestClass]
+ public class GeneralSettingsViewModelTest
+ {
+ [TestMethod]
+ [DebuggerStepThrough]
+ public void Packaged_ShouldSendConfigsWithUpdatedPackageValue_WhenSuccessful()
+ {
+ //GeneralViewModel viewModel = new GeneralViewModel();
+ //viewModel.Packaged = true;
+ }
+ }
+}