[warningsAsErrors] Getting settings online (#6053)

* getting everything to compile

* fixing json
This commit is contained in:
Clint Rutkas
2020-08-19 15:59:10 -07:00
committed by GitHub
parent 9724afd9ec
commit dc744f236e
46 changed files with 162 additions and 213 deletions

View File

@@ -3,9 +3,7 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using Microsoft.PowerToys.Settings.UI.Lib.Utilities;
namespace Microsoft.PowerToys.Settings.UI.Lib namespace Microsoft.PowerToys.Settings.UI.Lib
{ {

View File

@@ -21,7 +21,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public virtual string ToJsonString() public virtual string ToJsonString()
{ {
// By default JsonSerializer will only serialize the properties in the base class. This can be avoided by passing the object type (more details at https://stackoverflow.com/a/62498888) // By default JsonSerializer will only serialize the properties in the base class. This can be avoided by passing the object type (more details at https://stackoverflow.com/a/62498888)
return JsonSerializer.Serialize(this, this.GetType()); return JsonSerializer.Serialize(this, GetType());
} }
} }
} }

View File

@@ -2,9 +2,6 @@
// 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.Collections.Generic;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -14,7 +11,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{ {
public BoolProperty() public BoolProperty()
{ {
this.Value = false; Value = false;
} }
public BoolProperty(bool value) public BoolProperty(bool value)

View File

@@ -3,8 +3,6 @@
// 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.Collections.Generic;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;

View File

@@ -2,10 +2,6 @@
// 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.Collections.Generic;
using System.Text;
namespace Microsoft.PowerToys.Settings.UI.Lib namespace Microsoft.PowerToys.Settings.UI.Lib
{ {
public static class ConfigDefaults public static class ConfigDefaults

View File

@@ -12,7 +12,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{ {
public DoubleProperty() public DoubleProperty()
{ {
this.Value = 0.0; Value = 0.0;
} }
public DoubleProperty(double value) public DoubleProperty(double value)

View File

@@ -21,13 +21,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonPropertyName("FancyZones")] [JsonPropertyName("FancyZones")]
public bool FancyZones public bool FancyZones
{ {
get => this.fancyZones; get => fancyZones;
set set
{ {
if (this.fancyZones != value) if (fancyZones != value)
{ {
LogTelemetryEvent(value); LogTelemetryEvent(value);
this.fancyZones = value; fancyZones = value;
} }
} }
} }
@@ -37,13 +37,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonPropertyName("Image Resizer")] [JsonPropertyName("Image Resizer")]
public bool ImageResizer public bool ImageResizer
{ {
get => this.imageResizer; get => imageResizer;
set set
{ {
if (this.imageResizer != value) if (imageResizer != value)
{ {
LogTelemetryEvent(value); LogTelemetryEvent(value);
this.imageResizer = value; imageResizer = value;
} }
} }
} }
@@ -53,13 +53,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonPropertyName("File Explorer Preview")] [JsonPropertyName("File Explorer Preview")]
public bool FileExplorerPreview public bool FileExplorerPreview
{ {
get => this.fileExplorerPreview; get => fileExplorerPreview;
set set
{ {
if (this.fileExplorerPreview != value) if (fileExplorerPreview != value)
{ {
LogTelemetryEvent(value); LogTelemetryEvent(value);
this.fileExplorerPreview = value; fileExplorerPreview = value;
} }
} }
} }
@@ -69,13 +69,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonPropertyName("Shortcut Guide")] [JsonPropertyName("Shortcut Guide")]
public bool ShortcutGuide public bool ShortcutGuide
{ {
get => this.shortcutGuide; get => shortcutGuide;
set set
{ {
if (this.shortcutGuide != value) if (shortcutGuide != value)
{ {
LogTelemetryEvent(value); LogTelemetryEvent(value);
this.shortcutGuide = value; shortcutGuide = value;
} }
} }
} }
@@ -84,13 +84,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public bool PowerRename public bool PowerRename
{ {
get => this.powerRename; get => powerRename;
set set
{ {
if (this.powerRename != value) if (powerRename != value)
{ {
LogTelemetryEvent(value); LogTelemetryEvent(value);
this.powerRename = value; powerRename = value;
} }
} }
} }
@@ -100,13 +100,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonPropertyName("Keyboard Manager")] [JsonPropertyName("Keyboard Manager")]
public bool KeyboardManager public bool KeyboardManager
{ {
get => this.keyboardManager; get => keyboardManager;
set set
{ {
if (this.keyboardManager != value) if (keyboardManager != value)
{ {
LogTelemetryEvent(value); LogTelemetryEvent(value);
this.keyboardManager = value; keyboardManager = value;
} }
} }
} }
@@ -116,13 +116,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonPropertyName("PowerToys Run")] [JsonPropertyName("PowerToys Run")]
public bool PowerLauncher public bool PowerLauncher
{ {
get => this.powerLauncher; get => powerLauncher;
set set
{ {
if (this.powerLauncher != value) if (powerLauncher != value)
{ {
LogTelemetryEvent(value); LogTelemetryEvent(value);
this.powerLauncher = value; powerLauncher = value;
} }
} }
} }
@@ -132,13 +132,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonPropertyName("ColorPicker")] [JsonPropertyName("ColorPicker")]
public bool ColorPicker public bool ColorPicker
{ {
get => this.colorPicker; get => colorPicker;
set set
{ {
if (this.colorPicker != value) if (colorPicker != value)
{ {
LogTelemetryEvent(value); LogTelemetryEvent(value);
this.colorPicker = value; colorPicker = value;
} }
} }
} }

