Settingsv2 fix warnings (#2076)

* updating a ton of warnings.

* bunch of cleanup

* few smaller ones

* fixed naming

* reversing an oops

* adjusting json to use attribute

* more json properties
This commit is contained in:
Clint Rutkas 2020-04-10 15:22:07 -07:00 committed by GitHub
parent 3a46f4589b
commit 6fbed4ad5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
55 changed files with 354 additions and 357 deletions

View File

@ -1,5 +1,5 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// 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.
// This file is used by Code Analysis to maintain SuppressMessage

View File

@ -34,13 +34,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public GeneralSettings()
{
this.Packaged = false;
this.startup = false;
this.is_admin = false;
this.is_elevated = false;
this.theme = "system";
this.system_theme = "light";
this.powertoys_version = "v0.15.3";
Packaged = false;
startup = false;
is_admin = false;
is_elevated = false;
theme = "system";
system_theme = "light";
powertoys_version = "v0.15.3";
}
// converts the current to a json string.

View File

@ -1,10 +0,0 @@
// 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.
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:Element should begin with upper-case letter", Justification = "Element should not begin with upper-case letter to keep backward compatibilty with old settings.")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Identifiers should contain underscores to keep backward compatibilty with old settings.")]

View File

@ -24,27 +24,27 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
{
StringBuilder output = new StringBuilder();
if (this.win)
if (win)
{
output.Append("Win + ");
}
if (this.ctrl)
if (ctrl)
{
output.Append("Ctrl + ");
}
if (this.alt)
if (alt)
{
output.Append("Alt + ");
}
if (this.shift)
if (shift)
{
output.Append("Shift + ");
}
output.Append(this.key);
output.Append(key);
return output.ToString();
}
}

View File

@ -16,8 +16,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public KeyboardManagerProperties()
{
this.EditShortcut = new BoolProperty();
this.RemapKeyboard = new BoolProperty();
EditShortcut = new BoolProperty();
RemapKeyboard = new BoolProperty();
}
public string ToJsonString()

View File

@ -1,25 +1,31 @@
using System;
// 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;
using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;
namespace Microsoft.PowerToys.Settings.UI.Lib
{
public class KeyboardManagerSettings : BasePTModuleSettings
{
public KeyboardManagerProperties properties { get; set; }
[JsonPropertyName("properties")]
public KeyboardManagerProperties Properties { get; set; }
public KeyboardManagerSettings()
public KeyboardManagerSettings()
{
this.properties = new KeyboardManagerProperties();
this.version = "1";
this.name = "_unset_";
Properties = new KeyboardManagerProperties();
version = "1";
name = "_unset_";
}
public KeyboardManagerSettings(string ptName)
{
this.properties = new KeyboardManagerProperties();
this.version = "1";
this.name = ptName;
Properties = new KeyboardManagerProperties();
version = "1";
name = ptName;
}
}
}

View File

@ -19,6 +19,10 @@
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\codeAnalysis\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>

View File

@ -12,12 +12,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public OutGoingGeneralSettings()
{
this.general = null;
general = null;
}
public OutGoingGeneralSettings(GeneralSettings generalSettings)
{
this.general = generalSettings;
general = generalSettings;
}
public override string ToString()

View File

@ -28,12 +28,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public PowerLauncherProperties()
{
this.open_powerlauncher = new HotkeySettings();
this.open_file_location = new HotkeySettings();
this.copy_path_location = new HotkeySettings();
this.open_console = new HotkeySettings();
this.search_result_preference = "most_recently_used";
this.search_type_preference = "application_name";
open_powerlauncher = new HotkeySettings();
open_file_location = new HotkeySettings();
copy_path_location = new HotkeySettings();
open_console = new HotkeySettings();
search_result_preference = "most_recently_used";
search_type_preference = "application_name";
}
}
}

View File

@ -10,9 +10,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public PowerLauncherSettings()
{
this.properties = new PowerLauncherProperties();
this.version = "1";
this.name = "_unset_";
properties = new PowerLauncherProperties();
version = "1";
name = "_unset_";
}
}
}

View File

@ -18,8 +18,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public PowerPreviewProperties()
{
this.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL = new BoolProperty();
this.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID = new BoolProperty();
IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL = new BoolProperty();
PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID = new BoolProperty();
}
public override string ToString()

View File

@ -16,16 +16,16 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public PowerPreviewSettings()
{
this.properties = new PowerPreviewProperties();
this.version = "1";
this.name = "_unset_";
properties = new PowerPreviewProperties();
version = "1";
name = "_unset_";
}
public PowerPreviewSettings(string ptName)
{
this.properties = new PowerPreviewProperties();
this.version = "1";
this.name = ptName;
properties = new PowerPreviewProperties();
version = "1";
name = ptName;
}
public override string ToJsonString()

View File

