Program plugin fully on stylecop (#5964)

This commit is contained in:
Clint Rutkas
2020-08-14 12:46:23 -07:00
committed by GitHub
parent be5d58c849
commit e0a1b478a1
31 changed files with 361 additions and 279 deletions

View File

@@ -9,7 +9,6 @@ using System.Linq;
using System.Threading.Tasks;
using Microsoft.Plugin.Program.Programs;
using Microsoft.Plugin.Program.Storage;
using Microsoft.PowerToys.Settings.UI.Lib;
using Wox.Infrastructure.Logger;
using Wox.Infrastructure.Storage;
using Wox.Plugin;
@@ -19,9 +18,9 @@ namespace Microsoft.Plugin.Program
{
public class Main : IPlugin, IPluginI18n, IContextMenu, ISavable, IReloadable, IDisposable
{
internal static ProgramPluginSettings _settings { get; set; }
internal static ProgramPluginSettings Settings { get; set; }
private static bool IsStartupIndexProgramsRequired => _settings.LastIndexTime.AddDays(3) < DateTime.Today;
private static bool IsStartupIndexProgramsRequired => Settings.LastIndexTime.AddDays(3) < DateTime.Today;
private static PluginInitContext _context;
@@ -34,13 +33,13 @@ namespace Microsoft.Plugin.Program
public Main()
{
_settingsStorage = new PluginJsonStorage<ProgramPluginSettings>();
_settings = _settingsStorage.Load();
Settings = _settingsStorage.Load();
// This helper class initializes the file system watchers based on the locations to watch
_win32ProgramRepositoryHelper = new Win32ProgramFileSystemWatchers();
// Initialize the Win32ProgramRepository with the settings object
_win32ProgramRepository = new Win32ProgramRepository(_win32ProgramRepositoryHelper._fileSystemWatchers.Cast<IFileSystemWatcherWrapper>().ToList(), new BinaryStorage<IList<Programs.Win32Program>>("Win32"), _settings, _win32ProgramRepositoryHelper._pathsToWatch);
_win32ProgramRepository = new Win32ProgramRepository(_win32ProgramRepositoryHelper.FileSystemWatchers.Cast<IFileSystemWatcherWrapper>().ToList(), new BinaryStorage<IList<Programs.Win32Program>>("Win32"), Settings, _win32ProgramRepositoryHelper.PathsToWatch);
Stopwatch.Normal("|Microsoft.Plugin.Program.Main|Preload programs cost", () =>
{
@@ -67,7 +66,7 @@ namespace Microsoft.Plugin.Program
Task.WaitAll(a, b);
_settings.LastIndexTime = DateTime.Today;
Settings.LastIndexTime = DateTime.Today;
}
public void Save()
@@ -89,7 +88,7 @@ namespace Microsoft.Plugin.Program
var result = results1.Concat(results2).Where(r => r != null && r.Score > 0);
var maxScore = result.Max(x => x.Score);
result = result.Where(x => x.Score > _settings.MinScoreThreshold * maxScore);
result = result.Where(x => x.Score > Settings.MinScoreThreshold * maxScore);
return result.ToList();
}
@@ -98,12 +97,13 @@ namespace Microsoft.Plugin.Program
{
_context = context ?? throw new ArgumentNullException(nameof(context));
_context.API.ThemeChanged += OnThemeChanged;
UpdateUWPIconPath(_context.API.GetCurrentTheme());
}
public void OnThemeChanged(Theme _, Theme currentTheme)
public void OnThemeChanged(Theme currentTheme, Theme newTheme)
{
UpdateUWPIconPath(currentTheme);
UpdateUWPIconPath(newTheme);
}
public void UpdateUWPIconPath(Theme theme)
@@ -121,7 +121,7 @@ namespace Microsoft.Plugin.Program
Task.WaitAll(t1, t2);
_settings.LastIndexTime = DateTime.Today;
Settings.LastIndexTime = DateTime.Today;
}
public string GetTranslatedPluginTitle()
@@ -142,8 +142,7 @@ namespace Microsoft.Plugin.Program
}
var menuOptions = new List<ContextMenuResult>();
var program = selectedResult.ContextData as Programs.IProgram;
if (program != null)
if (selectedResult.ContextData is Programs.IProgram program)
{
menuOptions = program.ContextMenus(_context.API);
}
@@ -180,10 +179,6 @@ namespace Microsoft.Plugin.Program
{
IndexPrograms();
}
public static void UpdateSettings(PowerLauncherSettings _)
{
}
public void Dispose()
{