View File

@@ -2,9 +2,6 @@
// 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.Collections.Generic;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -21,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public FancyZonesSettingsIPCMessage(SndFancyZonesSettings settings) public FancyZonesSettingsIPCMessage(SndFancyZonesSettings settings)
{ {
this.Powertoys = settings; Powertoys = settings;
} }
public string ToJsonString() public string ToJsonString()

View File

@@ -52,24 +52,24 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public GeneralSettings() public GeneralSettings()
{ {
this.Packaged = false; Packaged = false;
this.Startup = false; Startup = false;
this.IsAdmin = false; IsAdmin = false;
this.IsElevated = false; IsElevated = false;
this.AutoDownloadUpdates = false; AutoDownloadUpdates = false;
this.Theme = "system"; Theme = "system";
this.SystemTheme = "light"; SystemTheme = "light";
try try
{ {
this.PowertoysVersion = DefaultPowertoysVersion(); PowertoysVersion = DefaultPowertoysVersion();
} }
catch catch
{ {
this.PowertoysVersion = "v0.0.0"; PowertoysVersion = "v0.0.0";
} }
this.Enabled = new EnabledModules(); Enabled = new EnabledModules();
this.CustomActionName = string.Empty; CustomActionName = string.Empty;
} }
// converts the current to a json string. // converts the current to a json string.

View File

@@ -2,7 +2,6 @@
// 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.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib namespace Microsoft.PowerToys.Settings.UI.Lib

View File

@@ -2,7 +2,6 @@
// 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.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;

View File

@@ -2,11 +2,8 @@
// 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.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;

View File