@ -2,31 +2,34 @@
// 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 PowerRenameProperties
{
public PowerRenameProperties()
{
this.bool_persist_input = new BoolProperty();
this.bool_mru_enabled = new BoolProperty();
this.int_max_mru_size = new IntProperty();
this.bool_show_icon_on_menu = new BoolProperty();
this.bool_show_extended_menu = new BoolProperty();
PersistInput = new BoolProperty();
MruEnabled = new BoolProperty();
MaxMruSize = new IntProperty();
ShowIconInMenu = new BoolProperty();
ShowExtendedMenu = new BoolProperty();
}
public BoolProperty bool_persist_input { get; set; }
[JsonPropertyName("bool_persist_input")]
public BoolProperty PersistInput { get; set; }
public BoolProperty bool_mru_enabled { get; set; }
[JsonPropertyName("bool_mru_enabled")]
public BoolProperty MruEnabled { get; set; }
public IntProperty int_max_mru_size { get; set; }
[JsonPropertyName("int_max_mru_size")]
public IntProperty MaxMruSize { get; set; }
public BoolProperty bool_show_icon_on_menu { get; set; }
[JsonPropertyName("bool_show_icon_on_menu")]
public BoolProperty ShowIconInMenu { get; set; }
public BoolProperty bool_show_extended_menu { get; set; }
[JsonPropertyName("bool_show_extended_menu")]
public BoolProperty ShowExtendedMenu { get; set; }
}
}

View File

@ -13,16 +13,16 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public PowerRenameSettings()
{
this.properties = new PowerRenameProperties();
this.version = "1";
this.name = "_unset_";
properties = new PowerRenameProperties();
version = "1";
name = "_unset_";
}
public PowerRenameSettings(string ptName)
{
this.properties = new PowerRenameProperties();
this.version = "1";
this.name = ptName;
properties = new PowerRenameProperties();
version = "1";
name = ptName;
}
public override string ToJsonString()

View File

@ -40,7 +40,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public static bool SettingsExists(string powertoy)
{
return File.Exists(SettingsUtils.GetSettingsPath(powertoy));
return File.Exists(GetSettingsPath(powertoy));
}
/// <summary>
@ -49,7 +49,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
/// <returns>Deserialized json settings object.</returns>
public static T GetSettings<T>(string powertoy)
{
var jsonSettingsString = System.IO.File.ReadAllText(SettingsUtils.GetSettingsPath(powertoy));
var jsonSettingsString = File.ReadAllText(GetSettingsPath(powertoy));
return JsonSerializer.Deserialize<T>(jsonSettingsString);
}
@ -63,9 +63,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
CreateSettingsFolder(powertoy);
}
System.IO.File.WriteAllText(
SettingsUtils.GetSettingsPath(powertoy),
jsonSettings);
File.WriteAllText(GetSettingsPath(powertoy), jsonSettings);
}
}

View File

@ -10,11 +10,11 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public class SndKeyboardManagerSettings
{
[JsonPropertyName("Keyboard Manager")]
public KeyboardManagerSettings keyboardManagerSettings { get; }
public KeyboardManagerSettings KeyboardManagerSettings { get; }
public SndKeyboardManagerSettings(KeyboardManagerSettings keyboardManagerSettings)
{
this.keyboardManagerSettings = keyboardManagerSettings;
KeyboardManagerSettings = keyboardManagerSettings;
}
public string ToJsonString()

View File

@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public SndModuleSettings(T settings)
{
this.powertoys = settings;
powertoys = settings;
}
public string ToJsonString()

View File

@ -17,7 +17,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public SndPowerPreviewSettings(PowerPreviewSettings settings)
{
this.File_Explorer_Preview = settings;
File_Explorer_Preview = settings;
}
public string ToJsonString()

View File

@ -14,7 +14,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
public SndPowerRenameSettings(PowerRenameSettings settings)
{
this.PowerRename = settings;
PowerRename = settings;
}
public string ToJsonString()

View File

@ -1,15 +1,13 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
// 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.Windows;
namespace Microsoft.PowerToys.Settings.UI.Runner
{
/// <summary>
/// Interaction logic for App.xaml
/// Interaction logic for App.xaml.
/// </summary>
public partial class App : Application
{

View File

@ -1,10 +1,7 @@
// 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.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

View File

@ -33,4 +33,4 @@ namespace Microsoft.PowerToys.Settings.UI.Runner
}
}
}
}
}

View File

@ -50,6 +50,10 @@
<AdditionalFiles Include="..\..\codeAnalysis\StyleCop.json" Link="StyleCop.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\codeAnalysis\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\settingsui\Assets\logo.png">
<Pack>True</Pack>
@ -70,4 +74,8 @@
<ProjectReference Include="..\Microsoft.PowerToys.Settings.UI\Microsoft.PowerToys.Settings.UI.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.VCRTForwarders.140" Version="1.0.5" />
</ItemGroup>
</Project>

View File

@ -13,7 +13,7 @@ namespace Microsoft.PowerToys.Settings.UI.Runner
// Create an instance of the IPC wrapper.
private static ITwoWayIPCManager ipcmanager = new TwoWayIPCManager();
[STAThreadAttribute()]
[STAThread]
public static void Main(string[] args)
{
using (new UI.App())

View File

@ -1,4 +1,7 @@
using System;
// 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.Threading.Tasks;
namespace Microsoft.PowerToys.Settings.UI.Activation
@ -12,19 +15,19 @@ namespace Microsoft.PowerToys.Settings.UI.Activation
public abstract Task HandleAsync(object args);
}
// Extend this class to implement new ActivationHandlers
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "abstract T and abstract")]
internal abstract class ActivationHandler<T> : ActivationHandler
where T : class
{
public override async Task HandleAsync(object args)
{
await this.HandleInternalAsync(args as T);
await HandleInternalAsync(args as T);
}
public override bool CanHandle(object args)
{
// CanHandle checks the args is of type you have configured
return args is T && this.CanHandleInternal(args as T);
return args is T && CanHandleInternal(args as T);
}
// Override this method to add the activation logic in your activation handler

View File

@ -28,14 +28,14 @@ namespace Microsoft.PowerToys.Settings.UI.Activation
arguments = launchArgs.Arguments;
}
NavigationService.Navigate(this.navElement, arguments);
NavigationService.Navigate(navElement, arguments);
await Task.CompletedTask;
}
protected override bool CanHandleInternal(IActivatedEventArgs args)
{
// None of the ActivationHandlers has handled the app activation
return NavigationService.Frame.Content == null && this.navElement != null;
return NavigationService.Frame.Content == null && navElement != null;
}
}
}

