mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
implement issue#8 part 1
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Wox.Plugin.Doc
|
|||||||
|
|
||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
docsetBasePath = context.CurrentPluginMetadata.PluginDirecotry + @"Docset";
|
docsetBasePath = Path.Combine(context.CurrentPluginMetadata.PluginDirecotry, @"Docset");
|
||||||
if (!Directory.Exists(docsetBasePath))
|
if (!Directory.Exists(docsetBasePath))
|
||||||
Directory.CreateDirectory(docsetBasePath);
|
Directory.CreateDirectory(docsetBasePath);
|
||||||
|
|
||||||
|
|||||||
BIN
Plugins/Wox.Plugin.PluginManagement/Images/plugin.png
Normal file
BIN
Plugins/Wox.Plugin.PluginManagement/Images/plugin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.7 KiB |
176
Plugins/Wox.Plugin.PluginManagement/Main.cs
Normal file
176
Plugins/Wox.Plugin.PluginManagement/Main.cs
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Wox.Plugin.PluginManagement
|
||||||
|
{
|
||||||
|
public class Main : IPlugin
|
||||||
|
{
|
||||||
|
private static string PluginPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins";
|
||||||
|
private static string PluginConfigName = "plugin.json";
|
||||||
|
private PluginInitContext context;
|
||||||
|
|
||||||
|
public List<Result> Query(Query query)
|
||||||
|
{
|
||||||
|
List<Result> results = new List<Result>();
|
||||||
|
if (query.ActionParameters.Count == 0)
|
||||||
|
{
|
||||||
|
results.Add(new Result()
|
||||||
|
{
|
||||||
|
Title = "wpm list",
|
||||||
|
SubTitle = "list plugins installed",
|
||||||
|
IcoPath = "Images\\plugin.png",
|
||||||
|
Action = e =>
|
||||||
|
{
|
||||||
|
context.ChangeQuery("wpm list");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
results.Add(new Result()
|
||||||
|
{
|
||||||
|
Title = "wpm uninstall <pluginName>",
|
||||||
|
SubTitle = "uninstall plugin",
|
||||||
|
IcoPath = "Images\\plugin.png",
|
||||||
|
Action = e =>
|
||||||
|
{
|
||||||
|
context.ChangeQuery("wpm uninstall ");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.ActionParameters.Count > 0)
|
||||||
|
{
|
||||||
|
switch (query.ActionParameters[0].ToLower())
|
||||||
|
{
|
||||||
|
case "list":
|
||||||
|
results = ListInstalledPlugins();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "uninstall":
|
||||||
|
results = ListUnInstalledPlugins(query);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Result> ListUnInstalledPlugins(Query query)
|
||||||
|
{
|
||||||
|
List<Result> results = new List<Result>();
|
||||||
|
List<PluginMetadata> allInstalledPlugins = ParseThirdPartyPlugins();
|
||||||
|
if (query.ActionParameters.Count > 1)
|
||||||
|
{
|
||||||
|
string pluginName = query.ActionParameters[1];
|
||||||
|
allInstalledPlugins =
|
||||||
|
allInstalledPlugins.Where(o => o.Name.ToLower().Contains(pluginName.ToLower())).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (PluginMetadata plugin in allInstalledPlugins)
|
||||||
|
{
|
||||||
|
results.Add(new Result()
|
||||||
|
{
|
||||||
|
Title = plugin.Name,
|
||||||
|
SubTitle = plugin.Description,
|
||||||
|
IcoPath = "Images\\plugin.png",
|
||||||
|
Action = e =>
|
||||||
|
{
|
||||||
|
UnInstalledPlugins(plugin);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UnInstalledPlugins(PluginMetadata plugin)
|
||||||
|
{
|
||||||
|
string content = string.Format("Do you want to uninstall following plugin?\r\n\r\nName: {0}\r\nVersion: {1}\r\nAuthor: {2}",plugin.Name, plugin.Version, plugin.Author);
|
||||||
|
if (MessageBox.Show(content, "Wox", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
File.Create(Path.Combine(plugin.PluginDirecotry, "NeedDelete.txt"));
|
||||||
|
MessageBox.Show("This plugin has been removed, restart Wox to take effect");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Result> ListInstalledPlugins()
|
||||||
|
{
|
||||||
|
List<Result> results = new List<Result>();
|
||||||
|
foreach (PluginMetadata plugin in ParseThirdPartyPlugins())
|
||||||
|
{
|
||||||
|
results.Add(new Result()
|
||||||
|
{
|
||||||
|
Title = plugin.Name,
|
||||||
|
SubTitle = plugin.Description,
|
||||||
|
IcoPath = "Images\\plugin.png"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<PluginMetadata> ParseThirdPartyPlugins()
|
||||||
|
{
|
||||||
|
List<PluginMetadata> pluginMetadatas = new List<PluginMetadata>();
|
||||||
|
if (!Directory.Exists(PluginPath))
|
||||||
|
Directory.CreateDirectory(PluginPath);
|
||||||
|
|
||||||
|
string[] directories = Directory.GetDirectories(PluginPath);
|
||||||
|
foreach (string directory in directories)
|
||||||
|
{
|
||||||
|
PluginMetadata metadata = GetMetadataFromJson(directory);
|
||||||
|
if (metadata != null) pluginMetadatas.Add(metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pluginMetadatas;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PluginMetadata GetMetadataFromJson(string pluginDirectory)
|
||||||
|
{
|
||||||
|
string configPath = Path.Combine(pluginDirectory, PluginConfigName);
|
||||||
|
PluginMetadata metadata;
|
||||||
|
|
||||||
|
if (!File.Exists(configPath))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
|
||||||
|
metadata.PluginType = PluginType.ThirdParty;
|
||||||
|
metadata.PluginDirecotry = pluginDirectory;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
string error = string.Format("Parse plugin config {0} failed: json format is not valid", configPath);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!AllowedLanguage.IsAllowed(metadata.Language))
|
||||||
|
{
|
||||||
|
string error = string.Format("Parse plugin config {0} failed: invalid language {1}", configPath,
|
||||||
|
metadata.Language);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!File.Exists(metadata.ExecuteFilePath))
|
||||||
|
{
|
||||||
|
string error = string.Format("Parse plugin config {0} failed: ExecuteFile {1} didn't exist", configPath,
|
||||||
|
metadata.ExecuteFilePath);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init(PluginInitContext context)
|
||||||
|
{
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,8 @@
|
|||||||
<AssemblyName>Wox.Plugin.PluginManagement</AssemblyName>
|
<AssemblyName>Wox.Plugin.PluginManagement</AssemblyName>
|
||||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
|
||||||
|
<RestorePackages>true</RestorePackages>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
@@ -30,8 +32,12 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
@@ -42,12 +48,32 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Wox.Plugin.csproj">
|
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj">
|
||||||
<Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project>
|
<Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project>
|
||||||
<Name>Wox.Plugin</Name>
|
<Name>Wox.Plugin</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
<None Include="plugin.json">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Images\plugin.png" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<PostBuildEvent>xcopy /Y /E $(TargetDir)*.* $(SolutionDir)Wox\bin\Debug\Plugins\$(ProjectName)\
|
||||||
|
xcopy /Y /E $(ProjectDir)Images $(SolutionDir)Wox\bin\Debug\Plugins\$(ProjectName)\Images\</PostBuildEvent>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
|
||||||
|
</Target>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
4
Plugins/Wox.Plugin.PluginManagement/packages.config
Normal file
4
Plugins/Wox.Plugin.PluginManagement/packages.config
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net35" />
|
||||||
|
</packages>
|
||||||
11
Plugins/Wox.Plugin.PluginManagement/plugin.json
Normal file
11
Plugins/Wox.Plugin.PluginManagement/plugin.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"ID":"D2D2C23B084D422DB66FE0C79D6C2A6A",
|
||||||
|
"ActionKeyword":"wpm",
|
||||||
|
"Name":"Wox Plugin Management",
|
||||||
|
"Description":"Manage your plugins in Wox",
|
||||||
|
"Author":"qianlifeng",
|
||||||
|
"Version":"1.0",
|
||||||
|
"Language":"csharp",
|
||||||
|
"Website":"http://www.getwox.com/plugin",
|
||||||
|
"ExecuteFileName":"Wox.Plugin.PluginManagement.dll"
|
||||||
|
}
|
||||||
@@ -19,5 +19,11 @@ namespace Wox.Plugin
|
|||||||
public Action OpenSettingDialog { get; set; }
|
public Action OpenSettingDialog { get; set; }
|
||||||
|
|
||||||
public Action<string> ShowCurrentResultItemTooltip { get; set; }
|
public Action<string> ShowCurrentResultItemTooltip { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// reload all plugins
|
||||||
|
/// </summary>
|
||||||
|
public Action ReloadPlugins { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Wox.Plugin.PluginManagement
|
|
||||||
{
|
|
||||||
public class Main:IPlugin
|
|
||||||
{
|
|
||||||
private PluginInitContext context;
|
|
||||||
|
|
||||||
public List<Result> Query(Query query)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Init(PluginInitContext context)
|
|
||||||
{
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2
Wox.sln
2
Wox.sln
@@ -27,7 +27,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.UAC", "Wox.UAC\Wox.UAC.
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Clipboard", "Plugins\Wox.Plugin.Clipboard\Wox.Plugin.Clipboard.csproj", "{8C14DC11-2737-4DCB-A121-5D7BDD57FEA2}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Clipboard", "Plugins\Wox.Plugin.Clipboard\Wox.Plugin.Clipboard.csproj", "{8C14DC11-2737-4DCB-A121-5D7BDD57FEA2}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.PluginManagement", "Wox.Plugin\Wox.Plugin.PluginManagement\Wox.Plugin.PluginManagement.csproj", "{049490F0-ECD2-4148-9B39-2135EC346EBE}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.PluginManagement", "Plugins\Wox.Plugin.PluginManagement\Wox.Plugin.PluginManagement.csproj", "{049490F0-ECD2-4148-9B39-2135EC346EBE}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Microsoft.VisualBasic.ApplicationServices;
|
using Microsoft.VisualBasic.ApplicationServices;
|
||||||
using Wox.Commands;
|
using Wox.Commands;
|
||||||
|
using Wox.Helper;
|
||||||
using StartupEventArgs = System.Windows.StartupEventArgs;
|
using StartupEventArgs = System.Windows.StartupEventArgs;
|
||||||
|
|
||||||
namespace Wox
|
namespace Wox
|
||||||
@@ -66,6 +68,22 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
base.OnStartup(e);
|
base.OnStartup(e);
|
||||||
|
|
||||||
|
//for install plugin command when wox didn't start up
|
||||||
|
//we shouldn't init MainWindow, just intall plugin and exit.
|
||||||
|
if (e.Args.Length > 0 && e.Args[0].ToLower() == "installplugin")
|
||||||
|
{
|
||||||
|
var path = e.Args[1];
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Plugin " + path + " didn't exist");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PluginInstaller.Install(path);
|
||||||
|
Environment.Exit(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
window = new MainWindow();
|
window = new MainWindow();
|
||||||
if (e.Args.Length == 0 || e.Args[0].ToLower() != "hidestart")
|
if (e.Args.Length == 0 || e.Args[0].ToLower() != "hidestart")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Windows;
|
|||||||
using ICSharpCode.SharpZipLib.Zip;
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
using Wox.PluginLoader;
|
||||||
|
|
||||||
namespace Wox.Helper
|
namespace Wox.Helper
|
||||||
{
|
{
|
||||||
@@ -18,37 +19,36 @@ namespace Wox.Helper
|
|||||||
{
|
{
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
{
|
{
|
||||||
string tempFoler = System.IO.Path.GetTempPath() + "\\wox\\plugins";
|
string tempFoler = Path.Combine(Path.GetTempPath(), "wox\\plugins");
|
||||||
if (Directory.Exists(tempFoler))
|
if (Directory.Exists(tempFoler))
|
||||||
{
|
{
|
||||||
Directory.Delete(tempFoler, true);
|
Directory.Delete(tempFoler, true);
|
||||||
}
|
}
|
||||||
UnZip(path, tempFoler, true);
|
UnZip(path, tempFoler, true);
|
||||||
|
|
||||||
string iniPath = tempFoler + "\\plugin.json";
|
string iniPath = Path.Combine(tempFoler, "plugin.json");
|
||||||
if (!File.Exists(iniPath))
|
if (!File.Exists(iniPath))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Install failed: config is missing");
|
MessageBox.Show("Install failed: plugin config is missing");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginMetadata plugin = GetMetadataFromJson(tempFoler);
|
PluginMetadata plugin = GetMetadataFromJson(tempFoler);
|
||||||
if (plugin == null || plugin.Name == null)
|
if (plugin == null || plugin.Name == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Install failed: config of this plugin is invalid");
|
MessageBox.Show("Install failed: plugin config is invalid");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string pluginFolerPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins";
|
string pluginFolerPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins");
|
||||||
if (!Directory.Exists(pluginFolerPath))
|
if (!Directory.Exists(pluginFolerPath))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Install failed: cound't find plugin directory");
|
Directory.CreateDirectory(pluginFolerPath);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string newPluginPath = pluginFolerPath + "\\" + plugin.Name;
|
string newPluginPath = Path.Combine(pluginFolerPath, plugin.Name);
|
||||||
string content = string.Format(
|
string content = string.Format(
|
||||||
"Do you want to install following plugin?\r\nName: {0}\r\nVersion: {1}\r\nAuthor: {2}",
|
"Do you want to install following plugin?\r\n\r\nName: {0}\r\nVersion: {1}\r\nAuthor: {2}",
|
||||||
plugin.Name, plugin.Version, plugin.Author);
|
plugin.Name, plugin.Version, plugin.Author);
|
||||||
if (Directory.Exists(newPluginPath))
|
if (Directory.Exists(newPluginPath))
|
||||||
{
|
{
|
||||||
@@ -61,7 +61,7 @@ namespace Wox.Helper
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
content = string.Format(
|
content = string.Format(
|
||||||
"Do you want to update following plugin?\r\nName: {0}\r\nOld Version: {1}\r\nNew Version: {2}\r\nAuthor: {3}",
|
"Do you want to update following plugin?\r\n\r\nName: {0}\r\nOld Version: {1}\r\nNew Version: {2}\r\nAuthor: {3}",
|
||||||
plugin.Name, existingPlugin.Version, plugin.Version, plugin.Author);
|
plugin.Name, existingPlugin.Version, plugin.Version, plugin.Author);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,22 +77,13 @@ namespace Wox.Helper
|
|||||||
UnZip(path, newPluginPath, true);
|
UnZip(path, newPluginPath, true);
|
||||||
Directory.Delete(tempFoler, true);
|
Directory.Delete(tempFoler, true);
|
||||||
|
|
||||||
|
if (MainWindow.Initialized)
|
||||||
|
{
|
||||||
|
Plugins.Init();
|
||||||
|
}
|
||||||
|
|
||||||
string wox = AppDomain.CurrentDomain.BaseDirectory + "Wox.exe";
|
|
||||||
if (File.Exists(wox))
|
|
||||||
{
|
|
||||||
ProcessStartInfo info = new ProcessStartInfo(wox, "reloadplugin")
|
|
||||||
{
|
|
||||||
UseShellExecute = true
|
|
||||||
};
|
|
||||||
Process.Start(info);
|
|
||||||
MessageBox.Show("You have installed plugin " + plugin.Name + " successfully.");
|
MessageBox.Show("You have installed plugin " + plugin.Name + " successfully.");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("You have installed plugin " + plugin.Name + " successfully. Please restart your wox to use new plugin.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace Wox
|
|||||||
public partial class MainWindow
|
public partial class MainWindow
|
||||||
{
|
{
|
||||||
private static readonly object locker = new object();
|
private static readonly object locker = new object();
|
||||||
|
public static bool Initialized = false;
|
||||||
|
|
||||||
private static readonly List<Result> waitShowResultList = new List<Result>();
|
private static readonly List<Result> waitShowResultList = new List<Result>();
|
||||||
private readonly GloablHotkey globalHotkey = new GloablHotkey();
|
private readonly GloablHotkey globalHotkey = new GloablHotkey();
|
||||||
@@ -41,10 +42,10 @@ namespace Wox
|
|||||||
private bool queryHasReturn;
|
private bool queryHasReturn;
|
||||||
private ToolTip toolTip = new ToolTip();
|
private ToolTip toolTip = new ToolTip();
|
||||||
|
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
Initialized = true;
|
||||||
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
|
||||||
@@ -65,6 +66,15 @@ namespace Wox
|
|||||||
|
|
||||||
SetHotkey(CommonStorage.Instance.UserSetting.Hotkey, OnHotkey);
|
SetHotkey(CommonStorage.Instance.UserSetting.Hotkey, OnHotkey);
|
||||||
SetCustomPluginHotkey();
|
SetCustomPluginHotkey();
|
||||||
|
|
||||||
|
globalHotkey.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Left = (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2;
|
||||||
|
Top = (SystemParameters.PrimaryScreenHeight - ActualHeight) / 3;
|
||||||
|
Plugins.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
@@ -75,6 +85,7 @@ namespace Wox
|
|||||||
Log.Error(error);
|
Log.Error(error);
|
||||||
if (e.IsTerminating)
|
if (e.IsTerminating)
|
||||||
{
|
{
|
||||||
|
notifyIcon.Visible = false;
|
||||||
MessageBox.Show(error);
|
MessageBox.Show(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,17 +255,8 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Left = (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2;
|
|
||||||
Top = (SystemParameters.PrimaryScreenHeight - ActualHeight) / 3;
|
|
||||||
|
|
||||||
|
|
||||||
Plugins.Init();
|
|
||||||
|
|
||||||
globalHotkey.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state)
|
private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, SpecialKeyState state)
|
||||||
{
|
{
|
||||||
if (CommonStorage.Instance.UserSetting.ReplaceWinR)
|
if (CommonStorage.Instance.UserSetting.ReplaceWinR)
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ namespace Wox.PluginLoader
|
|||||||
string[] directories = Directory.GetDirectories(PluginPath);
|
string[] directories = Directory.GetDirectories(PluginPath);
|
||||||
foreach (string directory in directories)
|
foreach (string directory in directories)
|
||||||
{
|
{
|
||||||
|
if (File.Exists((Path.Combine(directory, "NeedDelete.txt"))))
|
||||||
|
{
|
||||||
|
Directory.Delete(directory,true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
PluginMetadata metadata = GetMetadataFromJson(directory);
|
PluginMetadata metadata = GetMetadataFromJson(directory);
|
||||||
if (metadata != null) pluginMetadatas.Add(metadata);
|
if (metadata != null) pluginMetadatas.Add(metadata);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ namespace Wox.PluginLoader
|
|||||||
ShowApp = () => App.Window.ShowApp(),
|
ShowApp = () => App.Window.ShowApp(),
|
||||||
ShowMsg = (title, subTitle, iconPath) => App.Window.ShowMsg(title, subTitle, iconPath),
|
ShowMsg = (title, subTitle, iconPath) => App.Window.ShowMsg(title, subTitle, iconPath),
|
||||||
OpenSettingDialog = () => App.Window.OpenSettingDialog(),
|
OpenSettingDialog = () => App.Window.OpenSettingDialog(),
|
||||||
ShowCurrentResultItemTooltip = (msg) => App.Window.ShowCurrentResultItemTooltip(msg)
|
ShowCurrentResultItemTooltip = (msg) => App.Window.ShowCurrentResultItemTooltip(msg),
|
||||||
|
ReloadPlugins = ()=> Init()
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user