diff --git a/Plugins/WinAlfred.Plugin.Doc/DocViewFrm.Designer.cs b/Plugins/WinAlfred.Plugin.Doc/DocViewFrm.Designer.cs new file mode 100644 index 0000000000..e9caf7ef48 --- /dev/null +++ b/Plugins/WinAlfred.Plugin.Doc/DocViewFrm.Designer.cs @@ -0,0 +1,64 @@ +namespace WinAlfred.Plugin.Doc +{ + partial class DocViewFrm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.webBrowser1 = new System.Windows.Forms.WebBrowser(); + this.SuspendLayout(); + // + // webBrowser1 + // + this.webBrowser1.AllowNavigation = false; + this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill; + this.webBrowser1.IsWebBrowserContextMenuEnabled = false; + this.webBrowser1.Location = new System.Drawing.Point(0, 0); + this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20); + this.webBrowser1.Name = "webBrowser1"; + this.webBrowser1.Size = new System.Drawing.Size(926, 611); + this.webBrowser1.TabIndex = 0; + // + // DocViewFrm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(926, 611); + this.Controls.Add(this.webBrowser1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "DocViewFrm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "DocViewer"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.WebBrowser webBrowser1; + } +} \ No newline at end of file diff --git a/Plugins/WinAlfred.Plugin.Doc/DocViewFrm.cs b/Plugins/WinAlfred.Plugin.Doc/DocViewFrm.cs new file mode 100644 index 0000000000..f1e1066a21 --- /dev/null +++ b/Plugins/WinAlfred.Plugin.Doc/DocViewFrm.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace WinAlfred.Plugin.Doc +{ + public partial class DocViewFrm : Form + { + public DocViewFrm() + { + InitializeComponent(); + } + + public void ShowDoc(string path) + { + webBrowser1.Url = new Uri(String.Format("file:///{0}", path)); + Show(); + } + } +} diff --git a/Plugins/WinAlfred.Plugin.Doc/DocViewFrm.resx b/Plugins/WinAlfred.Plugin.Doc/DocViewFrm.resx new file mode 100644 index 0000000000..7080a7d118 --- /dev/null +++ b/Plugins/WinAlfred.Plugin.Doc/DocViewFrm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Plugins/WinAlfred.Plugin.Doc/Main.cs b/Plugins/WinAlfred.Plugin.Doc/Main.cs new file mode 100644 index 0000000000..a88670bbaf --- /dev/null +++ b/Plugins/WinAlfred.Plugin.Doc/Main.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Data.SQLite; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace WinAlfred.Plugin.Doc +{ + public class Main : IPlugin + { + static public string AssemblyDirectory + { + get + { + string codeBase = Assembly.GetExecutingAssembly().CodeBase; + UriBuilder uri = new UriBuilder(codeBase); + string path = Uri.UnescapeDataString(uri.Path); + return Path.GetDirectoryName(path); + } + } + + public List Query(Query query) + { + string path = @"D:\Personal\WinAlfred\WinAlfred\bin\Debug\Plugins\Doc\Docset\jQuery.docset\Contents\Resources\docSet.dsidx"; + if (query.ActionParameters.Count == 0) + { + //todo:return available docsets name + return new List(); + } + return QuerySqllite(path, query.ActionParameters[0]); + } + + public void Init(PluginInitContext context) + { + //todo:move to common place + var otherCompanyDlls = new DirectoryInfo(AssemblyDirectory + "\\Plugins\\Doc").GetFiles("*.dll"); + AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => + { + var dll = otherCompanyDlls.FirstOrDefault(fi => + { + try + { + Assembly assembly = Assembly.LoadFile(fi.FullName); + return assembly.FullName == args.Name; + } + catch + { + return false; + } + }); + if (dll == null) + { + return null; + } + + return Assembly.LoadFile(dll.FullName); + }; + } + + public List QuerySqllite(string path, string key) + { + SQLiteConnection conn = null; + string dbPath = "Data Source =" + path; + conn = new SQLiteConnection(dbPath); + conn.Open(); + string sql = "select * from searchIndex where name like '%" + key + "%'"; + SQLiteCommand cmdQ = new SQLiteCommand(sql, conn); + SQLiteDataReader reader = cmdQ.ExecuteReader(); + + List results = new List(); + while (reader.Read()) + { + string name = reader.GetString(1); + string type = reader.GetString(2); + string docPath = reader.GetString(3); + + results.Add(new Result + { + Title = name, + SubTitle = AssemblyDirectory + "\\Plugins\\Doc\\Docset\\" + docPath, + Action = () => + { + DocViewFrm frm = new DocViewFrm(); + frm.ShowDoc(AssemblyDirectory + @"\Plugins\Doc\Docset\jQuery.docset\Contents\Resources\Documents\" + docPath); + } + }); + } + conn.Close(); + + return results; + } + } +} diff --git a/Plugins/WinAlfred.Plugin.Doc/Properties/AssemblyInfo.cs b/Plugins/WinAlfred.Plugin.Doc/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..9a31651bd3 --- /dev/null +++ b/Plugins/WinAlfred.Plugin.Doc/Properties/AssemblyInfo.cs @@ -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.Doc")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Oracle Corporation")] +[assembly: AssemblyProduct("WinAlfred.Plugin.Doc")] +[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("e0efc3c8-af56-47c0-adb0-3967635b5394")] + +// 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")] diff --git a/Plugins/WinAlfred.Plugin.Doc/WinAlfred.Plugin.Doc.csproj b/Plugins/WinAlfred.Plugin.Doc/WinAlfred.Plugin.Doc.csproj new file mode 100644 index 0000000000..2324e3d3f1 --- /dev/null +++ b/Plugins/WinAlfred.Plugin.Doc/WinAlfred.Plugin.Doc.csproj @@ -0,0 +1,119 @@ + + + + + Debug + AnyCPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C} + Library + Properties + WinAlfred.Plugin.Doc + WinAlfred.Plugin.Doc + v3.5 + 512 + ..\..\ + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + MinimumRecommendedRules.ruleset + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + MinimumRecommendedRules.ruleset + + + + + + ..\..\packages\System.Data.SQLite.1.0.90.0\lib\net20\System.Data.SQLite.dll + + + ..\..\packages\System.Data.SQLite.1.0.90.0\lib\net20\System.Data.SQLite.Linq.dll + + + + + + + + + + + Form + + + DocViewFrm.cs + + + + + + + + Always + + + + + {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} + WinAlfred.Plugin + + + + + + + + + Always + + + Always + + + + + DocViewFrm.cs + + + + + xcopy /Y /E $(TargetDir)*.* $(SolutionDir)WinAlfred\bin\Debug\Plugins\Doc\ + + + + \ No newline at end of file diff --git a/Plugins/WinAlfred.Plugin.Doc/packages.config b/Plugins/WinAlfred.Plugin.Doc/packages.config new file mode 100644 index 0000000000..db58057cd6 --- /dev/null +++ b/Plugins/WinAlfred.Plugin.Doc/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Plugins/WinAlfred.Plugin.Doc/plugin.ini b/Plugins/WinAlfred.Plugin.Doc/plugin.ini new file mode 100644 index 0000000000..0e1fc40236 --- /dev/null +++ b/Plugins/WinAlfred.Plugin.Doc/plugin.ini @@ -0,0 +1,8 @@ +[plugin] +ActionKeyword = doc +Name = Dash.Doc +Author = qianlifeng +Version = 0.1 +Language = csharp +Description = Offline doc, inspired by dash +ExecuteFile = WinAlfred.Plugin.Doc.dll diff --git a/Plugins/WinAlfred.Plugin.Doc/x64/SQLite.Interop.dll b/Plugins/WinAlfred.Plugin.Doc/x64/SQLite.Interop.dll new file mode 100644 index 0000000000..078e83647d Binary files /dev/null and b/Plugins/WinAlfred.Plugin.Doc/x64/SQLite.Interop.dll differ diff --git a/Plugins/WinAlfred.Plugin.Doc/x86/SQLite.Interop.dll b/Plugins/WinAlfred.Plugin.Doc/x86/SQLite.Interop.dll new file mode 100644 index 0000000000..36cfca0464 Binary files /dev/null and b/Plugins/WinAlfred.Plugin.Doc/x86/SQLite.Interop.dll differ diff --git a/WinAlfred.sln b/WinAlfred.sln index 6bc6c2246e..c0fdbb5ef3 100644 --- a/WinAlfred.sln +++ b/WinAlfred.sln @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.WorkflowInstaller EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "Pythonnet.Runtime\Python.Runtime.csproj", "{097B4AC0-74E9-4C58-BCF8-C69746EC8271}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinAlfred.Plugin.Doc", "Plugins\WinAlfred.Plugin.Doc\WinAlfred.Plugin.Doc.csproj", "{6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -250,11 +252,40 @@ Global {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|x64.ActiveCfg = UnitTests|x64 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|x64.Build.0 = UnitTests|x64 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.UnitTests|x86.ActiveCfg = UnitTests|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Debug|Win32.ActiveCfg = Debug|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Debug|x64.ActiveCfg = Debug|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Debug|x86.ActiveCfg = Debug|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.EmbeddingTest|Any CPU.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.EmbeddingTest|Any CPU.Build.0 = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.EmbeddingTest|Mixed Platforms.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.EmbeddingTest|Mixed Platforms.Build.0 = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.EmbeddingTest|Win32.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.EmbeddingTest|x64.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.EmbeddingTest|x86.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Release|Any CPU.Build.0 = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Release|Win32.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Release|x64.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.Release|x86.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.UnitTests|Any CPU.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.UnitTests|Any CPU.Build.0 = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.UnitTests|Mixed Platforms.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.UnitTests|Mixed Platforms.Build.0 = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.UnitTests|Win32.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.UnitTests|x64.ActiveCfg = Release|Any CPU + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C}.UnitTests|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {353769D3-D11C-4D86-BD06-AC8C1D68642B} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} + {6B6696B1-A547-4FD4-85EF-E1FD0F54AD2C} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} EndGlobalSection EndGlobal diff --git a/WinAlfred/PluginLoader/CSharpPluginLoader.cs b/WinAlfred/PluginLoader/CSharpPluginLoader.cs index 25346eb3f1..836442e593 100644 --- a/WinAlfred/PluginLoader/CSharpPluginLoader.cs +++ b/WinAlfred/PluginLoader/CSharpPluginLoader.cs @@ -20,7 +20,8 @@ namespace WinAlfred.PluginLoader { try { - Assembly asm = Assembly.LoadFile(metadata.ExecuteFilePath); + byte[] buffer = System.IO.File.ReadAllBytes(metadata.ExecuteFilePath); + Assembly asm = Assembly.Load(buffer); List types = asm.GetTypes().Where(o => o.IsClass && o.GetInterfaces().Contains(typeof(IPlugin)) || o.GetInterfaces().Contains(typeof(ISystemPlugin))).ToList(); if (types.Count == 0) {