View File

@ -1,4 +1,8 @@
using Microsoft.Toolkit.Win32.UI.XamlHost;
// 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 Microsoft.Toolkit.Win32.UI.XamlHost;
namespace Microsoft.PowerToys.Settings.UI
{

View File

@ -1,4 +1,8 @@
using Microsoft.PowerToys.Settings.UI.Services;
// 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 Microsoft.PowerToys.Settings.UI.Services;
using Microsoft.Xaml.Interactivity;
using Windows.UI.Xaml;
@ -18,8 +22,8 @@ namespace Microsoft.PowerToys.Settings.UI.Behaviors
public object DefaultHeader
{
get { return this.GetValue(DefaultHeaderProperty); }
set { this.SetValue(DefaultHeaderProperty, value); }
get { return GetValue(DefaultHeaderProperty); }
set { SetValue(DefaultHeaderProperty, value); }
}
public static readonly DependencyProperty DefaultHeaderProperty = DependencyProperty.Register("DefaultHeader", typeof(object), typeof(NavigationViewHeaderBehavior), new PropertyMetadata(null, (d, e) => current.UpdateHeader()));
@ -67,13 +71,13 @@ namespace Microsoft.PowerToys.Settings.UI.Behaviors
{
base.OnAttached();
current = this;
NavigationService.Navigated += this.OnNavigated;
NavigationService.Navigated += OnNavigated;
}
protected override void OnDetaching()
{
base.OnDetaching();
NavigationService.Navigated -= this.OnNavigated;
NavigationService.Navigated -= OnNavigated;
}
private void OnNavigated(object sender, NavigationEventArgs e)
@ -81,42 +85,42 @@ namespace Microsoft.PowerToys.Settings.UI.Behaviors
var frame = sender as Frame;
if (frame.Content is Page page)
{
this.currentPage = page;
currentPage = page;
this.UpdateHeader();
this.UpdateHeaderTemplate();
UpdateHeader();
UpdateHeaderTemplate();
}
}
private void UpdateHeader()
{
if (this.currentPage != null)
if (currentPage != null)
{
var headerMode = GetHeaderMode(this.currentPage);
var headerMode = GetHeaderMode(currentPage);
if (headerMode == NavigationViewHeaderMode.Never)
{
this.AssociatedObject.Header = null;
this.AssociatedObject.AlwaysShowHeader = false;
AssociatedObject.Header = null;
AssociatedObject.AlwaysShowHeader = false;
}
else
{
var headerFromPage = GetHeaderContext(this.currentPage);
var headerFromPage = GetHeaderContext(currentPage);
if (headerFromPage != null)
{
this.AssociatedObject.Header = headerFromPage;
AssociatedObject.Header = headerFromPage;
}
else
{
this.AssociatedObject.Header = this.DefaultHeader;
AssociatedObject.Header = DefaultHeader;
}
if (headerMode == NavigationViewHeaderMode.Always)
{
this.AssociatedObject.AlwaysShowHeader = true;
AssociatedObject.AlwaysShowHeader = true;
}
else
{
this.AssociatedObject.AlwaysShowHeader = false;
AssociatedObject.AlwaysShowHeader = false;
}
}
}
@ -124,10 +128,10 @@ namespace Microsoft.PowerToys.Settings.UI.Behaviors
private void UpdateHeaderTemplate()
{
if (this.currentPage != null)
if (currentPage != null)
{
var headerTemplate = GetHeaderTemplate(this.currentPage);
this.AssociatedObject.HeaderTemplate = headerTemplate ?? this.DefaultHeaderTemplate;
var headerTemplate = GetHeaderTemplate(currentPage);
AssociatedObject.HeaderTemplate = headerTemplate ?? DefaultHeaderTemplate;
}
}
}

View File

@ -1,4 +1,8 @@
namespace Microsoft.PowerToys.Settings.UI.Behaviors
// 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.
namespace Microsoft.PowerToys.Settings.UI.Behaviors
{
public enum NavigationViewHeaderMode
{

View File

@ -28,24 +28,24 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
{
get
{
return this.hotkeySettings;
return hotkeySettings;
}
set
{
if (this.hotkeySettings != value)
if (hotkeySettings != value)
{
this.hotkeySettings = value;
this.SetValue(HotkeySettingsProperty, value);
this.HotkeyTextBox.Text = this.HotkeySettings.ToString();
hotkeySettings = value;
SetValue(HotkeySettingsProperty, value);
HotkeyTextBox.Text = HotkeySettings.ToString();
}
}
}
public HotkeySettingsControl()
{
this.InitializeComponent();
this.HotkeyTextBox.PreviewKeyDown += this.HotkeyTextBox_KeyDown;
InitializeComponent();
HotkeyTextBox.PreviewKeyDown += HotkeyTextBox_KeyDown;
}
private static bool IsDown(Windows.System.VirtualKey key)
@ -94,7 +94,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
// TODO: Check that e.OriginalKey is the ScanCode. It is not clear from docs.
settings.code = (int)e.OriginalKey;
this.HotkeySettings = settings;
HotkeySettings = settings;
}
}
}

