mirror of
https://github.com/microsoft/PowerToys
synced 2024-11-22 00:03:48 +00:00
Add system commands
This commit is contained in:
parent
5893564f46
commit
1eb3f449e2
20
WinAlfred.Plugin.System/CMD.cs
Normal file
20
WinAlfred.Plugin.System/CMD.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WinAlfred.Plugin.System
|
||||||
|
{
|
||||||
|
public class CMD:IPlugin
|
||||||
|
{
|
||||||
|
public List<Result> Query(Query query)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
WinAlfred.Plugin.System/ISystemPlugin.cs
Normal file
11
WinAlfred.Plugin.System/ISystemPlugin.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WinAlfred.Plugin.System
|
||||||
|
{
|
||||||
|
public interface ISystemPlugin : IPlugin
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
36
WinAlfred.Plugin.System/Properties/AssemblyInfo.cs
Normal file
36
WinAlfred.Plugin.System/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("WinAlfred.Plugin.System")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Oracle Corporation")]
|
||||||
|
[assembly: AssemblyProduct("WinAlfred.Plugin.System")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Oracle Corporation 2014")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("bab8d3dc-d6be-42b3-8aa4-24801d667528")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
59
WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj
Normal file
59
WinAlfred.Plugin.System/WinAlfred.Plugin.System.csproj
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{69CE0206-CB41-453D-88AF-DF86092EF9B8}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>WinAlfred.Plugin.System</RootNamespace>
|
||||||
|
<AssemblyName>WinAlfred.Plugin.System</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="CMD.cs" />
|
||||||
|
<Compile Include="ISystemPlugin.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\WinAlfred.Plugin\WinAlfred.Plugin.csproj">
|
||||||
|
<Project>{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}</Project>
|
||||||
|
<Name>WinAlfred.Plugin</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- 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.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
@ -16,5 +16,6 @@ namespace WinAlfred.Plugin
|
|||||||
public string ExecuteFileName { get; set; }
|
public string ExecuteFileName { get; set; }
|
||||||
public string PluginDirecotry { get; set; }
|
public string PluginDirecotry { get; set; }
|
||||||
public string ActionKeyword { get; set; }
|
public string ActionKeyword { get; set; }
|
||||||
|
public PluginType PluginType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
WinAlfred.Plugin/PluginType.cs
Normal file
13
WinAlfred.Plugin/PluginType.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace WinAlfred.Plugin
|
||||||
|
{
|
||||||
|
public enum PluginType
|
||||||
|
{
|
||||||
|
System,
|
||||||
|
ThirdParty
|
||||||
|
}
|
||||||
|
}
|
@ -61,6 +61,7 @@
|
|||||||
<Compile Include="IPlugin.cs" />
|
<Compile Include="IPlugin.cs" />
|
||||||
<Compile Include="Plugin.cs" />
|
<Compile Include="Plugin.cs" />
|
||||||
<Compile Include="PluginMetadata.cs" />
|
<Compile Include="PluginMetadata.cs" />
|
||||||
|
<Compile Include="PluginType.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="PythonResult.cs" />
|
<Compile Include="PythonResult.cs" />
|
||||||
<Compile Include="Query.cs" />
|
<Compile Include="Query.cs" />
|
||||||
|
@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred", "WinAlfred\WinA
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PyWinAlfred", "PyWinAlfred\PyWinAlfred.vcxproj", "{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PyWinAlfred", "PyWinAlfred\PyWinAlfred.vcxproj", "{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Plugin.System", "WinAlfred.Plugin.System\WinAlfred.Plugin.System.csproj", "{69CE0206-CB41-453D-88AF-DF86092EF9B8}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -104,6 +106,20 @@ Global
|
|||||||
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x64.Build.0 = Release|x64
|
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x64.Build.0 = Release|x64
|
||||||
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x86.ActiveCfg = Release|Win32
|
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x86.ActiveCfg = Release|Win32
|
||||||
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x86.Build.0 = Release|Win32
|
{D03FD663-38A8-4C1A-8431-EB44F93E7EBA}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{69CE0206-CB41-453D-88AF-DF86092EF9B8}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
31
WinAlfred/Commands/CommandDispatcher.cs
Normal file
31
WinAlfred/Commands/CommandDispatcher.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using WinAlfred.Helper;
|
||||||
|
using WinAlfred.Plugin;
|
||||||
|
|
||||||
|
namespace WinAlfred.Commands
|
||||||
|
{
|
||||||
|
public class CommandDispatcher
|
||||||
|
{
|
||||||
|
private PluginCommand pluginCmd = new PluginCommand();
|
||||||
|
private SystemCommand systemCmd = new SystemCommand();
|
||||||
|
|
||||||
|
//public delegate void resultUpdateDelegate(List<Result> results);
|
||||||
|
|
||||||
|
//public event resultUpdateDelegate OnResultUpdateEvent;
|
||||||
|
|
||||||
|
//protected virtual void OnOnResultUpdateEvent(List<Result> list)
|
||||||
|
//{
|
||||||
|
// resultUpdateDelegate handler = OnResultUpdateEvent;
|
||||||
|
// if (handler != null) handler(list);
|
||||||
|
//}
|
||||||
|
|
||||||
|
public void DispatchCommand(Query query)
|
||||||
|
{
|
||||||
|
systemCmd.Dispatch(query);
|
||||||
|
pluginCmd.Dispatch(query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
45
WinAlfred/Commands/PluginCommand.cs
Normal file
45
WinAlfred/Commands/PluginCommand.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using WinAlfred.Helper;
|
||||||
|
using WinAlfred.Plugin;
|
||||||
|
using WinAlfred.PluginLoader;
|
||||||
|
|
||||||
|
namespace WinAlfred.Commands
|
||||||
|
{
|
||||||
|
public class PluginCommand
|
||||||
|
{
|
||||||
|
public void Dispatch(Query q)
|
||||||
|
{
|
||||||
|
//ThreadPool.QueueUserWorkItem(state =>
|
||||||
|
//{
|
||||||
|
foreach (PluginPair pair in Plugins.AllPlugins)
|
||||||
|
{
|
||||||
|
if (pair.Metadata.ActionKeyword == q.ActionName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pair.Plugin.Query(q).ForEach(o => o.PluginDirectory = pair.Metadata.PluginDirecotry);
|
||||||
|
}
|
||||||
|
catch (Exception queryException)
|
||||||
|
{
|
||||||
|
Log.Error(string.Format("Plugin {0} query failed: {1}", pair.Metadata.Name,
|
||||||
|
queryException.Message));
|
||||||
|
#if (DEBUG)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultCtrl.Dispatcher.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
resultCtrl.AddResults(results.OrderByDescending(o => o.Score).ToList());
|
||||||
|
resultCtrl.SelectFirst();
|
||||||
|
}));
|
||||||
|
//});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
WinAlfred/Commands/SystemCommand.cs
Normal file
16
WinAlfred/Commands/SystemCommand.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using WinAlfred.Plugin;
|
||||||
|
|
||||||
|
namespace WinAlfred.Commands
|
||||||
|
{
|
||||||
|
public class SystemCommand
|
||||||
|
{
|
||||||
|
public void Dispatch(Query query)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ using System.Windows.Controls;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
using WinAlfred.Commands;
|
||||||
using WinAlfred.Helper;
|
using WinAlfred.Helper;
|
||||||
using WinAlfred.Plugin;
|
using WinAlfred.Plugin;
|
||||||
using WinAlfred.PluginLoader;
|
using WinAlfred.PluginLoader;
|
||||||
@ -18,9 +19,9 @@ namespace WinAlfred
|
|||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
private KeyboardHook hook = new KeyboardHook();
|
private KeyboardHook hook = new KeyboardHook();
|
||||||
public List<PluginPair> plugins = new List<PluginPair>();
|
|
||||||
private List<Result> results = new List<Result>();
|
private List<Result> results = new List<Result>();
|
||||||
private NotifyIcon notifyIcon = null;
|
private NotifyIcon notifyIcon = null;
|
||||||
|
private CommandDispatcher cmdDispatcher = new CommandDispatcher();
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
@ -67,38 +68,8 @@ namespace WinAlfred
|
|||||||
|
|
||||||
private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
|
private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
string query = tbQuery.Text;
|
var q = new Query(tbQuery.Text);
|
||||||
//ThreadPool.QueueUserWorkItem(state =>
|
cmdDispatcher.DispatchCommand(q);
|
||||||
//{
|
|
||||||
results.Clear();
|
|
||||||
foreach (PluginPair pair in plugins)
|
|
||||||
{
|
|
||||||
var q = new Query(query);
|
|
||||||
if (pair.Metadata.ActionKeyword == q.ActionName)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
results.AddRange(pair.Plugin.Query(q));
|
|
||||||
results.ForEach(o => o.PluginDirectory = pair.Metadata.PluginDirecotry);
|
|
||||||
}
|
|
||||||
catch (Exception queryException)
|
|
||||||
{
|
|
||||||
Log.Error(string.Format("Plugin {0} query failed: {1}", pair.Metadata.Name,
|
|
||||||
queryException.Message));
|
|
||||||
#if (DEBUG)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resultCtrl.Dispatcher.Invoke(new Action(() =>
|
|
||||||
{
|
|
||||||
resultCtrl.AddResults(results.OrderByDescending(o => o.Score).ToList());
|
|
||||||
resultCtrl.SelectFirst();
|
|
||||||
}));
|
|
||||||
//});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HideWinAlfred()
|
private void HideWinAlfred()
|
||||||
@ -116,9 +87,7 @@ namespace WinAlfred
|
|||||||
|
|
||||||
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
|
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
plugins.AddRange(new PythonPluginLoader().LoadPlugin());
|
Plugins.Init();
|
||||||
plugins.AddRange(new CSharpPluginLoader().LoadPlugin());
|
|
||||||
|
|
||||||
ShowWinAlfred();
|
ShowWinAlfred();
|
||||||
InitialTray();
|
InitialTray();
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using WinAlfred.Helper;
|
using WinAlfred.Helper;
|
||||||
using WinAlfred.Plugin;
|
using WinAlfred.Plugin;
|
||||||
|
using WinAlfred.Plugin.System;
|
||||||
|
|
||||||
namespace WinAlfred.PluginLoader
|
namespace WinAlfred.PluginLoader
|
||||||
{
|
{
|
||||||
@ -21,11 +24,34 @@ namespace WinAlfred.PluginLoader
|
|||||||
|
|
||||||
private static void ParsePlugins()
|
private static void ParsePlugins()
|
||||||
{
|
{
|
||||||
ParseDirectories();
|
ParseSystemPlugins();
|
||||||
ParsePackagedPlugin();
|
ParseThirdPartyPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ParseDirectories()
|
private static void ParseSystemPlugins()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Assembly asm = Assembly.GetAssembly(typeof (CMD));
|
||||||
|
List<Type> types = asm.GetTypes().Where(o => o.GetInterfaces().Contains(typeof(ISystemPlugin))).ToList();
|
||||||
|
foreach (Type type in types)
|
||||||
|
{
|
||||||
|
ISystemPlugin sysPlugin = Activator.CreateInstance(types[0]) as ISystemPlugin;
|
||||||
|
PluginMetadata metadata = new PluginMetadata();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error(string.Format("Cound't load system plugin: {0}", e.Message));
|
||||||
|
#if (DEBUG)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ParseThirdPartyPlugins()
|
||||||
{
|
{
|
||||||
string[] directories = Directory.GetDirectories(PluginPath);
|
string[] directories = Directory.GetDirectories(PluginPath);
|
||||||
foreach (string directory in directories)
|
foreach (string directory in directories)
|
||||||
@ -35,11 +61,6 @@ namespace WinAlfred.PluginLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ParsePackagedPlugin()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PluginMetadata GetMetadataFromIni(string directory)
|
private static PluginMetadata GetMetadataFromIni(string directory)
|
||||||
{
|
{
|
||||||
string iniPath = directory + "\\" + PluginConfigName;
|
string iniPath = directory + "\\" + PluginConfigName;
|
||||||
@ -50,7 +71,6 @@ namespace WinAlfred.PluginLoader
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PluginMetadata metadata = new PluginMetadata();
|
PluginMetadata metadata = new PluginMetadata();
|
||||||
@ -60,6 +80,7 @@ namespace WinAlfred.PluginLoader
|
|||||||
metadata.Description = ini.GetSetting("plugin", "Description");
|
metadata.Description = ini.GetSetting("plugin", "Description");
|
||||||
metadata.Language = ini.GetSetting("plugin", "Language");
|
metadata.Language = ini.GetSetting("plugin", "Language");
|
||||||
metadata.Version = ini.GetSetting("plugin", "Version");
|
metadata.Version = ini.GetSetting("plugin", "Version");
|
||||||
|
metadata.PluginType = PluginType.ThirdParty;
|
||||||
metadata.ActionKeyword = ini.GetSetting("plugin", "ActionKeyword");
|
metadata.ActionKeyword = ini.GetSetting("plugin", "ActionKeyword");
|
||||||
metadata.ExecuteFilePath = AppDomain.CurrentDomain.BaseDirectory + directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
|
metadata.ExecuteFilePath = AppDomain.CurrentDomain.BaseDirectory + directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
|
||||||
metadata.PluginDirecotry = AppDomain.CurrentDomain.BaseDirectory + directory + "\\";
|
metadata.PluginDirecotry = AppDomain.CurrentDomain.BaseDirectory + directory + "\\";
|
||||||
|
25
WinAlfred/PluginLoader/Plugins.cs
Normal file
25
WinAlfred/PluginLoader/Plugins.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using WinAlfred.Plugin;
|
||||||
|
|
||||||
|
namespace WinAlfred.PluginLoader
|
||||||
|
{
|
||||||
|
public static class Plugins
|
||||||
|
{
|
||||||
|
private static List<PluginPair> plugins = new List<PluginPair>();
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
plugins.Clear();
|
||||||
|
plugins.AddRange(new PythonPluginLoader().LoadPlugin());
|
||||||
|
plugins.AddRange(new CSharpPluginLoader().LoadPlugin());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<PluginPair> AllPlugins
|
||||||
|
{
|
||||||
|
get { return plugins; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -64,12 +64,16 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="Commands\CommandDispatcher.cs" />
|
||||||
|
<Compile Include="Commands\PluginCommand.cs" />
|
||||||
|
<Compile Include="Commands\SystemCommand.cs" />
|
||||||
<Compile Include="Helper\IniParser.cs" />
|
<Compile Include="Helper\IniParser.cs" />
|
||||||
<Compile Include="Helper\KeyboardHook.cs" />
|
<Compile Include="Helper\KeyboardHook.cs" />
|
||||||
<Compile Include="Helper\Log.cs" />
|
<Compile Include="Helper\Log.cs" />
|
||||||
<Compile Include="Helper\WinAlfredException.cs" />
|
<Compile Include="Helper\WinAlfredException.cs" />
|
||||||
<Compile Include="PluginLoader\BasePluginLoader.cs" />
|
<Compile Include="PluginLoader\BasePluginLoader.cs" />
|
||||||
<Compile Include="PluginLoader\CSharpPluginLoader.cs" />
|
<Compile Include="PluginLoader\CSharpPluginLoader.cs" />
|
||||||
|
<Compile Include="PluginLoader\Plugins.cs" />
|
||||||
<Compile Include="PluginLoader\PythonPluginLoader.cs" />
|
<Compile Include="PluginLoader\PythonPluginLoader.cs" />
|
||||||
<Compile Include="PluginLoader\PythonPluginWrapper.cs" />
|
<Compile Include="PluginLoader\PythonPluginWrapper.cs" />
|
||||||
<Compile Include="ResultPanel.xaml.cs">
|
<Compile Include="ResultPanel.xaml.cs">
|
||||||
@ -128,6 +132,10 @@
|
|||||||
<AppDesigner Include="Properties\" />
|
<AppDesigner Include="Properties\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\WinAlfred.Plugin.System\WinAlfred.Plugin.System.csproj">
|
||||||
|
<Project>{69ce0206-cb41-453d-88af-df86092ef9b8}</Project>
|
||||||
|
<Name>WinAlfred.Plugin.System</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\WinAlfred.Plugin\WinAlfred.Plugin.csproj">
|
<ProjectReference Include="..\WinAlfred.Plugin\WinAlfred.Plugin.csproj">
|
||||||
<Project>{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}</Project>
|
<Project>{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}</Project>
|
||||||
<Name>WinAlfred.Plugin</Name>
|
<Name>WinAlfred.Plugin</Name>
|
||||||
|
Loading…
Reference in New Issue
Block a user