Added Tests and Refactored code (#2129)
* Added Tests and Refactored code * removed un-used file * delete test files when test completes * removed extra build configs * added clean-up method * removed unused variable * re-added removed attributtion * added error handling and move strings to string resource * added error handling to file explorer view model * moved varible assignment to if statement block * removed savin of settings file from the UI * re-added open source notice * added missing controls for powerrename and fancy zones * removed dead coded * remove un-used configuration * added error handling for file saving and updated powerreanme constructor * removed added configurations * added settings state
@ -188,8 +188,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "powerpreviewTest", "src\mod
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{C3081D9A-1586-441A-B5F4-ED815B3719C1}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{C3081D9A-1586-441A-B5F4-ED815B3719C1}"
|
||||||
EndProject
|
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}"
|
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
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{F88B6FD1-14BD-48DB-85C2-6C51B8045121} = {F88B6FD1-14BD-48DB-85C2-6C51B8045121}
|
{F88B6FD1-14BD-48DB-85C2-6C51B8045121} = {F88B6FD1-14BD-48DB-85C2-6C51B8045121}
|
||||||
@ -209,6 +207,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
EndProject
|
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}"
|
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
|
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
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x64 = Debug|x64
|
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}.Debug|x64.Build.0 = Debug|x64
|
||||||
{47310AB4-9034-4BD1-8D8B-E88AD21A171B}.Release|x64.ActiveCfg = Release|x64
|
{47310AB4-9034-4BD1-8D8B-E88AD21A171B}.Release|x64.ActiveCfg = Release|x64
|
||||||
{47310AB4-9034-4BD1-8D8B-E88AD21A171B}.Release|x64.Build.0 = 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.ActiveCfg = Debug|x64
|
||||||
{E4E0D2AE-B17D-4BD4-8BEE-AFC8CC464C5F}.Debug|x64.Build.0 = Debug|x64
|
{E4E0D2AE-B17D-4BD4-8BEE-AFC8CC464C5F}.Debug|x64.Build.0 = Debug|x64
|
||||||
{E4E0D2AE-B17D-4BD4-8BEE-AFC8CC464C5F}.Release|x64.ActiveCfg = Release|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
|
{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.ActiveCfg = Debug|x64
|
||||||
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Debug|x64.Build.0 = 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.ActiveCfg = Release|x64
|
||||||
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A}.Release|x64.Build.0 = Release|Any CPU
|
{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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -438,12 +440,12 @@ Global
|
|||||||
{748417CA-F17E-487F-9411-CAFB6D3F4877} = {2F305555-C296-497E-AC20-5FA1B237996A}
|
{748417CA-F17E-487F-9411-CAFB6D3F4877} = {2F305555-C296-497E-AC20-5FA1B237996A}
|
||||||
{217DF501-135C-4E38-BFC8-99D4821032EA} = {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}
|
{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}
|
{E4E0D2AE-B17D-4BD4-8BEE-AFC8CC464C5F} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
|
||||||
{F88B6FD1-14BD-48DB-85C2-6C51B8045121} = {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}
|
{A7D5099E-F0FD-4BF3-8522-5A682759F915} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
|
||||||
{C073B057-B157-40F0-8678-1DCD119D841C} = {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}
|
{B1BCC8C6-46B5-4BFA-8F22-20F32D99EC6A} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
|
||||||
|
{A80355C2-780D-4245-BD80-25B8DE698EE3} = {C3081D9A-1586-441A-B5F4-ED815B3719C1}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
|
|
||||||
<IsPackable>false</IsPackable>
|
|
||||||
|
|
||||||
<Platforms>x64</Platforms>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
|
||||||
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
|
|
||||||
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
|
|
||||||
<PackageReference Include="coverlet.collector" Version="1.0.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,13 +0,0 @@
|
|||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
|
|
||||||
namespace Microsoft.PowerToys.Settings.Test
|
|
||||||
{
|
|
||||||
[TestClass]
|
|
||||||
public class UnitTest1
|
|
||||||
{
|
|
||||||
[TestMethod]
|
|
||||||
public void TestMethod1()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,6 +22,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
|||||||
this.FancyzonesHighlightOpacity = new IntProperty();
|
this.FancyzonesHighlightOpacity = new IntProperty();
|
||||||
this.FancyzonesEditorHotkey = new KeyBoardKeysProperty();
|
this.FancyzonesEditorHotkey = new KeyBoardKeysProperty();
|
||||||
this.FancyzonesExcludedApps = new StringProperty();
|
this.FancyzonesExcludedApps = new StringProperty();
|
||||||
|
this.FancyzonesInActiveColor = new StringProperty();
|
||||||
|
this.FancyzonesBorderColor = new StringProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonPropertyName("fancyzones_shiftDrag")]
|
[JsonPropertyName("fancyzones_shiftDrag")]
|
||||||
@ -62,5 +64,11 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
|||||||
|
|
||||||
[JsonPropertyName("fancyzones_excluded_apps")]
|
[JsonPropertyName("fancyzones_excluded_apps")]
|
||||||
public StringProperty FancyzonesExcludedApps { get; set; }
|
public StringProperty FancyzonesExcludedApps { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("fancyzones_zoneBorderColor")]
|
||||||
|
public StringProperty FancyzonesBorderColor { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("fancyzones_zoneColor")]
|
||||||
|
public StringProperty FancyzonesInActiveColor { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,26 +10,26 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
|||||||
{
|
{
|
||||||
public PowerRenameProperties()
|
public PowerRenameProperties()
|
||||||
{
|
{
|
||||||
PersistInput = new BoolProperty();
|
PersistState = new BoolProperty();
|
||||||
MruEnabled = new BoolProperty();
|
MRUEnabled = new BoolProperty();
|
||||||
MaxMruSize = new IntProperty();
|
MaxMRUSize = new IntProperty();
|
||||||
ShowIconInMenu = new BoolProperty();
|
ShowIcon = new BoolProperty();
|
||||||
ShowExtendedMenu = new BoolProperty();
|
ExtendedContextMenuOnly = new BoolProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonPropertyName("bool_persist_input")]
|
[JsonPropertyName("bool_persist_input")]
|
||||||
public BoolProperty PersistInput { get; set; }
|
public BoolProperty PersistState { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("bool_mru_enabled")]
|
[JsonPropertyName("bool_mru_enabled")]
|
||||||
public BoolProperty MruEnabled { get; set; }
|
public BoolProperty MRUEnabled { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("int_max_mru_size")]
|
[JsonPropertyName("int_max_mru_size")]
|
||||||
public IntProperty MaxMruSize { get; set; }
|
public IntProperty MaxMRUSize { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("bool_show_icon_on_menu")]
|
[JsonPropertyName("bool_show_icon_on_menu")]
|
||||||
public BoolProperty ShowIconInMenu { get; set; }
|
public BoolProperty ShowIcon { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("bool_show_extended_menu")]
|
[JsonPropertyName("bool_show_extended_menu")]
|
||||||
public BoolProperty ShowExtendedMenu { get; set; }
|
public BoolProperty ExtendedContextMenuOnly { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,20 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
|||||||
{
|
{
|
||||||
properties = new PowerRenameProperties();
|
properties = new PowerRenameProperties();
|
||||||
version = "1";
|
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)
|
public PowerRenameSettings(string ptName)
|
||||||
|
@ -10,6 +10,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
|||||||
{
|
{
|
||||||
public static class SettingsUtils
|
public static class SettingsUtils
|
||||||
{
|
{
|
||||||
|
private const string DefaultFileName = "settings.json";
|
||||||
|
|
||||||
public static bool SettingsFolderExists(string powertoy)
|
public static bool SettingsFolderExists(string powertoy)
|
||||||
{
|
{
|
||||||
return Directory.Exists(Path.Combine(LocalApplicationDataFolder(), $"Microsoft\\PowerToys\\{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.
|
/// Get path to the json settings file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>string path.</returns>
|
/// <returns>string path.</returns>
|
||||||
public static string GetSettingsPath(string powertoy)
|
public static string GetSettingsPath(string powertoy, string fileName = DefaultFileName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(powertoy))
|
if (string.IsNullOrWhiteSpace(powertoy))
|
||||||
{
|
{
|
||||||
return Path.Combine(
|
return Path.Combine(
|
||||||
LocalApplicationDataFolder(),
|
LocalApplicationDataFolder(),
|
||||||
$"Microsoft\\PowerToys\\settings.json");
|
$"Microsoft\\PowerToys\\{fileName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Path.Combine(
|
return Path.Combine(
|
||||||
LocalApplicationDataFolder(),
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a Deserialized object of the json settings string.
|
/// Get a Deserialized object of the json settings string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Deserialized json settings object.</returns>
|
/// <returns>Deserialized json settings object.</returns>
|
||||||
public static T GetSettings<T>(string powertoy)
|
public static T GetSettings<T>(string powertoy, string fileName = DefaultFileName)
|
||||||
{
|
{
|
||||||
var jsonSettingsString = File.ReadAllText(GetSettingsPath(powertoy));
|
var jsonSettingsString = File.ReadAllText(GetSettingsPath(powertoy, fileName));
|
||||||
return JsonSerializer.Deserialize<T>(jsonSettingsString);
|
return JsonSerializer.Deserialize<T>(jsonSettingsString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save settings to a json file.
|
// 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);
|
return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
<Compile Include="ViewModels\ImageResizerViewModel.cs" />
|
<Compile Include="ViewModels\ImageResizerViewModel.cs" />
|
||||||
<Compile Include="ViewModels\KeyboardManagerViewModel.cs" />
|
<Compile Include="ViewModels\KeyboardManagerViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Keys.cs" />
|
<Compile Include="ViewModels\Keys.cs" />
|
||||||
|
<Compile Include="ViewModels\PowerPreviewViewModel.cs" />
|
||||||
<Compile Include="ViewModels\PowerRenameViewModel.cs" />
|
<Compile Include="ViewModels\PowerRenameViewModel.cs" />
|
||||||
<Compile Include="ViewModels\PowerLauncherViewModel.cs" />
|
<Compile Include="ViewModels\PowerLauncherViewModel.cs" />
|
||||||
<Compile Include="ViewModels\RemapKeysModel.cs" />
|
<Compile Include="ViewModels\RemapKeysModel.cs" />
|
||||||
|
@ -134,7 +134,7 @@
|
|||||||
<comment>Navigation view item name for General</comment>
|
<comment>Navigation view item name for General</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="Shell_PowerLauncher.Content" xml:space="preserve">
|
<data name="Shell_PowerLauncher.Content" xml:space="preserve">
|
||||||
<value>PowerLauncher</value>
|
<value>PowerLauncher [Not Functional]</value>
|
||||||
<comment>Navigation view item name for PowerLauncher</comment>
|
<comment>Navigation view item name for PowerLauncher</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="Shell_PowerRename.Content" xml:space="preserve">
|
<data name="Shell_PowerRename.Content" xml:space="preserve">
|
||||||
@ -142,7 +142,7 @@
|
|||||||
<comment>Navigation view item name for PowerRename</comment>
|
<comment>Navigation view item name for PowerRename</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="Shell_ShortcutGuide.Content" xml:space="preserve">
|
<data name="Shell_ShortcutGuide.Content" xml:space="preserve">
|
||||||
<value>Shortcut Guide</value>
|
<value>Shortcut Guide [Not Functional]</value>
|
||||||
<comment>Navigation view item name for Shortcut Guide</comment>
|
<comment>Navigation view item name for Shortcut Guide</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="Shell_PowerPreview.Content" xml:space="preserve">
|
<data name="Shell_PowerPreview.Content" xml:space="preserve">
|
||||||
@ -154,7 +154,7 @@
|
|||||||
<comment>Navigation view item name for FancyZones</comment>
|
<comment>Navigation view item name for FancyZones</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="Shell_ImageResizer.Content" xml:space="preserve">
|
<data name="Shell_ImageResizer.Content" xml:space="preserve">
|
||||||
<value>Image Resizer</value>
|
<value>Image Resizer [Not Functional]</value>
|
||||||
<comment>Navigation view item name for Image Resizer</comment>
|
<comment>Navigation view item name for Image Resizer</comment>
|
||||||
</data>
|
</data>
|
||||||
<data name="Shell_KeyboardManager.Content" xml:space="preserve">
|
<data name="Shell_KeyboardManager.Content" xml:space="preserve">
|
||||||
@ -290,8 +290,8 @@
|
|||||||
<data name="FancyZones_OverrideSnapHotkeysCheckBoxControl.Content" xml:space="preserve">
|
<data name="FancyZones_OverrideSnapHotkeysCheckBoxControl.Content" xml:space="preserve">
|
||||||
<value>Override Windows Snap hotkeys (Win + arrow) to move windows between zones</value>
|
<value>Override Windows Snap hotkeys (Win + arrow) to move windows between zones</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="FancyZones_SaveColorChoice.Content" xml:space="preserve">
|
<data name="FancyZones_SaveZoneHighlightColor.Content" xml:space="preserve">
|
||||||
<value>Save Color Choice</value>
|
<value>Save Zone Highlight Color Choice</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="FancyZones_ShiftDragCheckBoxControl_Header.Content" xml:space="preserve">
|
<data name="FancyZones_ShiftDragCheckBoxControl_Header.Content" xml:space="preserve">
|
||||||
<value>Hold Shift key or any non-primary mouse button to enable zones while dragging</value>
|
<value>Hold Shift key or any non-primary mouse button to enable zones while dragging</value>
|
||||||
@ -320,4 +320,94 @@
|
|||||||
<data name="Module_overview.Content" xml:space="preserve">
|
<data name="Module_overview.Content" xml:space="preserve">
|
||||||
<value>Module overview</value>
|
<value>Module overview</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="AttributionTitle.Text" xml:space="preserve">
|
||||||
|
<value>Attribution</value>
|
||||||
|
</data>
|
||||||
|
<data name="GeneralPage_AboutPowerToysHeader.Text" xml:space="preserve">
|
||||||
|
<value>About PowerToys</value>
|
||||||
|
</data>
|
||||||
|
<data name="GeneralPage_CheckForUpdates.Content" xml:space="preserve">
|
||||||
|
<value>Check for updates</value>
|
||||||
|
</data>
|
||||||
|
<data name="GeneralPage_PrivacyStatement_URL.Content" xml:space="preserve">
|
||||||
|
<value>Privacy statement</value>
|
||||||
|
</data>
|
||||||
|
<data name="GeneralPage_Radio_Theme_Dark.Content" xml:space="preserve">
|
||||||
|
<value>Dark</value>
|
||||||
|
</data>
|
||||||
|
<data name="GeneralPage_Radio_Theme_Default.Content" xml:space="preserve">
|
||||||
|
<value>System default</value>
|
||||||
|
</data>
|
||||||
|
<data name="GeneralPage_Radio_Theme_Light.Content" xml:space="preserve">
|
||||||
|
<value>Light</value>
|
||||||
|
</data>
|
||||||
|
<data name="GeneralPage_ReportAbug.Content" xml:space="preserve">
|
||||||
|
<value>Report a bug</value>
|
||||||
|
</data>
|
||||||
|
<data name="GeneralPage_RequestAFeature_URL.Content" xml:space="preserve">
|
||||||
|
<value>Request a feature</value>
|
||||||
|
</data>
|
||||||
|
<data name="GeneralPage_RestartAsAdmin_Button.Content" xml:space="preserve">
|
||||||
|
<value>Restart as admin</value>
|
||||||
|
</data>
|
||||||
|
<data name="GeneralPage_ToggleSwitch_RunAtStartUp.Header" xml:space="preserve">
|
||||||
|
<value>Run at startup</value>
|
||||||
|
</data>
|
||||||
|
<data name="MiscellaneousTextBlockTitle.Text" xml:space="preserve">
|
||||||
|
<value>Miscellaneous</value>
|
||||||
|
</data>
|
||||||
|
<data name="PowerRename_Description.Text" xml:space="preserve">
|
||||||
|
<value>A Windows Shell Extension for more advanced bulk renaming using search and replace or regular expressions.</value>
|
||||||
|
</data>
|
||||||
|
<data name="PowerRename_ShellIntergration.Text" xml:space="preserve">
|
||||||
|
<value>Shell integration</value>
|
||||||
|
</data>
|
||||||
|
<data name="PowerRename_Toggle_Enable.Header" xml:space="preserve">
|
||||||
|
<value>Enable PowerRename</value>
|
||||||
|
</data>
|
||||||
|
<data name="RadioButtons_Name_Theme.Header" xml:space="preserve">
|
||||||
|
<value>Theme</value>
|
||||||
|
</data>
|
||||||
|
<data name="PowerRename_Toggle_EnableOnContextMenu.Header" xml:space="preserve">
|
||||||
|
<value>Show on default context menu</value>
|
||||||
|
</data>
|
||||||
|
<data name="PowerRename_Toggle_EnableOnExtendedContextMenu.Header" xml:space="preserve">
|
||||||
|
<value>Only show on extended context menu (Shift + Right-click)</value>
|
||||||
|
</data>
|
||||||
|
<data name="PowerRename_Toggle_MaxDispListNum.Text" xml:space="preserve">
|
||||||
|
<value>Maximum numbers of items to show in recently used list</value>
|
||||||
|
</data>
|
||||||
|
<data name="PowerRename_Toggle_RestoreFlagsOnLaunch.Header" xml:space="preserve">
|
||||||
|
<value>Restore search, replace and flags values on launch from previous run</value>
|
||||||
|
</data>
|
||||||
|
<data name="FileEplorerPreview_ToggleSwitch_Preview_MD.Header" xml:space="preserve">
|
||||||
|
<value>Markdown Preview Handler</value>
|
||||||
|
</data>
|
||||||
|
<data name="FileEplorerPreview_ToggleSwitch_Preview_SVG.Header" xml:space="preserve">
|
||||||
|
<value>Svg Preview Handler</value>
|
||||||
|
</data>
|
||||||
|
<data name="FileExplorerPreview_Description.Text" xml:space="preserve">
|
||||||
|
<value>These settings allow you to manage your Windows File Explorer custom preview handlers.</value>
|
||||||
|
</data>
|
||||||
|
<data name="Miscellaneous.Text" xml:space="preserve">
|
||||||
|
<value>Miscellaneous</value>
|
||||||
|
</data>
|
||||||
|
<data name="OpenSource_Notice.Content" xml:space="preserve">
|
||||||
|
<value>Open-source notice</value>
|
||||||
|
</data>
|
||||||
|
<data name="PowerRename_Toggle_AutoComplete.Header" xml:space="preserve">
|
||||||
|
<value>Enable Auto Complete</value>
|
||||||
|
</data>
|
||||||
|
<data name="FancyZones_BorderColor.Text" xml:space="preserve">
|
||||||
|
<value>Zone border color (Default #FFFFFF)</value>
|
||||||
|
</data>
|
||||||
|
<data name="FancyZones_InActiveColor.Text" xml:space="preserve">
|
||||||
|
<value>Zone inactive color (Default #F5FCFF)</value>
|
||||||
|
</data>
|
||||||
|
<data name="FancyZones_SaveBorderColor.Content" xml:space="preserve">
|
||||||
|
<value>Save Zone Border Color Choice</value>
|
||||||
|
</data>
|
||||||
|
<data name="FancyZones_SaveZoneInActiveColor.Content" xml:space="preserve">
|
||||||
|
<value>Save Zone Inactive Color Choice</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
@ -20,11 +20,27 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
|
|
||||||
public ButtonClickCommand LaunchEditorEventHandler { get; set; }
|
public ButtonClickCommand LaunchEditorEventHandler { get; set; }
|
||||||
|
|
||||||
public ICommand SaveColorChoiceEventHandler
|
public ICommand SaveZoneHighlightColorEventHandler
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return new RelayCommand<Color>(SaveColorChoice);
|
return new RelayCommand<Color>(SaveZoneHighlightColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICommand SaveBorderColorEventHandler
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new RelayCommand<Color>(SaveZoneBorderColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICommand SaveInActiveColorEventHandler
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new RelayCommand<Color>(SaveZoneInActiveColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,9 +48,17 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
|
|
||||||
public FancyZonesViewModel()
|
public FancyZonesViewModel()
|
||||||
{
|
{
|
||||||
Settings = SettingsUtils.GetSettings<FancyZonesSettings>(ModuleName);
|
try
|
||||||
|
{
|
||||||
|
Settings = SettingsUtils.GetSettings<FancyZonesSettings>(ModuleName);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Settings = new FancyZonesSettings();
|
||||||
|
SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
||||||
|
}
|
||||||
|
|
||||||
this.LaunchEditorEventHandler = new ButtonClickCommand(LaunchEditor);
|
this.LaunchEditorEventHandler = new ButtonClickCommand(LaunchEditor);
|
||||||
// this.SaveColorChoiceEventHandler = new ButtonClickCommand(SaveColorChoice);
|
|
||||||
|
|
||||||
this._shiftDrag = Settings.Properties.FancyzonesShiftDrag.Value;
|
this._shiftDrag = Settings.Properties.FancyzonesShiftDrag.Value;
|
||||||
this._overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value;
|
this._overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value;
|
||||||
@ -49,8 +73,20 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
this._highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value;
|
this._highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value;
|
||||||
this._excludedApps = Settings.Properties.FancyzonesExcludedApps.Value;
|
this._excludedApps = Settings.Properties.FancyzonesExcludedApps.Value;
|
||||||
this._editorHotkey = Settings.Properties.FancyzonesEditorHotkey.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<GeneralSettings>(string.Empty);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
generalSettings = new GeneralSettings();
|
||||||
|
SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
GeneralSettings generalSettings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
|
|
||||||
this._isEnabled = generalSettings.Enabled.FancyZones;
|
this._isEnabled = generalSettings.Enabled.FancyZones;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,6 +104,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
private int _highlightOpacity;
|
private int _highlightOpacity;
|
||||||
private string _excludedApps;
|
private string _excludedApps;
|
||||||
private HotkeySettings _editorHotkey;
|
private HotkeySettings _editorHotkey;
|
||||||
|
private string _zoneBorderColor;
|
||||||
|
private string _zoneInActiveColor;
|
||||||
|
|
||||||
public bool IsEnabled
|
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
|
public int HighlightOpacity
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -351,11 +425,21 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
ShellPage.DefaultSndMSGCallback("{\"action\":{\"FancyZones\":{\"action_name\":\"ToggledFZEditor\", \"value\":\"\"}}}");
|
ShellPage.DefaultSndMSGCallback("{\"action\":{\"FancyZones\":{\"action_name\":\"ToggledFZEditor\", \"value\":\"\"}}}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveColorChoice(Color color)
|
private void SaveZoneHighlightColor(Color color)
|
||||||
{
|
{
|
||||||
ZoneHighlightColor = color.ToString();
|
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)
|
public void RaisePropertyChanged([CallerMemberName] string propertyName = null)
|
||||||
{
|
{
|
||||||
OnPropertyChanged(propertyName);
|
OnPropertyChanged(propertyName);
|
||||||
|
@ -2,14 +2,225 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// 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.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
|
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||||
{
|
{
|
||||||
public class GeneralViewModel : Observable
|
public class GeneralViewModel : Observable
|
||||||
{
|
{
|
||||||
|
private GeneralSettings GeneralSettingsConfigs { get; set; }
|
||||||
|
|
||||||
|
public ButtonClickCommand CheckFoUpdatesEventHandler { get; set; }
|
||||||
|
|
||||||
|
public ButtonClickCommand RestartElevatedButtonEventHandler { get; set; }
|
||||||
|
|
||||||
public GeneralViewModel()
|
public GeneralViewModel()
|
||||||
{
|
{
|
||||||
|
this.CheckFoUpdatesEventHandler = new ButtonClickCommand(CheckForUpdates_Click);
|
||||||
|
this.RestartElevatedButtonEventHandler = new ButtonClickCommand(Restart_Elevated);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
GeneralSettingsConfigs = SettingsUtils.GetSettings<GeneralSettings>(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<GeneralSettings>(string.Empty);
|
||||||
|
settings.RunElevated = true;
|
||||||
|
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
|
||||||
|
|
||||||
|
if (ShellPage.DefaultSndMSGCallback != null)
|
||||||
|
{
|
||||||
|
ShellPage.DefaultSndMSGCallback(outsettings.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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<PowerPreviewSettings>(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<SndPowerPreviewSettings> ipcMessage = new SndModuleSettings<SndPowerPreviewSettings>(snd);
|
||||||
|
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,14 +2,186 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// 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.Helpers;
|
||||||
|
using Microsoft.PowerToys.Settings.UI.Lib;
|
||||||
|
using Microsoft.PowerToys.Settings.UI.Views;
|
||||||
|
|
||||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||||
{
|
{
|
||||||
public class PowerRenameViewModel : Observable
|
public class PowerRenameViewModel : Observable
|
||||||
{
|
{
|
||||||
|
private const string ModuleName = "PowerRename";
|
||||||
|
|
||||||
|
private PowerRenameSettings Settings { get; set; }
|
||||||
|
|
||||||
public PowerRenameViewModel()
|
public PowerRenameViewModel()
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PowerRenameLocalProperties localSettings = SettingsUtils.GetSettings<PowerRenameLocalProperties>(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<GeneralSettings>(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<GeneralSettings>(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<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
||||||
|
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -130,12 +130,12 @@
|
|||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Margin="{StaticResource SmallTopMargin}"
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||||
|
|
||||||
<TextBlock x:Uid="FancyZones_ZoneHighlightColor"
|
<TextBlock x:Uid="FancyZones_ZoneHighlightColor"
|
||||||
Style="{StaticResource BodyTextBlockStyle}"
|
Style="{StaticResource BodyTextBlockStyle}"
|
||||||
Margin="{StaticResource SmallTopMargin}" />
|
Margin="{StaticResource SmallTopMargin}" />
|
||||||
|
|
||||||
<muxc:ColorPicker x:Name="ColorChoice"
|
<muxc:ColorPicker x:Name="FancyZones_ZoneHighlightColor"
|
||||||
Margin="0,6,0,0"
|
Margin="0,6,0,0"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
IsMoreButtonVisible="True"
|
IsMoreButtonVisible="True"
|
||||||
@ -146,15 +146,66 @@
|
|||||||
IsAlphaSliderVisible="True"
|
IsAlphaSliderVisible="True"
|
||||||
IsAlphaTextInputVisible="True"
|
IsAlphaTextInputVisible="True"
|
||||||
Color="{Binding Path=ZoneHighlightColor, Mode=TwoWay, Source={StaticResource eventViewModel}}"
|
Color="{Binding Path=ZoneHighlightColor, Mode=TwoWay, Source={StaticResource eventViewModel}}"
|
||||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||||
|
DataContext="{Binding ZoneHighlightColor, Source={StaticResource eventViewModel}}"/>
|
||||||
|
|
||||||
<Button x:Uid="FancyZones_SaveColorChoice"
|
<Button x:Uid="FancyZones_SaveZoneHighlightColor"
|
||||||
Margin="{StaticResource SmallTopMargin}"
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
Style="{StaticResource AccentButtonStyle}"
|
Style="{StaticResource AccentButtonStyle}"
|
||||||
Command = "{Binding SaveColorChoiceEventHandler, Source={StaticResource eventViewModel}}"
|
Command = "{Binding SaveZoneHighlightColorEventHandler, Source={StaticResource eventViewModel}}"
|
||||||
CommandParameter="{Binding Color, ElementName=ColorChoice}"
|
CommandParameter="{Binding Color, ElementName=FancyZones_ZoneHighlightColor}"
|
||||||
|
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||||
|
|
||||||
|
<TextBlock x:Uid="FancyZones_InActiveColor"
|
||||||
|
Style="{StaticResource BodyTextBlockStyle}"
|
||||||
|
Margin="{StaticResource SmallTopMargin}" />
|
||||||
|
|
||||||
|
<muxc:ColorPicker x:Name="FancyZones_InActiveColor"
|
||||||
|
Margin="0,6,0,0"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
IsMoreButtonVisible="True"
|
||||||
|
IsColorSliderVisible="True"
|
||||||
|
IsColorChannelTextInputVisible="True"
|
||||||
|
IsHexInputVisible="True"
|
||||||
|
IsAlphaEnabled="True"
|
||||||
|
IsAlphaSliderVisible="True"
|
||||||
|
IsAlphaTextInputVisible="True"
|
||||||
|
Color="{Binding Path=ZoneInActiveColor, Mode=TwoWay, Source={StaticResource eventViewModel}}"
|
||||||
|
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||||
|
DataContext="{Binding ZoneInActiveColor, Source={StaticResource eventViewModel}}"/>
|
||||||
|
|
||||||
|
<Button x:Uid="FancyZones_SaveZoneInActiveColor"
|
||||||
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
|
Style="{StaticResource AccentButtonStyle}"
|
||||||
|
Command = "{Binding SaveInActiveColorEventHandler, Source={StaticResource eventViewModel}}"
|
||||||
|
CommandParameter="{Binding Color, ElementName=FancyZones_InActiveColor}"
|
||||||
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||||
|
|
||||||
|
<TextBlock x:Uid="FancyZones_BorderColor"
|
||||||
|
Style="{StaticResource BodyTextBlockStyle}"
|
||||||
|
Margin="{StaticResource SmallTopMargin}" />
|
||||||
|
|
||||||
|
<muxc:ColorPicker x:Name="FancyZones_BorderColor"
|
||||||
|
Margin="0,6,0,0"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
IsMoreButtonVisible="True"
|
||||||
|
IsColorSliderVisible="True"
|
||||||
|
IsColorChannelTextInputVisible="True"
|
||||||
|
IsHexInputVisible="True"
|
||||||
|
IsAlphaEnabled="True"
|
||||||
|
IsAlphaSliderVisible="True"
|
||||||
|
IsAlphaTextInputVisible="True"
|
||||||
|
Color="{Binding Path=ZoneBorderColor, Mode=TwoWay, Source={StaticResource eventViewModel}}"
|
||||||
|
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||||
|
DataContext="{Binding ZoneBorderColor, Source={StaticResource eventViewModel}}"/>
|
||||||
|
|
||||||
|
<Button x:Uid="FancyZones_SaveBorderColor"
|
||||||
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
|
Style="{StaticResource AccentButtonStyle}"
|
||||||
|
Command = "{Binding SaveBorderColorEventHandler, Source={StaticResource eventViewModel}}"
|
||||||
|
CommandParameter="{Binding Color, ElementName=FancyZones_BorderColor}"
|
||||||
|
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"/>
|
||||||
|
|
||||||
<TextBlock x:Uid="FancyZones_ExcludeApps"
|
<TextBlock x:Uid="FancyZones_ExcludeApps"
|
||||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||||
|
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
<Page
|
<Page
|
||||||
x:Class="Microsoft.PowerToys.Settings.UI.Views.GeneralPage"
|
x:Class="Microsoft.PowerToys.Settings.UI.Views.GeneralPage"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Views"
|
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Views"
|
||||||
|
xmlns:viewModel="using:Microsoft.PowerToys.Settings.UI.ViewModels"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||||
|
|
||||||
|
<Page.Resources>
|
||||||
|
<viewModel:GeneralViewModel x:Key="eventViewModel"/>
|
||||||
|
</Page.Resources>
|
||||||
|
|
||||||
|
|
||||||
<Grid ColumnSpacing="{StaticResource DefaultColumnSpacing}" RowSpacing="{StaticResource DefaultRowSpacing}">
|
<Grid ColumnSpacing="{StaticResource DefaultColumnSpacing}" RowSpacing="{StaticResource DefaultRowSpacing}">
|
||||||
<VisualStateManager.VisualStateGroups>
|
<VisualStateManager.VisualStateGroups>
|
||||||
<VisualStateGroup x:Name="LayoutVisualStates">
|
<VisualStateGroup x:Name="LayoutVisualStates">
|
||||||
@ -40,76 +46,70 @@
|
|||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel Orientation="Vertical">
|
|
||||||
|
|
||||||
<ToggleSwitch Header="Run at startup" x:Name="ToggleSwitch_RunAtStartUp" Margin="{StaticResource SmallTopMargin}" Toggled="ToggleSwitch_RunAtStartUp_Toggled" />
|
<StackPanel Orientation="Vertical"
|
||||||
|
x:Name="GeneralSettingsView">
|
||||||
|
|
||||||
<muxc:RadioButtons Header="Theme" Margin="{StaticResource MediumTopMargin}">
|
<ToggleSwitch x:Uid="GeneralPage_ToggleSwitch_RunAtStartUp"
|
||||||
<RadioButton x:Name="Radio_Theme_Dark" Content="Dark" Tag="Dark" Checked="Theme_Changed"/>
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
<RadioButton x:Name="Radio_Theme_Light" Content="Light" Tag="Light" Checked="Theme_Changed"/>
|
IsOn="{Binding Mode=TwoWay, Path=Startup}"/>
|
||||||
<RadioButton x:Name="Radio_Theme_Default" Content="System default" Tag="System" Checked="Theme_Changed"/>
|
|
||||||
|
<muxc:RadioButtons x:Uid="RadioButtons_Name_Theme" Margin="{StaticResource SmallTopMargin}">
|
||||||
|
<RadioButton x:Uid="GeneralPage_Radio_Theme_Dark"
|
||||||
|
Content="Dark"
|
||||||
|
IsChecked="{ Binding Mode=TwoWay, Path=IsDarkThemeRadioButtonChecked}"/>
|
||||||
|
|
||||||
|
<RadioButton x:Uid="GeneralPage_Radio_Theme_Light"
|
||||||
|
Content="Light"
|
||||||
|
IsChecked="{ Binding Mode=TwoWay, Path=IsLightThemeRadioButtonChecked}"/>
|
||||||
|
|
||||||
|
<RadioButton x:Uid="GeneralPage_Radio_Theme_Default"
|
||||||
|
Content="System default"
|
||||||
|
IsChecked="{ Binding Mode=TwoWay, Path=IsSystemThemeRadioButtonChecked}"/>
|
||||||
</muxc:RadioButtons>
|
</muxc:RadioButtons>
|
||||||
|
|
||||||
<!--
|
<Button x:Uid="GeneralPage_RestartAsAdmin_Button"
|
||||||
<TextBlock Text="Default apps" Style="{StaticResource SettingsGroupTitleStyle}"/>
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
<ToggleSwitch Header="Disable telemetry" IsOn="True" Margin="0,14,0,0" />
|
Style="{StaticResource AccentButtonStyle}"
|
||||||
<TextBlock Text="PowerToys currently respects the Windows data & feedback setting" Opacity="0.8" Margin="0,0,0,0" />
|
Command = "{Binding RestartElevatedButtonEventHandler, Source={StaticResource eventViewModel}}"
|
||||||
-->
|
/>
|
||||||
|
|
||||||
<Button
|
|
||||||
Content="Restart as admin"
|
|
||||||
Margin="{StaticResource MediumTopMargin}"
|
|
||||||
Style="{StaticResource AccentButtonStyle}"
|
|
||||||
Click="Restart_Elevated" />
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<TextBlock Text="Default apps" Style="{StaticResource SubtitleTextBlockStyle}" Margin="0,34,0,8"/>
|
|
||||||
<ComboBox Header="Shell" SelectedIndex="0" MinWidth="240" Margin="0,14,0,0">
|
|
||||||
<ComboBoxItem>PowerShell</ComboBoxItem>
|
|
||||||
</ComboBox>
|
|
||||||
<ComboBox Header="Terminal" SelectedIndex="0" MinWidth="240" Margin="0,14,0,0">
|
|
||||||
<ComboBoxItem>Windows Console</ComboBoxItem>
|
|
||||||
</ComboBox>
|
|
||||||
-->
|
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel
|
<StackPanel x:Name="SidePanel"
|
||||||
x:Name="SidePanel"
|
Orientation="Vertical"
|
||||||
Orientation="Vertical"
|
HorizontalAlignment="Left"
|
||||||
HorizontalAlignment="Left"
|
Width="{StaticResource SidePanelWidth}"
|
||||||
Width="{StaticResource SidePanelWidth}"
|
Grid.Column="1">
|
||||||
Grid.Column="1">
|
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock x:Uid="GeneralPage_AboutPowerToysHeader"
|
||||||
Text="About PowerToys"
|
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
Margin="{StaticResource XSmallBottomMargin}"/>
|
||||||
Margin="{StaticResource XSmallBottomMargin}"/>
|
|
||||||
<TextBlock
|
<TextBlock Text="Version 0.15.2"
|
||||||
Text="Version 0.15.2"
|
FontWeight="Bold"
|
||||||
FontWeight="Bold"
|
Margin="{StaticResource SmallTopMargin}" />
|
||||||
Margin="{StaticResource SmallTopMargin}" />
|
|
||||||
<HyperlinkButton
|
<Button x:Uid="GeneralPage_CheckForUpdates"
|
||||||
Content="Release notes"
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
NavigateUri="https://github.com/microsoft/PowerToys/releases" />
|
Style="{StaticResource AccentButtonStyle}"
|
||||||
<Button
|
Foreground="White"
|
||||||
Content="Check for updates"
|
Command = "{Binding CheckFoUpdatesEventHandler, Source={StaticResource eventViewModel}}"
|
||||||
Margin="{StaticResource SmallTopMargin}"
|
/>
|
||||||
Style="{StaticResource AccentButtonStyle}"
|
|
||||||
Click="CheckForUpdates_Click" />
|
<HyperlinkButton x:Uid="GeneralPage_ReportAbug"
|
||||||
<HyperlinkButton
|
NavigateUri="https://github.com/microsoft/PowerToys/issues"
|
||||||
Content="Report a bug"
|
Margin="{StaticResource SmallTopMargin}" />
|
||||||
NavigateUri="https://github.com/microsoft/PowerToys/issues"
|
|
||||||
Margin="{StaticResource MediumTopMargin}" />
|
<HyperlinkButton x:Uid="GeneralPage_RequestAFeature_URL"
|
||||||
<HyperlinkButton
|
NavigateUri="https://github.com/microsoft/PowerToys/issues"/>
|
||||||
Content="Request a feature"
|
|
||||||
NavigateUri="https://github.com/microsoft/PowerToys/issues"/>
|
<HyperlinkButton x:Uid="GeneralPage_PrivacyStatement_URL"
|
||||||
<HyperlinkButton
|
NavigateUri=" http://go.microsoft.com/fwlink/?LinkId=521839" />
|
||||||
Content="Privacy statement"
|
|
||||||
NavigateUri="http://go.microsoft.com/fwlink/?LinkId=521839" />
|
<HyperlinkButton x:Uid="OpenSource_Notice"
|
||||||
<HyperlinkButton
|
NavigateUri="https://github.com/microsoft/PowerToys/blob/master/NOTICE.md"
|
||||||
Content="Open-source notice"
|
/>
|
||||||
NavigateUri="https://github.com/microsoft/PowerToys/blob/master/NOTICE.md" />
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using Microsoft.PowerToys.Settings.UI.Lib;
|
using Microsoft.PowerToys.Settings.UI.Lib;
|
||||||
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
||||||
using Windows.System;
|
using Windows.System;
|
||||||
|
using Windows.UI.Popups;
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Navigation;
|
using Windows.UI.Xaml.Navigation;
|
||||||
@ -18,9 +20,9 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
public sealed partial class GeneralPage : Page
|
public sealed partial class GeneralPage : Page
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets view model.
|
/// Gets or sets view model.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GeneralViewModel ViewModel { get; } = new GeneralViewModel();
|
public GeneralViewModel ViewModel { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="GeneralPage"/> class.
|
/// Initializes a new instance of the <see cref="GeneralPage"/> class.
|
||||||
@ -28,122 +30,10 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public GeneralPage()
|
public GeneralPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
this.InitializeComponent();
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
this.ViewModel = new GeneralViewModel();
|
||||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
this.GeneralSettingsView.DataContext = this.ViewModel;
|
||||||
{
|
|
||||||
base.OnNavigatedTo(e);
|
|
||||||
GeneralSettings settings = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// get settings file if they exist.
|
|
||||||
settings = SettingsUtils.GetSettings<GeneralSettings>(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update and save theme settings to json file.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="themeName">theme name.</param>
|
|
||||||
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<GeneralSettings>(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<GeneralSettings>(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<GeneralSettings>(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"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,40 +38,36 @@
|
|||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical"
|
||||||
<TextBlock Text="These settings allow you to manage your Windows File Explorer Addons."
|
x:Name="PowerPreviewSettingsView">
|
||||||
|
<TextBlock x:Uid="FileExplorerPreview_Description"
|
||||||
TextWrapping="Wrap"/>
|
TextWrapping="Wrap"/>
|
||||||
|
|
||||||
<ToggleSwitch Header="Svg Preview Handler"
|
<ToggleSwitch x:Uid="FileEplorerPreview_ToggleSwitch_Preview_SVG"
|
||||||
x:Name="ToggleSwitch_Preview_SVG"
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
Margin="{StaticResource SmallTopMargin}"
|
IsOn="{Binding Mode=TwoWay, Path=SVGRenderIsEnebled}" />
|
||||||
Toggled="ToggleSwitch_Preview_SVG_Toggled" />
|
|
||||||
|
|
||||||
<ToggleSwitch Header="Markdown Preview Handler"
|
<ToggleSwitch x:Uid="FileEplorerPreview_ToggleSwitch_Preview_MD"
|
||||||
x:Name="ToggleSwitch_Preview_MD"
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
Margin="{StaticResource SmallTopMargin}"
|
IsOn="{Binding Mode=TwoWay, Path=MDRenderIsEnebled}" />
|
||||||
Toggled="ToggleSwitch_Preview_MD_Toggled" />
|
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel
|
<StackPanel x:Name="SidePanel"
|
||||||
x:Name="SidePanel"
|
Orientation="Vertical"
|
||||||
Orientation="Vertical"
|
HorizontalAlignment="Left"
|
||||||
HorizontalAlignment="Left"
|
Width="{StaticResource SidePanelWidth}"
|
||||||
Width="{StaticResource SidePanelWidth}"
|
Grid.Column="1">
|
||||||
Grid.Column="1">
|
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock x:Uid="About_This_Feature"
|
||||||
Text="About this feature"
|
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
Margin="{StaticResource XSmallBottomMargin}"/>
|
||||||
Margin="{StaticResource XSmallBottomMargin}"/>
|
|
||||||
|
|
||||||
<HyperlinkButton
|
<HyperlinkButton x:Uid="Module_overview"
|
||||||
Content="Module overview"
|
NavigateUri="https://github.com/microsoft/PowerToys/tree/master/src/modules/previewpane"/>
|
||||||
NavigateUri="https://github.com/microsoft/PowerToys/tree/master/src/modules/previewpane"/>
|
|
||||||
<HyperlinkButton
|
<HyperlinkButton x:Uid="Give_Feedback"
|
||||||
Content="Give feedback"
|
NavigateUri="https://github.com/microsoft/PowerToys/issues"/>
|
||||||
NavigateUri="https://github.com/microsoft/PowerToys/issues"/>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
@ -2,7 +2,9 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using Microsoft.PowerToys.Settings.UI.Lib;
|
using Microsoft.PowerToys.Settings.UI.Lib;
|
||||||
|
using Microsoft.PowerToys.Settings.UI.ViewModels;
|
||||||
using Windows.UI.Xaml;
|
using Windows.UI.Xaml;
|
||||||
using Windows.UI.Xaml.Controls;
|
using Windows.UI.Xaml.Controls;
|
||||||
using Windows.UI.Xaml.Navigation;
|
using Windows.UI.Xaml.Navigation;
|
||||||
@ -14,67 +16,13 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class PowerPreviewPage : Page
|
public sealed partial class PowerPreviewPage : Page
|
||||||
{
|
{
|
||||||
private const string PreviewPaneKey = "File Explorer Preview";
|
public PowerPreviewViewModel viewModel { get; set; }
|
||||||
|
|
||||||
public PowerPreviewPage()
|
public PowerPreviewPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
this.InitializeComponent();
|
||||||
}
|
viewModel = new PowerPreviewViewModel();
|
||||||
|
this.PowerPreviewSettingsView.DataContext = viewModel;
|
||||||
/// <inheritdoc/>
|
|
||||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
|
||||||
{
|
|
||||||
PowerPreviewSettings settings;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
base.OnNavigatedTo(e);
|
|
||||||
settings = SettingsUtils.GetSettings<PowerPreviewSettings>(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<PowerPreviewSettings>(PreviewPaneKey);
|
|
||||||
settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.Value = swt.IsOn;
|
|
||||||
|
|
||||||
if (ShellPage.DefaultSndMSGCallback != null)
|
|
||||||
{
|
|
||||||
SndPowerPreviewSettings snd = new SndPowerPreviewSettings(settings);
|
|
||||||
SndModuleSettings<SndPowerPreviewSettings> ipcMessage = new SndModuleSettings<SndPowerPreviewSettings>(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<PowerPreviewSettings>(PreviewPaneKey);
|
|
||||||
settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.Value = swt.IsOn;
|
|
||||||
|
|
||||||
if (ShellPage.DefaultSndMSGCallback != null)
|
|
||||||
{
|
|
||||||
SndPowerPreviewSettings snd = new SndPowerPreviewSettings(settings);
|
|
||||||
SndModuleSettings<SndPowerPreviewSettings> ipcMessage = new SndModuleSettings<SndPowerPreviewSettings>(snd);
|
|
||||||
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,74 +39,81 @@
|
|||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical"
|
||||||
<TextBlock Text="A Windows Shell Extension for more advanced bulk renaming using search and replace or regular expressions."
|
x:Name="PowerRenameSettingsView">
|
||||||
|
|
||||||
|
<TextBlock x:Uid="PowerRename_Description"
|
||||||
TextWrapping="Wrap"/>
|
TextWrapping="Wrap"/>
|
||||||
|
|
||||||
<ToggleSwitch x:Name="Toggle_PowerRename_Enable"
|
<ToggleSwitch x:Uid="PowerRename_Toggle_Enable"
|
||||||
Header="Enable PowerRename"
|
|
||||||
Margin="{StaticResource SmallTopMargin}"
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
Toggled="Toggle_PowerRename_Enable_Toggled"
|
IsOn="{Binding Mode=TwoWay, Path=IsEnabled}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextBlock Text="Shell integration"
|
<ToggleSwitch x:Uid="PowerRename_Toggle_AutoComplete"
|
||||||
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
|
IsOn="{Binding Mode=TwoWay, Path=MRUEnabled}"
|
||||||
|
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextBlock x:Uid="PowerRename_ShellIntergration"
|
||||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||||
|
|
||||||
<ToggleSwitch x:Name="Toggle_PowerRename_EnableOnContextMenu"
|
<ToggleSwitch x:Uid="PowerRename_Toggle_EnableOnContextMenu"
|
||||||
Header="Show on default context menu"
|
|
||||||
Margin="{StaticResource SmallTopMargin}"
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
Toggled="Toggle_PowerRename_EnableOnContextMenu_Toggled"
|
IsOn="{Binding Mode=TwoWay, Path=EnabledOnContextMenu}"
|
||||||
|
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ToggleSwitch x:Name="Toggle_PowerRename_EnableOnExtendedContextMenu"
|
<ToggleSwitch x:Uid="PowerRename_Toggle_EnableOnExtendedContextMenu"
|
||||||
Header="Only show on extended context menu (Shift + Right-click)"
|
|
||||||
Margin="{StaticResource SmallTopMargin}"
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
Toggled="Toggle_PowerRename_EnableOnExtendedContextMenu_Toggled"
|
IsOn="{Binding Mode=TwoWay, Path=EnabledOnContextExtendedMenu}"
|
||||||
|
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextBlock Text="Miscellaneous"
|
<TextBlock x:Uid="Miscellaneous"
|
||||||
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
Style="{StaticResource SettingsGroupTitleStyle}"/>
|
||||||
|
|
||||||
<ToggleSwitch x:Name="Toggle_PowerRename_RestoreFlagsOnLaunch"
|
<ToggleSwitch x:Uid="PowerRename_Toggle_RestoreFlagsOnLaunch"
|
||||||
Header="Restore search, replace and flags values on launch from previous run"
|
|
||||||
Margin="{StaticResource SmallTopMargin}"
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
Toggled="Toggle_PowerRename_RestoreFlagsOnLaunch_Toggled"
|
IsOn="{Binding Mode=TwoWay, Path=RestoreFlagsOnLaunch}"
|
||||||
|
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<muxc:NumberBox x:Name="Toggle_PowerRename_MaxDispListNum"
|
<muxc:NumberBox x:Name="PowerRename_Toggle_MaxDispListNum"
|
||||||
Header="Maximum numbers of items to show in recently used list"
|
|
||||||
SpinButtonPlacementMode="Inline"
|
SpinButtonPlacementMode="Inline"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Margin="{StaticResource SmallTopMargin}"
|
Margin="{StaticResource SmallTopMargin}"
|
||||||
ValueChanged="Toggle_PowerRename_MaxDispListNum_ValueChanged"
|
Value="{Binding Mode=TwoWay, Path=MaxDispListNum}"
|
||||||
|
IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}"
|
||||||
/>
|
/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
<StackPanel
|
<StackPanel x:Name="SidePanel"
|
||||||
x:Name="SidePanel"
|
Orientation="Vertical"
|
||||||
Orientation="Vertical"
|
HorizontalAlignment="Left"
|
||||||
HorizontalAlignment="Left"
|
Width="{StaticResource SidePanelWidth}"
|
||||||
Width="{StaticResource SidePanelWidth}"
|
Grid.Column="1">
|
||||||
Grid.Column="1">
|
|
||||||
|
<TextBlock x:Uid="About_This_Feature"
|
||||||
|
Style="{StaticResource SettingsGroupTitleStyle}"
|
||||||
|
Margin="{StaticResource XSmallBottomMargin}"/>
|
||||||
|
|
||||||
|
<HyperlinkButton x:Uid="Module_overview"
|
||||||
|
NavigateUri="https://github.com/microsoft/PowerToys/tree/master/src/modules/powerrename"/>
|
||||||
|
|
||||||
|
<HyperlinkButton x:Uid="Give_Feedback"
|
||||||
|
NavigateUri="https://github.com/microsoft/PowerToys/issues"/>
|
||||||
|
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="About this feature"
|
x:Uid="AttributionTitle"
|
||||||
Style="{StaticResource SettingsGroupTitleStyle}"
|
|
||||||
Margin="{StaticResource XSmallBottomMargin}"/>
|
|
||||||
|
|
||||||
<HyperlinkButton
|
|
||||||
Content="Module overview"
|
|
||||||
NavigateUri="https://github.com/microsoft/PowerToys/tree/master/src/modules/powerrename"/>
|
|
||||||
|
|
||||||
<TextBlock
|
|
||||||
Text="Attribution"
|
|
||||||
Style="{StaticResource SettingsGroupTitleStyle}" />
|
Style="{StaticResource SettingsGroupTitleStyle}" />
|
||||||
|
|
||||||
<HyperlinkButton
|
<HyperlinkButton
|
||||||
Content="Chris Davis's SmartRenamer"
|
Content="Chris Davis's SmartRenamer"
|
||||||
NavigateUri="https://github.com/chrdavis/SmartRename" />
|
NavigateUri="https://github.com/chrdavis/SmartRename" />
|
||||||
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
@ -14,128 +14,14 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
{
|
{
|
||||||
public sealed partial class PowerRenamePage : Page
|
public sealed partial class PowerRenamePage : Page
|
||||||
{
|
{
|
||||||
public PowerRenameViewModel ViewModel { get; } = new PowerRenameViewModel();
|
public PowerRenameViewModel ViewModel { get; set; }
|
||||||
|
|
||||||
private const string POWERTOYNAME = "PowerRename";
|
|
||||||
|
|
||||||
public PowerRenamePage()
|
public PowerRenamePage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
this.InitializeComponent();
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
ViewModel = new PowerRenameViewModel();
|
||||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
this.PowerRenameSettingsView.DataContext = ViewModel;
|
||||||
{
|
|
||||||
base.OnNavigatedTo(e);
|
|
||||||
PowerRenameSettings settings;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
settings = SettingsUtils.GetSettings<PowerRenameSettings>(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<PowerRenameSettings>(POWERTOYNAME);
|
|
||||||
settings.properties.MruEnabled.Value = swt.IsOn;
|
|
||||||
|
|
||||||
if (ShellPage.DefaultSndMSGCallback != null)
|
|
||||||
{
|
|
||||||
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
|
||||||
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(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<PowerRenameSettings>(POWERTOYNAME);
|
|
||||||
settings.properties.ShowIconInMenu.Value = swt.IsOn;
|
|
||||||
|
|
||||||
if (ShellPage.DefaultSndMSGCallback != null)
|
|
||||||
{
|
|
||||||
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
|
||||||
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(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<PowerRenameSettings>(POWERTOYNAME);
|
|
||||||
settings.properties.ShowExtendedMenu.Value = swt.IsOn;
|
|
||||||
|
|
||||||
if (ShellPage.DefaultSndMSGCallback != null)
|
|
||||||
{
|
|
||||||
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
|
||||||
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(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<PowerRenameSettings>(POWERTOYNAME);
|
|
||||||
settings.properties.PersistInput.Value = swt.IsOn;
|
|
||||||
|
|
||||||
if (ShellPage.DefaultSndMSGCallback != null)
|
|
||||||
{
|
|
||||||
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
|
||||||
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
|
||||||
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Toggle_PowerRename_MaxDispListNum_ValueChanged(NumberBox sender, NumberBoxValueChangedEventArgs args)
|
|
||||||
{
|
|
||||||
if (sender != null)
|
|
||||||
{
|
|
||||||
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
|
|
||||||
settings.properties.MaxMruSize.Value = Convert.ToInt32(sender.Value);
|
|
||||||
|
|
||||||
if (ShellPage.DefaultSndMSGCallback != null)
|
|
||||||
{
|
|
||||||
SndPowerRenameSettings snd = new SndPowerRenameSettings(settings);
|
|
||||||
SndModuleSettings<SndPowerRenameSettings> ipcMessage = new SndModuleSettings<SndPowerRenameSettings>(snd);
|
|
||||||
ShellPage.DefaultSndMSGCallback(ipcMessage.ToJsonString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 3.1 KiB |
@ -0,0 +1,184 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
|
<ProjectGuid>{A80355C2-780D-4245-BD80-25B8DE698EE3}</ProjectGuid>
|
||||||
|
<OutputType>AppContainerExe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Microsoft.PowerToys.Settings.UnitTest</RootNamespace>
|
||||||
|
<AssemblyName>Microsoft.PowerToys.Settings.UnitTest</AssemblyName>
|
||||||
|
<DefaultLanguage>en-US</DefaultLanguage>
|
||||||
|
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||||
|
<TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
|
||||||
|
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
|
||||||
|
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<UnitTestPlatformVersion Condition="'$(UnitTestPlatformVersion)' == ''">$(VisualStudioVersion)</UnitTestPlatformVersion>
|
||||||
|
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>ARM</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||||
|
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>ARM</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\ARM64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>ARM64</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
|
||||||
|
<OutputPath>bin\ARM64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>ARM64</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\Debug\Test\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<SDKReference Include="TestPlatform.Universal, Version=$(UnitTestPlatformVersion)" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="ModelsTests\BasePTModuleSettingsTest.cs" />
|
||||||
|
<Compile Include="ModelsTests\BasePTSettingsTest.cs" />
|
||||||
|
<Compile Include="ModelsTests\SettingsUtilsTests.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="UnitTestApp.xaml.cs">
|
||||||
|
<DependentUpon>UnitTestApp.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ViewModelTests\GeneralSettingsViewModelTest.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ApplicationDefinition Include="UnitTestApp.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</ApplicationDefinition>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AppxManifest Include="Package.appxmanifest">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</AppxManifest>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||||
|
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||||
|
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||||
|
<Content Include="Assets\Square44x44Logo.scale-200.png" />
|
||||||
|
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||||
|
<Content Include="Assets\StoreLogo.png" />
|
||||||
|
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||||
|
<Version>6.2.9</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="MSTest.TestAdapter">
|
||||||
|
<Version>1.4.0</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="MSTest.TestFramework">
|
||||||
|
<Version>1.4.0</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Microsoft.PowerToys.Settings.UI.Lib\Microsoft.PowerToys.Settings.UI.Lib.csproj">
|
||||||
|
<Project>{b1bcc8c6-46b5-4bfa-8f22-20f32d99ec6a}</Project>
|
||||||
|
<Name>Microsoft.PowerToys.Settings.UI.Lib</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Microsoft.PowerToys.Settings.UI\Microsoft.PowerToys.Settings.UI.csproj">
|
||||||
|
<Project>{a7d5099e-f0fd-4bf3-8522-5a682759f915}</Project>
|
||||||
|
<Name>Microsoft.PowerToys.Settings.UI</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
|
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||||
|
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
@ -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<BasePTSettingsTest>(file_name).ToJsonString());
|
||||||
|
bool valid = actualSchema.IsValid(expectedSchema);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.IsTrue(valid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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<BasePTSettingsTest>(file_contents_correct_json_content);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
SettingsUtils.SaveSettings(file_contents_correct_json_content, file_name);
|
||||||
|
BasePTSettingsTest actual_json = SettingsUtils.GetSettings<BasePTSettingsTest>(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<BasePTSettingsTest>(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<BasePTSettingsTest>(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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Package
|
||||||
|
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||||
|
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||||
|
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||||
|
IgnorableNamespaces="uap mp">
|
||||||
|
|
||||||
|
<Identity Name="08e1807b-8b6d-4bfa-adc4-79c64aae8e78"
|
||||||
|
Publisher="CN=lamotile"
|
||||||
|
Version="1.0.0.0" />
|
||||||
|
|
||||||
|
<mp:PhoneIdentity PhoneProductId="08e1807b-8b6d-4bfa-adc4-79c64aae8e78" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||||
|
|
||||||
|
<Properties>
|
||||||
|
<DisplayName>Microsoft.PowerToys.Settings.UnitTest</DisplayName>
|
||||||
|
<PublisherDisplayName>lamotile</PublisherDisplayName>
|
||||||
|
<Logo>Assets\StoreLogo.png</Logo>
|
||||||
|
</Properties>
|
||||||
|
|
||||||
|
<Dependencies>
|
||||||
|
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||||
|
</Dependencies>
|
||||||
|
|
||||||
|
<Resources>
|
||||||
|
<Resource Language="x-generate" />
|
||||||
|
</Resources>
|
||||||
|
<Applications>
|
||||||
|
<Application Id="vstest.executionengine.universal.App"
|
||||||
|
Executable="$targetnametoken$.exe"
|
||||||
|
EntryPoint="Microsoft.PowerToys.Settings.UnitTest.App">
|
||||||
|
<uap:VisualElements
|
||||||
|
DisplayName="Microsoft.PowerToys.Settings.UnitTest"
|
||||||
|
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||||
|
Square44x44Logo="Assets\Square44x44Logo.png"
|
||||||
|
Description="Microsoft.PowerToys.Settings.UnitTest"
|
||||||
|
BackgroundColor="transparent">
|
||||||
|
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
|
||||||
|
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||||
|
</uap:VisualElements>
|
||||||
|
</Application>
|
||||||
|
</Applications>
|
||||||
|
<Capabilities>
|
||||||
|
<Capability Name="internetClientServer" />
|
||||||
|
<Capability Name="privateNetworkClientServer" />
|
||||||
|
</Capabilities>
|
||||||
|
</Package>
|
@ -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)]
|
@ -0,0 +1,7 @@
|
|||||||
|
<Application
|
||||||
|
x:Class="Microsoft.PowerToys.Settings.UnitTest.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="using:Microsoft.PowerToys.Settings.UnitTest">
|
||||||
|
|
||||||
|
</Application>
|
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides application-specific behavior to supplement the default Application class.
|
||||||
|
/// </summary>
|
||||||
|
sealed partial class App : Application
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 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().
|
||||||
|
/// </summary>
|
||||||
|
public App()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
this.Suspending += OnSuspending;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">Details about the launch request and process.</param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when Navigation to a certain page fails
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The Frame which failed navigation</param>
|
||||||
|
/// <param name="e">Details about the navigation failure</param>
|
||||||
|
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||||
|
{
|
||||||
|
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The source of the suspend request.</param>
|
||||||
|
/// <param name="e">Details about the suspend request.</param>
|
||||||
|
private void OnSuspending(object sender, SuspendingEventArgs e)
|
||||||
|
{
|
||||||
|
var deferral = e.SuspendingOperation.GetDeferral();
|
||||||
|
//TODO: Save application state and stop any background activity
|
||||||
|
deferral.Complete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|