View File

@ -1,6 +0,0 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "Classes contain the same name and creating a separate file would result in a new with '1 appended")]

View File

@ -1,4 +1,7 @@
using System;
// 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.ComponentModel;
using System.Runtime.CompilerServices;
@ -16,9 +19,9 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
}
storage = value;
this.OnPropertyChanged(propertyName);
OnPropertyChanged(propertyName);
}
protected void OnPropertyChanged(string propertyName) => this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
protected void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}

View File

@ -1,13 +1,16 @@
using System;
// 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;
using System.Windows.Input;
namespace Microsoft.PowerToys.Settings.UI.Helpers
{
public class RelayCommand : ICommand
{
private readonly Action execute;
private readonly Func<bool> canExecute;
private readonly Action _execute;
private readonly Func<bool> _canExecute;
public event EventHandler CanExecuteChanged;
@ -18,17 +21,18 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
public RelayCommand(Action execute, Func<bool> canExecute)
{
this.execute = execute ?? throw new ArgumentNullException(nameof(execute));
this.canExecute = canExecute;
_execute = execute ?? throw new ArgumentNullException(nameof(execute));
_canExecute = canExecute;
}
public bool CanExecute(object parameter) => this.canExecute == null || this.canExecute();
public bool CanExecute(object parameter) => _canExecute == null || _canExecute();
public void Execute(object parameter) => this.execute();
public void Execute(object parameter) => _execute();
public void OnCanExecuteChanged() => this.CanExecuteChanged?.Invoke(this, EventArgs.Empty);
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "abstract T and abstract")]
public class RelayCommand<T> : ICommand
{
private readonly Action<T> execute;
@ -48,10 +52,10 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
this.canExecute = canExecute;
}
public bool CanExecute(object parameter) => this.canExecute == null || this.canExecute((T)parameter);
public bool CanExecute(object parameter) => canExecute == null || canExecute((T)parameter);
public void Execute(object parameter) => this.execute((T)parameter);
public void Execute(object parameter) => execute((T)parameter);
public void OnCanExecuteChanged() => this.CanExecuteChanged?.Invoke(this, EventArgs.Empty);
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
}

View File

@ -2,9 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
using Windows.ApplicationModel.Resources;
namespace Microsoft.PowerToys.Settings.UI.Helpers

View File

@ -46,6 +46,9 @@
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\codeAnalysis\GlobalSuppressions.cs">
<Link>GlobalSuppressions.cs</Link>
</Compile>
<Compile Include="Activation\ActivationHandler.cs" />
<Compile Include="Activation\DefaultActivationHandler.cs" />
<Compile Include="App.xaml.cs">
@ -56,7 +59,6 @@
<Compile Include="Controls\HotkeySettingsControl.xaml.cs">
<DependentUpon>HotkeySettingsControl.xaml</DependentUpon>
</Compile>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Helpers\NavHelper.cs" />
<Compile Include="Helpers\Observable.cs" />
<Compile Include="Helpers\RelayCommand.cs" />
@ -68,6 +70,7 @@
<Compile Include="ViewModels\FancyZonesViewModel.cs" />
<Compile Include="ViewModels\ImageResizerViewModel.cs" />
<Compile Include="ViewModels\KeyboardManagerViewModel.cs" />
<Compile Include="ViewModels\Keys.cs" />
<Compile Include="ViewModels\PowerRenameViewModel.cs" />
<Compile Include="ViewModels\PowerLauncherViewModel.cs" />
<Compile Include="ViewModels\RemapKeysModel.cs" />

View File

@ -1,8 +1,11 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// 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.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Microsoft.PowerToys.Settings.UI")]
@ -17,13 +20,13 @@ using System.Runtime.InteropServices;
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ComVisible(false)]
[assembly: ComVisible(false)]

View File

@ -34,33 +34,33 @@ namespace Microsoft.PowerToys.Settings.UI.Services
public async Task ActivateAsync(object activationArgs)
{
if (this.IsInteractive(activationArgs))
if (IsInteractive(activationArgs))
{
// Initialize services that you need before app activation
// take into account that the splash screen is shown while this code runs.
await this.InitializeAsync();
await InitializeAsync();
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (Window.Current.Content == null)
{
// Create a Shell or Frame to act as the navigation context
Window.Current.Content = this.shell?.Value ?? new Frame();
Window.Current.Content = shell?.Value ?? new Frame();
}
}
// Depending on activationArgs one of ActivationHandlers or DefaultActivationHandler
// will navigate to the first page
await this.HandleActivationAsync(activationArgs);
this.lastActivationArgs = activationArgs;
await HandleActivationAsync(activationArgs);
lastActivationArgs = activationArgs;
if (this.IsInteractive(activationArgs))
if (IsInteractive(activationArgs))
{
// Ensure the current window is active
Window.Current.Activate();
// Tasks after activation
await this.StartupAsync();
await StartupAsync();
}
}
@ -71,7 +71,7 @@ namespace Microsoft.PowerToys.Settings.UI.Services
private async Task HandleActivationAsync(object activationArgs)
{
var activationHandler = this.GetActivationHandlers()
var activationHandler = GetActivationHandlers()
.FirstOrDefault(h => h.CanHandle(activationArgs));
if (activationHandler != null)
@ -79,9 +79,9 @@ namespace Microsoft.PowerToys.Settings.UI.Services
await activationHandler.HandleAsync(activationArgs);
}
if (this.IsInteractive(activationArgs))
if (IsInteractive(activationArgs))
{
var defaultHandler = new DefaultActivationHandler(this.defaultNavItem);
var defaultHandler = new DefaultActivationHandler(defaultNavItem);
if (defaultHandler.CanHandle(activationArgs))
{
await defaultHandler.HandleAsync(activationArgs);

View File

@ -12,4 +12,4 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
}
}
}
}

