From d766e0857d9deab78a01e118994da928ade9771b Mon Sep 17 00:00:00 2001 From: Yeechan Lu Date: Sun, 23 Mar 2014 04:28:23 +0800 Subject: [PATCH] Finish 1.0.0 --- Plugin.cs | 34 ++++++++++++++++++++++++++++++++-- README.md | 9 ++++++++- Wox.Plugin.Switcheroo.csproj | 4 ---- packages.config | 1 - 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/Plugin.cs b/Plugin.cs index 8a5bf10..2089391 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -1,8 +1,9 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; -using Newtonsoft.Json; +using System.Windows.Media.Imaging; using S = Switcheroo; namespace Wox.Plugin.Switcheroo @@ -17,6 +18,26 @@ public void Init(PluginInitContext context) S.CoreStuff.Initialize(); } + public String IconImageDataUri(S.AppWindow self) + { + var key = "IconImageDataUri-" + self.HWnd; + var iconImageDataUri = System.Runtime.Caching.MemoryCache.Default.Get(key) as String; ; + if (iconImageDataUri == null) + { + var iconImage = self.IconImage; + using (MemoryStream memoryStream = new MemoryStream()) + { + BitmapEncoder encoder = new PngBitmapEncoder(); + encoder.Frames.Add(BitmapFrame.Create(iconImage)); + encoder.Save(memoryStream); + var b64String = Convert.ToBase64String(memoryStream.ToArray()); + iconImageDataUri = "data:image/png;base64," + b64String; + System.Runtime.Caching.MemoryCache.Default.Add(key, iconImageDataUri, DateTimeOffset.Now.AddHours(1)); + } + } + return iconImageDataUri; + } + public List Query(Query query) { var queryString = query.GetAllRemainingParameter(); @@ -31,10 +52,19 @@ public List Query(Query query) { Title = o.AppWindow.Title, SubTitle = o.AppWindow.ProcessTitle, + IcoPath = IconImageDataUri(o.AppWindow), Action = con => { context.HideApp(); - o.AppWindow.SwitchTo(); + if (con.SpecialKeyState.CtrlPressed) + { + o.AppWindow.PostClose(); + o.AppWindow.SwitchTo(); + } + else + { + o.AppWindow.SwitchTo(); + } return true; } }; diff --git a/README.md b/README.md index a6535d7..b92ad66 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ [Wox](http://getwox.com) Plugin: Switcheroo -=========================================== \ No newline at end of file +=========================================== +![image](https://f.cloud.github.com/assets/158528/2491834/eefa9062-b1ff-11e3-95ec-0e4e06ef9776.png) + +[![Build status](https://ci.appveyor.com/api/projects/status/8n8q2rm7b8e1m269)](https://ci.appveyor.com/project/orzFly/wox-plugin-switcheroo) + +Switcheroo +---------- +[Switcheroo](http://www.switcheroo.io/) is for anyone who spends more time using a keyboard than a mouse. Instead of alt-tabbing through a (long) list of open windows, Switcheroo allows you to quickly switch to any window by typing in just a few characters of its title. It's inspired by Emacs's IDO mode buffer switching and JetBrains' ReSharper. \ No newline at end of file diff --git a/Wox.Plugin.Switcheroo.csproj b/Wox.Plugin.Switcheroo.csproj index edaf182..7c5dad7 100644 --- a/Wox.Plugin.Switcheroo.csproj +++ b/Wox.Plugin.Switcheroo.csproj @@ -33,10 +33,6 @@ - - packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll - True - diff --git a/packages.config b/packages.config index b773d12..19b5486 100644 --- a/packages.config +++ b/packages.config @@ -1,5 +1,4 @@  - \ No newline at end of file