whitespace stylecop fixes for Wox.Infra (#5689)

* Limited to whitespace

* removing stylecop again
This commit is contained in:
Clint Rutkas 2020-08-06 11:28:13 -07:00 committed by GitHub
parent 7b767df0b5
commit d6e46d73b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 81 additions and 28 deletions

View file

@ -167,7 +167,7 @@ namespace Wox.Infrastructure
if (word.Length > 40)
{
//Skip strings that are too long string for Pinyin conversion.
// Skip strings that are too long string for Pinyin conversion.
return false;
}

View file

@ -18,7 +18,7 @@ namespace Wox.Infrastructure.Exception
return CreateExceptionReport(exception);
}
//todo log /display line by line
// todo log /display line by line
private static string CreateExceptionReport(System.Exception ex)
{
var sb = new StringBuilder();
@ -96,12 +96,10 @@ namespace Wox.Infrastructure.Exception
else if (string.IsNullOrEmpty(ass.Location))
{
sb.Append("location is null or empty");
}
else
{
sb.Append(ass.Location);
}
sb.AppendLine(")");
@ -151,9 +149,7 @@ namespace Wox.Infrastructure.Exception
else if (install == "1")
result.Add(string.Format("{0} {1} {2}", versionKeyName, subKeyName, name));
}
}
}
}
}
@ -179,7 +175,6 @@ namespace Wox.Infrastructure.Exception
{
return new List<string>();
}
}
}
}

View file

@ -10,6 +10,7 @@ namespace Wox.Infrastructure.FileSystemHelper
public class FileVersionInfoWrapper : IFileVersionInfoWrapper
{
public FileVersionInfoWrapper() { }
public FileVersionInfo GetVersionInfo(string path)
{
if (File.Exists(path))

View file

@ -9,6 +9,7 @@ namespace Wox.Infrastructure.FileSystemHelper
public interface IFileVersionInfoWrapper
{
FileVersionInfo GetVersionInfo(string path);
string FileDescription { get; set; }
}
}

View file

@ -12,15 +12,19 @@ namespace Wox.Infrastructure.Hotkey
public class HotkeyModel
{
public bool Alt { get; set; }
public bool Shift { get; set; }
public bool Win { get; set; }
public bool Ctrl { get; set; }
public Key CharKey { get; set; }
Dictionary<Key, string> specialSymbolDictionary = new Dictionary<Key, string>
{
{Key.Space, "Space"},
{Key.Oem3, "~"}
{ Key.Space, "Space" },
{ Key.Oem3, "~" }
};
public ModifierKeys ModifierKeys
@ -54,7 +58,6 @@ namespace Wox.Infrastructure.Hotkey
public HotkeyModel()
{
}
public HotkeyModel(string hotkeyString)
@ -119,7 +122,6 @@ namespace Wox.Infrastructure.Hotkey
}
catch (ArgumentException)
{
}
}
}

View file

@ -27,6 +27,7 @@ namespace Wox.Infrastructure.Http
}
public static HttpProxy Proxy { private get; set; }
public static IWebProxy WebProxy()
{
if (Proxy != null && Proxy.Enabled && !string.IsNullOrEmpty(Proxy.Server))

View file

@ -26,6 +26,7 @@ namespace Wox.Infrastructure.Image
var i = _data[path];
return i;
}
set
{
_data[path] = value;
@ -89,5 +90,4 @@ namespace Wox.Infrastructure.Image
Usage = new ConcurrentDictionary<string, int>(usage);
}
}
}

View file

@ -48,7 +48,6 @@ namespace Wox.Infrastructure.Image
{
return null;
}
}
}
}

View file