View File

@ -12,4 +12,4 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
}
}
}
}

View File

@ -0,0 +1,13 @@
// 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.
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class Keys
{
public string From { get; set; }
public string To { get; set; }
}
}

View File

@ -19,45 +19,45 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
if (SettingsUtils.SettingsExists(POWERTOYNAME))
{
this.settings = SettingsUtils.GetSettings<PowerLauncherSettings>(POWERTOYNAME);
settings = SettingsUtils.GetSettings<PowerLauncherSettings>(POWERTOYNAME);
}
else
{
this.settings = new PowerLauncherSettings();
settings = new PowerLauncherSettings();
}
}
private void UpdateSettings([CallerMemberName] string propertyName = null)
{
// Notify UI of property change
this.OnPropertyChanged(propertyName);
OnPropertyChanged(propertyName);
// Save settings to file
var options = new JsonSerializerOptions
{
WriteIndented = true,
};
SettingsUtils.SaveSettings(JsonSerializer.Serialize(this.settings, options), POWERTOYNAME);
SettingsUtils.SaveSettings(JsonSerializer.Serialize(settings, options), POWERTOYNAME);
// Propagate changes to Power Launcher through IPC
var propertiesJson = JsonSerializer.Serialize(this.settings.properties);
var propertiesJson = JsonSerializer.Serialize(settings.properties);
ShellPage.DefaultSndMSGCallback(
string.Format("{{ \"{0}\": {1} }}", POWERTOYNAME, JsonSerializer.Serialize(this.settings.properties)));
string.Format("{{ \"{0}\": {1} }}", POWERTOYNAME, JsonSerializer.Serialize(settings.properties)));
}
public bool EnablePowerLauncher
{
get
{
return this.settings.properties.enable_powerlauncher;
return settings.properties.enable_powerlauncher;
}
set
{
if (this.settings.properties.enable_powerlauncher != value)
if (settings.properties.enable_powerlauncher != value)
{
this.settings.properties.enable_powerlauncher = value;
this.UpdateSettings();
settings.properties.enable_powerlauncher = value;
UpdateSettings();
}
}
}
@ -66,15 +66,15 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
get
{
return this.settings.properties.search_result_preference;
return settings.properties.search_result_preference;
}
set
{
if (this.settings.properties.search_result_preference != value)
if (settings.properties.search_result_preference != value)
{
this.settings.properties.search_result_preference = value;
this.UpdateSettings();
settings.properties.search_result_preference = value;
UpdateSettings();
}
}
}
@ -83,15 +83,15 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
get
{
return this.settings.properties.search_type_preference;
return settings.properties.search_type_preference;
}
set
{
if (this.settings.properties.search_type_preference != value)
if (settings.properties.search_type_preference != value)
{
this.settings.properties.search_type_preference = value;
this.UpdateSettings();
settings.properties.search_type_preference = value;
UpdateSettings();
}
}
}
@ -100,15 +100,15 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
get
{
return this.settings.properties.maximum_number_of_results;
return settings.properties.maximum_number_of_results;
}
set
{
if (this.settings.properties.maximum_number_of_results != value)
if (settings.properties.maximum_number_of_results != value)
{
this.settings.properties.maximum_number_of_results = value;
this.UpdateSettings();
settings.properties.maximum_number_of_results = value;
UpdateSettings();
}
}
}
@ -117,15 +117,15 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
get
{
return this.settings.properties.open_powerlauncher;
return settings.properties.open_powerlauncher;
}
set
{
if (this.settings.properties.open_powerlauncher != value)
if (settings.properties.open_powerlauncher != value)
{
this.settings.properties.open_powerlauncher = value;
this.UpdateSettings();
settings.properties.open_powerlauncher = value;
UpdateSettings();
}
}
}
@ -134,15 +134,15 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
get
{
return this.settings.properties.open_file_location;
return settings.properties.open_file_location;
}
set
{
if (this.settings.properties.open_file_location != value)
if (settings.properties.open_file_location != value)
{
this.settings.properties.open_file_location = value;
this.UpdateSettings();
settings.properties.open_file_location = value;
UpdateSettings();
}
}
}
@ -151,15 +151,15 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
get
{
return this.settings.properties.copy_path_location;
return settings.properties.copy_path_location;
}
set
{
if (this.settings.properties.copy_path_location != value)
if (settings.properties.copy_path_location != value)
{
this.settings.properties.copy_path_location = value;
this.UpdateSettings();
settings.properties.copy_path_location = value;
UpdateSettings();
}
}
}
@ -168,15 +168,15 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
get
{
return this.settings.properties.open_console;
return settings.properties.open_console;
}
set
{
if (this.settings.properties.open_console != value)
if (settings.properties.open_console != value)
{
this.settings.properties.open_console = value;
this.UpdateSettings();
settings.properties.open_console = value;
UpdateSettings();
}
}
}
@ -185,15 +185,15 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
get
{
return this.settings.properties.override_win_r_key;
return settings.properties.override_win_r_key;
}
set
{
if (this.settings.properties.override_win_r_key != value)
if (settings.properties.override_win_r_key != value)
{
this.settings.properties.override_win_r_key = value;
this.UpdateSettings();
settings.properties.override_win_r_key = value;
UpdateSettings();
}
}
}
@ -202,15 +202,15 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
get
{
return this.settings.properties.override_win_s_key;
return settings.properties.override_win_s_key;
}
set
{
if (this.settings.properties.override_win_s_key != value)
if (settings.properties.override_win_s_key != value)
{
this.settings.properties.override_win_s_key = value;
this.UpdateSettings();
settings.properties.override_win_s_key = value;
UpdateSettings();
}
}
}