@@ -12,7 +12,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{ {
public IntProperty() public IntProperty()
{ {
this.Value = 0; Value = 0;
} }
public IntProperty(int value) public IntProperty(int value)

View File

@@ -2,7 +2,6 @@
// 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.Collections.Generic;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib namespace Microsoft.PowerToys.Settings.UI.Lib

View File

@@ -14,6 +14,7 @@
<RepositoryType>Github</RepositoryType> <RepositoryType>Github</RepositoryType>
<PackageTags>PowerToys</PackageTags> <PackageTags>PowerToys</PackageTags>
<NeutralLanguage>en-US</NeutralLanguage> <NeutralLanguage>en-US</NeutralLanguage>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">

View File

@@ -18,13 +18,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonConverter(typeof(BoolPropertyJsonConverter))] [JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool EnableSvgPreview public bool EnableSvgPreview
{ {
get => this.enableSvgPreview; get => enableSvgPreview;
set set
{ {
if (value != this.enableSvgPreview) if (value != enableSvgPreview)
{ {
LogTelemetryEvent(value); LogTelemetryEvent(value);
this.enableSvgPreview = value; enableSvgPreview = value;
} }
} }
} }
@@ -35,13 +35,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonConverter(typeof(BoolPropertyJsonConverter))] [JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool EnableSvgThumbnail public bool EnableSvgThumbnail
{ {
get => this.enableSvgThumbnail; get => enableSvgThumbnail;
set set
{ {
if (value != this.enableSvgThumbnail) if (value != enableSvgThumbnail)
{ {
LogTelemetryEvent(value); LogTelemetryEvent(value);
this.enableSvgThumbnail = value; enableSvgThumbnail = value;
} }
} }
} }
@@ -52,13 +52,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
[JsonConverter(typeof(BoolPropertyJsonConverter))] [JsonConverter(typeof(BoolPropertyJsonConverter))]
public bool EnableMdPreview public bool EnableMdPreview
{ {
get => this.enableMdPreview; get => enableMdPreview;
set set
{ {
if (value != this.enableMdPreview) if (value != enableMdPreview)
{ {
LogTelemetryEvent(value); LogTelemetryEvent(value);
this.enableMdPreview = value; enableMdPreview = value;
} }
} }
} }

View File

@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib namespace Microsoft.PowerToys.Settings.UI.Lib
{ {

View File

@@ -2,9 +2,6 @@
// 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.Collections.Generic;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -21,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public PowerRenameSettingsIPCMessage(SndPowerRenameSettings settings) public PowerRenameSettingsIPCMessage(SndPowerRenameSettings settings)
{ {
this.Powertoys = settings; Powertoys = settings;
} }
public string ToJsonString() public string ToJsonString()

View File

@@ -2,9 +2,6 @@
// 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.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib namespace Microsoft.PowerToys.Settings.UI.Lib

View File

@@ -2,9 +2,6 @@
// 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.Collections.Generic;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -21,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public ShortcutGuideSettingsIPCMessage(SndShortcutGuideSettings settings) public ShortcutGuideSettingsIPCMessage(SndShortcutGuideSettings settings)
{ {
this.Powertoys = settings; Powertoys = settings;
} }
public string ToJsonString() public string ToJsonString()

View File

@@ -2,11 +2,7 @@
// 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.Collections.Generic;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib namespace Microsoft.PowerToys.Settings.UI.Lib
{ {
@@ -20,7 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public SndFancyZonesSettings(FancyZonesSettings settings) public SndFancyZonesSettings(FancyZonesSettings settings)
{ {
this.FancyZones = settings; FancyZones = settings;
} }
public string ToJsonString() public string ToJsonString()

View File

@@ -2,9 +2,6 @@
// 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.Collections.Generic;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -17,7 +14,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public SndImageResizerSettings(ImageResizerSettings settings) public SndImageResizerSettings(ImageResizerSettings settings)
{ {
this.ImageResizer = settings; ImageResizer = settings;
} }
public string ToJsonString() public string ToJsonString()

View File

@@ -3,13 +3,15 @@
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib namespace Microsoft.PowerToys.Settings.UI.Lib
{ {
// Represents a powertoys module settings setnt to the runner. // Represents a powertoys module settings setnt to the runner.
public class SndModuleSettings<T> public class SndModuleSettings<T>
{ {
public T powertoys { get; set; } [JsonPropertyName("powertoys")]
public T PowertoysSetting { get; set; }
public SndModuleSettings() public SndModuleSettings()
{ {
@@ -17,7 +19,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public SndModuleSettings(T settings) public SndModuleSettings(T settings)
{ {
this.powertoys = settings; PowertoysSetting = settings;
} }
public string ToJsonString() public string ToJsonString()

View File

@@ -2,9 +2,6 @@
// 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.Collections.Generic;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;

View File

@@ -2,9 +2,6 @@
// 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.Collections.Generic;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -21,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public SndShortcutGuideSettings(ShortcutGuideSettings settings) public SndShortcutGuideSettings(ShortcutGuideSettings settings)
{ {
this.ShortcutGuide = settings; ShortcutGuide = settings;
} }
public string ToJsonString() public string ToJsonString()

View File

@@ -2,9 +2,6 @@
// 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.Collections.Generic;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -15,7 +12,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{ {
public StringProperty() public StringProperty()
{ {
this.Value = string.Empty; Value = string.Empty;
} }
public StringProperty(string value) public StringProperty(string value)

View File

@@ -7,9 +7,6 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using Microsoft.PowerToys.Settings.UI.Lib.CustomAction; using Microsoft.PowerToys.Settings.UI.Lib.CustomAction;
namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities

View File

@@ -13,7 +13,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels.Commands
public ButtonClickCommand(Action execute) public ButtonClickCommand(Action execute)
{ {
this._execute = execute; _execute = execute;
} }
// Occurs when changes occur that affect whether or not the command should execute. // Occurs when changes occur that affect whether or not the command should execute.
@@ -30,5 +30,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels.Commands
{ {
_execute(); _execute();
} }
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
} }
} }

View File

@@ -35,35 +35,35 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
SettingsUtils.SaveSettings(Settings.ToJsonString(), GetSettingsSubPath()); SettingsUtils.SaveSettings(Settings.ToJsonString(), GetSettingsSubPath());
} }
this.LaunchEditorEventHandler = new ButtonClickCommand(LaunchEditor); LaunchEditorEventHandler = new ButtonClickCommand(LaunchEditor);
this._shiftDrag = Settings.Properties.FancyzonesShiftDrag.Value; _shiftDrag = Settings.Properties.FancyzonesShiftDrag.Value;
this._mouseSwitch = Settings.Properties.FancyzonesMouseSwitch.Value; _mouseSwitch = Settings.Properties.FancyzonesMouseSwitch.Value;
this._overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value; _overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value;
this._moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value; _moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value;
this._displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value; _displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value;
this._zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value; _zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value;
this._appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value; _appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value;
this._openWindowOnActiveMonitor = Settings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value; _openWindowOnActiveMonitor = Settings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value;
this._restoreSize = Settings.Properties.FancyzonesRestoreSize.Value; _restoreSize = Settings.Properties.FancyzonesRestoreSize.Value;
this._useCursorPosEditorStartupScreen = Settings.Properties.UseCursorposEditorStartupscreen.Value; _useCursorPosEditorStartupScreen = Settings.Properties.UseCursorposEditorStartupscreen.Value;
this._showOnAllMonitors = Settings.Properties.FancyzonesShowOnAllMonitors.Value; _showOnAllMonitors = Settings.Properties.FancyzonesShowOnAllMonitors.Value;
this._makeDraggedWindowTransparent = Settings.Properties.FancyzonesMakeDraggedWindowTransparent.Value; _makeDraggedWindowTransparent = Settings.Properties.FancyzonesMakeDraggedWindowTransparent.Value;
this._highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value; _highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value;
this._excludedApps = Settings.Properties.FancyzonesExcludedApps.Value; _excludedApps = Settings.Properties.FancyzonesExcludedApps.Value;
this.EditorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value; EditorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value;
// set the callback functions value to hangle outgoing IPC message. // set the callback functions value to hangle outgoing IPC message.
SendConfigMSG = ipcMSGCallBackFunc; SendConfigMSG = ipcMSGCallBackFunc;
string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value; string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value;
this._zoneInActiveColor = inactiveColor != string.Empty ? inactiveColor : "#F5FCFF"; _zoneInActiveColor = inactiveColor != string.Empty ? inactiveColor : "#F5FCFF";
string borderColor = Settings.Properties.FancyzonesBorderColor.Value; string borderColor = Settings.Properties.FancyzonesBorderColor.Value;
this._zoneBorderColor = borderColor != string.Empty ? borderColor : "#FFFFFF"; _zoneBorderColor = borderColor != string.Empty ? borderColor : "#FFFFFF";
string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value; string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value;
this._zoneHighlightColor = highlightColor != string.Empty ? highlightColor : "#0078D7"; _zoneHighlightColor = highlightColor != string.Empty ? highlightColor : "#0078D7";
GeneralSettings generalSettings; GeneralSettings generalSettings;
try try
@@ -76,7 +76,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty); SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty);
} }
this._isEnabled = generalSettings.Enabled.FancyZones; _isEnabled = generalSettings.Enabled.FancyZones;
} }
private bool _isEnabled; private bool _isEnabled;