@ -69,7 +69,7 @@ namespace Wox.Infrastructure.Image
_storage.Save(ImageCache.GetUsageAsDictionary());
}
//Todo : Update it with icons specific to each theme.
// Todo : Update it with icons specific to each theme.
public static void UpdateIconPath(Theme theme)
{
if (theme == Theme.Light || theme == Theme.HighContrastWhite)
@ -93,6 +93,7 @@ namespace Wox.Infrastructure.Image
}
public ImageType ImageType { get; }
public ImageSource ImageSource { get; }
}
@ -138,14 +139,13 @@ namespace Wox.Infrastructure.Image
{
/* Directories can also have thumbnails instead of shell icons.
* Generating thumbnails for a bunch of folders while scrolling through
* results from Everything makes a big impact on performance and
* Wox responsibility.
* results from Everything makes a big impact on performance and
* Wox responsibility.
* - Solution: just load the icon
*/
type = ImageType.Folder;
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize,
Constant.ThumbnailSize, ThumbnailOptions.IconOnly);
}
else if (File.Exists(path))
{
@ -159,9 +159,9 @@ namespace Wox.Infrastructure.Image
}
else
{
/* Although the documentation for GetImage on MSDN indicates that
/* Although the documentation for GetImage on MSDN indicates that
* if a thumbnail is available it will return one, this has proved to not
* be the case in many situations while testing.
* be the case in many situations while testing.
* - Solution: explicitly pass the ThumbnailOnly flag
*/
image = WindowsThumbnailProvider.GetThumbnail(path, Constant.ThumbnailSize,

View file

@ -50,11 +50,13 @@ namespace Wox.Infrastructure.Image
out IntPtr ppv);
void GetParent(out IShellItem ppsi);
void GetDisplayName(SIGDN sigdnName, out IntPtr ppszName);
void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
void Compare(IShellItem psi, uint hint, out int piOrder);
}
;
internal enum SIGDN : uint
{
@ -105,9 +107,9 @@ namespace Wox.Infrastructure.Image
private int height;
public int Width { set { width = value; } }
public int Height { set { height = value; } }
}
;
public static BitmapSource GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
{

View file

@ -12,6 +12,7 @@ namespace Wox.Infrastructure
{
private static readonly Dictionary<string, long> Count = new Dictionary<string, long>();
private static readonly object Locker = new object();
/// <summary>
/// This stopwatch will appear only in Debug mode
/// </summary>

View file

@ -37,6 +37,7 @@ namespace Wox.Infrastructure.Storage
public T TryLoad(T defaultData)
{
_storageHelper = new StoragePowerToysVersionInfo(FilePath, BINARY_STORAGE);
// Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible
if (_storageHelper.clearCache)
{
@ -72,7 +73,7 @@ namespace Wox.Infrastructure.Storage
private T Deserialize(FileStream stream, T defaultData)
{
//http://stackoverflow.com/questions/2120055/binaryformatter-deserialize-gives-serializationexception
// http://stackoverflow.com/questions/2120055/binaryformatter-deserialize-gives-serializationexception
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
BinaryFormatter binaryFormatter = new BinaryFormatter
{

View file

@ -11,15 +11,22 @@ namespace Wox.Infrastructure.Storage
{
// Events to watch out for
event FileSystemEventHandler Created;
event FileSystemEventHandler Deleted;
event FileSystemEventHandler Changed;
event RenamedEventHandler Renamed;
// Properties of File System watcher
Collection<string> Filters { get; set; }
bool EnableRaisingEvents { get; set; }
NotifyFilters NotifyFilter { get; set; }
string Path { get; set; }
bool IncludeSubdirectories { get; set; }
}
}

View file

@ -9,9 +9,13 @@ namespace Wox.Infrastructure.Storage
public interface IRepository<T>
{
void Add(T insertedItem);
void Remove(T removedItem);
bool Contains(T item);
void Set(IList<T> list);
bool Any();
}
}

View file

@ -5,7 +5,7 @@
namespace Wox.Infrastructure.Storage
{
/// <summary>
/// Save plugin settings/cache,
/// Save plugin settings/cache,
/// todo should be merged into a abstract class instead of separate interface
/// </summary>
public interface ISavable

View file

@ -17,10 +17,13 @@ namespace Wox.Infrastructure.Storage
{
private readonly JsonSerializerSettings _serializerSettings;
private T _data;
// need a new directory name
public const string DirectoryName = "Settings";
public const string FileSuffix = ".json";
public string FilePath { get; set; }
public string DirectoryPath { get; set; }
// This storage helper returns whether or not to delete the json storage items
@ -41,6 +44,7 @@ namespace Wox.Infrastructure.Storage
public T Load()
{
_storageHelper = new StoragePowerToysVersionInfo(FilePath, JSON_STORAGE);
// Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible
if (_storageHelper.clearCache)
{
@ -108,6 +112,7 @@ namespace Wox.Infrastructure.Storage
var backupName = $"{originName}-{timestamp}{FileSuffix}";
var backupPath = Path.Combine(directory, backupName);
File.Copy(FilePath, backupPath, true);
// todo give user notification for the backup process
}

View file

@ -13,7 +13,7 @@ namespace Wox.Infrastructure.Storage
{
/// <summary>
/// The intent of this class is to provide a basic subset of 'list' like operations, without exposing callers to the internal representation
/// of the data structure. Currently this is implemented as a list for it's simplicity.
/// of the data structure. Currently this is implemented as a list for it's simplicity.
/// </summary>
/// <typeparam name="T"></typeparam>
public class ListRepository<T> : IRepository<T>, IEnumerable<T>
@ -24,12 +24,11 @@ namespace Wox.Infrastructure.Storage
public ListRepository()
{
}
public void Set(IList<T> items)
{
//enforce that internal representation
// enforce that internal representation
try
{
_items = new ConcurrentDictionary<int, T>(items.ToDictionary(i => i.GetHashCode()));
@ -51,7 +50,6 @@ namespace Wox.Infrastructure.Storage
{
Log.Error($"|ListRepository.Add| Item Already Exists <{insertedItem}>");
}
}
public void Remove(T removedItem)

View file

@ -13,6 +13,7 @@ namespace Wox.Infrastructure.Storage
public bool clearCache = false;
private String currentPowerToysVersion = String.Empty;
private String FilePath { get; set; } = String.Empty;
// As of now this information is not pertinent but may be in the future
@ -102,6 +103,7 @@ namespace Wox.Infrastructure.Storage
public StoragePowerToysVersionInfo(String AssociatedFilePath, int type)
{
FilePath = GetFilePath(AssociatedFilePath, type);
// Get the previous version of PowerToys and cache Storage details from the CacheDetails.json storage file
String previousVersion = GetPreviousVersion();
currentPowerToysVersion = Microsoft.PowerToys.Settings.UI.Lib.Utilities.Helper.GetProductVersion();

View file

@ -9,6 +9,7 @@ using System.Runtime.CompilerServices;
using static Wox.Infrastructure.StringMatcher;
[assembly: InternalsVisibleToAttribute("Microsoft.Plugin.Program.UnitTests")]
namespace Wox.Infrastructure
{
public class StringMatcher
@ -225,7 +226,7 @@ namespace Wox.Infrastructure
private static int CalculateSearchScore(string query, string stringToCompare, int firstIndex, int matchLen, bool allSubstringsContainedInCompareString)
{
// A match found near the beginning of a string is scored more than a match found near the end
// A match is scored more if the characters in the patterns are closer to each other,
// A match is scored more if the characters in the patterns are closer to each other,
// while the score is lower if they are more spread out
var score = 100 * (query.Length + 1) / ((1 + firstIndex) + (matchLen + 1));
@ -301,6 +302,7 @@ namespace Wox.Infrastructure
public int RawScore
{
get { return _rawScore; }
set
{
_rawScore = value;

View file

@ -7,9 +7,13 @@ namespace Wox.Infrastructure.UserSettings
public class HttpProxy
{
public bool Enabled { get; set; } = false;
public string Server { get; set; }
public int Port { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}
}

View file

@ -9,6 +9,7 @@ namespace Wox.Infrastructure.UserSettings
public class CustomPluginHotkey : BaseModel
{
public string Hotkey { get; set; }
public string ActionKeyword { get; set; }
}
}

View file

@ -43,7 +43,9 @@ namespace Wox.Infrastructure.UserSettings
public class Plugin
{
public string ID { get; set; }
public string Name { get; set; }
public List<string> ActionKeywords { get; set; } // a reference of the action keywords from plugin manager
/// <summary>

View file

@ -15,6 +15,7 @@ namespace Wox.Infrastructure.UserSettings
{
private string _hotkey = "Alt + Space";
private string _previousHotkey = "";
public string PreviousHotkey
{
get
@ -29,6 +30,7 @@ namespace Wox.Infrastructure.UserSettings
{
return _hotkey;
}
set
{
if (_hotkey != value)
@ -41,14 +43,23 @@ namespace Wox.Infrastructure.UserSettings
}
public string Language { get; set; } = "en";
public string Theme { get; set; } = "Dark";
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;
public string QueryBoxFontStyle { get; set; }
public string QueryBoxFontWeight { get; set; }
public string QueryBoxFontStretch { get; set; }
public string ResultFont { get; set; } = FontFamily.GenericSansSerif.Name;
public string ResultFontStyle { get; set; }
public string ResultFontWeight { get; set; }
public string ResultFontStretch { get; set; }
/// <summary>
@ -62,6 +73,7 @@ namespace Wox.Infrastructure.UserSettings
public string QuerySearchPrecisionString
{
get { return QuerySearchPrecision.ToString(); }
set
{
try
@ -87,15 +99,18 @@ namespace Wox.Infrastructure.UserSettings
public bool AutoUpdates { get; set; } = false;
public double WindowLeft { get; set; }
public double WindowTop { get; set; }
private int _maxResultsToShow = 4;
public int MaxResultsToShow
{
get
{
return _maxResultsToShow;
}
set
{
if (_maxResultsToShow != value)
@ -111,6 +126,7 @@ namespace Wox.Infrastructure.UserSettings
// Order defaults to 0 or -1, so 1 will let this property appear last
[JsonProperty(Order = 1)]
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
public ObservableCollection<CustomPluginHotkey> CustomPluginHotkeys { get; set; } = new ObservableCollection<CustomPluginHotkey>();
[Obsolete]
@ -120,14 +136,19 @@ namespace Wox.Infrastructure.UserSettings
public OpacityMode OpacityMode { get; set; } = OpacityMode.Normal;
public bool DontPromptUpdateMsg { get; set; }
public bool EnableUpdateLog { get; set; }
public bool StartWoxOnSystemStartup { get; set; } = true;
public bool HideOnStartup { get; set; }
bool _hideNotifyIcon { get; set; }
public bool HideNotifyIcon
{
get { return _hideNotifyIcon; }
set
{
_hideNotifyIcon = value;
@ -136,10 +157,13 @@ namespace Wox.Infrastructure.UserSettings
}
public bool LeaveCmdOpen { get; set; }
public bool HideWhenDeactivated { get; set; } = true;
public bool ClearInputOnLaunch { get; set; } = false;
public bool RememberLastLaunchLocation { get; set; }
public bool IgnoreHotkeysOnFullscreen { get; set; }
public HttpProxy Proxy { get; set; } = new HttpProxy();

View file

@ -22,6 +22,7 @@ namespace Wox.Infrastructure
public static bool IsPortableMode;
public const string PortableFolderName = "UserData";
public static string PortableDataPath = Path.Combine(ProgramDirectory, PortableFolderName);
public static string DetermineDataDirectory()
{
if (Directory.Exists(PortableDataPath))