View File

@ -12,4 +12,4 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
}
}
}
}

View File

@ -2,30 +2,23 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.ObjectModel;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
// Dummy data model for the UI. Will be removed moving forward.
public class RemapKeysModel : ObservableCollection<Keys>
{
public RemapKeysModel()
{
this.Add(new Keys { From = "A", To = "B" });
this.Add(new Keys { From = "B", To = "A" });
this.Add(new Keys { From = "Ctrl", To = "Shift" });
this.Add(new Keys { From = "Shift", To = "Ctrl" });
this.Add(new Keys { From = "A", To = "B" });
this.Add(new Keys { From = "B", To = "B" });
this.Add(new Keys { From = "Ctrl", To = "Shift" });
this.Add(new Keys { From = "Shift", To = "Ctrl" });
}
}
public class Keys
{
public string From { get; set; }
public string To { get; set; }
}
}
using System.Collections.ObjectModel;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
// Dummy data model for the UI. Will be removed moving forward.
public class RemapKeysModel : ObservableCollection<Keys>
{
public RemapKeysModel()
{
Add(new Keys { From = "A", To = "B" });
Add(new Keys { From = "B", To = "A" });
Add(new Keys { From = "Ctrl", To = "Shift" });
Add(new Keys { From = "Shift", To = "Ctrl" });
Add(new Keys { From = "A", To = "B" });
Add(new Keys { From = "B", To = "B" });
Add(new Keys { From = "Ctrl", To = "Shift" });
Add(new Keys { From = "Shift", To = "Ctrl" });
}
}
}

View File

@ -32,19 +32,19 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public bool IsBackEnabled
{
get { return this.isBackEnabled; }
set { this.Set(ref this.isBackEnabled, value); }
get { return isBackEnabled; }
set { Set(ref isBackEnabled, value); }
}
public WinUI.NavigationViewItem Selected
{
get { return this.selected; }
set { this.Set(ref this.selected, value); }
get { return selected; }
set { Set(ref selected, value); }
}
public ICommand LoadedCommand => this.loadedCommand ?? (this.loadedCommand = new RelayCommand(this.OnLoaded));
public ICommand LoadedCommand => loadedCommand ?? (loadedCommand = new RelayCommand(OnLoaded));
public ICommand ItemInvokedCommand => this.itemInvokedCommand ?? (this.itemInvokedCommand = new RelayCommand<WinUI.NavigationViewItemInvokedEventArgs>(this.OnItemInvoked));
public ICommand ItemInvokedCommand => itemInvokedCommand ?? (itemInvokedCommand = new RelayCommand<WinUI.NavigationViewItemInvokedEventArgs>(OnItemInvoked));
public ShellViewModel()
{
@ -55,9 +55,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
this.navigationView = navigationView;
this.keyboardAccelerators = keyboardAccelerators;
NavigationService.Frame = frame;
NavigationService.NavigationFailed += this.Frame_NavigationFailed;
NavigationService.Navigated += this.Frame_Navigated;
this.navigationView.BackRequested += this.OnBackRequested;
NavigationService.NavigationFailed += Frame_NavigationFailed;
NavigationService.Navigated += Frame_Navigated;
this.navigationView.BackRequested += OnBackRequested;
}
private static KeyboardAccelerator BuildKeyboardAccelerator(VirtualKey key, VirtualKeyModifiers? modifiers = null)
@ -82,14 +82,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
// Keyboard accelerators are added here to avoid showing 'Alt + left' tooltip on the page.
// More info on tracking issue https://github.com/Microsoft/microsoft-ui-xaml/issues/8
this.keyboardAccelerators.Add(this.altLeftKeyboardAccelerator);
this.keyboardAccelerators.Add(this.backKeyboardAccelerator);
keyboardAccelerators.Add(altLeftKeyboardAccelerator);
keyboardAccelerators.Add(backKeyboardAccelerator);
await Task.CompletedTask;
}
private void OnItemInvoked(WinUI.NavigationViewItemInvokedEventArgs args)
{
var item = this.navigationView.MenuItems
var item = navigationView.MenuItems
.OfType<WinUI.NavigationViewItem>()
.First(menuItem => (string)menuItem.Content == (string)args.InvokedItem);
var pageType = item.GetValue(NavHelper.NavigateToProperty) as Type;
@ -108,10 +108,10 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private void Frame_Navigated(object sender, NavigationEventArgs e)
{
this.IsBackEnabled = NavigationService.CanGoBack;
this.Selected = this.navigationView.MenuItems
IsBackEnabled = NavigationService.CanGoBack;
Selected = navigationView.MenuItems
.OfType<WinUI.NavigationViewItem>()
.FirstOrDefault(menuItem => this.IsMenuItemForPageType(menuItem, e.SourcePageType));
.FirstOrDefault(menuItem => IsMenuItemForPageType(menuItem, e.SourcePageType));
}
private bool IsMenuItemForPageType(WinUI.NavigationViewItem menuItem, Type sourcePageType)

View File

@ -12,4 +12,4 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
}
}
}
}

