Stylecop compliance

This commit is contained in:
Tomas Raies
2020-04-08 00:19:00 -07:00
committed by Tomas Agustin Raies
parent 443b3c8b82
commit a85b84fd56
17 changed files with 260 additions and 183 deletions

View File

@@ -1,181 +1,218 @@
// 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.Runtime.CompilerServices;
using System.Text.Json;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.Views;
using Windows.UI.Xaml.Controls;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
public class PowerLauncherViewModel : Observable
{
public PowerLauncherSettings settings;
private const string POWERTOY_NAME = "PowerLauncher";
private const string POWERTOYNAME = "PowerLauncher";
private PowerLauncherSettings settings;
public PowerLauncherViewModel()
{
if (SettingsUtils.SettingsExists(POWERTOY_NAME))
if (SettingsUtils.SettingsExists(POWERTOYNAME))
{
settings = SettingsUtils.GetSettings<PowerLauncherSettings>(POWERTOY_NAME);
} else
this.settings = SettingsUtils.GetSettings<PowerLauncherSettings>(POWERTOYNAME);
}
else
{
settings = new PowerLauncherSettings();
this.settings = new PowerLauncherSettings();
}
}
private void UpdateSettings([CallerMemberName] string propertyName = null)
{
// Notify UI of property change
OnPropertyChanged(propertyName);
this.OnPropertyChanged(propertyName);
// Save settings to file
var options = new JsonSerializerOptions
{
WriteIndented = true
WriteIndented = true,
};
SettingsUtils.SaveSettings(JsonSerializer.Serialize(settings, options), POWERTOY_NAME);
SettingsUtils.SaveSettings(JsonSerializer.Serialize(this.settings, options), POWERTOYNAME);
// Propagate changes to Power Launcher through IPC
var propertiesJson = JsonSerializer.Serialize(settings.properties);
ShellPage.Default_SndMSG_Callback(
string.Format("{{ \"{0}\": {1} }}", POWERTOY_NAME, JsonSerializer.Serialize(settings.properties)));
var propertiesJson = JsonSerializer.Serialize(this.settings.properties);
ShellPage.DefaultSndMSGCallback(
string.Format("{{ \"{0}\": {1} }}", POWERTOYNAME, JsonSerializer.Serialize(this.settings.properties)));
}
public bool EnablePowerLauncher
{
get { return settings.properties.enable_powerlauncher; }
set
get
{
if (settings.properties.enable_powerlauncher != value)
return this.settings.properties.enable_powerlauncher;
}
set
{
if (this.settings.properties.enable_powerlauncher != value)
{
settings.properties.enable_powerlauncher = value;
UpdateSettings();
this.settings.properties.enable_powerlauncher = value;
this.UpdateSettings();
}
}
}
public string SearchResultPreference
{
get { return settings.properties.search_result_preference; }
set
get
{
if (settings.properties.search_result_preference != value)
return this.settings.properties.search_result_preference;
}
set
{
if (this.settings.properties.search_result_preference != value)
{
settings.properties.search_result_preference = value;
UpdateSettings();
this.settings.properties.search_result_preference = value;
this.UpdateSettings();
}
}
}
public string SearchTypePreference
{
get { return settings.properties.search_type_preference; }
get
{
return this.settings.properties.search_type_preference;
}
set
{
if (settings.properties.search_type_preference != value)
if (this.settings.properties.search_type_preference != value)
{
settings.properties.search_type_preference = value;
UpdateSettings();
this.settings.properties.search_type_preference = value;
this.UpdateSettings();
}
}
}
public int MaximumNumberOfResults
{
get { return settings.properties.maximum_number_of_results; }
get
{
return this.settings.properties.maximum_number_of_results;
}
set
{
if (settings.properties.maximum_number_of_results != value)
if (this.settings.properties.maximum_number_of_results != value)
{
settings.properties.maximum_number_of_results = value;
UpdateSettings();
this.settings.properties.maximum_number_of_results = value;
this.UpdateSettings();
}
}
}
public HotkeySettings OpenPowerLauncher
{
get { return settings.properties.open_powerlauncher; }
get
{
return this.settings.properties.open_powerlauncher;
}
set
{
if (settings.properties.open_powerlauncher != value)
if (this.settings.properties.open_powerlauncher != value)
{
settings.properties.open_powerlauncher = value;
UpdateSettings();
}
this.settings.properties.open_powerlauncher = value;
this.UpdateSettings();
}
}
}
public HotkeySettings OpenFileLocation
{
get { return settings.properties.open_file_location; }
get
{
return this.settings.properties.open_file_location;
}
set
{
if (settings.properties.open_file_location != value)
if (this.settings.properties.open_file_location != value)
{
settings.properties.open_file_location = value;
UpdateSettings();
this.settings.properties.open_file_location = value;
this.UpdateSettings();
}
}
}
public HotkeySettings CopyPathLocation
{
get { return settings.properties.copy_path_location; }
get
{
return this.settings.properties.copy_path_location;
}
set
{
if (settings.properties.copy_path_location != value)
if (this.settings.properties.copy_path_location != value)
{
settings.properties.copy_path_location = value;
UpdateSettings();
this.settings.properties.copy_path_location = value;
this.UpdateSettings();
}
}
}
public HotkeySettings OpenConsole
{
get { return settings.properties.open_console; }
get
{
return this.settings.properties.open_console;
}
set
{
if (settings.properties.open_console != value)
if (this.settings.properties.open_console != value)
{
settings.properties.open_console = value;
UpdateSettings();
this.settings.properties.open_console = value;
this.UpdateSettings();
}
}
}
public bool OverrideWinRKey
{
get { return settings.properties.override_win_r_key; }
get
{
return this.settings.properties.override_win_r_key;
}
set
{
if (settings.properties.override_win_r_key != value)
if (this.settings.properties.override_win_r_key != value)
{
settings.properties.override_win_r_key = value;
UpdateSettings();
this.settings.properties.override_win_r_key = value;
this.UpdateSettings();
}
}
}
public bool OverrideWinSKey
{
get { return settings.properties.override_win_s_key; }
get
{
return this.settings.properties.override_win_s_key;
}
set
{
if (settings.properties.override_win_s_key != value)
if (this.settings.properties.override_win_s_key != value)
{
settings.properties.override_win_s_key = value;
UpdateSettings();
this.settings.properties.override_win_s_key = value;
this.UpdateSettings();
}
}
}
}
}
}