Skip to content
This repository has been archived by the owner on Nov 13, 2019. It is now read-only.

Commit

Permalink
Finish 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
orzFly committed Mar 22, 2014
1 parent 60460ff commit d766e08
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
34 changes: 32 additions & 2 deletions Plugin.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<Result> Query(Query query)
{
var queryString = query.GetAllRemainingParameter();
Expand All @@ -31,10 +52,19 @@ public List<Result> 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;
}
};
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
[Wox](http://getwox.com) Plugin: Switcheroo
===========================================
===========================================
![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.
4 changes: 0 additions & 4 deletions Wox.Plugin.Switcheroo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Accessibility" />
<Reference Include="Newtonsoft.Json">
<HintPath>packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
Expand Down
1 change: 0 additions & 1 deletion packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net35" />
<package id="Wox.Plugin" version="1.0.0" targetFramework="net35" />
</packages>

0 comments on commit d766e08

Please sign in to comment.