View File

@ -2,21 +2,8 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.PowerToys.Settings.UI.ViewModels;
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.UI.Views
{
@ -26,7 +13,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public FancyZonesPage()
{
this.InitializeComponent();
InitializeComponent();
}
}
}

View File

@ -3,11 +3,9 @@
// See the LICENSE file in the project root for more information.
using System;
using System.IO;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Windows.System;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
@ -30,7 +28,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// </summary>
public GeneralPage()
{
this.InitializeComponent();
InitializeComponent();
}
/// <inheritdoc/>
@ -44,10 +42,10 @@ namespace Microsoft.PowerToys.Settings.UI.Views
settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
// load and apply theme settings
this.ReLoadTheme(settings.theme);
ReLoadTheme(settings.theme);
// load run on start-up settings value and update the ui state.
this.ToggleSwitch_RunAtStartUp.IsOn = settings.startup;
ToggleSwitch_RunAtStartUp.IsOn = settings.startup;
}
catch
{
@ -56,10 +54,10 @@ namespace Microsoft.PowerToys.Settings.UI.Views
SettingsUtils.SaveSettings(settings.ToJsonString(), string.Empty);
// load and apply theme settings
this.ReLoadTheme(settings.theme);
ReLoadTheme(settings.theme);
// load run on start up ui settings value and update the ui state.
this.ToggleSwitch_RunAtStartUp.IsOn = settings.startup;
ToggleSwitch_RunAtStartUp.IsOn = settings.startup;
}
}
@ -73,15 +71,15 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
case "light":
ShellPage.ShellHandler.RequestedTheme = ElementTheme.Light;
this.Radio_Theme_Light.IsChecked = true;
Radio_Theme_Light.IsChecked = true;
break;
case "dark":
ShellPage.ShellHandler.RequestedTheme = ElementTheme.Dark;
this.Radio_Theme_Dark.IsChecked = true;
Radio_Theme_Dark.IsChecked = true;
break;
case "system":
ShellPage.ShellHandler.RequestedTheme = ElementTheme.Default;
this.Radio_Theme_Default.IsChecked = true;
Radio_Theme_Default.IsChecked = true;
break;
}
}
@ -134,7 +132,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (rb != null)
{
string themeName = rb.Tag.ToString();
this.ReLoadTheme(themeName);
ReLoadTheme(themeName);
// update and save settings to file.
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);

View File

@ -2,32 +2,18 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.PowerToys.Settings.UI.ViewModels;
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.UI.Views
{
public sealed partial class ImageResizerPage : Page
{
public ImageResizerViewModel ViewModel { get; } = new ImageResizerViewModel();
public ImageResizerPage()
{
this.InitializeComponent();
InitializeComponent();
}
}
}

View File

@ -16,7 +16,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public KeyboardManagerPage()
{
this.InitializeComponent();
InitializeComponent();
}
}
}

View File

@ -18,33 +18,33 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public PowerLauncherPage()
{
this.InitializeComponent();
InitializeComponent();
var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
this.searchResultPreferencesOptions = new ObservableCollection<Tuple<string, string>>();
this.searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_AlphabeticalOrder"), "alphabetical_order"));
this.searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_MostRecentlyUsed"), "most_recently_used"));
this.searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_RunningProcessesOpenApplications"), "running_processes_open_applications"));
searchResultPreferencesOptions = new ObservableCollection<Tuple<string, string>>();
searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_AlphabeticalOrder"), "alphabetical_order"));
searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_MostRecentlyUsed"), "most_recently_used"));
searchResultPreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchResultPreference_RunningProcessesOpenApplications"), "running_processes_open_applications"));
this.searchTypePreferencesOptions = new ObservableCollection<Tuple<string, string>>();
this.searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ApplicationName"), "application_name"));
this.searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_StringInApplication"), "string_in_application"));
this.searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ExecutableName"), "executable_name"));
searchTypePreferencesOptions = new ObservableCollection<Tuple<string, string>>();
searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ApplicationName"), "application_name"));
searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_StringInApplication"), "string_in_application"));
searchTypePreferencesOptions.Add(Tuple.Create(loader.GetString("PowerLauncher_SearchTypePreference_ExecutableName"), "executable_name"));
}
public Tuple<string, string> SelectedSearchResultPreference
{
get
{
return this.searchResultPreferencesOptions.First(item => item.Item2 == this.ViewModel.SearchResultPreference);
return searchResultPreferencesOptions.First(item => item.Item2 == ViewModel.SearchResultPreference);
}
set
{
if (this.ViewModel.SearchResultPreference != value.Item2)
if (ViewModel.SearchResultPreference != value.Item2)
{
this.ViewModel.SearchResultPreference = value.Item2;
ViewModel.SearchResultPreference = value.Item2;
}
}
}
@ -53,14 +53,14 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
get
{
return this.searchTypePreferencesOptions.First(item => item.Item2 == this.ViewModel.SearchTypePreference);
return searchTypePreferencesOptions.First(item => item.Item2 == ViewModel.SearchTypePreference);
}
set
{
if (this.ViewModel.SearchTypePreference != value.Item2)
if (ViewModel.SearchTypePreference != value.Item2)
{
this.ViewModel.SearchTypePreference = value.Item2;
ViewModel.SearchTypePreference = value.Item2;
}
}
}

View File

