diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Bookmark.cs b/Plugins/Wox.Plugin.BrowserBookmark/Bookmark.cs new file mode 100644 index 0000000000..9c86ecdd75 --- /dev/null +++ b/Plugins/Wox.Plugin.BrowserBookmark/Bookmark.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Wox.Infrastructure; + +namespace Wox.Plugin.BrowserBookmark +{ + public class Bookmark : IEquatable, IEqualityComparer + { + private string m_Name; + public string Name + { + get + { + return m_Name; + } + set + { + m_Name = value; + PinyinName = m_Name.Unidecode(); + } + } + public string PinyinName { get; private set; } + public string Url { get; set; } + public string Source { get; set; } + public int Score { get; set; } + + /* TODO: since Source maybe unimportant, we just need to compare Name and Url */ + public bool Equals(Bookmark other) + { + return Equals(this, other); + } + + public bool Equals(Bookmark x, Bookmark y) + { + if (Object.ReferenceEquals(x, y)) return true; + if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null)) + return false; + + return x.Name == y.Name && x.Url == y.Url; + } + + public int GetHashCode(Bookmark bookmark) + { + if (Object.ReferenceEquals(bookmark, null)) return 0; + int hashName = bookmark.Name == null ? 0 : bookmark.Name.GetHashCode(); + int hashUrl = bookmark.Url == null ? 0 : bookmark.Url.GetHashCode(); + return hashName ^ hashUrl; + } + + public override int GetHashCode() + { + return GetHashCode(this); + } + } +} diff --git a/Wox/Images/bookmark.png b/Plugins/Wox.Plugin.BrowserBookmark/Images/bookmark.png similarity index 100% rename from Wox/Images/bookmark.png rename to Plugins/Wox.Plugin.BrowserBookmark/Images/bookmark.png diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Images/plugin.png b/Plugins/Wox.Plugin.BrowserBookmark/Images/plugin.png new file mode 100644 index 0000000000..aa447afd8d Binary files /dev/null and b/Plugins/Wox.Plugin.BrowserBookmark/Images/plugin.png differ diff --git a/Wox.Plugin.SystemPlugins/BrowserBookmarks.cs b/Plugins/Wox.Plugin.BrowserBookmark/Main.cs similarity index 67% rename from Wox.Plugin.SystemPlugins/BrowserBookmarks.cs rename to Plugins/Wox.Plugin.BrowserBookmark/Main.cs index 59a201f158..1f662aba4c 100644 --- a/Wox.Plugin.SystemPlugins/BrowserBookmarks.cs +++ b/Plugins/Wox.Plugin.BrowserBookmark/Main.cs @@ -1,25 +1,52 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; -using System.Windows.Forms; -using Newtonsoft.Json; using Wox.Infrastructure; -namespace Wox.Plugin.SystemPlugins +namespace Wox.Plugin.BrowserBookmark { - public class BrowserBookmarks : BaseSystemPlugin + public class Main : IPlugin { private PluginInitContext context; private List bookmarks = new List(); - protected override List QueryInternal(Query query) + + public void Init(PluginInitContext context) { - if (query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List(); + if (!Wox.Infrastructure.Storage.UserSettings.UserSettingStorage.Instance.EnableBookmarkPlugin) + { + return; + } + + bookmarks.Clear(); + LoadChromeBookmarks(); + + bookmarks = bookmarks.Distinct().ToList(); + this.context = context; + } + + public List Query(Query query) + { + if (query.ActionParameters.Count == 0) + { + return bookmarks.Select(c => new Result() + { + Title = c.Name, + SubTitle = "Bookmark: " + c.Url, + IcoPath = @"Images\bookmark.png", + Score = 5, + Action = (e) => + { + context.HideApp(); + context.ShellRun(c.Url); + return true; + } + }).ToList(); + } + var fuzzyMather = FuzzyMatcher.Create(query.RawQuery); List returnList = bookmarks.Where(o => MatchProgram(o, fuzzyMather)).ToList(); @@ -28,7 +55,7 @@ namespace Wox.Plugin.SystemPlugins { Title = c.Name, SubTitle = "Bookmark: " + c.Url, - IcoPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\bookmark.png", + IcoPath = @"Images\bookmark.png", Score = 5, Action = (e) => { @@ -38,6 +65,7 @@ namespace Wox.Plugin.SystemPlugins } }).ToList(); } + private bool MatchProgram(Bookmark bookmark, FuzzyMatcher matcher) { if ((bookmark.Score = matcher.Evaluate(bookmark.Name).Score) > 0) return true; @@ -47,20 +75,6 @@ namespace Wox.Plugin.SystemPlugins return false; } - protected override void InitInternal(PluginInitContext context) - { - if (!Wox.Infrastructure.Storage.UserSettings.UserSettingStorage.Instance.EnableBookmarkPlugin) - { - return; - } - - bookmarks.Clear(); - LoadChromeBookmarks(); - - bookmarks = bookmarks.Distinct().ToList(); - this.context = context; - } - private void ParseChromeBookmarks(String path, string source) { if (!File.Exists(path)) return; @@ -127,66 +141,20 @@ namespace Wox.Plugin.SystemPlugins return reg.Replace(dataStr, m => ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString()); } - public override string Name + public string Name { get { return "Bookmarks"; } } - public override string IcoPath + public string IcoPath { get { return @"Images\bookmark.png"; } } - public override string Description + public string Description { - get { return base.Description; } - } - } - - public class Bookmark : IEquatable, IEqualityComparer - { - private string m_Name; - public string Name { - get{ - return m_Name; - } - set - { - m_Name = value; - PinyinName = m_Name.Unidecode(); - } - } - public string PinyinName { get; private set; } - public string Url { get; set; } - public string Source { get; set; } - public int Score { get; set; } - - /* TODO: since Source maybe unimportant, we just need to compare Name and Url */ - public bool Equals(Bookmark other) - { - return Equals(this, other); + get { return "System workflow"; } } - public bool Equals(Bookmark x, Bookmark y) - { - if (Object.ReferenceEquals(x, y)) return true; - if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null)) - return false; - - return x.Name == y.Name && x.Url == y.Url; - } - - public int GetHashCode(Bookmark bookmark) - { - if (Object.ReferenceEquals(bookmark, null)) return 0; - int hashName = bookmark.Name == null ? 0 : bookmark.Name.GetHashCode(); - int hashUrl = bookmark.Url == null ? 0 : bookmark.Url.GetHashCode(); - return hashName ^ hashUrl; - } - - public override int GetHashCode() - { - return GetHashCode(this); - } } } diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Properties/AssemblyInfo.cs b/Plugins/Wox.Plugin.BrowserBookmark/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..982c549994 --- /dev/null +++ b/Plugins/Wox.Plugin.BrowserBookmark/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("Wox.Plugin.BrowserBookmark")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Oracle Corporation")] +[assembly: AssemblyProduct("Wox.Plugin.BrowserBookmark")] +[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("7dd2e33e-d029-4661-8f1d-594e82cef077")] + +// 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/Wox.Plugin.BrowserBookmark/Wox.Plugin.BrowserBookmark.csproj b/Plugins/Wox.Plugin.BrowserBookmark/Wox.Plugin.BrowserBookmark.csproj new file mode 100644 index 0000000000..af4cc45223 --- /dev/null +++ b/Plugins/Wox.Plugin.BrowserBookmark/Wox.Plugin.BrowserBookmark.csproj @@ -0,0 +1,79 @@ + + + + + Debug + AnyCPU + {9B130CC5-14FB-41FF-B310-0A95B6894C37} + Library + Properties + Wox.Plugin.BrowserBookmark + Wox.Plugin.BrowserBookmark + v3.5 + 512 + + + true + full + false + ..\..\Output\Debug\Plugins\Wox.Plugin.BrowserBookmark\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\Output\Release\Plugins\Wox.Plugin.BrowserBookmark\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} + Wox.Infrastructure + + + {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} + Wox.Plugin + + + + + PreserveNewest + + + + + Always + + + Always + + + + + \ No newline at end of file diff --git a/Plugins/Wox.Plugin.BrowserBookmark/plugin.json b/Plugins/Wox.Plugin.BrowserBookmark/plugin.json new file mode 100644 index 0000000000..a3aec5c3c8 --- /dev/null +++ b/Plugins/Wox.Plugin.BrowserBookmark/plugin.json @@ -0,0 +1,12 @@ +{ + "ID":"0ECADE17459B49F587BF81DC3A125110", + "ActionKeyword":"b", + "Name":"Browser Bookmark", + "Description":"Search your browser bookmarks", + "Author":"qianlifeng", + "Version":"1.0", + "Language":"csharp", + "Website":"http://www.getwox.com/plugin", + "ExecuteFileName":"Wox.Plugin.browserBookmark.dll", + "IcoPath":"Images\\plugin.png" +} diff --git a/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj b/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj index 0576782cd1..642b7d65c4 100644 --- a/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj +++ b/Wox.Plugin.SystemPlugins/Wox.Plugin.SystemPlugins.csproj @@ -70,7 +70,6 @@ - diff --git a/Wox.sln b/Wox.sln index 10d0a2842e..c4ecc8b278 100644 --- a/Wox.sln +++ b/Wox.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30110.0 +VisualStudioVersion = 12.0.21005.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Test", "Wox.Test\Wox.Test.csproj", "{FF742965-9A80-41A5-B042-D6C7D3A21708}" EndProject @@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.UAC", "Wox.UAC\Wox.UAC. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.PluginManagement", "Plugins\Wox.Plugin.PluginManagement\Wox.Plugin.PluginManagement.csproj", "{049490F0-ECD2-4148-9B39-2135EC346EBE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.BrowserBookmark", "Plugins\Wox.Plugin.BrowserBookmark\Wox.Plugin.BrowserBookmark.csproj", "{9B130CC5-14FB-41FF-B310-0A95B6894C37}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -59,11 +61,16 @@ Global {049490F0-ECD2-4148-9B39-2135EC346EBE}.Debug|Any CPU.Build.0 = Debug|Any CPU {049490F0-ECD2-4148-9B39-2135EC346EBE}.Release|Any CPU.ActiveCfg = Release|Any CPU {049490F0-ECD2-4148-9B39-2135EC346EBE}.Release|Any CPU.Build.0 = Release|Any CPU + {9B130CC5-14FB-41FF-B310-0A95B6894C37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9B130CC5-14FB-41FF-B310-0A95B6894C37}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B130CC5-14FB-41FF-B310-0A95B6894C37}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9B130CC5-14FB-41FF-B310-0A95B6894C37}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {049490F0-ECD2-4148-9B39-2135EC346EBE} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} + {9B130CC5-14FB-41FF-B310-0A95B6894C37} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87} EndGlobalSection EndGlobal diff --git a/Wox/ResultPanel.xaml b/Wox/ResultPanel.xaml index 641765bc77..c37b9b67a0 100644 --- a/Wox/ResultPanel.xaml +++ b/Wox/ResultPanel.xaml @@ -5,9 +5,6 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:converters="clr-namespace:Wox.Converters" mc:Ignorable="d" d:DesignWidth="100" d:DesignHeight="100"> - - - @@ -26,8 +23,11 @@ + + + - + diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index f7a4836473..5a7a651131 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -308,9 +308,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest