Merge branch 'V1.2.0'

This commit is contained in:
qianlifeng 2015-02-01 22:48:33 +08:00
commit d74dd48d24
140 changed files with 5653 additions and 1115 deletions

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Settings>
<SCOTT-PC>
<IgnoreVsHosting>True</IgnoreVsHosting>
<CompareSize>False</CompareSize>
<CleanUp>True</CleanUp>
<IgnoreDebugSymbols>True</IgnoreDebugSymbols>
<IgnoreFiles>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" /&gt;</IgnoreFiles>
<CopyFiles>True</CopyFiles>
<CompareVersion>True</CompareVersion>
<OutputFolder>E:\github\Wox\Output\Debug</OutputFolder>
<CompareHash>True</CompareHash>
<CompareDate>False</CompareDate>
<FeedXML>E:\github\Wox\Output\Update\Update.xml</FeedXML>
</SCOTT-PC>
<BaseURL>http://127.0.0.1:8888</BaseURL>
</Settings>

Binary file not shown.

View File

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="FeedBuilder.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<FeedBuilder.Properties.Settings>
<setting name="BaseURL" serializeAs="String">
<value />
</setting>
<setting name="CleanUp" serializeAs="String">
<value>True</value>
</setting>
<setting name="CompareDate" serializeAs="String">
<value>False</value>
</setting>
<setting name="CompareHash" serializeAs="String">
<value>True</value>
</setting>
<setting name="CompareSize" serializeAs="String">
<value>False</value>
</setting>
<setting name="CompareVersion" serializeAs="String">
<value>True</value>
</setting>
<setting name="CopyFiles" serializeAs="String">
<value>True</value>
</setting>
<setting name="FeedXML" serializeAs="String">
<value />
</setting>
<setting name="IgnoreDebugSymbols" serializeAs="String">
<value>True</value>
</setting>
<setting name="IgnoreFiles" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<string>*.pdb</string>
<string>*.config</string>
</ArrayOfString>
</value>
</setting>
<setting name="IgnoreVsHosting" serializeAs="String">
<value>True</value>
</setting>
<setting name="OutputFolder" serializeAs="String">
<value />
</setting>
</FeedBuilder.Properties.Settings>
</userSettings>
</configuration>

View File

@ -1 +0,0 @@
FeedBuilder.exe "FeedBuilder.config" -Build

View File

@ -1 +0,0 @@
FeedBuilder.exe "FeedBuilder.config" -ShowGUI

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,2 @@
cd /d %~dp0
%~dp0Wox.UpdateFeedGenerator.exe

View File

@ -0,0 +1,10 @@
{
"OutputDirectory": "..\\..\\Output\\Update",
"SourceDirectory": "..\\..\\Output\\Release",
"BaseURL": "http://127.0.0.1:8888",
"FeedXMLName": "update.xml",
"CheckVersion": false,
"CheckSize": false,
"CheckDate": false,
"CheckHash": true
}

View File

@ -6,12 +6,13 @@ using System.Reflection;
using System.Windows.Forms;
using WindowsInput;
using WindowsInput.Native;
using Wox.Infrastructure;
using Wox.Infrastructure.Hotkey;
using Control = System.Windows.Controls.Control;
namespace Wox.Plugin.CMD
{
public class CMD : IPlugin, ISettingProvider, IPluginI18n
public class CMD : IPlugin, ISettingProvider, IPluginI18n, IInstantSearch
{
private PluginInitContext context;
private bool WinRStroked;
@ -21,14 +22,14 @@ namespace Wox.Plugin.CMD
{
List<Result> results = new List<Result>();
List<Result> pushedResults = new List<Result>();
if (query.RawQuery == ">")
if (query.Search == ">")
{
return GetAllHistoryCmds();
}
if (query.RawQuery.StartsWith(">") && query.RawQuery.Length > 1)
if (query.Search.StartsWith(">") && query.Search.Length > 1)
{
string cmd = query.RawQuery.Substring(1);
string cmd = query.Search.Substring(1);
var queryCmd = GetCurrentCmd(cmd);
context.API.PushResults(query, context.CurrentPluginMetadata, new List<Result>() { queryCmd });
pushedResults.Add(queryCmd);
@ -37,6 +38,7 @@ namespace Wox.Plugin.CMD
context.API.PushResults(query, context.CurrentPluginMetadata, history);
pushedResults.AddRange(history);
try
{
string basedir = null;
@ -72,6 +74,7 @@ namespace Wox.Plugin.CMD
}
}
catch (Exception) { }
}
return results;
}
@ -207,5 +210,11 @@ namespace Wox.Plugin.CMD
{
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
}
public bool IsInstantSearch(string query)
{
if (query.StartsWith(">")) return true;
return false;
}
}
}

View File

@ -50,9 +50,8 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Reference Include="WindowsInput, Version=0.2.0.0, Culture=neutral, PublicKeyToken=9b287f7dc5073cad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\WindowsInput.0.2.0.0\lib\net20\WindowsInput.dll</HintPath>
<Reference Include="WindowsInput">
<HintPath>..\..\packages\InputSimulator.1.0.4.0\lib\net20\WindowsInput.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="InputSimulator" version="1.0.4.0" targetFramework="net35" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net35" />
<package id="WindowsInput" version="0.2.0.0" targetFramework="net35" />
</packages>

View File