@ -2,7 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using Microsoft.PowerToys.Settings.UI.Lib;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@ -15,11 +14,11 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// </summary>
public sealed partial class PowerPreviewPage : Page
{
private const string POWERTOY_NAME = "File Explorer Preview";
private const string PreviewPaneKey = "File Explorer Preview";
public PowerPreviewPage()
{
this.InitializeComponent();
InitializeComponent();
}
/// <inheritdoc/>
@ -29,16 +28,16 @@ namespace Microsoft.PowerToys.Settings.UI.Views
try
{
base.OnNavigatedTo(e);
settings = SettingsUtils.GetSettings<PowerPreviewSettings>(POWERTOY_NAME);
this.ToggleSwitch_Preview_SVG.IsOn = settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.value;
this.ToggleSwitch_Preview_MD.IsOn = settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.value;
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(POWERTOY_NAME);
SettingsUtils.SaveSettings(settings.ToJsonString(), POWERTOY_NAME);
this.ToggleSwitch_Preview_SVG.IsOn = settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.value;
this.ToggleSwitch_Preview_MD.IsOn = settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.value;
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;
}
}
@ -48,7 +47,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (swt != null)
{
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(POWERTOY_NAME);
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(PreviewPaneKey);
settings.properties.IDS_PREVPANE_SVG_BOOL_TOGGLE_CONTROLL.value = swt.IsOn;
if (ShellPage.DefaultSndMSGCallback != null)
@ -66,7 +65,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (swt != null)
{
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(POWERTOY_NAME);
PowerPreviewSettings settings = SettingsUtils.GetSettings<PowerPreviewSettings>(PreviewPaneKey);
settings.properties.PREVPANE_MD_BOOL_TOGGLE_CONTROLL_ID.value = swt.IsOn;
if (ShellPage.DefaultSndMSGCallback != null)
@ -77,6 +76,5 @@ namespace Microsoft.PowerToys.Settings.UI.Views
}
}
}
}
}

View File

@ -20,7 +20,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public PowerRenamePage()
{
this.InitializeComponent();
InitializeComponent();
}
/// <inheritdoc/>
@ -31,23 +31,23 @@ namespace Microsoft.PowerToys.Settings.UI.Views
try
{
settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
this.UpdateView(settings);
UpdateView(settings);
}
catch
{
settings = new PowerRenameSettings(POWERTOYNAME);
SettingsUtils.SaveSettings(settings.ToJsonString(), POWERTOYNAME);
this.UpdateView(settings);
UpdateView(settings);
}
}
private void UpdateView(PowerRenameSettings settings)
{
this.Toggle_PowerRename_Enable.IsOn = settings.properties.bool_mru_enabled.value;
this.Toggle_PowerRename_EnableOnExtendedContextMenu.IsOn = settings.properties.bool_show_extended_menu.value;
this.Toggle_PowerRename_MaxDispListNum.Value = settings.properties.int_max_mru_size.value;
this.Toggle_PowerRename_EnableOnContextMenu.IsOn = settings.properties.bool_show_icon_on_menu.value;
this.Toggle_PowerRename_RestoreFlagsOnLaunch.IsOn = settings.properties.bool_persist_input.value;
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)
@ -57,7 +57,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (swt != null)
{
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
settings.properties.bool_mru_enabled.value = swt.IsOn;
settings.properties.MruEnabled.value = swt.IsOn;
if (ShellPage.DefaultSndMSGCallback != null)
{
@ -75,7 +75,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (swt != null)
{
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
settings.properties.bool_show_icon_on_menu.value = swt.IsOn;
settings.properties.ShowIconInMenu.value = swt.IsOn;
if (ShellPage.DefaultSndMSGCallback != null)
{
@ -93,7 +93,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (swt != null)
{
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
settings.properties.bool_show_extended_menu.value = swt.IsOn;
settings.properties.ShowExtendedMenu.value = swt.IsOn;
if (ShellPage.DefaultSndMSGCallback != null)
{
@ -111,7 +111,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (swt != null)
{
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
settings.properties.bool_persist_input.value = swt.IsOn;
settings.properties.PersistInput.value = swt.IsOn;
if (ShellPage.DefaultSndMSGCallback != null)
{
@ -127,7 +127,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
if (sender != null)
{
PowerRenameSettings settings = SettingsUtils.GetSettings<PowerRenameSettings>(POWERTOYNAME);
settings.properties.int_max_mru_size.value = Convert.ToInt32(sender.Value);
settings.properties.MaxMruSize.value = Convert.ToInt32(sender.Value);
if (ShellPage.DefaultSndMSGCallback != null)
{
@ -139,4 +139,3 @@ namespace Microsoft.PowerToys.Settings.UI.Views
}
}
}

View File

@ -39,12 +39,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// </summary>
public ShellPage()
{
this.InitializeComponent();
InitializeComponent();
this.DataContext = this.ViewModel;
DataContext = ViewModel;
ShellHandler = this;
this.ViewModel.Initialize(this.shellFrame, this.navigationView, this.KeyboardAccelerators);
this.shellFrame.Navigate(typeof(GeneralPage));
ViewModel.Initialize(shellFrame, navigationView, KeyboardAccelerators);
shellFrame.Navigate(typeof(GeneralPage));
}
/// <summary>

View File

@ -13,7 +13,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public ShortcutGuidePage()
{
this.InitializeComponent();
InitializeComponent();
}
}
}

View File

@ -233,7 +233,7 @@
<Version>2.0.0-alpha0455</Version>
</PackageReference>
<PackageReference Include="System.Text.Json">
<Version>4.7.0</Version>
<Version>4.7.1</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.1.118</Version>