mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
Move websearch images to %APPDATA%
This commit is contained in:
@@ -6,6 +6,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Plugin.Everything.Everything;
|
||||
|
||||
@@ -15,9 +16,7 @@ namespace Wox.Plugin.Everything
|
||||
{
|
||||
private readonly EverythingAPI _api = new EverythingAPI();
|
||||
|
||||
public const string SDK = "EverythingSDK";
|
||||
public const string DLL = "Everything.dll";
|
||||
internal static string SDKPath;
|
||||
|
||||
private PluginInitContext _context;
|
||||
|
||||
@@ -130,34 +129,16 @@ namespace Wox.Plugin.Everything
|
||||
_settings = _storage.Load();
|
||||
|
||||
var pluginDirectory = context.CurrentPluginMetadata.PluginDirectory;
|
||||
var bundledSDKDirectory = Path.Combine(pluginDirectory, SDK, CpuType());
|
||||
var bundledSDKPath = Path.Combine(bundledSDKDirectory, DLL);
|
||||
const string sdk = "EverythingSDK";
|
||||
var bundledSDKDirectory = Path.Combine(pluginDirectory, sdk, CpuType());
|
||||
var sdkDirectory = Path.Combine(_storage.DirectoryPath, sdk, CpuType());
|
||||
Helper.ValidateDataDirectory(bundledSDKDirectory, sdkDirectory);
|
||||
|
||||
var SDKDirectory = Path.Combine(_storage.DirectoryPath, SDK, CpuType());
|
||||
SDKPath = Path.Combine(SDKDirectory, DLL);
|
||||
if (!Directory.Exists(SDKDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(SDKDirectory);
|
||||
}
|
||||
|
||||
if (!File.Exists(SDKPath))
|
||||
{
|
||||
File.Copy(bundledSDKPath, SDKPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
var newSDK = new FileInfo(bundledSDKPath).LastWriteTimeUtc;
|
||||
var oldSDK = new FileInfo(SDKPath).LastWriteTimeUtc;
|
||||
if (oldSDK != newSDK)
|
||||
{
|
||||
File.Copy(bundledSDKPath, SDKPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
LoadLibrary(SDKPath);
|
||||
var sdkPath = Path.Combine(sdkDirectory, DLL);
|
||||
LoadLibrary(sdkPath);
|
||||
}
|
||||
|
||||
private string CpuType()
|
||||
private static string CpuType()
|
||||
{
|
||||
return Environment.Is64BitOperatingSystem ? "x64" : "x86";
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using JetBrains.Annotations;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Plugin.WebSearch.SuggestionSources;
|
||||
|
||||
@@ -20,8 +22,8 @@ namespace Wox.Plugin.WebSearch
|
||||
private CancellationTokenSource _updateSource;
|
||||
private CancellationToken _updateToken;
|
||||
|
||||
public const string ImageDirectory = "Images";
|
||||
public static string PluginDirectory;
|
||||
public const string Images = "Images";
|
||||
public static string ImagesDirectory;
|
||||
|
||||
public void Save()
|
||||
{
|
||||
@@ -86,7 +88,7 @@ namespace Wox.Plugin.WebSearch
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
results.AddRange(ResultsFromSuggestions(keyword, subtitle, webSearch));
|
||||
|
||||
|
||||
}, _updateToken);
|
||||
|
||||
if (!task.Wait(waittime))
|
||||
@@ -123,12 +125,24 @@ namespace Wox.Plugin.WebSearch
|
||||
return new List<Result>();
|
||||
}
|
||||
|
||||
static Main()
|
||||
{
|
||||
var plugins = Infrastructure.Wox.Plugins;
|
||||
var assemblyName = typeof(Main).Assembly.GetName().Name;
|
||||
var pluginDirectory = Path.Combine(Infrastructure.Wox.SettingsPath, plugins, assemblyName);
|
||||
ImagesDirectory = Path.Combine(pluginDirectory, Images);
|
||||
}
|
||||
|
||||
public void Init(PluginInitContext context)
|
||||
{
|
||||
Context = context;
|
||||
PluginDirectory = Context.CurrentPluginMetadata.PluginDirectory;
|
||||
|
||||
_storage = new PluginJsonStorage<Settings>();
|
||||
_settings = _storage.Load();
|
||||
|
||||
var pluginDirectory = context.CurrentPluginMetadata.PluginDirectory;
|
||||
var bundledImagesDirectory = Path.Combine(pluginDirectory, Images);
|
||||
Helper.ValidateDataDirectory(bundledImagesDirectory, ImagesDirectory);
|
||||
}
|
||||
|
||||
#region ISettingProvider Members
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Wox.Plugin.WebSearch
|
||||
set
|
||||
{
|
||||
_icon = value;
|
||||
IconPath = Path.Combine(Main.PluginDirectory, Main.ImageDirectory, value);
|
||||
IconPath = Path.Combine(Main.ImagesDirectory, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Wox.Plugin.WebSearch
|
||||
[JsonIgnore]
|
||||
internal string IconPath { get; private set; } = Path.Combine
|
||||
(
|
||||
Main.PluginDirectory, Main.ImageDirectory, DefaultIcon
|
||||
Main.ImagesDirectory, DefaultIcon
|
||||
);
|
||||
|
||||
public string Url { get; set; }
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace Wox.Plugin.WebSearch
|
||||
|
||||
private void SelectIconButtonOnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var directory = Path.Combine(Main.PluginDirectory, Main.ImageDirectory);
|
||||
var directory = Path.Combine(Main.ImagesDirectory, Main.Images);
|
||||
var dlg = new OpenFileDialog
|
||||
{
|
||||
InitialDirectory = directory,
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
||||
Reference in New Issue
Block a user