@ -28,13 +28,13 @@ namespace Wox.Plugin.Caculator
public List<Result> Query(Query query)
{
if (query.RawQuery.Length <= 2 // don't affect when user only input "e" or "i" keyword
|| !regValidExpressChar.IsMatch(query.RawQuery)
|| !IsBracketComplete(query.RawQuery)) return new List<Result>();
if (query.Search.Length <= 2 // don't affect when user only input "e" or "i" keyword
|| !regValidExpressChar.IsMatch(query.Search)
|| !IsBracketComplete(query.Search)) return new List<Result>();
try
{
var result = yampContext.Run(query.RawQuery);
var result = yampContext.Run(query.Search);
if (result.Output != null && !string.IsNullOrEmpty(result.Result))
{
return new List<Result>() { new Result() {

View File

@ -81,6 +81,10 @@
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- 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">

View File

@ -29,7 +29,7 @@ namespace Wox.Plugin.Color
public List<Result> Query(Query query)
{
var raw = query.RawQuery;
var raw = query.Search;
if (!IsAvailable(raw)) return new List<Result>(0);
try
{

View File

@ -38,9 +38,7 @@ namespace Wox.Plugin.ControlPanel
public List<Result> Query(Query query)
{
if (query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>();
string myQuery = query.RawQuery.Trim();
string myQuery = query.Search.Trim();
List<Result> results = new List<Result>();
foreach (var item in controlPanelItems)

View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

156
Plugins/Wox.Plugin.Everything/.gitignore vendored Normal file
View File

@ -0,0 +1,156 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
# =========================
# Windows detritus
# =========================
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac desktop service store files
.DS_Store

View File

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Wox.Infrastructure.Storage;
using System.IO;
using System.Reflection;
namespace Wox.Plugin.Everything
{
public class ContextMenuStorage : JsonStrorage<ContextMenuStorage>
{
[JsonProperty]
public List<ContextMenu> ContextMenus = new List<ContextMenu>();
[JsonProperty]
public int MaxSearchCount { get; set; }
protected override string ConfigName
{
get { return "EverythingContextMenu"; }
}
protected override string ConfigFolder
{
get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
}
protected override ContextMenuStorage LoadDefault()
{
ContextMenus = new List<ContextMenu>()
{
new ContextMenu()
{
Name = "Open Containing Folder",
Command = "explorer.exe",
Argument = " /select,\"{path}\"",
ImagePath ="Images\\folder.png"
}
};
MaxSearchCount = 100;
Save();
return this;
}
}
public class ContextMenu
{
[JsonProperty]
public string Name { get; set; }
[JsonProperty]
public string Command { get; set; }
[JsonProperty]
public string Argument { get; set; }
[JsonProperty]
public string ImagePath { get; set; }
}
}

View File

@ -0,0 +1,248 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using Wox.Plugin.Everything.Everything.Exceptions;
namespace Wox.Plugin.Everything.Everything
{
public sealed class EverythingAPI
{
#region DllImport
[DllImport(EVERYTHING_DLL_NAME)]
private static extern int Everything_SetSearch(string lpSearchString);
[DllImport(EVERYTHING_DLL_NAME)]
private static extern void Everything_SetMatchPath(bool bEnable);
[DllImport(EVERYTHING_DLL_NAME)]
private static extern void Everything_SetMatchCase(bool bEnable);
[DllImport(EVERYTHING_DLL_NAME)]
private static extern void Everything_SetMatchWholeWord(bool bEnable);
[DllImport(EVERYTHING_DLL_NAME)]
private static extern void Everything_SetRegex(bool bEnable);
[DllImport(EVERYTHING_DLL_NAME)]
private static extern void Everything_SetMax(int dwMax);
[DllImport(EVERYTHING_DLL_NAME)]
private static extern void Everything_SetOffset(int dwOffset);
[DllImport(EVERYTHING_DLL_NAME)]
private static extern bool Everything_GetMatchPath();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern bool Everything_GetMatchCase();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern bool Everything_GetMatchWholeWord();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern bool Everything_GetRegex();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern UInt32 Everything_GetMax();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern UInt32 Everything_GetOffset();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern string Everything_GetSearch();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern StateCode Everything_GetLastError();
[DllImport(EVERYTHING_DLL_NAME, EntryPoint = "Everything_QueryW")]
private static extern bool Everything_Query(bool bWait);
[DllImport(EVERYTHING_DLL_NAME)]
private static extern void Everything_SortResultsByPath();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern int Everything_GetNumFileResults();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern int Everything_GetNumFolderResults();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern int Everything_GetNumResults();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern int Everything_GetTotFileResults();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern int Everything_GetTotFolderResults();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern int Everything_GetTotResults();
[DllImport(EVERYTHING_DLL_NAME)]
private static extern bool Everything_IsVolumeResult(int nIndex);
[DllImport(EVERYTHING_DLL_NAME)]
private static extern bool Everything_IsFolderResult(int nIndex);
[DllImport(EVERYTHING_DLL_NAME)]
private static extern bool Everything_IsFileResult(int nIndex);
[DllImport(EVERYTHING_DLL_NAME)]
private static extern void Everything_GetResultFullPathName(int nIndex, StringBuilder lpString, int nMaxCount);
[DllImport(EVERYTHING_DLL_NAME)]
private static extern void Everything_Reset();
#endregion
const string EVERYTHING_DLL_NAME = "Everything.dll";
enum StateCode
{
OK,
MemoryError,
IPCError,
RegisterClassExError,
CreateWindowError,
CreateThreadError,
InvalidIndexError,
InvalidCallError
}
/// <summary>
/// Gets or sets a value indicating whether [match path].
/// </summary>
/// <value><c>true</c> if [match path]; otherwise, <c>false</c>.</value>
public Boolean MatchPath
{
get
{
return Everything_GetMatchPath();
}
set
{
Everything_SetMatchPath(value);
}
}
/// <summary>
/// Gets or sets a value indicating whether [match case].
/// </summary>
/// <value><c>true</c> if [match case]; otherwise, <c>false</c>.</value>
public Boolean MatchCase
{
get
{
return Everything_GetMatchCase();
}
set
{
Everything_SetMatchCase(value);
}
}
/// <summary>
/// Gets or sets a value indicating whether [match whole word].
/// </summary>
/// <value><c>true</c> if [match whole word]; otherwise, <c>false</c>.</value>
public Boolean MatchWholeWord
{
get
{
return Everything_GetMatchWholeWord();
}
set
{
Everything_SetMatchWholeWord(value);
}
}
/// <summary>
/// Gets or sets a value indicating whether [enable regex].
/// </summary>
/// <value><c>true</c> if [enable regex]; otherwise, <c>false</c>.</value>
public Boolean EnableRegex
{
get
{
return Everything_GetRegex();
}
set
{
Everything_SetRegex(value);
}
}
/// <summary>
/// Resets this instance.
/// </summary>
public void Reset()
{
Everything_Reset();
}
private void no()
{
switch (Everything_GetLastError())
{
case StateCode.CreateThreadError:
throw new CreateThreadException();
case StateCode.CreateWindowError:
throw new CreateWindowException();
case StateCode.InvalidCallError:
throw new InvalidCallException();
case StateCode.InvalidIndexError:
throw new InvalidIndexException();
case StateCode.IPCError:
throw new IPCErrorException();
case StateCode.MemoryError:
throw new MemoryErrorException();
case StateCode.RegisterClassExError:
throw new RegisterClassExException();
}
}
/// <summary>
/// Searches the specified key word.
/// </summary>
/// <param name="keyWord">The key word.</param>
/// <param name="offset">The offset.</param>
/// <param name="maxCount">The max count.</param>
/// <returns></returns>
public IEnumerable<SearchResult> Search(string keyWord, int offset = 0, int maxCount = 100)
{
if (string.IsNullOrEmpty(keyWord))
throw new ArgumentNullException("keyWord");
if (offset < 0)
throw new ArgumentOutOfRangeException("offset");
if (maxCount < 0)
throw new ArgumentOutOfRangeException("maxCount");
if (keyWord.StartsWith("@"))
{
Everything_SetRegex(true);
keyWord = keyWord.Substring(1);
}
Everything_SetSearch(keyWord);
Everything_SetOffset(offset);
Everything_SetMax(maxCount);
if (!Everything_Query(true))
{
switch (Everything_GetLastError())
{
case StateCode.CreateThreadError:
throw new CreateThreadException();
case StateCode.CreateWindowError:
throw new CreateWindowException();
case StateCode.InvalidCallError:
throw new InvalidCallException();
case StateCode.InvalidIndexError:
throw new InvalidIndexException();
case StateCode.IPCError:
throw new IPCErrorException();
case StateCode.MemoryError:
throw new MemoryErrorException();
case StateCode.RegisterClassExError:
throw new RegisterClassExException();
}
yield break;
}
Everything_SortResultsByPath();
const int bufferSize = 4096;
StringBuilder buffer = new StringBuilder(bufferSize);
for (int idx = 0; idx < Everything_GetNumResults(); ++idx)
{
Everything_GetResultFullPathName(idx, buffer, bufferSize);
var result = new SearchResult() { FullPath = buffer.ToString() };
if (Everything_IsFolderResult(idx))
result.Type = ResultType.Folder;
else if (Everything_IsFileResult(idx))
result.Type = ResultType.File;
yield return result;
}
}
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Wox.Plugin.Everything.Everything
{
/// <summary>
///
/// </summary>
public class CreateThreadException : ApplicationException
{
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Wox.Plugin.Everything.Everything
{
/// <summary>
///
/// </summary>
public class CreateWindowException : ApplicationException
{
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Wox.Plugin.Everything.Everything
{
/// <summary>
///
/// </summary>
public class IPCErrorException : ApplicationException
{
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Wox.Plugin.Everything.Everything
{
/// <summary>
///
/// </summary>
public class InvalidCallException : ApplicationException
{
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Wox.Plugin.Everything.Everything
{
/// <summary>
///
/// </summary>
public class InvalidIndexException : ApplicationException
{
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Wox.Plugin.Everything.Everything.Exceptions
{
/// <summary>
///
/// </summary>
public class MemoryErrorException : ApplicationException
{
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace Wox.Plugin.Everything.Everything
{
/// <summary>
///
/// </summary>
public class RegisterClassExException : ApplicationException
{
}
}

View File

@ -0,0 +1,9 @@
namespace Wox.Plugin.Everything.Everything
{
public enum ResultType
{
Volume,
Folder,
File
}
}

View File

@ -0,0 +1,8 @@
namespace Wox.Plugin.Everything.Everything
{
public class SearchResult
{
public string FullPath { get; set; }
public ResultType Type { get; set; }
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -0,0 +1,182 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Wox.Infrastructure;
using System.Reflection;
using Wox.Plugin.Everything.Everything;
namespace Wox.Plugin.Everything
{
public class Main : IPlugin
{
PluginInitContext context;
EverythingAPI api = new EverythingAPI();
private static List<string> imageExts = new List<string>() { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".ico" };
private static List<string> executableExts = new List<string>() { ".exe" };
public List<Result> Query(Query query)
{
var results = new List<Result>();
if (!string.IsNullOrEmpty(query.Search))
{
var keyword = query.Search;
if (ContextMenuStorage.Instance.MaxSearchCount <= 0)
{
ContextMenuStorage.Instance.MaxSearchCount = 100;
ContextMenuStorage.Instance.Save();
}
try
{
var searchList = api.Search(keyword, maxCount: ContextMenuStorage.Instance.MaxSearchCount).ToList();
var fuzzyMather = FuzzyMatcher.Create(keyword);
searchList.Sort(
(x, y) =>
fuzzyMather.Evaluate(Path.GetFileName(y.FullPath)).Score -
fuzzyMather.Evaluate(Path.GetFileName(x.FullPath)).Score);
foreach (var s in searchList)
{
var path = s.FullPath;
Result r = new Result();
r.Title = Path.GetFileName(path);
r.SubTitle = path;
r.IcoPath = GetIconPath(s);
r.Action = (c) =>
{
context.API.HideApp();
context.API.ShellRun(path);
return true;
};
r.ContextMenu = GetContextMenu(s);
results.Add(r);
}
}
catch (IPCErrorException)
{
StartEverything();
results.Add(new Result()
{
Title = "Everything is not running, we already run it for you now. Try search again",
IcoPath = "Images\\warning.png"
});
}
catch (Exception e)
{
results.Add(new Result()
{
Title = "Everything plugin has an error (enter to copy error message)",
SubTitle = e.Message,
Action = _ =>
{
System.Windows.Clipboard.SetText(e.Message + "\r\n" + e.StackTrace);
context.API.ShowMsg("Copied", "Error message has copied to your clipboard", string.Empty);
return false;
},
IcoPath = "Images\\error.png"
});
}
}
api.Reset();
return results;
}
private string GetIconPath(SearchResult s)
{
var ext = Path.GetExtension(s.FullPath);
if (s.Type == ResultType.Folder)
{
return "Images\\folder.png";
}
else if (!string.IsNullOrEmpty(ext))
{
if (imageExts.Contains(ext.ToLower()))
{
return "Images\\image.png";
}
else if (executableExts.Contains(ext.ToLower()))
{
return s.FullPath;
}
}
return "Images\\file.png";
}
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern int LoadLibrary(string name);
private List<Result> GetContextMenu(SearchResult record)
{
List<Result> contextMenus = new List<Result>();
if (record.Type == ResultType.File)
{
foreach (ContextMenu contextMenu in ContextMenuStorage.Instance.ContextMenus)
{
contextMenus.Add(new Result()
{
Title = contextMenu.Name,
Action = _ =>
{
string argument = contextMenu.Argument.Replace("{path}", record.FullPath);
try
{
System.Diagnostics.Process.Start(contextMenu.Command, argument);
}
catch
{
context.API.ShowMsg("Can't start " + record.FullPath, string.Empty, string.Empty);
return false;
}
return true;
},
IcoPath = contextMenu.ImagePath
});
}
}
return contextMenus;
}
public void Init(PluginInitContext context)
{
this.context = context;
LoadLibrary(Path.Combine(
Path.Combine(context.CurrentPluginMetadata.PluginDirectory, (IntPtr.Size == 4) ? "x86" : "x64"),
"Everything.dll"
));
StartEverything();
}
private void StartEverything()
{
if (!CheckEverythingIsRunning())
{
Process p = new Process();
p.StartInfo.Verb = "runas";
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.FileName = GetEverythingPath();
p.StartInfo.UseShellExecute = true;
p.Start();
}
}
private bool CheckEverythingIsRunning()
{
return Process.GetProcessesByName("Everything").Length > 0;
}
private string GetEverythingPath()
{
string everythingFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "PortableEverything");
return Path.Combine(everythingFolder, "Everything.exe");
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Wox.Plugin.Everything")]
[assembly: AssemblyDescription("https://github.com/qianlifeng/Wox")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Wox.Plugin.Everything")]
[assembly: AssemblyCopyright("The MIT License (MIT)")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("97f6ccd0-e9dc-4aa2-b4ce-6b9f14ea20a7")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,4 @@
Wox.Plugin.Everything
=====================
Wox plugin for Everything

View File

@ -0,0 +1,130 @@
<?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>{230AE83F-E92E-4E69-8355-426B305DA9C0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wox.Plugin.Everything</RootNamespace>
<AssemblyName>Wox.Plugin.Everything</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\Wox\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Output\Debug\Plugins\Wox.Plugin.Everything\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Plugins\Wox.Plugin.Everything\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<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="Everything\Exceptions\CreateThreadException.cs" />
<Compile Include="Everything\Exceptions\CreateWindowException.cs" />
<Compile Include="Everything\EverythingAPI.cs" />
<Compile Include="Everything\Exceptions\MemoryErrorException.cs" />
<Compile Include="Everything\Exceptions\InvalidCallException.cs" />
<Compile Include="Everything\Exceptions\InvalidIndexException.cs" />
<Compile Include="Everything\Exceptions\IPCErrorException.cs" />
<Compile Include="Everything\Exceptions\RegisterClassExException.cs" />
<Compile Include="Everything\ResultType.cs" />
<Compile Include="Everything\SearchResult.cs" />
<Compile Include="ContextMenuStorage.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\error.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\file.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\find.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\folder.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\image.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\warning.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="packages.config" />
<None Include="PortableEverything\Everything.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="x64\Everything.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="x86\Everything.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<None Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj">
<Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project>
<Name>Wox.Infrastructure</Name>
</ProjectReference>
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj">
<Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project>
<Name>Wox.Plugin</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<!-- 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>

View File

@ -0,0 +1,29 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Everything", "Wox.Plugin.Everything.csproj", "{230AE83F-E92E-4E69-8355-426B305DA9C0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{9BEA8C30-8CC3-48FE-87FD-8D7E65898C1A}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
.nuget\NuGet.exe = .nuget\NuGet.exe
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{230AE83F-E92E-4E69-8355-426B305DA9C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{230AE83F-E92E-4E69-8355-426B305DA9C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{230AE83F-E92E-4E69-8355-426B305DA9C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{230AE83F-E92E-4E69-8355-426B305DA9C0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,51 @@
LIBRARY Everything
EXPORTS
Everything_GetLastError
Everything_SetSearchA
Everything_SetSearchW
Everything_SetMatchPath
Everything_SetMatchCase
Everything_SetMatchWholeWord
Everything_SetRegex
Everything_SetMax
Everything_SetOffset
Everything_GetSearchA
Everything_GetSearchW
Everything_GetMatchPath
Everything_GetMatchCase
Everything_GetMatchWholeWord
Everything_GetRegex
Everything_GetMax
Everything_GetOffset
Everything_QueryA
Everything_QueryW
Everything_IsQueryReply
Everything_SortResultsByPath
Everything_GetNumFileResults
Everything_GetNumFolderResults
Everything_GetNumResults
Everything_GetTotFileResults
Everything_GetTotFolderResults
Everything_GetTotResults
Everything_IsVolumeResult
Everything_IsFolderResult
Everything_IsFileResult
Everything_GetResultFileNameA
Everything_GetResultFileNameW
Everything_GetResultPathA
Everything_GetResultPathW
Everything_GetResultFullPathNameA
Everything_GetResultFullPathNameW
Everything_Reset

View File

@ -0,0 +1,95 @@
#ifndef _EVERYTHING_DLL_
#define _EVERYTHING_DLL_
#ifndef _INC_WINDOWS
#include <windows.h>
#endif
#define EVERYTHING_OK 0
#define EVERYTHING_ERROR_MEMORY 1
#define EVERYTHING_ERROR_IPC 2
#define EVERYTHING_ERROR_REGISTERCLASSEX 3
#define EVERYTHING_ERROR_CREATEWINDOW 4
#define EVERYTHING_ERROR_CREATETHREAD 5
#define EVERYTHING_ERROR_INVALIDINDEX 6
#define EVERYTHING_ERROR_INVALIDCALL 7
#ifndef EVERYTHINGAPI
#define EVERYTHINGAPI __stdcall
#endif
#ifndef EVERYTHINGUSERAPI
#define EVERYTHINGUSERAPI __declspec(dllimport)
#endif
// write search state
EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetSearchW(LPCWSTR lpString);
EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetSearchA(LPCSTR lpString);
EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetMatchPath(BOOL bEnable);
EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetMatchCase(BOOL bEnable);
EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetMatchWholeWord(BOOL bEnable);
EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetRegex(BOOL bEnable);
EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetMax(DWORD dwMax);
EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetOffset(DWORD dwOffset);
EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetReplyWindow(HWND hWnd);
EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SetReplyID(DWORD nId);
// read search state
EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_GetMatchPath(VOID);
EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_GetMatchCase(VOID);
EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_GetMatchWholeWord(VOID);
EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_GetRegex(VOID);
EVERYTHINGUSERAPI DWORD EVERYTHINGAPI Everything_GetMax(VOID);
EVERYTHINGUSERAPI DWORD EVERYTHINGAPI Everything_GetOffset(VOID);
EVERYTHINGUSERAPI LPCSTR EVERYTHINGAPI Everything_GetSearchA(VOID);
EVERYTHINGUSERAPI LPCWSTR EVERYTHINGAPI Everything_GetSearchW(VOID);
EVERYTHINGUSERAPI DWORD EVERYTHINGAPI Everything_GetLastError(VOID);
EVERYTHINGUSERAPI HWND EVERYTHINGAPI Everything_GetReplyWindow(VOID);
EVERYTHINGUSERAPI DWORD EVERYTHINGAPI Everything_GetReplyID(VOID);
// execute query
EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_QueryA(BOOL bWait);
EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_QueryW(BOOL bWait);
// query reply
BOOL EVERYTHINGAPI Everything_IsQueryReply(UINT message,WPARAM wParam,LPARAM lParam,DWORD nId);
// write result state
EVERYTHINGUSERAPI VOID EVERYTHINGAPI Everything_SortResultsByPath(VOID);
// read result state
EVERYTHINGUSERAPI int EVERYTHINGAPI Everything_GetNumFileResults(VOID);
EVERYTHINGUSERAPI int EVERYTHINGAPI Everything_GetNumFolderResults(VOID);
EVERYTHINGUSERAPI int EVERYTHINGAPI Everything_GetNumResults(VOID);
EVERYTHINGUSERAPI int EVERYTHINGAPI Everything_GetTotFileResults(VOID);
EVERYTHINGUSERAPI int EVERYTHINGAPI Everything_GetTotFolderResults(VOID);
EVERYTHINGUSERAPI int EVERYTHINGAPI Everything_GetTotResults(VOID);
EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_IsVolumeResult(int nIndex);
EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_IsFolderResult(int nIndex);
EVERYTHINGUSERAPI BOOL EVERYTHINGAPI Everything_IsFileResult(int nIndex);
EVERYTHINGUSERAPI LPCWSTR EVERYTHINGAPI Everything_GetResultFileNameW(int nIndex);
EVERYTHINGUSERAPI LPCSTR EVERYTHINGAPI Everything_GetResultFileNameA(int nIndex);
EVERYTHINGUSERAPI LPCWSTR EVERYTHINGAPI Everything_GetResultPathW(int nIndex);
EVERYTHINGUSERAPI LPCSTR EVERYTHINGAPI Everything_GetResultPathA(int nIndex);
EVERYTHINGUSERAPI int Everything_GetResultFullPathNameW(int nIndex,LPWSTR wbuf,int wbuf_size_in_wchars);
EVERYTHINGUSERAPI int Everything_GetResultFullPathNameA(int nIndex,LPSTR buf,int bufsize);
EVERYTHINGUSERAPI VOID Everything_Reset(VOID);
#ifdef UNICODE
#define Everything_SetSearch Everything_SetSearchW
#define Everything_GetSearch Everything_GetSearchW
#define Everything_Query Everything_QueryW
#define Everything_GetResultFileName Everything_GetResultFileNameW
#define Everything_GetResultPath Everything_GetResultPathW
#else
#define Everything_SetSearch Everything_SetSearchA
#define Everything_GetSearch Everything_GetSearchA
#define Everything_Query Everything_QueryA
#define Everything_GetResultFileName Everything_GetResultFileNameA
#define Everything_GetResultPath Everything_GetResultPathA
#endif
#endif

View File

@ -0,0 +1,287 @@
// Everything IPC
#ifndef _EVERYTHING_IPC_H_
#define _EVERYTHING_IPC_H_
// C
#ifdef __cplusplus
extern "C" {
#endif
// 1 byte packing for our varible sized structs
#pragma pack(push, 1)
// WM_USER (send to the taskbar notification window)
// SendMessage(FindWindow(EVERYTHING_IPC_WNDCLASS,0),WM_USER,EVERYTHING_IPC_*,lParam)
// version format: major.minor.revision.build
// example: 1.1.4.309
#define EVERYTHING_IPC_GET_MAJOR_VERSION 0 // int major_version = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_GET_MAJOR_VERSION,0);
#define EVERYTHING_IPC_GET_MINOR_VERSION 1 // int minor_version = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_GET_MINOR_VERSION,0);
#define EVERYTHING_IPC_GET_REVISION 2 // int revision = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_GET_REVISION,0);
#define EVERYTHING_IPC_GET_BUILD_NUMBER 3 // int build = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_GET_BUILD,0);
// uninstall options
#define EVERYTHING_IPC_DELETE_START_MENU_SHORTCUTS 100 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_DELETE_START_MENU_SHORTCUTS,0);
#define EVERYTHING_IPC_DELETE_QUICK_LAUNCH_SHORTCUT 101 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_DELETE_QUICK_LAUNCH_SHORTCUT,0);
#define EVERYTHING_IPC_DELETE_DESKTOP_SHORTCUT 102 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_DELETE_DESKTOP_SHORTCUT,0);
#define EVERYTHING_IPC_DELETE_FOLDER_CONTEXT_MENU 103 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_DELETE_FOLDER_CONTEXT_MENU,0);
#define EVERYTHING_IPC_DELETE_RUN_ON_SYSTEM_STARTUP 104 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_DELETE_RUN_ON_SYSTEM_STARTUP,0);
// install options
#define EVERYTHING_IPC_CREATE_START_MENU_SHORTCUTS 200 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_CREATE_START_MENU_SHORTCUTS,0);
#define EVERYTHING_IPC_CREATE_QUICK_LAUNCH_SHORTCUT 201 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_CREATE_QUICK_LAUNCH_SHORTCUT,0);
#define EVERYTHING_IPC_CREATE_DESKTOP_SHORTCUT 202 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_CREATE_DESKTOP_SHORTCUT,0);
#define EVERYTHING_IPC_CREATE_FOLDER_CONTEXT_MENU 203 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_CREATE_FOLDER_CONTEXT_MENU,0);
#define EVERYTHING_IPC_CREATE_RUN_ON_SYSTEM_STARTUP 204 // SendMessage(hwnd,WM_USER,EVERYTHING_IPC_CREATE_RUN_ON_SYSTEM_STARTUP,0);
// get option status; 0 = no, 1 = yes, 2 = indeterminate (partially installed)
#define EVERYTHING_IPC_IS_START_MENU_SHORTCUTS 300 // int ret = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_IS_START_MENU_SHORTCUTS,0);
#define EVERYTHING_IPC_IS_QUICK_LAUNCH_SHORTCUT 301 // int ret = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_IS_QUICK_LAUNCH_SHORTCUT,0);
#define EVERYTHING_IPC_IS_DESKTOP_SHORTCUT 302 // int ret = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_IS_DESKTOP_SHORTCUT,0);
#define EVERYTHING_IPC_IS_FOLDER_CONTEXT_MENU 303 // int ret = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_IS_FOLDER_CONTEXT_MENU,0);
#define EVERYTHING_IPC_IS_RUN_ON_SYSTEM_STARTUP 304 // int ret = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_IS_RUN_ON_SYSTEM_STARTUP,0);
// find the everything window
#define EVERYTHING_IPC_WNDCLASS TEXT("EVERYTHING_TASKBAR_NOTIFICATION")
// find a everything search window
#define EVERYTHING_IPC_SEARCH_WNDCLASS TEXT("EVERYTHING")
// this global window message is sent to all top level windows when everything starts.
#define EVERYTHING_IPC_CREATED TEXT("EVERYTHING_IPC_CREATED")
// search flags for querys
#define EVERYTHING_IPC_MATCHCASE 0x00000001 // match case
#define EVERYTHING_IPC_MATCHWHOLEWORD 0x00000002 // match whole word
#define EVERYTHING_IPC_MATCHPATH 0x00000004 // include paths in search
#define EVERYTHING_IPC_REGEX 0x00000008 // enable regex
// item flags
#define EVERYTHING_IPC_FOLDER 0x00000001 // The item is a folder. (its a file if not set)
#define EVERYTHING_IPC_DRIVE 0x00000002 // The folder is a drive. Path will be an empty string.
// (will also have the folder bit set)
// the WM_COPYDATA message for a query.
#define EVERYTHING_IPC_COPYDATAQUERYA 1
#define EVERYTHING_IPC_COPYDATAQUERYW 2
// all results
#define EVERYTHING_IPC_ALLRESULTS 0xFFFFFFFF // all results
// macro to get the filename of an item
#define EVERYTHING_IPC_ITEMFILENAMEA(list,item) (CHAR *)((CHAR *)(list) + ((EVERYTHING_IPC_ITEMA *)(item))->filename_offset)
#define EVERYTHING_IPC_ITEMFILENAMEW(list,item) (WCHAR *)((CHAR *)(list) + ((EVERYTHING_IPC_ITEMW *)(item))->filename_offset)
// macro to get the path of an item
#define EVERYTHING_IPC_ITEMPATHA(list,item) (CHAR *)((CHAR *)(list) + ((EVERYTHING_IPC_ITEMW *)(item))->path_offset)
#define EVERYTHING_IPC_ITEMPATHW(list,item) (WCHAR *)((CHAR *)(list) + ((EVERYTHING_IPC_ITEMW *)(item))->path_offset)
//
// Varible sized query struct sent to everything.
//
// sent in the form of a WM_COPYDAYA message with EVERYTHING_IPC_COPYDATAQUERY as the
// dwData member in the COPYDATASTRUCT struct.
// set the lpData member of the COPYDATASTRUCT struct to point to your EVERYTHING_IPC_QUERY struct.
// set the cbData member of the COPYDATASTRUCT struct to the size of the
// EVERYTHING_IPC_QUERY struct minus the size of a CHAR plus the length of the search string in bytes plus
// one CHAR for the null terminator.
//
// NOTE: to determine the size of this structure use
// ASCII: sizeof(EVERYTHING_IPC_QUERYA) - sizeof(CHAR) + strlen(search_string)*sizeof(CHAR) + sizeof(CHAR)
// UNICODE: sizeof(EVERYTHING_IPC_QUERYW) - sizeof(WCHAR) + unicode_length_in_wchars(search_string)*sizeof(WCHAR) + sizeof(WCHAR)
//
// NOTE: Everything will only do one query per window.
// Sending another query when a query has not completed
// will cancel the old query and start the new one.
//
// Everything will send the results to the reply_hwnd in the form of a
// WM_COPYDAYA message with the dwData value you specify.
//
// Everything will return TRUE if successful.
// returns FALSE if not supported.
//
// If you query with EVERYTHING_IPC_COPYDATAQUERYW, the results sent from Everything will be Unicode.
//
typedef struct EVERYTHING_IPC_QUERYW
{
// the window that will receive the new results.
INT32 reply_hwnd;
// the value to set the dwData member in the COPYDATASTRUCT struct
// sent by Everything when the query is complete.
INT32 reply_copydata_message;
// search flags (see EVERYTHING_MATCHCASE | EVERYTHING_MATCHWHOLEWORD | EVERYTHING_MATCHPATH)
INT32 search_flags;
// only return results after 'offset' results (0 to return the first result)
// useful for scrollable lists
INT32 offset;
// the number of results to return
// zero to return no results
// EVERYTHING_IPC_ALLRESULTS to return ALL results
INT32 max_results;
// null terminated string. arbitrary sized search_string buffer.
INT32 search_string[1];
}EVERYTHING_IPC_QUERYW;
// ASCII version
typedef struct EVERYTHING_IPC_QUERYA
{
// the window that will receive the new results.
INT32 reply_hwnd;
// the value to set the dwData member in the COPYDATASTRUCT struct
// sent by Everything when the query is complete.
INT32 reply_copydata_message;
// search flags (see EVERYTHING_MATCHCASE | EVERYTHING_MATCHWHOLEWORD | EVERYTHING_MATCHPATH)
INT32 search_flags;
// only return results after 'offset' results (0 to return the first result)
// useful for scrollable lists
INT32 offset;
// the number of results to return
// zero to return no results
// EVERYTHING_IPC_ALLRESULTS to return ALL results
INT32 max_results;
// null terminated string. arbitrary sized search_string buffer.
INT32 search_string[1];
}EVERYTHING_IPC_QUERYA;
//
// Varible sized result list struct received from Everything.
//
// Sent in the form of a WM_COPYDATA message to the hwnd specifed in the
// EVERYTHING_IPC_QUERY struct.
// the dwData member of the COPYDATASTRUCT struct will match the sent
// reply_copydata_message member in the EVERYTHING_IPC_QUERY struct.
//
// make a copy of the data before returning.
//
// return TRUE if you processed the WM_COPYDATA message.
//
typedef struct EVERYTHING_IPC_ITEMW
{
// item flags
DWORD flags;
// The offset of the filename from the beginning of the list structure.
// (wchar_t *)((char *)everything_list + everythinglist->name_offset)
DWORD filename_offset;
// The offset of the filename from the beginning of the list structure.
// (wchar_t *)((char *)everything_list + everythinglist->path_offset)
DWORD path_offset;
}EVERYTHING_IPC_ITEMW;
typedef struct EVERYTHING_IPC_ITEMA
{
// item flags
DWORD flags;
// The offset of the filename from the beginning of the list structure.
// (char *)((char *)everything_list + everythinglist->name_offset)
DWORD filename_offset;
// The offset of the filename from the beginning of the list structure.
// (char *)((char *)everything_list + everythinglist->path_offset)
DWORD path_offset;
}EVERYTHING_IPC_ITEMA;
typedef struct EVERYTHING_IPC_LISTW
{
// the total number of folders found.
DWORD totfolders;
// the total number of files found.
DWORD totfiles;
// totfolders + totfiles
DWORD totitems;
// the number of folders available.
DWORD numfolders;
// the number of files available.
DWORD numfiles;
// the number of items available.
DWORD numitems;
// index offset of the first result in the item list.
DWORD offset;
// arbitrary sized item list.
// use numitems to determine the actual number of items available.
EVERYTHING_IPC_ITEMW items[1];
}EVERYTHING_IPC_LISTW;
typedef struct EVERYTHING_IPC_LISTA
{
// the total number of folders found.
DWORD totfolders;
// the total number of files found.
DWORD totfiles;
// totfolders + totfiles
DWORD totitems;
// the number of folders available.
DWORD numfolders;
// the number of files available.
DWORD numfiles;
// the number of items available.
DWORD numitems;
// index offset of the first result in the item list.
DWORD offset;
// arbitrary sized item list.
// use numitems to determine the actual number of items available.
EVERYTHING_IPC_ITEMA items[1];
}EVERYTHING_IPC_LISTA;
#ifdef UNICODE
#define EVERYTHING_IPC_COPYDATAQUERY EVERYTHING_IPC_COPYDATAQUERYW
#define EVERYTHING_IPC_ITEMFILENAME EVERYTHING_IPC_ITEMFILENAMEW
#define EVERYTHING_IPC_ITEMPATH EVERYTHING_IPC_ITEMPATHW
#define EVERYTHING_IPC_QUERY EVERYTHING_IPC_QUERYW
#define EVERYTHING_IPC_ITEM EVERYTHING_IPC_ITEMW
#define EVERYTHING_IPC_LIST EVERYTHING_IPC_LISTW
#else
#define EVERYTHING_IPC_COPYDATAQUERY EVERYTHING_IPC_COPYDATAQUERYA
#define EVERYTHING_IPC_ITEMFILENAME EVERYTHING_IPC_ITEMFILENAMEA
#define EVERYTHING_IPC_ITEMPATH EVERYTHING_IPC_ITEMPATHA
#define EVERYTHING_IPC_QUERY EVERYTHING_IPC_QUERYA
#define EVERYTHING_IPC_ITEM EVERYTHING_IPC_ITEMA
#define EVERYTHING_IPC_LIST EVERYTHING_IPC_LISTA
#endif
// restore packing
#pragma pack(pop)
// end extern C
#ifdef __cplusplus
}
#endif
#endif // _EVERYTHING_H_

View File

@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dll", "dll.vcxproj", "{7C90030E-6EDB-445E-A61B-5540B7355C59}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7C90030E-6EDB-445E-A61B-5540B7355C59}.Debug|Win32.ActiveCfg = Debug|x64
{7C90030E-6EDB-445E-A61B-5540B7355C59}.Debug|Win32.Build.0 = Debug|x64
{7C90030E-6EDB-445E-A61B-5540B7355C59}.Debug|x64.ActiveCfg = Debug|x64
{7C90030E-6EDB-445E-A61B-5540B7355C59}.Debug|x64.Build.0 = Debug|x64
{7C90030E-6EDB-445E-A61B-5540B7355C59}.Release|Win32.ActiveCfg = Release|Win32
{7C90030E-6EDB-445E-A61B-5540B7355C59}.Release|Win32.Build.0 = Release|Win32
{7C90030E-6EDB-445E-A61B-5540B7355C59}.Release|x64.ActiveCfg = Release|x64
{7C90030E-6EDB-445E-A61B-5540B7355C59}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,291 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7C90030E-6EDB-445E-A61B-5540B7355C59}</ProjectGuid>
<RootNamespace>dll</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v90</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v90</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v90</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v90</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir>
<IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</IgnoreImportLibrary>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
<IgnoreImportLibrary Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</IgnoreImportLibrary>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BZ_NO_STDIO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<OutputFile>$(OutDir)Everything.dll</OutputFile>
<ModuleDefinitionFile>
</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
<SubSystem>Console</SubSystem>
<StackReserveSize>0</StackReserveSize>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<Manifest>
<AdditionalManifestFiles>%(AdditionalManifestFiles)</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>ComCtl32.lib;UxTheme.lib;Ws2_32.lib;shlwapi.lib;ole32.lib;htmlhelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)Everything.dll</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)dll.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX64</TargetMachine>
</Link>
<Manifest>
<AdditionalManifestFiles>%(AdditionalManifestFiles)</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>false</OmitFramePointers>
<WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BZ_NO_STDIO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>Sync</ExceptionHandling>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<FloatingPointModel>Fast</FloatingPointModel>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<CallingConvention>Cdecl</CallingConvention>
<CompileAs>CompileAsC</CompileAs>
</ClCompile>
<PreLinkEvent>
<Command>
</Command>
</PreLinkEvent>
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
<Link>
<ShowProgress>NotSet</ShowProgress>
<OutputFile>$(OutDir)Everything.dll</OutputFile>
<AdditionalManifestDependencies>%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>everything.def</ModuleDefinitionFile>
<GenerateDebugInformation>false</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
<SubSystem>Windows</SubSystem>
<StackReserveSize>0</StackReserveSize>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LinkTimeCodeGeneration>
</LinkTimeCodeGeneration>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<Manifest>
<AdditionalManifestFiles>%(AdditionalManifestFiles)</AdditionalManifestFiles>
<SuppressStartupBanner>false</SuppressStartupBanner>
<VerboseOutput>false</VerboseOutput>
</Manifest>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>false</OmitFramePointers>
<WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling>
</ExceptionHandling>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<FloatingPointModel>Fast</FloatingPointModel>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
<CompileAs>CompileAsC</CompileAs>
</ClCompile>
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
<Link>
<AdditionalDependencies>comctl32.lib;UxTheme.lib;Ws2_32.lib;HTMLHelp.lib;msimg32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ShowProgress>NotSet</ShowProgress>
<OutputFile>$(OutDir)Everything.dll</OutputFile>
<AdditionalManifestDependencies>%(AdditionalManifestDependencies)</AdditionalManifestDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LinkTimeCodeGeneration>
</LinkTimeCodeGeneration>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX64</TargetMachine>
</Link>
<Manifest>
<AdditionalManifestFiles>%(AdditionalManifestFiles)</AdditionalManifestFiles>
<SuppressStartupBanner>false</SuppressStartupBanner>
<VerboseOutput>false</VerboseOutput>
</Manifest>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Everything.c" />
</ItemGroup>
<ItemGroup>
<None Include="Everything.def" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Everything.h" />
<ClInclude Include="Everything_IPC.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="src">
<UniqueIdentifier>{072e536f-0b4e-4b52-bbf4-45486ca2a90b}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Everything.c">
<Filter>src</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Everything.def">
<Filter>src</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Everything.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="Everything_IPC.h">
<Filter>src</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net35" />
</packages>

View File

@ -0,0 +1,12 @@
{
"ID":"D2D2C23B084D411DB66FE0C79D6C2A6E",
"ActionKeyword":"f",
"Name":"Everything",
"Description":"Search Everything",
"Author":"qianlifeng,orzfly",
"Version":"1.1.0",
"Language":"csharp",
"Website":"http://www.getwox.com",
"IcoPath":"Images\\find.png",
"ExecuteFileName":"Wox.Plugin.Everything.dll"
}

Binary file not shown.

Binary file not shown.

View File

@ -53,8 +53,7 @@ namespace Wox.Plugin.Folder
public List<Result> Query(Query query)
{
if(string.IsNullOrEmpty(query.RawQuery)) return new List<Result>();
string input = query.RawQuery.ToLower();
string input = query.Search.ToLower();
List<FolderLink> userFolderLinks = FolderStorage.Instance.FolderLinks.Where(
x => x.Nickname.StartsWith(input, StringComparison.OrdinalIgnoreCase)).ToList();

View File

@ -13,8 +13,6 @@ namespace Wox.Plugin.PluginIndicator
public List<Result> Query(Query query)
{
List<Result> results = new List<Result>();
if (string.IsNullOrEmpty(query.RawQuery)) return results;
if (allPlugins.Count == 0)
{
allPlugins = context.API.GetAllPlugins().Where(o => !PluginManager.IsSystemPlugin(o.Metadata)).ToList();
@ -22,7 +20,7 @@ namespace Wox.Plugin.PluginIndicator
foreach (PluginMetadata metadata in allPlugins.Select(o => o.Metadata))
{
if (metadata.ActionKeyword.StartsWith(query.RawQuery))
if (metadata.ActionKeyword.StartsWith(query.Search))
{
PluginMetadata metadataCopy = metadata;
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == metadataCopy.ID);
@ -47,18 +45,18 @@ namespace Wox.Plugin.PluginIndicator
}
}
results.AddRange(UserSettingStorage.Instance.WebSearches.Where(o => o.ActionWord.StartsWith(query.RawQuery) && o.Enabled).Select(n => new Result()
{
Title = n.ActionWord,
SubTitle = string.Format("Activate {0} web search", n.ActionWord),
Score = 100,
IcoPath = "Images/work.png",
Action = (c) =>
{
context.API.ChangeQuery(n.ActionWord + " ");
return false;
}
}));
//results.AddRange(UserSettingStorage.Instance.WebSearches.Where(o => o.ActionWord.StartsWith(query.Search) && o.Enabled).Select(n => new Result()
//{
// Title = n.ActionWord,
// SubTitle = string.Format("Activate {0} web search", n.ActionWord),
// Score = 100,
// IcoPath = "Images/work.png",
// Action = (c) =>
// {
// context.API.ChangeQuery(n.ActionWord + " ");
// return false;
// }
//}));
return results;
}

View File

@ -10,59 +10,37 @@ using Newtonsoft.Json;
namespace Wox.Plugin.PluginManagement
{
public class WoxPluginResult
{
public string plugin_file;
public string description;
public int liked_count;
public string name;
public string version;
}
public class Main : IPlugin
{
private static string APIBASE = "https://api.getwox.com";
private static string PluginPath = AppDomain.CurrentDomain.BaseDirectory + "Plugins";
private static string PluginConfigName = "plugin.json";
private static string pluginSearchUrl = APIBASE +"/plugin/search/";
private static string pluginSearchUrl = APIBASE + "/plugin/search/";
private PluginInitContext context;
public List<Result> Query(Query query)
{
List<Result> results = new List<Result>();
if (query.ActionParameters.Count == 0)
if (string.IsNullOrEmpty(query.Search))
{
results.Add(new Result("wpm install <pluginName>", "Images\\plugin.png", "search and install wox plugins")
results.Add(new Result("install <pluginName>", "Images\\plugin.png", "search and install wox plugins")
{
Action = e =>
{
context.API.ChangeQuery("wpm install ");
return false;
}
Action = e => ChangeToInstallCommand()
});
results.Add(new Result("wpm uninstall <pluginName>", "Images\\plugin.png", "uninstall plugin")
results.Add(new Result("uninstall <pluginName>", "Images\\plugin.png", "uninstall plugin")
{
Action = e =>
{
context.API.ChangeQuery("wpm uninstall ");
return false;
}
Action = e => ChangeToUninstallCommand()
});
results.Add(new Result("wpm list", "Images\\plugin.png", "list plugins installed")
results.Add(new Result("list", "Images\\plugin.png", "list plugins installed")
{
Action = e =>
{
context.API.ChangeQuery("wpm list");
return false;
}
Action = e => ChangeToListCommand()
});
return results;
}
if (query.ActionParameters.Count > 0)
if (!string.IsNullOrEmpty(query.FirstSearch))
{
bool hit = false;
switch (query.ActionParameters[0].ToLower())
switch (query.FirstSearch.ToLower())
{
case "list":
hit = true;
@ -71,51 +49,39 @@ namespace Wox.Plugin.PluginManagement
case "uninstall":
hit = true;
results = ListUnInstalledPlugins(query);
results = UnInstallPlugins(query);
break;
case "install":
hit = true;
if (query.ActionParameters.Count > 1)
if (!string.IsNullOrEmpty(query.SecondSearch))
{
results = InstallPlugin(query);
results = InstallPlugin(query.SecondSearch);
}
break;
}
if (!hit)
{
if ("install".Contains(query.ActionParameters[0].ToLower()))
if ("install".Contains(query.FirstSearch.ToLower()))
{
results.Add(new Result("wpm install <pluginName>", "Images\\plugin.png", "search and install wox plugins")
results.Add(new Result("install <pluginName>", "Images\\plugin.png", "search and install wox plugins")
{
Action = e =>
{
context.API.ChangeQuery("wpm install ");
return false;
}
Action = e => ChangeToInstallCommand()
});
}
if ("uninstall".Contains(query.ActionParameters[0].ToLower()))
if ("uninstall".Contains(query.FirstSearch.ToLower()))
{
results.Add(new Result("wpm uninstall <pluginName>", "Images\\plugin.png", "uninstall plugin")
results.Add(new Result("uninstall <pluginName>", "Images\\plugin.png", "uninstall plugin")
{
Action = e =>
{
context.API.ChangeQuery("wpm uninstall ");
return false;
}
Action = e => ChangeToUninstallCommand()
});
}
if ("list".Contains(query.ActionParameters[0].ToLower()))
if ("list".Contains(query.FirstSearch.ToLower()))
{
results.Add(new Result("wpm list", "Images\\plugin.png", "list plugins installed")
results.Add(new Result("list", "Images\\plugin.png", "list plugins installed")
{
Action = e =>
{
context.API.ChangeQuery("wpm list");
return false;
}
Action = e => ChangeToListCommand()
});
}
}
@ -124,10 +90,49 @@ namespace Wox.Plugin.PluginManagement
return results;
}
private List<Result> InstallPlugin(Query query)
private bool ChangeToListCommand()
{
if (context.CurrentPluginMetadata.ActionKeyword == "*")
{
context.API.ChangeQuery("list ");
}
else
{
context.API.ChangeQuery(string.Format("{0} list ", context.CurrentPluginMetadata.ActionKeyword));
}
return false;
}
private bool ChangeToUninstallCommand()
{
if (context.CurrentPluginMetadata.ActionKeyword == "*")
{
context.API.ChangeQuery("uninstall ");
}
else
{
context.API.ChangeQuery(string.Format("{0} uninstall ", context.CurrentPluginMetadata.ActionKeyword));
}
return false;
}
private bool ChangeToInstallCommand()
{
if (context.CurrentPluginMetadata.ActionKeyword == "*")
{
context.API.ChangeQuery("install ");
}
else
{
context.API.ChangeQuery(string.Format("{0} install ", context.CurrentPluginMetadata.ActionKeyword));
}
return false;
}
private List<Result> InstallPlugin(string queryPluginName)
{
List<Result> results = new List<Result>();
HttpWebResponse response = HttpRequest.CreateGetHttpResponse(pluginSearchUrl + query.ActionParameters[1], context.Proxy);
HttpWebResponse response = HttpRequest.CreateGetHttpResponse(pluginSearchUrl + queryPluginName, context.Proxy);
Stream s = response.GetResponseStream();
if (s != null)
{
@ -140,7 +145,7 @@ namespace Wox.Plugin.PluginManagement
}
catch
{
context.API.ShowMsg("Coundn't parse api search results", "Please update your Wox!",string.Empty);
context.API.ShowMsg("Coundn't parse api search results", "Please update your Wox!", string.Empty);
return results;
}
@ -194,19 +199,19 @@ namespace Wox.Plugin.PluginManagement
return results;
}
private List<Result> ListUnInstalledPlugins(Query query)
private List<Result> UnInstallPlugins(Query query)
{
List<Result> results = new List<Result>();
List<PluginMetadata> allInstalledPlugins = ParseUserPlugins();
if (query.ActionParameters.Count > 1)
List<PluginMetadata> allInstalledPlugins = context.API.GetAllPlugins().Select(o => o.Metadata).ToList();
if (!string.IsNullOrEmpty(query.SecondSearch))
{
string pluginName = query.ActionParameters[1];
allInstalledPlugins =
allInstalledPlugins.Where(o => o.Name.ToLower().Contains(pluginName.ToLower())).ToList();
allInstalledPlugins.Where(o => o.Name.ToLower().Contains(query.SecondSearch.ToLower())).ToList();
}
foreach (PluginMetadata plugin in allInstalledPlugins)
{
var plugin1 = plugin;
results.Add(new Result()
{
Title = plugin.Name,
@ -214,7 +219,7 @@ namespace Wox.Plugin.PluginManagement
IcoPath = plugin.FullIcoPath,
Action = e =>
{
UnInstalledPlugins(plugin);
UnInstallPlugin(plugin1);
return false;
}
});
@ -222,7 +227,7 @@ namespace Wox.Plugin.PluginManagement
return results;
}
private void UnInstalledPlugins(PluginMetadata plugin)
private void UnInstallPlugin(PluginMetadata plugin)
{
string content = string.Format("Do you want to uninstall following plugin?\r\n\r\nName: {0}\r\nVersion: {1}\r\nAuthor: {2}", plugin.Name, plugin.Version, plugin.Author);
if (MessageBox.Show(content, "Wox", MessageBoxButtons.YesNo) == DialogResult.Yes)
@ -235,7 +240,7 @@ namespace Wox.Plugin.PluginManagement
private List<Result> ListInstalledPlugins()
{
List<Result> results = new List<Result>();
foreach (PluginMetadata plugin in ParseUserPlugins())
foreach (PluginMetadata plugin in context.API.GetAllPlugins().Select(o => o.Metadata))
{
results.Add(new Result()
{
@ -247,61 +252,6 @@ namespace Wox.Plugin.PluginManagement
return results;
}
private static List<PluginMetadata> ParseUserPlugins()
{
List<PluginMetadata> pluginMetadatas = new List<PluginMetadata>();
if (!Directory.Exists(PluginPath))
Directory.CreateDirectory(PluginPath);
string[] directories = Directory.GetDirectories(PluginPath);
foreach (string directory in directories)
{
PluginMetadata metadata = GetMetadataFromJson(directory);
if (metadata != null) pluginMetadatas.Add(metadata);
}
return pluginMetadatas;
}
private static PluginMetadata GetMetadataFromJson(string pluginDirectory)
{
string configPath = Path.Combine(pluginDirectory, PluginConfigName);
PluginMetadata metadata;
if (!File.Exists(configPath))
{
return null;
}
try
{
metadata = JsonConvert.DeserializeObject<PluginMetadata>(File.ReadAllText(configPath));
metadata.PluginType = PluginType.User;
metadata.PluginDirectory = pluginDirectory;
}
catch (Exception)
{
string error = string.Format("Parse plugin config {0} failed: json format is not valid", configPath);
return null;
}
if (!AllowedLanguage.IsAllowed(metadata.Language))
{
string error = string.Format("Parse plugin config {0} failed: invalid language {1}", configPath,
metadata.Language);
return null;
}
if (!File.Exists(metadata.ExecuteFilePath))
{
string error = string.Format("Parse plugin config {0} failed: ExecuteFile {1} didn't exist", configPath,
metadata.ExecuteFilePath);
return null;
}
return metadata;
}
public void Init(PluginInitContext context)
{
this.context = context;

View File

@ -51,6 +51,7 @@
<Compile Include="HttpRequest.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WoxPluginResult.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj">

View File

@ -0,0 +1,11 @@
namespace Wox.Plugin.PluginManagement
{
public class WoxPluginResult
{
public string plugin_file;
public string description;
public int liked_count;
public string name;
public string version;
}
}

View File

@ -8,6 +8,7 @@ using System.Threading;
using System.Windows;
using Wox.Infrastructure;
using Wox.Plugin.Program.ProgramSources;
using IWshRuntimeLibrary;
namespace Wox.Plugin.Program
{
@ -26,9 +27,7 @@ namespace Wox.Plugin.Program
public List<Result> Query(Query query)
{
if (query.RawQuery.Trim().Length <= 1) return new List<Result>();
var fuzzyMather = FuzzyMatcher.Create(query.RawQuery);
var fuzzyMather = FuzzyMatcher.Create(query.Search);
List<Program> returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList();
returnList.ForEach(ScoreFilter);
returnList = returnList.OrderByDescending(o => o.Score).ToList();
@ -57,11 +56,40 @@ namespace Wox.Plugin.Program
return true;
},
IcoPath = "Images/cmd.png"
},
new Result()
{
Title = "Open Containing Folder",
Action = _ =>
{
context.API.HideApp();
String Path=c.ExecutePath;
//check if shortcut
if (Path.EndsWith(".lnk"))
{
//get location of shortcut
Path = ResolveShortcut(Path);
}
//get parent folder
Path=System.IO.Directory.GetParent(Path).FullName;
//open the folder
context.API.ShellRun("explorer.exe "+Path,false);
return true;
},
IcoPath = "Images/folder.png"
}
}
}).ToList();
}
static string ResolveShortcut(string filePath)
{
// IWshRuntimeLibrary is in the COM library "Windows Script Host Object Model"
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
return shortcut.TargetPath;
}
private bool MatchProgram(Program program, FuzzyMatcher matcher)
{
if ((program.Score = matcher.Evaluate(program.Title).Score) > 0) return true;

View File

@ -121,7 +121,17 @@
<Name>Wox.Plugin</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<COMReference Include="IWshRuntimeLibrary">
<Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

View File

@ -13,7 +13,7 @@ namespace Wox.Plugin.QueryHistory
public List<Result> Query(Query query)
{
var histories = QueryHistoryStorage.Instance.GetHistory();
string filter = query.GetAllRemainingParameter();
string filter = query.Search;
if (!string.IsNullOrEmpty(filter))
{
histories = histories.Where(o => o.Query.Contains(filter)).ToList();

View File

@ -26,7 +26,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Plugins\Wox.Plugin.Program\</OutputPath>
<OutputPath>..\..\Output\Release\Plugins\Wox.Plugin.QueryHistory\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>

View File

@ -34,7 +34,6 @@ namespace Wox.Plugin.Sys
public List<Result> Query(Query query)
{
if (query.RawQuery.EndsWith(" ") || query.RawQuery.Length <= 1) return new List<Result>();
if (availableResults.Count == 0)
{
LoadCommands();
@ -43,7 +42,7 @@ namespace Wox.Plugin.Sys
List<Result> results = new List<Result>();
foreach (Result availableResult in availableResults)
{
if (availableResult.Title.ToLower().StartsWith(query.RawQuery.ToLower()))
if (availableResult.Title.ToLower().StartsWith(query.Search.ToLower()))
{
results.Add(availableResult);
}

View File

@ -45,9 +45,7 @@ namespace Wox.Plugin.Url
public List<Result> Query(Query query)
{
if(string.IsNullOrEmpty(query.RawQuery)) return new List<Result>();
var raw = query.RawQuery;
var raw = query.Search;
if (IsURL(raw))
{
return new List<Result>

View File

@ -1,6 +1,6 @@
using System;
namespace Wox.Core.UserSettings
namespace Wox.Plugin.WebSearch
{
[Serializable]
public class WebSearch

View File

@ -9,7 +9,7 @@ using Wox.Plugin.WebSearch.SuggestionSources;
namespace Wox.Plugin.WebSearch
{
public class WebSearchPlugin : IPlugin, ISettingProvider,IPluginI18n
public class WebSearchPlugin : IPlugin, ISettingProvider, IPluginI18n, IInstantSearch
{
private PluginInitContext context;
@ -17,12 +17,12 @@ namespace Wox.Plugin.WebSearch
{
List<Result> results = new List<Result>();
Core.UserSettings.WebSearch webSearch =
UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.ActionName && o.Enabled);
WebSearch webSearch =
WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.FirstSearch.Trim() && o.Enabled);
if (webSearch != null)
{
string keyword = query.ActionParameters.Count > 0 ? query.GetAllRemainingParameter() : "";
string keyword = query.SecondToEndSearch;
string title = keyword;
string subtitle = "Search " + webSearch.Title;
if (string.IsNullOrEmpty(keyword))
@ -44,12 +44,12 @@ namespace Wox.Plugin.WebSearch
return true;
}
}
},true);
});
if (UserSettingStorage.Instance.EnableWebSearchSuggestion && !string.IsNullOrEmpty(keyword))
if (WebSearchStorage.Instance.EnableWebSearchSuggestion && !string.IsNullOrEmpty(keyword))
{
ISuggestionSource sugg = SuggestionSourceFactory.GetSuggestionSource(
UserSettingStorage.Instance.WebSearchSuggestionSource);
WebSearchStorage.Instance.WebSearchSuggestionSource);
if (sugg != null)
{
var result = sugg.GetSuggestions(keyword);
@ -80,8 +80,8 @@ namespace Wox.Plugin.WebSearch
{
this.context = context;
if (UserSettingStorage.Instance.WebSearches == null)
UserSettingStorage.Instance.WebSearches = UserSettingStorage.Instance.LoadDefaultWebSearches();
if (WebSearchStorage.Instance.WebSearches == null)
WebSearchStorage.Instance.WebSearches = WebSearchStorage.Instance.LoadDefaultWebSearches();
}
#region ISettingProvider Members
@ -97,5 +97,16 @@ namespace Wox.Plugin.WebSearch
{
return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Languages");
}
public bool IsInstantSearch(string query)
{
var strings = query.Split(' ');
if (strings.Length > 1)
{
return WebSearchStorage.Instance.EnableWebSearchSuggestion &&
WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == strings[0] && o.Enabled);
}
return false;
}
}
}

View File

@ -14,7 +14,7 @@ namespace Wox.Plugin.WebSearch
private string defaultWebSearchImageDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Images\\websearch");
private WebSearchesSetting settingWindow;
private bool update;
private Core.UserSettings.WebSearch updateWebSearch;
private WebSearch updateWebSearch;
private PluginInitContext context;
public WebSearchSetting(WebSearchesSetting settingWidow,PluginInitContext context)
@ -24,9 +24,9 @@ namespace Wox.Plugin.WebSearch
InitializeComponent();
}
public void UpdateItem(Core.UserSettings.WebSearch webSearch)
public void UpdateItem(WebSearch webSearch)
{
updateWebSearch = UserSettingStorage.Instance.WebSearches.FirstOrDefault(o => o == webSearch);
updateWebSearch = WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o == webSearch);
if (updateWebSearch == null || string.IsNullOrEmpty(updateWebSearch.Url))
{
@ -91,13 +91,13 @@ namespace Wox.Plugin.WebSearch
if (!update)
{
if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == action))
if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == action))
{
string warning = context.API.GetTranslation("wox_plugin_websearch_action_keyword_exist");
MessageBox.Show(warning);
return;
}
UserSettingStorage.Instance.WebSearches.Add(new Core.UserSettings.WebSearch()
WebSearchStorage.Instance.WebSearches.Add(new WebSearch()
{
ActionWord = action,
Enabled = cbEnable.IsChecked ?? false,
@ -110,7 +110,7 @@ namespace Wox.Plugin.WebSearch
}
else
{
if (UserSettingStorage.Instance.WebSearches.Exists(o => o.ActionWord == action && o != updateWebSearch))
if (WebSearchStorage.Instance.WebSearches.Exists(o => o.ActionWord == action && o != updateWebSearch))
{
string warning = context.API.GetTranslation("wox_plugin_websearch_action_keyword_exist");
MessageBox.Show(warning);

View File

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Newtonsoft.Json;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Storage;
namespace Wox.Plugin.WebSearch
{
public class WebSearchStorage :JsonStrorage<WebSearchStorage>
{
[JsonProperty]
public List<WebSearch> WebSearches { get; set; }
[JsonProperty]
public bool EnableWebSearchSuggestion { get; set; }
[JsonProperty]
public string WebSearchSuggestionSource { get; set; }
protected override string ConfigFolder
{
get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
}
protected override string ConfigName
{
get { return "setting"; }
}
protected override WebSearchStorage LoadDefault()
{
WebSearches = LoadDefaultWebSearches();
return this;
}
public List<WebSearch> LoadDefaultWebSearches()
{
List<WebSearch> webSearches = new List<WebSearch>();
WebSearch googleWebSearch = new WebSearch()
{
Title = "Google",
ActionWord = "g",
IconPath = @"Images\websearch\google.png",
Url = "https://www.google.com/search?q={q}",
Enabled = true
};
webSearches.Add(googleWebSearch);
WebSearch wikiWebSearch = new WebSearch()
{
Title = "Wikipedia",
ActionWord = "wiki",
IconPath = @"Images\websearch\wiki.png",
Url = "http://en.wikipedia.org/wiki/{q}",
Enabled = true
};
webSearches.Add(wikiWebSearch);
WebSearch findIcon = new WebSearch()
{
Title = "FindIcon",
ActionWord = "findicon",
IconPath = @"Images\websearch\pictures.png",
Url = "http://findicons.com/search/{q}",
Enabled = true
};
webSearches.Add(findIcon);
return webSearches;
}
}
}

View File

@ -24,9 +24,9 @@ namespace Wox.Plugin.WebSearch
private void Setting_Loaded(object sender, RoutedEventArgs e)
{
webSearchView.ItemsSource = UserSettingStorage.Instance.WebSearches;
cbEnableWebSearchSuggestion.IsChecked = UserSettingStorage.Instance.EnableWebSearchSuggestion;
comboBoxSuggestionSource.Visibility = UserSettingStorage.Instance.EnableWebSearchSuggestion
webSearchView.ItemsSource = WebSearchStorage.Instance.WebSearches;
cbEnableWebSearchSuggestion.IsChecked = WebSearchStorage.Instance.EnableWebSearchSuggestion;
comboBoxSuggestionSource.Visibility = WebSearchStorage.Instance.EnableWebSearchSuggestion
? Visibility.Visible
: Visibility.Collapsed;
@ -35,7 +35,7 @@ namespace Wox.Plugin.WebSearch
new ComboBoxItem() {Content = "Google"},
new ComboBoxItem() {Content = "Baidu"},
};
ComboBoxItem selected = items.FirstOrDefault(o => o.Content.ToString() == UserSettingStorage.Instance.WebSearchSuggestionSource);
ComboBoxItem selected = items.FirstOrDefault(o => o.Content.ToString() == WebSearchStorage.Instance.WebSearchSuggestionSource);
if (selected == null)
{
selected = items[0];
@ -58,14 +58,14 @@ namespace Wox.Plugin.WebSearch
private void btnDeleteWebSearch_OnClick(object sender, RoutedEventArgs e)
{
Core.UserSettings.WebSearch selectedWebSearch = webSearchView.SelectedItem as Core.UserSettings.WebSearch;
WebSearch selectedWebSearch = webSearchView.SelectedItem as WebSearch;
if (selectedWebSearch != null)
{
string msg = string.Format(context.API.GetTranslation("wox_plugin_websearch_delete_warning"),selectedWebSearch.Title);
if (MessageBox.Show(msg,string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
UserSettingStorage.Instance.WebSearches.Remove(selectedWebSearch);
WebSearchStorage.Instance.WebSearches.Remove(selectedWebSearch);
webSearchView.Items.Refresh();
}
}
@ -78,7 +78,7 @@ namespace Wox.Plugin.WebSearch
private void btnEditWebSearch_OnClick(object sender, RoutedEventArgs e)
{
Core.UserSettings.WebSearch selectedWebSearch = webSearchView.SelectedItem as Core.UserSettings.WebSearch;
WebSearch selectedWebSearch = webSearchView.SelectedItem as WebSearch;
if (selectedWebSearch != null)
{
WebSearchSetting webSearch = new WebSearchSetting(this,context);
@ -95,23 +95,22 @@ namespace Wox.Plugin.WebSearch
private void CbEnableWebSearchSuggestion_OnChecked(object sender, RoutedEventArgs e)
{
comboBoxSuggestionSource.Visibility = Visibility.Visible;
UserSettingStorage.Instance.EnableWebSearchSuggestion = true;
UserSettingStorage.Instance.Save();
WebSearchStorage.Instance.EnableWebSearchSuggestion = true;
WebSearchStorage.Instance.Save();
}
private void CbEnableWebSearchSuggestion_OnUnchecked(object sender, RoutedEventArgs e)
{
comboBoxSuggestionSource.Visibility = Visibility.Collapsed;
UserSettingStorage.Instance.EnableWebSearchSuggestion = false;
UserSettingStorage.Instance.Save();
WebSearchStorage.Instance.EnableWebSearchSuggestion = false;
WebSearchStorage.Instance.Save();
}
private void ComboBoxSuggestionSource_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
UserSettingStorage.Instance.WebSearchSuggestionSource =
((ComboBoxItem) e.AddedItems[0]).Content.ToString();
WebSearchStorage.Instance.WebSearchSuggestionSource = ((ComboBoxItem) e.AddedItems[0]).Content.ToString();
UserSettingStorage.Instance.Save();
}
}

View File

@ -56,6 +56,7 @@
<Compile Include="SuggestionSources\Google.cs" />
<Compile Include="SuggestionSources\ISuggestionSource.cs" />
<Compile Include="SuggestionSources\SuggestionSourceFactory.cs" />
<Compile Include="WebSearch.cs" />
<Compile Include="WebSearchesSetting.xaml.cs">
<DependentUpon>WebSearchesSetting.xaml</DependentUpon>
</Compile>
@ -63,6 +64,7 @@
<Compile Include="WebSearchSetting.xaml.cs">
<DependentUpon>WebSearchSetting.xaml</DependentUpon>
</Compile>
<Compile Include="WebSearchStorage.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Languages\en.xaml">

View File

@ -19,6 +19,11 @@ namespace Wox.Core.Plugin
/// </summary>
public static class PluginManager
{
public const string ActionKeywordWildcardSign = "*";
private static List<PluginMetadata> pluginMetadatas;
private static List<IInstantSearch> instantSearches = new List<IInstantSearch>();
public static String DebuggerMode { get; private set; }
public static IPublicAPI API { get; private set; }
@ -29,7 +34,6 @@ namespace Wox.Core.Plugin
/// </summary>
private static List<string> pluginDirectories = new List<string>();
private static void SetupPluginDirectories()
{
pluginDirectories.Add(PluginDirectory);
@ -70,7 +74,7 @@ namespace Wox.Core.Plugin
API = api;
plugins.Clear();
List<PluginMetadata> pluginMetadatas = PluginConfig.Parse(pluginDirectories);
pluginMetadatas = PluginConfig.Parse(pluginDirectories);
plugins.AddRange(new CSharpPluginLoader().LoadPlugin(pluginMetadatas));
plugins.AddRange(new JsonRPCPluginLoader<PythonPlugin>().LoadPlugin(pluginMetadatas));
@ -93,6 +97,8 @@ namespace Wox.Core.Plugin
}
});
}
LoadInstantSearches();
}
public static void InstallPlugin(string path)
@ -101,28 +107,36 @@ namespace Wox.Core.Plugin
}
public static void Query(Query query)
{
if (!string.IsNullOrEmpty(query.RawQuery.Trim()))
{
QueryDispatcher.QueryDispatcher.Dispatch(query);
}
}
public static List<PluginPair> AllPlugins
{
get
{
return plugins;
return plugins.OrderBy(o => o.Metadata.Name).ToList();
}
}
public static bool IsUserPluginQuery(Query query)
{
if (string.IsNullOrEmpty(query.ActionName)) return false;
if (string.IsNullOrEmpty(query.RawQuery)) return false;
var strings = query.RawQuery.Split(' ');
if(strings.Length == 1) return false;
return plugins.Any(o => o.Metadata.PluginType == PluginType.User && o.Metadata.ActionKeyword == query.ActionName);
var actionKeyword = strings[0].Trim();
if (string.IsNullOrEmpty(actionKeyword)) return false;
return plugins.Any(o => o.Metadata.PluginType == PluginType.User && o.Metadata.ActionKeyword == actionKeyword);
}
public static bool IsSystemPlugin(PluginMetadata metadata)
{
return metadata.ActionKeyword == "*";
return metadata.ActionKeyword == ActionKeywordWildcardSign;
}
public static void ActivatePluginDebugger(string path)
@ -130,6 +144,46 @@ namespace Wox.Core.Plugin
DebuggerMode = path;
}
public static bool IsInstantSearch(string query)
{
return LoadInstantSearches().Any(o => o.IsInstantSearch(query));
}
private static List<IInstantSearch> LoadInstantSearches()
{
if (instantSearches.Count > 0) return instantSearches;
List<PluginMetadata> CSharpPluginMetadatas = pluginMetadatas.Where(o => o.Language.ToUpper() == AllowedLanguage.CSharp.ToUpper()).ToList();
foreach (PluginMetadata metadata in CSharpPluginMetadatas)
{
try
{
Assembly asm = Assembly.Load(AssemblyName.GetAssemblyName(metadata.ExecuteFilePath));
List<Type> types = asm.GetTypes().Where(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Contains(typeof(IInstantSearch))).ToList();
if (types.Count == 0)
{
continue;
}
foreach (Type type in types)
{
instantSearches.Add(Activator.CreateInstance(type) as IInstantSearch);
}
}
catch (System.Exception e)
{
Log.Error(string.Format("Couldn't load plugin {0}: {1}", metadata.Name, e.Message));
#if (DEBUG)
{
throw;
}
#endif
}
}
return instantSearches;
}
/// <summary>
/// get specified plugin, return null if not found
/// </summary>

View File

@ -3,18 +3,20 @@ namespace Wox.Core.Plugin.QueryDispatcher
{
internal static class QueryDispatcher
{
private static IQueryDispatcher pluginCmd = new UserPluginQueryDispatcher();
private static IQueryDispatcher systemCmd = new SystemPluginQueryDispatcher();
private static readonly IQueryDispatcher UserPluginDispatcher = new UserPluginQueryDispatcher();
private static readonly IQueryDispatcher SystemPluginDispatcher = new SystemPluginQueryDispatcher();
public static void Dispatch(Wox.Plugin.Query query)
{
if (PluginManager.IsUserPluginQuery(query))
{
pluginCmd.Dispatch(query);
query.Search = query.RawQuery.Substring(query.RawQuery.IndexOf(' ') + 1);
UserPluginDispatcher.Dispatch(query);
}
else
{
systemCmd.Dispatch(query);
query.Search = query.RawQuery;
SystemPluginDispatcher.Dispatch(query);
}
}
}

View File

@ -5,7 +5,6 @@ using Wox.Core.Exception;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Logger;
using Wox.Plugin;
//using Wox.Plugin.SystemPlugins;
namespace Wox.Core.Plugin.QueryDispatcher
{
@ -24,7 +23,10 @@ namespace Wox.Core.Plugin.QueryDispatcher
try
{
List<Result> results = pair1.Plugin.Query(query);
results.ForEach(o => { o.AutoAjustScore = true; });
results.ForEach(o =>
{
o.PluginID = pair1.Metadata.ID;
});
PluginManager.API.PushResults(query, pair1.Metadata, results);
}

View File

@ -13,7 +13,7 @@ namespace Wox.Core.Plugin.QueryDispatcher
{
public void Dispatch(Query query)
{
PluginPair userPlugin = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.ActionName);
PluginPair userPlugin = PluginManager.AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.GetActionKeyword());
if (userPlugin != null && !string.IsNullOrEmpty(userPlugin.Metadata.ActionKeyword))
{
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == userPlugin.Metadata.ID);
@ -29,7 +29,11 @@ namespace Wox.Core.Plugin.QueryDispatcher
try
{
List<Result> results = userPlugin.Plugin.Query(query) ?? new List<Result>();
PluginManager.API.PushResults(query,userPlugin.Metadata,results);
results.ForEach(o =>
{
o.PluginID = userPlugin.Metadata.ID;
});
PluginManager.API.PushResults(query, userPlugin.Metadata, results);
}
catch (System.Exception e)
{

View File

@ -2,6 +2,8 @@
=====
* Handle Query
* Define Wox exceptions
* Manage Plugins (including system plugin and user plugin)
* Manage Themes
* Manage i18n
* Manage Update and version

View File

@ -102,7 +102,7 @@ namespace Wox.Core.Theme
.Where(filePath => filePath.EndsWith(".xaml") && !filePath.EndsWith("Base.xaml"))
.ToList());
}
return themes;
return themes.OrderBy(o => o).ToList();
}
private string GetThemePath(string themeName)

View File

@ -39,7 +39,7 @@ namespace Wox.Core.UI
foreach (var pluginI18n in pluginI18ns)
{
string languageFile = InternationalizationManager.Internationalization.GetLanguageFile(
string languageFile = InternationalizationManager.Instance.GetLanguageFile(
((IPluginI18n)Activator.CreateInstance(pluginI18n)).GetLanguagesFolder());
if (!string.IsNullOrEmpty(languageFile))
{

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Wox.Update
namespace Wox.Core.Updater
{
public class Release
{
@ -12,5 +7,10 @@ namespace Wox.Update
public string download_link1 { get; set; }
public string download_link2 { get; set; }
public string description { get; set; }
public override string ToString()
{
return version;
}
}
}

View File

@ -1,11 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wox.Core.Exception;
namespace Wox.Core.Version
namespace Wox.Core.Updater
{
public class SemanticVersion : IComparable
{

View File

@ -1,11 +1,19 @@

using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Windows.Forms;
using System.Windows.Threading;
using NAppUpdate.Framework;
using NAppUpdate.Framework.Common;
using NAppUpdate.Framework.Sources;
using NAppUpdate.Framework.Tasks;
using Newtonsoft.Json;
using Wox.Core.i18n;
using Wox.Core.UserSettings;
using Wox.Infrastructure.Http;
using Wox.Infrastructure.Logger;
namespace Wox.Core.Updater
@ -13,6 +21,15 @@ namespace Wox.Core.Updater
public class UpdaterManager
{
private static UpdaterManager instance;
private const string VersionCheckURL = "https://api.getwox.com/release/latest/";
//private const string UpdateFeedURL = "http://upgrade.getwox.com/update.xml";
private const string UpdateFeedURL = "http://127.0.0.1:8888/update.xml";
private static SemanticVersion currentVersion;
public event EventHandler PrepareUpdateReady;
public event EventHandler UpdateError;
public Release NewRelease { get; set; }
public static UpdaterManager Instance
{
@ -31,11 +48,61 @@ namespace Wox.Core.Updater
UpdateManager.Instance.UpdateSource = GetUpdateSource();
}
public SemanticVersion CurrentVersion
{
get
{
if (currentVersion == null)
{
currentVersion = new SemanticVersion(Assembly.GetExecutingAssembly().GetName().Version);
}
return currentVersion;
}
}
private bool IsNewerThanCurrent(Release release)
{
if (release == null) return false;
return new SemanticVersion(release.version) > CurrentVersion;
}
public List<string> GetAvailableUpdateFiles()
{
List<string> files = new List<string>();
foreach (var task in UpdateManager.Instance.Tasks)
{
if (task is FileUpdateTask)
{
files.Add(((FileUpdateTask)task).LocalPath);
}
}
return files;
}
public void CheckUpdate()
{
// Get a local pointer to the UpdateManager instance
UpdateManager updManager = UpdateManager.Instance;
string json = HttpRequest.Get(VersionCheckURL, HttpProxy.Instance);
if (!string.IsNullOrEmpty(json))
{
try
{
NewRelease = JsonConvert.DeserializeObject<Release>(json);
if (IsNewerThanCurrent(NewRelease) && !UserSettingStorage.Instance.DontPromptUpdateMsg)
{
StartUpdate();
}
}
catch (System.Exception e)
{
Log.Error(e);
}
}
}
private void StartUpdate()
{
UpdateManager updManager = UpdateManager.Instance;
updManager.BeginCheckForUpdates(asyncResult =>
{
if (asyncResult.IsCompleted)
@ -43,9 +110,9 @@ namespace Wox.Core.Updater
// still need to check for caught exceptions if any and rethrow
try
{
((UpdateProcessAsyncResult) asyncResult).EndInvoke();
((UpdateProcessAsyncResult)asyncResult).EndInvoke();
}
catch(System.Exception e)
catch (System.Exception e)
{
Log.Error(e);
updManager.CleanUp();
@ -55,7 +122,6 @@ namespace Wox.Core.Updater
// No updates were found, or an error has occured. We might want to check that...
if (updManager.UpdatesAvailable == 0)
{
MessageBox.Show("All is up to date!");
return;
}
}
@ -63,54 +129,52 @@ namespace Wox.Core.Updater
updManager.BeginPrepareUpdates(result =>
{
((UpdateProcessAsyncResult)result).EndInvoke();
OnPrepareUpdateReady();
}, null);
}, null);
}
public void CleanUp()
{
UpdateManager.Instance.CleanUp();
}
public void ApplyUpdates()
{
// ApplyUpdates is a synchronous method by design. Make sure to save all user work before calling
// it as it might restart your application
// get out of the way so the console window isn't obstructed
try
{
updManager.ApplyUpdates(true,false,true);
UpdateManager.Instance.ApplyUpdates(true, UserSettingStorage.Instance.EnableUpdateLog, false);
}
catch
catch (System.Exception e)
{
// this.WindowState = WindowState.Normal;
MessageBox.Show(
"An error occurred while trying to install software updates");
string updateError = InternationalizationManager.Instance.GetTranslation("update_wox_update_error");
Log.Error(e);
MessageBox.Show(updateError);
OnUpdateError();
}
updManager.CleanUp();
}, null);
}, null);
}
public void Reinstall()
{
UpdateManager.Instance.ReinstateIfRestarted();
}
private void OnPrepareUpdatesCompleted(bool obj)
{
UpdateManager updManager = UpdateManager.Instance;
DialogResult dr = MessageBox.Show(
"Updates are ready to install. Do you wish to install them now?",
"Software updates ready",
MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
// This is a synchronous method by design, make sure to save all user work before calling
// it as it might restart your application
updManager.ApplyUpdates(true,true,true);
}
UpdateManager.Instance.CleanUp();
}
private IUpdateSource GetUpdateSource()
{
// Normally this would be a web based source.
// But for the demo app, we prepare an in-memory source.
var source = new NAppUpdate.Framework.Sources.SimpleWebSource("http://127.0.0.1:8888/Update.xml");
var source = new WoxUpdateSource(UpdateFeedURL, HttpRequest.GetWebProxy(HttpProxy.Instance));
return source;
}
protected virtual void OnPrepareUpdateReady()
{
var handler = PrepareUpdateReady;
if (handler != null) handler(this, EventArgs.Empty);
}
protected virtual void OnUpdateError()
{
var handler = UpdateError;
if (handler != null) handler(this, EventArgs.Empty);
}
}
}

View File

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using NAppUpdate.Framework.Common;
using NAppUpdate.Framework.Sources;
using NAppUpdate.Framework.Utils;
namespace Wox.Core.Updater
{
internal class WoxUpdateSource : IUpdateSource
{
public IWebProxy Proxy { get; set; }
public string FeedUrl { get; set; }
public WoxUpdateSource(string feedUrl,IWebProxy proxy)
{
this.FeedUrl = feedUrl;
this.Proxy = proxy;
}
private void TryResolvingHost()
{
Uri uri = new Uri(this.FeedUrl);
try
{
Dns.GetHostEntry(uri.Host);
}
catch (System.Exception ex)
{
throw new WebException(string.Format("Failed to resolve {0}. Check your connectivity.", (object)uri.Host), WebExceptionStatus.ConnectFailure);
}
}
public string GetUpdatesFeed()
{
this.TryResolvingHost();
string str = string.Empty;
WebRequest webRequest = WebRequest.Create(this.FeedUrl);
webRequest.Method = "GET";
webRequest.Proxy = this.Proxy;
using (WebResponse response = webRequest.GetResponse())
{
Stream responseStream = response.GetResponseStream();
if (responseStream != null)
{
using (StreamReader streamReader = new StreamReader(responseStream, true))
str = streamReader.ReadToEnd();
}
}
return str;
}
public bool GetData(string url, string baseUrl, Action<UpdateProgressInfo> onProgress, ref string tempLocation)
{
if (!string.IsNullOrEmpty(baseUrl) && !baseUrl.EndsWith("/"))
baseUrl += "/";
FileDownloader fileDownloader = !Uri.IsWellFormedUriString(url, UriKind.Absolute) ? (!Uri.IsWellFormedUriString(baseUrl, UriKind.Absolute) ? (string.IsNullOrEmpty(baseUrl) ? new FileDownloader(url) : new FileDownloader(new Uri(new Uri(baseUrl), url))) : new FileDownloader(new Uri(new Uri(baseUrl, UriKind.Absolute), url))) : new FileDownloader(url);
fileDownloader.Proxy = this.Proxy;
if (string.IsNullOrEmpty(tempLocation) || !Directory.Exists(Path.GetDirectoryName(tempLocation)))
tempLocation = Path.GetTempFileName();
return fileDownloader.DownloadToFile(tempLocation, onProgress);
}
}
}

View File

@ -6,6 +6,7 @@ using Newtonsoft.Json;
using Wox.Infrastructure.Storage;
using Wox.Plugin;
using System.Drawing;
using System.Reflection;
namespace Wox.Core.UserSettings
{
@ -14,6 +15,13 @@ namespace Wox.Core.UserSettings
[JsonProperty]
public bool DontPromptUpdateMsg { get; set; }
[JsonProperty]
public int ActivateTimes { get; set; }
[JsonProperty]
public bool EnableUpdateLog { get; set; }
[JsonProperty]
public string Hotkey { get; set; }
@ -47,9 +55,6 @@ namespace Wox.Core.UserSettings
[JsonProperty]
public string ResultItemFontStretch { get; set; }
[JsonProperty]
public List<WebSearch> WebSearches { get; set; }
[JsonProperty]
public double WindowLeft { get; set; }
@ -64,18 +69,14 @@ namespace Wox.Core.UserSettings
[JsonProperty]
public bool StartWoxOnSystemStartup { get; set; }
[Obsolete]
[JsonProperty]
public double Opacity { get; set; }
[Obsolete]
[JsonProperty]
public OpacityMode OpacityMode { get; set; }
[JsonProperty]
public bool EnableWebSearchSuggestion { get; set; }
[JsonProperty]
public string WebSearchSuggestionSource { get; set; }
[JsonProperty]
public bool LeaveCmdOpen { get; set; }
@ -97,55 +98,9 @@ namespace Wox.Core.UserSettings
[JsonProperty]
public string ProxyPassword { get; set; }
public List<WebSearch> LoadDefaultWebSearches()
{
List<WebSearch> webSearches = new List<WebSearch>();
WebSearch googleWebSearch = new WebSearch()
{
Title = "Google",
ActionWord = "g",
IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\google.png",
Url = "https://www.google.com/search?q={q}",
Enabled = true
};
webSearches.Add(googleWebSearch);
WebSearch wikiWebSearch = new WebSearch()
{
Title = "Wikipedia",
ActionWord = "wiki",
IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\wiki.png",
Url = "http://en.wikipedia.org/wiki/{q}",
Enabled = true
};
webSearches.Add(wikiWebSearch);
WebSearch findIcon = new WebSearch()
{
Title = "FindIcon",
ActionWord = "findicon",
IconPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\Images\websearch\pictures.png",
Url = "http://findicons.com/search/{q}",
Enabled = true
};
webSearches.Add(findIcon);
return webSearches;
}
protected override string ConfigFolder
{
get
{
string userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");
if (userProfilePath == null)
{
throw new ArgumentException("Environment variable USERPROFILE is empty");
}
return Path.Combine(Path.Combine(userProfilePath, ".Wox"), "Config");
}
get { return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Config"); }
}
protected override string ConfigName
@ -153,12 +108,20 @@ namespace Wox.Core.UserSettings
get { return "config"; }
}
public void IncreaseActivateTimes()
{
ActivateTimes++;
if (ActivateTimes % 15 == 0)
{
Save();
}
}
protected override UserSettingStorage LoadDefault()
{
DontPromptUpdateMsg = false;
Theme = "Dark";
Language = "en";
WebSearches = LoadDefaultWebSearches();
CustomizedPluginConfigs = new List<CustomizedPluginConfig>();
Hotkey = "Alt + Space";
QueryBoxFont = FontFamily.GenericSansSerif.Name;

View File

@ -1,36 +0,0 @@
using System.Reflection;
namespace Wox.Core.Version
{
public class VersionManager
{
private static VersionManager versionManager;
private static SemanticVersion currentVersion;
public static VersionManager Instance
{
get
{
if (versionManager == null)
{
versionManager = new VersionManager();
}
return versionManager;
}
}
private VersionManager() { }
public SemanticVersion CurrentVersion
{
get
{
if (currentVersion == null)
{
currentVersion = new SemanticVersion(Assembly.GetExecutingAssembly().GetName().Version);
}
return currentVersion;
}
}
}
}

View File

@ -69,7 +69,9 @@
<Compile Include="Exception\WoxI18nException.cs" />
<Compile Include="Exception\WoxJsonRPCException.cs" />
<Compile Include="Exception\WoxPluginException.cs" />
<Compile Include="Updater\Release.cs" />
<Compile Include="Updater\UpdaterManager.cs" />
<Compile Include="Updater\WoxUpdateSource.cs" />
<Compile Include="UserSettings\HttpProxy.cs" />
<Compile Include="i18n\AvailableLanguages.cs" />
<Compile Include="i18n\IInternationalization.cs" />
@ -99,9 +101,7 @@
<Compile Include="UserSettings\CustomizedPluginConfig.cs" />
<Compile Include="UserSettings\PluginHotkey.cs" />
<Compile Include="UserSettings\UserSettingStorage.cs" />
<Compile Include="UserSettings\WebSearch.cs" />
<Compile Include="Version\SemanticVersion.cs" />
<Compile Include="Version\VersionManager.cs" />
<Compile Include="Updater\SemanticVersion.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View File

@ -14,7 +14,7 @@ namespace Wox.Core.i18n
private static Internationalization instance;
private static object syncObject = new object();
public static Internationalization Internationalization
public static Internationalization Instance
{
get
{

View File

@ -16,8 +16,8 @@ using Wox.Core;
using Wox.Core.Exception;
using Wox.Core.i18n;
using Wox.Core.UI;
using Wox.Core.Updater;
using Wox.Core.UserSettings;
using Wox.Core.Version;
using Wox.Infrastructure.Http;
namespace Wox.CrashReporter
@ -36,7 +36,7 @@ namespace Wox.CrashReporter
private void SetException(Exception exception)
{
tbSummary.AppendText(exception.Message);
tbVersion.Text = VersionManager.Instance.CurrentVersion.ToString();
tbVersion.Text = UpdaterManager.Instance.CurrentVersion.ToString();
tbDatetime.Text = DateTime.Now.ToString();
tbStackTrace.AppendText(exception.StackTrace);
tbSource.Text = exception.Source;
@ -45,7 +45,7 @@ namespace Wox.CrashReporter
private void btnSend_Click(object sender, RoutedEventArgs e)
{
string sendingMsg = InternationalizationManager.Internationalization.GetTranslation("reportWindow_sending");
string sendingMsg = InternationalizationManager.Instance.GetTranslation("reportWindow_sending");
tbSendReport.Content = sendingMsg;
btnSend.IsEnabled = false;
ThreadPool.QueueUserWorkItem(o => SendReport());
@ -57,11 +57,11 @@ namespace Wox.CrashReporter
string response = HttpRequest.Post(APIServer.ErrorReportURL, error, HttpProxy.Instance);
if (response.ToLower() == "ok")
{
MessageBox.Show(InternationalizationManager.Internationalization.GetTranslation("reportWindow_report_succeed"));
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("reportWindow_report_succeed"));
}
else
{
MessageBox.Show(InternationalizationManager.Internationalization.GetTranslation("reportWindow_report_failed"));
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("reportWindow_report_failed"));
}
Dispatcher.Invoke(new Action(Close));
}

View File

@ -14,6 +14,24 @@ namespace Wox.Infrastructure.Http
return Get(url, encoding, proxy);
}
public static WebProxy GetWebProxy(IHttpProxy proxy)
{
if (proxy != null && proxy.Enabled && !string.IsNullOrEmpty(proxy.Server))
{
if (string.IsNullOrEmpty(proxy.UserName) || string.IsNullOrEmpty(proxy.Password))
{
return new WebProxy(proxy.Server, proxy.Port);
}
return new WebProxy(proxy.Server, proxy.Port)
{
Credentials = new NetworkCredential(proxy.UserName, proxy.Password)
};
}
return null;
}
private static string Get(string url, string encoding, IHttpProxy proxy)
{
if (string.IsNullOrEmpty(url)) return string.Empty;
@ -21,20 +39,7 @@ namespace Wox.Infrastructure.Http
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "GET";
request.Timeout = 10 * 1000;
if (proxy != null && proxy.Enabled && !string.IsNullOrEmpty(proxy.Server))
{
if (string.IsNullOrEmpty(proxy.UserName) || string.IsNullOrEmpty(proxy.Password))
{
request.Proxy = new WebProxy(proxy.Server, proxy.Port);
}
else
{
request.Proxy = new WebProxy(proxy.Server, proxy.Port)
{
Credentials = new NetworkCredential(proxy.UserName, proxy.Password)
};
}
}
request.Proxy = GetWebProxy(proxy);
try
{

View File

@ -15,11 +15,9 @@
Error - error messages
Fatal - very serious errors-->
<targets>
<target xsi:type="File" name="file" fileName="${basedir}/logs/${shortdate}.log"/>
<target xsi:type="Console" name="console" />
<target xsi:type="File" name="file" fileName="${basedir}/Logs/${shortdate}.log"/>
</targets>
<rules>
<logger name="*" minlevel="Warn" writeTo="file" />
<logger name="*" minlevel="Debug" writeTo="console" />
</rules>
</nlog>

View File

@ -6,6 +6,7 @@ using System.Reflection;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading;
using Wox.Infrastructure.Logger;
namespace Wox.Infrastructure.Storage
@ -18,6 +19,7 @@ namespace Wox.Infrastructure.Storage
[Serializable]
public abstract class BinaryStorage<T> : BaseStorage<T> where T : class, IStorage, new()
{
private static object syncObject = new object();
protected override string FileSuffix
{
get { return ".dat"; }
@ -86,6 +88,10 @@ namespace Wox.Infrastructure.Storage
}
protected override void SaveInternal()
{
ThreadPool.QueueUserWorkItem(o =>
{
lock (syncObject)
{
try
{
@ -99,7 +105,7 @@ namespace Wox.Infrastructure.Storage
}
catch (Exception e)
{
Log.Error(e.Message);
Log.Error(e);
#if (DEBUG)
{
throw;
@ -107,5 +113,7 @@ namespace Wox.Infrastructure.Storage
#endif
}
}
});
}
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using Newtonsoft.Json;
namespace Wox.Infrastructure.Storage
@ -12,6 +13,7 @@ namespace Wox.Infrastructure.Storage
/// </summary>
public abstract class JsonStrorage<T> : BaseStorage<T> where T : class, IStorage, new()
{
private static object syncObject = new object();
protected override string FileSuffix
{
get { return ".json"; }
@ -38,9 +40,15 @@ namespace Wox.Infrastructure.Storage
}
protected override void SaveInternal()
{
ThreadPool.QueueUserWorkItem(o =>
{
lock (syncObject)
{
string json = JsonConvert.SerializeObject(serializedObject, Formatting.Indented);
File.WriteAllText(ConfigPath, json);
}
});
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Wox.Plugin
{
public interface IInstantSearch
{
bool IsInstantSearch(string query);
}
}

View File

@ -15,8 +15,7 @@ namespace Wox.Plugin
/// <param name="query"></param>
/// <param name="plugin"></param>
/// <param name="results"></param>
/// <param name="clearBeforeInsert"></param>
void PushResults(Query query,PluginMetadata plugin, List<Result> results,bool clearBeforeInsert = false);
void PushResults(Query query,PluginMetadata plugin, List<Result> results);
/// <summary>
/// Execute command

View File

@ -7,7 +7,7 @@ namespace Wox.Plugin
{
public class PluginInitContext
{
public PluginMetadata CurrentPluginMetadata { get; set; }
public PluginMetadata CurrentPluginMetadata { get; internal set; }
/// <summary>
/// Public APIs for plugin invocation
@ -15,75 +15,5 @@ namespace Wox.Plugin
public IPublicAPI API { get; set; }
public IHttpProxy Proxy { get; set; }
#region Legacy APIs
[Obsolete("This method has been obsoleted, use API.ShellRun instead")]
public bool ShellRun(string cmd)
{
return API.ShellRun(cmd);
}
[Obsolete("This method has been obsoleted, use API.OpenSettingDialog instead")]
public void ChangeQuery(string query, bool requery = false)
{
API.ChangeQuery(query, requery);
}
[Obsolete("This method has been obsoleted, use API.CloseApp instead")]
public void CloseApp()
{
API.CloseApp();
}
[Obsolete("This method has been obsoleted, use API.HideApp instead")]
public void HideApp()
{
API.HideApp();
}
[Obsolete("This method has been obsoleted, use API.ShowApp instead")]
public void ShowApp()
{
API.ShowApp();
}
[Obsolete("This method has been obsoleted, use API.OpenSettingDialog instead")]
public void ShowMsg(string title, string subTitle, string iconPath)
{
API.ShowMsg(title, subTitle, iconPath);
}
[Obsolete("This method has been obsoleted, use API.OpenSettingDialog instead")]
public void OpenSettingDialog()
{
API.OpenSettingDialog();
}
[Obsolete("This method has been obsoleted, use API.StartLoadingBar instead")]
public void StartLoadingBar()
{
API.StartLoadingBar();
}
[Obsolete("This method has been obsoleted, use API.StopLoadingBar instead")]
public void StopLoadingBar()
{
API.StopLoadingBar();
}
[Obsolete("This method has been obsoleted, use API.InstallPlugin instead")]
public void InstallPlugin(string path)
{
API.InstallPlugin(path);
}
[Obsolete("This method has been obsoleted, use API.ReloadPlugins instead")]
public void ReloadPlugins()
{
API.ReloadPlugins();
}
#endregion
}
}

View File

@ -9,17 +9,6 @@ namespace Wox.Plugin
{
public class PluginMetadata
{
private int configVersion = 1;
/// <summary>
/// if we need to change the plugin config in the futher, use this to
/// indicate config version
/// </summary>
public int ConfigVersion
{
get { return configVersion; }
set { configVersion = value; }
}
public string ID { get; set; }
public string Name { get; set; }
public string Author { get; set; }
@ -37,17 +26,16 @@ namespace Wox.Plugin
public string ExecuteFileName { get; set; }
public string PluginDirectory { get; set; }
[Obsolete("This property has been obsoleted, use PluginDirectory instead")]
public string PluginDirecotry
{
get { return PluginDirectory; }
}
public string ActionKeyword { get; set; }
public PluginType PluginType { get; set; }
public string IcoPath { get; set; }
public override string ToString()
{
return Name;
}
public string FullIcoPath
{
get

View File

@ -9,5 +9,10 @@ namespace Wox.Plugin
{
public IPlugin Plugin { get; set; }
public PluginMetadata Metadata { get; set; }
public override string ToString()
{
return Metadata.Name;
}
}
}

View File

@ -2,9 +2,6 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Wox.Plugin")]
[assembly: AssemblyDescription("https://github.com/qianlifeng/Wox")]
[assembly: AssemblyConfiguration("")]
@ -13,24 +10,11 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("The MIT License (MIT)")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("c22be00d-a6f5-4e45-8ecc-09ebf297c812")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: InternalsVisibleTo("Wox")]
[assembly: InternalsVisibleTo("Wox.Core")]
[assembly: InternalsVisibleTo("Wox.Test")]

View File

@ -1,11 +1,112 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace Wox.Plugin
{
public class Query
{
public string RawQuery { get; set; }
/// <summary>
/// Raw query, this includes action keyword if it has
/// We didn't recommend use this property directly. You should always use Search property.
/// </summary>
public string RawQuery { get; internal set; }
/// <summary>
/// Search part of a query.
/// This will not include action keyword if regular plugin gets it, and if a system plugin gets it, it should be same as RawQuery.
/// Since we allow user to switch a regular plugin to system plugin, so this property will always give you the "real" query part of
/// the query
/// </summary>
public string Search { get; internal set; }
internal string GetActionKeyword()
{
if (!string.IsNullOrEmpty(RawQuery))
{
var strings = RawQuery.Split(' ');
if (strings.Length > 0)
{
return strings[0];
}
}
return string.Empty;
}
/// <summary>
/// Return first search split by space if it has
/// </summary>
public string FirstSearch
{
get
{
return SplitSearch(0);
}
}
/// <summary>
/// strings from second search (including) to last search
/// </summary>
public string SecondToEndSearch
{
get
{
if (string.IsNullOrEmpty(Search)) return string.Empty;
var strings = Search.Split(' ');
if (strings.Length > 1)
{
return Search.Substring(Search.IndexOf(' ') + 1);
}
return string.Empty;
}
}
/// <summary>
/// Return second search split by space if it has
/// </summary>
public string SecondSearch
{
get
{
return SplitSearch(1);
}
}
/// <summary>
/// Return third search split by space if it has
/// </summary>
public string ThirdSearch
{
get
{
return SplitSearch(2);
}
}
private string SplitSearch(int index)
{
if (string.IsNullOrEmpty(Search)) return string.Empty;
var strings = Search.Split(' ');
if (strings.Length > index)
{
return strings[index];
}
return string.Empty;
}
public override string ToString()
{
return RawQuery;
}
[Obsolete("Use Search instead, A plugin developer shouldn't care about action name, as it may changed by users. " +
"this property will be removed in v1.3.0")]
public string ActionName { get; private set; }
[Obsolete("Use Search instead, this property will be removed in v1.3.0")]
public List<string> ActionParameters { get; private set; }
public Query(string rawQuery)
@ -33,10 +134,11 @@ namespace Wox.Plugin
}
}
[Obsolete("Use Search instead, this method will be removed in v1.3.0")]
public string GetAllRemainingParameter()
{
string[] strings = RawQuery.Split(new char[]{ ' ' }, 2, System.StringSplitOptions.None);
string[] strings = RawQuery.Split(new char[] { ' ' }, 2, System.StringSplitOptions.None);
if (strings.Length > 1)
{
return strings[1];

View File

@ -8,7 +8,6 @@ namespace Wox.Plugin
public class Result
{
public string Title { get; set; }
public string SubTitle { get; set; }
public string IcoPath { get; set; }
@ -34,21 +33,15 @@ namespace Wox.Plugin
public int Score { get; set; }
/// <summary>
/// Auto add scores for MRU items
/// </summary>
public bool AutoAjustScore { get; set; }
//todo: this should be controlled by system, not visible to users
/// <summary>
/// Only resulsts that originQuery match with curren query will be displayed in the panel
/// </summary>
public Query OriginQuery { get; set; }
internal Query OriginQuery { get; set; }
/// <summary>
/// Don't set this property if you are developing a plugin
/// Plugin directory
/// </summary>
public string PluginDirectory { get; set; }
public string PluginDirectory { get; internal set; }
public new bool Equals(object obj)
{
@ -75,6 +68,14 @@ namespace Wox.Plugin
this.SubTitle = SubTitle;
}
/// <summary>
/// Context menus associate with this result
/// </summary>
public List<Result> ContextMenu { get; set; }
/// <summary>
/// Plugin ID that generate this result
/// </summary>
public string PluginID { get; set; }
}
}

Some files were not shown because too many files have changed in this diff Show More