View File

@@ -5,7 +5,6 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text.Json;
using Microsoft.PowerToys.Settings.UI.Lib.Helpers; using Microsoft.PowerToys.Settings.UI.Lib.Helpers;
using Microsoft.PowerToys.Settings.UI.Lib.Utilities; using Microsoft.PowerToys.Settings.UI.Lib.Utilities;
using Microsoft.PowerToys.Settings.UI.Lib.ViewModels.Commands; using Microsoft.PowerToys.Settings.UI.Lib.ViewModels.Commands;
@@ -20,7 +19,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
public ButtonClickCommand RestartElevatedButtonEventHandler { get; set; } public ButtonClickCommand RestartElevatedButtonEventHandler { get; set; }
public Func<string, int> UpdateUIThemeCallBack { get; } public Func<string, int> UpdateUIThemeCallBack { get; }
public Func<string, int> SendConfigMSG { get; } public Func<string, int> SendConfigMSG { get; }
@@ -29,16 +27,16 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
public Func<string, int> SendCheckForUpdatesConfigMSG { get; } public Func<string, int> SendCheckForUpdatesConfigMSG { get; }
public readonly string RunningAsUserDefaultText; public string RunningAsUserDefaultText { get; set; }
public readonly string RunningAsAdminDefaultText; public string RunningAsAdminDefaultText { get; set; }
public string SettingsConfigFileFolder = string.Empty; private string _settingsConfigFileFolder = string.Empty;
public GeneralViewModel(string runAsAdminText, string runAsUserText, bool isElevated, bool isAdmin, Func<string, int> updateTheme, Func<string, int> ipcMSGCallBackFunc, Func<string, int> ipcMSGRestartAsAdminMSGCallBackFunc, Func<string, int> ipcMSGCheckForUpdatesCallBackFunc, string configFileSubfolder = "") public GeneralViewModel(string runAsAdminText, string runAsUserText, bool isElevated, bool isAdmin, Func<string, int> updateTheme, Func<string, int> ipcMSGCallBackFunc, Func<string, int> ipcMSGRestartAsAdminMSGCallBackFunc, Func<string, int> ipcMSGCheckForUpdatesCallBackFunc, string configFileSubfolder = "")
{ {
this.CheckFoUpdatesEventHandler = new ButtonClickCommand(CheckForUpdates_Click); CheckFoUpdatesEventHandler = new ButtonClickCommand(CheckForUpdates_Click);
this.RestartElevatedButtonEventHandler = new ButtonClickCommand(Restart_Elevated); RestartElevatedButtonEventHandler = new ButtonClickCommand(Restart_Elevated);
try try
{ {
@@ -72,7 +70,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
UpdateUIThemeCallBack(GeneralSettingsConfigs.Theme.ToLower()); UpdateUIThemeCallBack(GeneralSettingsConfigs.Theme.ToLower());
// Update Settings file folder: // Update Settings file folder:
SettingsConfigFileFolder = configFileSubfolder; _settingsConfigFileFolder = configFileSubfolder;
switch (GeneralSettingsConfigs.Theme.ToLower()) switch (GeneralSettingsConfigs.Theme.ToLower())
{ {
@@ -341,9 +339,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
} }
// callback function to launch the URL to check for updates. // callback function to launch the URL to check for updates.
private async void CheckForUpdates_Click() private void CheckForUpdates_Click()
{ {
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(SettingsConfigFileFolder); GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(_settingsConfigFileFolder);
settings.CustomActionName = "check_for_updates"; settings.CustomActionName = "check_for_updates";
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings); OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
@@ -354,7 +352,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
public void Restart_Elevated() public void Restart_Elevated()
{ {
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(SettingsConfigFileFolder); GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(_settingsConfigFileFolder);
settings.CustomActionName = "restart_elevation"; settings.CustomActionName = "restart_elevation";
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings); OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);

View File

@@ -3,14 +3,10 @@
// 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.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Windows.Input;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.Lib.Helpers; using Microsoft.PowerToys.Settings.UI.Lib.Helpers;
using Microsoft.PowerToys.Settings.UI.Lib.ViewModels.Commands;
namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
{ {
@@ -49,14 +45,14 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
// set the callback functions value to hangle outgoing IPC message. // set the callback functions value to hangle outgoing IPC message.
SendConfigMSG = ipcMSGCallBackFunc; SendConfigMSG = ipcMSGCallBackFunc;
this._isEnabled = generalSettings.Enabled.ImageResizer; _isEnabled = generalSettings.Enabled.ImageResizer;
this._advancedSizes = Settings.Properties.ImageresizerSizes.Value; _advancedSizes = Settings.Properties.ImageresizerSizes.Value;
this._jpegQualityLevel = Settings.Properties.ImageresizerJpegQualityLevel.Value; _jpegQualityLevel = Settings.Properties.ImageresizerJpegQualityLevel.Value;
this._pngInterlaceOption = Settings.Properties.ImageresizerPngInterlaceOption.Value; _pngInterlaceOption = Settings.Properties.ImageresizerPngInterlaceOption.Value;
this._tiffCompressOption = Settings.Properties.ImageresizerTiffCompressOption.Value; _tiffCompressOption = Settings.Properties.ImageresizerTiffCompressOption.Value;
this._fileName = Settings.Properties.ImageresizerFileName.Value; _fileName = Settings.Properties.ImageresizerFileName.Value;
this._keepDateModified = Settings.Properties.ImageresizerKeepDateModified.Value; _keepDateModified = Settings.Properties.ImageresizerKeepDateModified.Value;
this._encoderGuidId = GetEncoderIndex(Settings.Properties.ImageresizerFallbackEncoder.Value); _encoderGuidId = GetEncoderIndex(Settings.Properties.ImageresizerFallbackEncoder.Value);
int i = 0; int i = 0;
foreach (ImageSize size in _advancedSizes) foreach (ImageSize size in _advancedSizes)

View File

@@ -4,7 +4,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -26,13 +25,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
private const string ProfileFileMutexName = "PowerToys.KeyboardManager.ConfigMutex"; private const string ProfileFileMutexName = "PowerToys.KeyboardManager.ConfigMutex";
private const int ProfileFileMutexWaitTimeoutMilliseconds = 1000; private const int ProfileFileMutexWaitTimeoutMilliseconds = 1000;
private readonly FileSystemWatcher watcher; public KeyboardManagerSettings Settings { get; set; }
private ICommand remapKeyboardCommand; private ICommand _remapKeyboardCommand;
private ICommand editShortcutCommand; private ICommand _editShortcutCommand;
public KeyboardManagerSettings settings; private KeyboardManagerProfile _profile;
private KeyboardManagerProfile profile; private GeneralSettings _generalSettings;
private GeneralSettings generalSettings;
private Func<string, int> SendConfigMSG { get; } private Func<string, int> SendConfigMSG { get; }
@@ -47,28 +45,28 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
if (SettingsUtils.SettingsExists(PowerToyName)) if (SettingsUtils.SettingsExists(PowerToyName))
{ {
// Todo: Be more resilient while reading and saving settings. // Todo: Be more resilient while reading and saving settings.
settings = SettingsUtils.GetSettings<KeyboardManagerSettings>(PowerToyName); Settings = SettingsUtils.GetSettings<KeyboardManagerSettings>(PowerToyName);
// Load profile. // Load profile.
if (!LoadProfile()) if (!LoadProfile())
{ {
profile = new KeyboardManagerProfile(); _profile = new KeyboardManagerProfile();
} }
} }
else else
{ {
settings = new KeyboardManagerSettings(PowerToyName); Settings = new KeyboardManagerSettings(PowerToyName);
SettingsUtils.SaveSettings(settings.ToJsonString(), PowerToyName); SettingsUtils.SaveSettings(Settings.ToJsonString(), PowerToyName);
} }
if (SettingsUtils.SettingsExists()) if (SettingsUtils.SettingsExists())
{ {
generalSettings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty); _generalSettings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
} }
else else
{ {
generalSettings = new GeneralSettings(); _generalSettings = new GeneralSettings();
SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty); SettingsUtils.SaveSettings(_generalSettings.ToJsonString(), string.Empty);
} }
} }
@@ -76,16 +74,16 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
{ {
get get
{ {
return generalSettings.Enabled.KeyboardManager; return _generalSettings.Enabled.KeyboardManager;
} }
set set
{ {
if (generalSettings.Enabled.KeyboardManager != value) if (_generalSettings.Enabled.KeyboardManager != value)
{ {
generalSettings.Enabled.KeyboardManager = value; _generalSettings.Enabled.KeyboardManager = value;
OnPropertyChanged(nameof(Enabled)); OnPropertyChanged(nameof(Enabled));
OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(generalSettings); OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(_generalSettings);
SendConfigMSG(outgoing.ToString()); SendConfigMSG(outgoing.ToString());
} }
@@ -97,9 +95,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
{ {
get get
{ {
if (profile != null) if (_profile != null)
{ {
return profile.RemapKeys.InProcessRemapKeys; return _profile.RemapKeys.InProcessRemapKeys;
} }
else else
{ {
@@ -117,9 +115,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
{ {
get get
{ {
if (profile != null) if (_profile != null)
{ {
return CombineShortcutLists(profile.RemapShortcuts.GlobalRemapShortcuts, profile.RemapShortcuts.AppSpecificRemapShortcuts); return CombineShortcutLists(_profile.RemapShortcuts.GlobalRemapShortcuts, _profile.RemapShortcuts.AppSpecificRemapShortcuts);
} }
else else
{ {
@@ -128,9 +126,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
} }
} }
public ICommand RemapKeyboardCommand => remapKeyboardCommand ?? (remapKeyboardCommand = new RelayCommand(OnRemapKeyboard)); public ICommand RemapKeyboardCommand => _remapKeyboardCommand ?? (_remapKeyboardCommand = new RelayCommand(OnRemapKeyboard));
public ICommand EditShortcutCommand => editShortcutCommand ?? (editShortcutCommand = new RelayCommand(OnEditShortcut)); public ICommand EditShortcutCommand => _editShortcutCommand ?? (_editShortcutCommand = new RelayCommand(OnEditShortcut));
private async void OnRemapKeyboard() private async void OnRemapKeyboard()
{ {
@@ -175,8 +173,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
// update the UI element here. // update the UI element here.
try try
{ {
profile = SettingsUtils.GetSettings<KeyboardManagerProfile>(PowerToyName, settings.Properties.ActiveConfiguration.Value + JsonFileType); _profile = SettingsUtils.GetSettings<KeyboardManagerProfile>(PowerToyName, Settings.Properties.ActiveConfiguration.Value + JsonFileType);
FilterRemapKeysList(profile.RemapKeys.InProcessRemapKeys); FilterRemapKeysList(_profile.RemapKeys.InProcessRemapKeys);
} }
finally finally
{ {
@@ -198,6 +196,5 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
return success; return success;
} }
} }
} }

View File

@@ -57,7 +57,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
} }
catch catch
{ {
} }
} }

View File

@@ -4,7 +4,6 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.Lib.Helpers; using Microsoft.PowerToys.Settings.UI.Lib.Helpers;
namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
@@ -17,12 +16,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
private Func<string, int> SendConfigMSG { get; } private Func<string, int> SendConfigMSG { get; }
public string SettingsConfigFileFolder = string.Empty; private string _settingsConfigFileFolder = string.Empty;
public PowerPreviewViewModel(Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "") public PowerPreviewViewModel(Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "")
{ {
// Update Settings file folder: // Update Settings file folder:
SettingsConfigFileFolder = configFileSubfolder; _settingsConfigFileFolder = configFileSubfolder;
try try
{ {
@@ -37,9 +36,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
// set the callback functions value to hangle outgoing IPC message. // set the callback functions value to hangle outgoing IPC message.
SendConfigMSG = ipcMSGCallBackFunc; SendConfigMSG = ipcMSGCallBackFunc;
this._svgRenderIsEnabled = Settings.Properties.EnableSvgPreview; _svgRenderIsEnabled = Settings.Properties.EnableSvgPreview;
this._svgThumbnailIsEnabled = Settings.Properties.EnableSvgThumbnail; _svgThumbnailIsEnabled = Settings.Properties.EnableSvgThumbnail;
this._mdRenderIsEnabled = Settings.Properties.EnableMdPreview; _mdRenderIsEnabled = Settings.Properties.EnableMdPreview;
} }
private bool _svgRenderIsEnabled = false; private bool _svgRenderIsEnabled = false;
@@ -102,7 +101,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
public string GetSettingsSubPath() public string GetSettingsSubPath()
{ {
return SettingsConfigFileFolder + "\\" + ModuleName; return _settingsConfigFileFolder + "\\" + ModuleName;
} }
private void RaisePropertyChanged([CallerMemberName] string propertyName = null) private void RaisePropertyChanged([CallerMemberName] string propertyName = null)

View File

@@ -12,7 +12,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
{ {
private const string ModuleName = "PowerRename"; private const string ModuleName = "PowerRename";
public string SettingsConfigFileFolder = string.Empty; private string _settingsConfigFileFolder = string.Empty;
private PowerRenameSettings Settings { get; set; } private PowerRenameSettings Settings { get; set; }
@@ -21,7 +21,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
public PowerRenameViewModel(Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "") public PowerRenameViewModel(Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "")
{ {
// Update Settings file folder: // Update Settings file folder:
SettingsConfigFileFolder = configFileSubfolder; _settingsConfigFileFolder = configFileSubfolder;
try try
{ {
@@ -76,7 +76,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
{ {
if (value != _powerRenameEnabled) if (value != _powerRenameEnabled)
{ {
GeneralSettings generalSettings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty); GeneralSettings generalSettings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
generalSettings.Enabled.PowerRename = value; generalSettings.Enabled.PowerRename = value;
OutGoingGeneralSettings snd = new OutGoingGeneralSettings(generalSettings); OutGoingGeneralSettings snd = new OutGoingGeneralSettings(generalSettings);
@@ -190,7 +189,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
public string GetSettingsSubPath() public string GetSettingsSubPath()
{ {
return SettingsConfigFileFolder + "\\" + ModuleName; return _settingsConfigFileFolder + "\\" + ModuleName;
} }
private void RaisePropertyChanged([CallerMemberName] string propertyName = null) private void RaisePropertyChanged([CallerMemberName] string propertyName = null)

View File

@@ -16,12 +16,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
private Func<string, int> SendConfigMSG { get; } private Func<string, int> SendConfigMSG { get; }
public string SettingsConfigFileFolder = string.Empty; private string _settingsConfigFileFolder = string.Empty;
public ShortcutGuideViewModel(Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "") public ShortcutGuideViewModel(Func<string, int> ipcMSGCallBackFunc, string configFileSubfolder = "")
{ {
// Update Settings file folder: // Update Settings file folder:
SettingsConfigFileFolder = configFileSubfolder; _settingsConfigFileFolder = configFileSubfolder;
try try
{ {
@@ -48,9 +48,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
// set the callback functions value to hangle outgoing IPC message. // set the callback functions value to hangle outgoing IPC message.
SendConfigMSG = ipcMSGCallBackFunc; SendConfigMSG = ipcMSGCallBackFunc;
this._isEnabled = generalSettings.Enabled.ShortcutGuide; _isEnabled = generalSettings.Enabled.ShortcutGuide;
this._pressTime = Settings.Properties.PressTime.Value; _pressTime = Settings.Properties.PressTime.Value;
this._opacity = Settings.Properties.OverlayOpacity.Value; _opacity = Settings.Properties.OverlayOpacity.Value;
string theme = Settings.Properties.Theme.Value; string theme = Settings.Properties.Theme.Value;
@@ -172,7 +172,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
public string GetSettingsSubPath() public string GetSettingsSubPath()
{ {
return SettingsConfigFileFolder + "\\" + ModuleName; return _settingsConfigFileFolder + "\\" + ModuleName;
} }
public void RaisePropertyChanged([CallerMemberName] string propertyName = null) public void RaisePropertyChanged([CallerMemberName] string propertyName = null)

View File

@@ -25,6 +25,7 @@
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers> <RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- crutkas TODO: added for fallback, may need to be removed for WinUI3 --> <!-- crutkas TODO: added for fallback, may need to be removed for WinUI3 -->
<AssetTargetFallback>uap10.0.18362</AssetTargetFallback> <AssetTargetFallback>uap10.0.18362</AssetTargetFallback>

View File

@@ -2,10 +2,9 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<Platforms>x64</Platforms> <Platforms>x64</Platforms>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">

View File

@@ -55,7 +55,7 @@ namespace ViewModelTests
Func<string, int> SendMockIPCConfigMSG = msg => Func<string, int> SendMockIPCConfigMSG = msg =>
{ {
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg); SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.Properties.EnableSvgPreview); Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnableSvgPreview);
return 0; return 0;
}; };
@@ -73,7 +73,7 @@ namespace ViewModelTests
Func<string, int> SendMockIPCConfigMSG = msg => Func<string, int> SendMockIPCConfigMSG = msg =>
{ {
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg); SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.Properties.EnableSvgThumbnail); Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnableSvgThumbnail);
return 0; return 0;
}; };
@@ -91,7 +91,7 @@ namespace ViewModelTests
Func<string, int> SendMockIPCConfigMSG = msg => Func<string, int> SendMockIPCConfigMSG = msg =>
{ {
SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg); SndModuleSettings<SndPowerPreviewSettings> snd = JsonSerializer.Deserialize<SndModuleSettings<SndPowerPreviewSettings>>(msg);
Assert.IsTrue(snd.powertoys.FileExplorerPreviewSettings.Properties.EnableMdPreview); Assert.IsTrue(snd.PowertoysSetting.FileExplorerPreviewSettings.Properties.EnableMdPreview);
return 0; return 0;
}; };

View File

@@ -9,6 +9,7 @@
<AssemblyCompany>Microsoft Corp.</AssemblyCompany> <AssemblyCompany>Microsoft Corp.</AssemblyCompany>
<AssemblyCopyright>Copyright (C) 2020 Microsoft Corp.</AssemblyCopyright> <AssemblyCopyright>Copyright (C) 2020 Microsoft Corp.</AssemblyCopyright>
<AssemblyProduct>PowerToys</AssemblyProduct> <AssemblyProduct>PowerToys</AssemblyProduct>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<AssemblyVersionFiles Include="Generated Files\AssemblyInfo.cs" /> <AssemblyVersionFiles Include="Generated Files\AssemblyInfo.cs" />
@@ -297,6 +298,12 @@
<EnableTypeInfoReflection>false</EnableTypeInfoReflection> <EnableTypeInfoReflection>false</EnableTypeInfoReflection>
<EnableXBindDiagnostics>false</EnableXBindDiagnostics> <EnableXBindDiagnostics>false</EnableXBindDiagnostics>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'">
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'">
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" /> <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. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.

View File

@@ -13,7 +13,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public FancyZonesPage() public FancyZonesPage()
{ {
this.InitializeComponent(); InitializeComponent();
ViewModel = new FancyZonesViewModel(ShellPage.SendDefaultIPCMessage); ViewModel = new FancyZonesViewModel(ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel; DataContext = ViewModel;
} }

View File

@@ -25,12 +25,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// </summary> /// </summary>
public GeneralPage() public GeneralPage()
{ {
this.InitializeComponent(); InitializeComponent();
// Load string resources // Load string resources
ResourceLoader loader = ResourceLoader.GetForViewIndependentUse(); ResourceLoader loader = ResourceLoader.GetForViewIndependentUse();
this.ViewModel = new GeneralViewModel( ViewModel = new GeneralViewModel(
loader.GetString("GeneralSettings_RunningAsAdminText"), loader.GetString("GeneralSettings_RunningAsAdminText"),
loader.GetString("GeneralSettings_RunningAsUserText"), loader.GetString("GeneralSettings_RunningAsUserText"),
ShellPage.IsElevated, ShellPage.IsElevated,

View File

@@ -2,9 +2,7 @@
// 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.ViewModels; using Microsoft.PowerToys.Settings.UI.Lib.ViewModels;
using Windows.UI.Popups;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
@@ -30,7 +28,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
int rowNum = int.Parse(deleteRowButton.CommandParameter.ToString()); int rowNum = int.Parse(deleteRowButton.CommandParameter.ToString());
ViewModel.DeleteImageSize(rowNum); ViewModel.DeleteImageSize(rowNum);
} }
catch (Exception exp) catch
{ {
} }
} }
@@ -41,7 +39,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{ {
ViewModel.AddRow(); ViewModel.AddRow();
} }
catch (Exception exp) catch
{ {
} }
} }

View File

@@ -35,7 +35,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
watcher = Helper.GetFileWatcher( watcher = Helper.GetFileWatcher(
PowerToyName, PowerToyName,
ViewModel.settings.Properties.ActiveConfiguration.Value + ".json", ViewModel.Settings.Properties.ActiveConfiguration.Value + ".json",
OnConfigFileUpdate); OnConfigFileUpdate);
InitializeComponent(); InitializeComponent();

View File

@@ -12,13 +12,13 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// </summary> /// </summary>
public sealed partial class PowerPreviewPage : Page public sealed partial class PowerPreviewPage : Page
{ {
public PowerPreviewViewModel viewModel { get; set; } public PowerPreviewViewModel ViewModel { get; set; }
public PowerPreviewPage() public PowerPreviewPage()
{ {
this.InitializeComponent(); InitializeComponent();
viewModel = new PowerPreviewViewModel(ShellPage.SendDefaultIPCMessage); ViewModel = new PowerPreviewViewModel(ShellPage.SendDefaultIPCMessage);
DataContext = viewModel; DataContext = ViewModel;
} }
} }
} }

View File

@@ -13,7 +13,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public PowerRenamePage() public PowerRenamePage()
{ {
this.InitializeComponent(); InitializeComponent();
ViewModel = new PowerRenameViewModel(ShellPage.SendDefaultIPCMessage); ViewModel = new PowerRenameViewModel(ShellPage.SendDefaultIPCMessage);
DataContext = ViewModel; DataContext = ViewModel;