mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge remote-tracking branch 'refs/remotes/origin/master' into dev
This commit is contained in:
commit
06010b1366
24 changed files with 526 additions and 509 deletions
6
Plugins/HelloWorldCSharp/App.config
Normal file
6
Plugins/HelloWorldCSharp/App.config
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
74
Plugins/HelloWorldCSharp/HelloWorldCSharp.csproj
Normal file
74
Plugins/HelloWorldCSharp/HelloWorldCSharp.csproj
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.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>{03FFA443-5F50-48D5-8869-F3DF316803AA}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>HelloWorldCSharp</RootNamespace>
|
||||
<AssemblyName>HelloWorldCSharp</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\Output\Debug\Plugins\HelloWorldCSharp\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\Output\Release\Plugins\HelloWorldCSharp\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="plugin.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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" />
|
||||
<!-- 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>
|
||||
28
Plugins/HelloWorldCSharp/Main.cs
Normal file
28
Plugins/HelloWorldCSharp/Main.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace HelloWorldCSharp
|
||||
{
|
||||
class Main : IPlugin
|
||||
{
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
var result = new Result
|
||||
{
|
||||
Title = "Hello Word from CSharp",
|
||||
SubTitle = $"Query: {query.Search}",
|
||||
IcoPath = "app.png"
|
||||
};
|
||||
return new List<Result> {result};
|
||||
}
|
||||
|
||||
public void Init(PluginInitContext context)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Plugins/HelloWorldCSharp/Properties/AssemblyInfo.cs
Normal file
36
Plugins/HelloWorldCSharp/Properties/AssemblyInfo.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("HelloWorldCSharp")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("HelloWorldCSharp")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("03ffa443-5f50-48d5-8869-f3df316803aa")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
12
Plugins/HelloWorldCSharp/plugin.json
Normal file
12
Plugins/HelloWorldCSharp/plugin.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"ID":"CEA0FDFC6D3B4085823D60DC76F28844",
|
||||
"ActionKeyword":"hc",
|
||||
"Name":"Hello World CSharp",
|
||||
"Description":"Hello World CSharp",
|
||||
"Author":"happlebao",
|
||||
"Version":"1.0.0",
|
||||
"Language":"csharp",
|
||||
"Website":"https://github.com/Wox-launcher/Wox",
|
||||
"ExecuteFileName":"HelloWorldCSharp.dll",
|
||||
"IcoPath":"app.png"
|
||||
}
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.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="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{88731DA8-C020-476E-B79A-3ADEF65ACA9F}</ProjectGuid>
|
||||
<Keyword>MakeFileProj</Keyword>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
<NMakeBuildCommandLine>taskkill /f /fi "IMAGENAME eq Wox.exe"</NMakeBuildCommandLine>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
<NMakeBuildCommandLine>taskkill /f /fi "IMAGENAME eq Wox.exe"</NMakeBuildCommandLine>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<NMakeBuildCommandLine>taskkill /f /fi "IMAGENAME eq Wox.exe"</NMakeBuildCommandLine>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<NMakeBuildCommandLine>taskkill /f /fi "IMAGENAME eq Wox.exe"</NMakeBuildCommandLine>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="readme.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="readme.txt" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
This is project is just a workaround for pre solution level build event
|
||||
See http://stackoverflow.com/a/2295583/2833083
|
||||
todo: we currently can only force close Wox, there should be a better way
|
||||
38
README.md
38
README.md
|
|
@ -5,51 +5,43 @@
|
|||
|
||||
=========
|
||||
|
||||
Wox is a launcher for Windows, an alternative to [Alfred](https://www.alfredapp.com/) and [Launchy](http://www.launchy.net/). You can launch everything with just a few keystrokes!
|
||||
Launcher for Windows, an alternative to [Alfred](https://www.alfredapp.com/) and [Launchy](http://www.launchy.net/).
|
||||
|
||||
# Demo
|
||||
|
||||
|
||||

|
||||
|
||||
# Features
|
||||
|
||||
1. Search all applications, folders, files.
|
||||
2. Search Web using keyword (e.g. search google with `g search_term`)
|
||||
3. Build custom themes in [http://www.getwox.com/theme/builder](http://www.getwox.com/theme/builder)
|
||||
4. Install plugins from [http://www.getwox.com/plugin](http://www.getwox.com/plugin)
|
||||
5. Use **pinyin** to search programs / 支持用 **拼音** 搜索程序 e.g. yyy / wangyiyun -> 网易云音乐
|
||||
- Search all applications, folders, files.
|
||||
- Search Web using keyword (e.g. search google with `g search_term`)
|
||||
- Build custom themes in [http://www.getwox.com/theme/builder](http://www.getwox.com/theme/builder)
|
||||
- Install plugins from [http://www.getwox.com/plugin](http://www.getwox.com/plugin)
|
||||
- Use **pinyin** to search programs / 支持用 **拼音** 搜索程序 e.g. yyy / wangyiyun -> 网易云音乐
|
||||
|
||||
# Installation
|
||||
- Latest stable version: [releases](https://github.com/Wox-launcher/Wox/releases).
|
||||
- Latest beta version: try **Pre-release** labeled release in [releases](https://github.com/Wox-launcher/Wox/releases)
|
||||
|
||||
|
||||
1. Download
|
||||
1. Latest stable version: [release page](https://github.com/Wox-launcher/Wox/releases).
|
||||
2. Latest build: [English guide](https://github.com/Wox-launcher/Wox/wiki/FAQ-English#how-to-install-latest-build), [中文说明](https://github.com/Wox-launcher/Wox/wiki/FAQ-%E4%B8%AD%E6%96%87#%E5%A6%82%E4%BD%95%E5%AE%89%E8%A3%85%E6%9C%80%E6%96%B0-build)
|
||||
2. Unzip it and put it into your user directory (`C:\Users\YOUUSERNAME` or `%userprofile%`)
|
||||
3. Windows 10 user, please have a look at https://github.com/Wox-launcher/Wox/issues/279
|
||||
|
||||
|
||||
# Simple Usage
|
||||
# Usage
|
||||
- Launch: <kbd>Alt</kbd>+<kbd>Space</kbd>
|
||||
- Install/Uninstall plugin: type `wpm install/uninstall`
|
||||
|
||||
# Contribute
|
||||
|
||||
If you are a developer, please feel free to send a pull request to the **Dev** branch. We still have a lot of features and bugs to resolve. Take a look at [issues page](https://github.com/Wox-launcher/Wox/issues), especially for [help_needed](https://github.com/Wox-launcher/Wox/issues?q=is%3Aopen+is%3Aissue+label%3Ahelp_needed) labeled issue. :)
|
||||
|
||||
If you are not a developer, please try **Pre-release** in [Releases](https://github.com/Wox-launcher/Wox/releases) and report bugs.
|
||||
- Send PR to **dev** branch
|
||||
- I'd appreciate if you could solve [help_needed](https://github.com/Wox-launcher/Wox/issues?q=is%3Aopen+is%3Aissue+label%3Ahelp_needed) labeled issue
|
||||
- Don't hesitate to ask questions in the [issues](https://github.com/Wox-launcher/Wox/issues)
|
||||
|
||||
# Docs
|
||||
|
||||
Full documentation can be found here [Wox doc](http://doc.getwox.com). This is a good place to start if you are installing Wox for the first time.
|
||||
|
||||
In the future, all of the documentation will be moved back to Github wiki.
|
||||
Outdated doc: [Wox doc](http://doc.getwox.com).
|
||||
Just ask questions in the [issues](https://github.com/Wox-launcher/Wox/issues)
|
||||
|
||||
# Development / Author Status
|
||||
|
||||
- [x] unified directory `%APPDATA%` for all storage
|
||||
- [ ] bring unitest for wox back
|
||||
- [ ] add autoupdate / installer
|
||||
- [x] add autoupdate / installer
|
||||
- [ ] disable plugin properly
|
||||
|
||||
|
|
|
|||
90
Wox.Core/Updater.cs
Normal file
90
Wox.Core/Updater.cs
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Squirrel;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Infrastructure.Http;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Core
|
||||
{
|
||||
public static class Updater
|
||||
{
|
||||
[Conditional("RELEASE")]
|
||||
public static async void UpdateApp()
|
||||
{
|
||||
|
||||
var client = new WebClient {Proxy = HttpRequest.WebProxy(HttpProxy.Instance)};
|
||||
var downloader = new FileDownloader(client);
|
||||
|
||||
try
|
||||
{
|
||||
// todo 5/9 the return value of UpdateApp() is NULL, fucking useless!
|
||||
using (var updater= await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github, urlDownloader:downloader))
|
||||
{
|
||||
await updater.UpdateApp();
|
||||
}
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
Log.Error(ex);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
const string info = "Update.exe not found, not a Squirrel-installed app?";
|
||||
if (exception.Message == info)
|
||||
{
|
||||
Log.Warn(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<string> NewVersion()
|
||||
{
|
||||
const string githubAPI = @"https://api.github.com/repos/wox-launcher/wox/releases/latest";
|
||||
var response = await HttpRequest.Get(githubAPI, HttpProxy.Instance);
|
||||
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
{
|
||||
JContainer json;
|
||||
try
|
||||
{
|
||||
json = (JContainer)JsonConvert.DeserializeObject(response);
|
||||
}
|
||||
catch (JsonSerializationException e)
|
||||
{
|
||||
Log.Error(e);
|
||||
return string.Empty;
|
||||
}
|
||||
var version = json?["tag_name"]?.ToString();
|
||||
if (!string.IsNullOrEmpty(version))
|
||||
{
|
||||
return version;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warn("Can't find tag_name from Github API response");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warn("Can't get response from Github API");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static int NumericVersion(string version)
|
||||
{
|
||||
var newVersion = version.Replace("v", ".").Replace(".", "").Replace("*", "");
|
||||
return int.Parse(newVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,24 +34,60 @@
|
|||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
<Reference Include="DeltaCompressionDotNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1d14d6e5194e7f4a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="DeltaCompressionDotNet.MsDelta, Version=1.0.0.0, Culture=neutral, PublicKeyToken=46b2138a390abf55, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.MsDelta.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="DeltaCompressionDotNet.PatchApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3e8888ee913ed789, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.PatchApi.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\squirrel.windows.1.4.0\lib\Net45\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="JetBrains.Annotations, Version=10.1.4.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\JetBrains.Annotations.10.1.4\lib\net20\JetBrains.Annotations.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NAppUpdate.Framework, Version=0.3.2.0, Culture=neutral, PublicKeyToken=d1f1d1f19f9e5a56, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NAppUpdate.Framework.0.3.2.0\lib\net20\NAppUpdate.Framework.dll</HintPath>
|
||||
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Mdb.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Pdb.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NuGet.Squirrel, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\squirrel.windows.1.4.0\lib\Net45\NuGet.Squirrel.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Squirrel, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\squirrel.windows.1.4.0\lib\Net45\Squirrel.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
|
|
@ -66,6 +102,7 @@
|
|||
</Compile>
|
||||
<Compile Include="Plugin\ExecutablePlugin.cs" />
|
||||
<Compile Include="Plugin\PluginsLoader.cs" />
|
||||
<Compile Include="Updater.cs" />
|
||||
<Compile Include="UserSettings\HttpProxy.cs" />
|
||||
<Compile Include="Resource\AvailableLanguages.cs" />
|
||||
<Compile Include="Resource\Internationalization.cs" />
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="DeltaCompressionDotNet" version="1.0.0" targetFramework="net452" />
|
||||
<package id="JetBrains.Annotations" version="10.1.4" targetFramework="net452" />
|
||||
<package id="NAppUpdate.Framework" version="0.3.2.0" targetFramework="net452" />
|
||||
<package id="Mono.Cecil" version="0.9.6.1" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net452" />
|
||||
<package id="SharpZipLib" version="0.86.0" targetFramework="net452" />
|
||||
<package id="Splat" version="1.6.2" targetFramework="net452" />
|
||||
<package id="squirrel.windows" version="1.4.0" targetFramework="net452" />
|
||||
<package id="System.Runtime" version="4.0.0" targetFramework="net452" />
|
||||
</packages>
|
||||
|
|
@ -13,7 +13,7 @@ namespace Wox.Infrastructure.Http
|
|||
{
|
||||
public static class HttpRequest
|
||||
{
|
||||
private static WebProxy GetWebProxy(IHttpProxy proxy)
|
||||
public static WebProxy WebProxy(IHttpProxy proxy)
|
||||
{
|
||||
if (proxy != null && proxy.Enabled && !string.IsNullOrEmpty(proxy.Server))
|
||||
{
|
||||
|
|
@ -43,7 +43,7 @@ namespace Wox.Infrastructure.Http
|
|||
HttpWebRequest request = WebRequest.CreateHttp(url);
|
||||
request.Method = "GET";
|
||||
request.Timeout = 10 * 1000;
|
||||
request.Proxy = GetWebProxy(proxy);
|
||||
request.Proxy = WebProxy(proxy);
|
||||
request.UserAgent = @"Mozilla/5.0 (Trident/7.0; rv:11.0) like Gecko";
|
||||
HttpWebResponse response;
|
||||
try
|
||||
|
|
|
|||
41
Wox.sln
41
Wox.sln
|
|
@ -6,13 +6,9 @@ MinimumVisualStudioVersion = 10.0.40219.1
|
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Test", "Wox.Test\Wox.Test.csproj", "{FF742965-9A80-41A5-B042-D6C7D3A21708}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{DB90F671-D861-46BB-93A3-F1304F5BA1C5} = {DB90F671-D861-46BB-93A3-F1304F5BA1C5}
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin", "Wox.Plugin\Wox.Plugin.csproj", "{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}"
|
||||
EndProject
|
||||
|
|
@ -25,7 +21,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox", "Wox\Wox.csproj", "{D
|
|||
{59BD9891-3837-438A-958D-ADC7F91F6F7E} = {59BD9891-3837-438A-958D-ADC7F91F6F7E}
|
||||
{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} = {C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0}
|
||||
{787B8AA6-CA93-4C84-96FE-DF31110AD1C4} = {787B8AA6-CA93-4C84-96FE-DF31110AD1C4}
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F}
|
||||
{F35190AA-4758-4D9E-A193-E3BDF6AD3567} = {F35190AA-4758-4D9E-A193-E3BDF6AD3567}
|
||||
{FDED22C8-B637-42E8-824A-63B5B6E05A3A} = {FDED22C8-B637-42E8-824A-63B5B6E05A3A}
|
||||
{A3DCCBCA-ACC1-421D-B16E-210896234C26} = {A3DCCBCA-ACC1-421D-B16E-210896234C26}
|
||||
|
|
@ -34,16 +29,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox", "Wox\Wox.csproj", "{D
|
|||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Infrastructure", "Wox.Infrastructure\Wox.Infrastructure.csproj", "{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.PluginManagement", "Plugins\Wox.Plugin.PluginManagement\Wox.Plugin.PluginManagement.csproj", "{049490F0-ECD2-4148-9B39-2135EC346EBE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Core", "Wox.Core\Wox.Core.csproj", "{B749F0DB-8E75-47DB-9E5E-265D16D0C0D2}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Program", "Plugins\Wox.Plugin.Program\Wox.Plugin.Program.csproj", "{FDB3555B-58EF-4AE6-B5F1-904719637AB4}"
|
||||
EndProject
|
||||
|
|
@ -66,9 +55,6 @@ EndProject
|
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Color", "Plugins\Wox.Plugin.Color\Wox.Plugin.Color.csproj", "{F35190AA-4758-4D9E-A193-E3BDF6AD3567}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.CrashReporter", "Wox.CrashReporter\Wox.CrashReporter.csproj", "{2FEB2298-7653-4009-B1EA-FFFB1A768BCC}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Everything", "Plugins\Wox.Plugin.Everything\Wox.Plugin.Everything.csproj", "{230AE83F-E92E-4E69-8355-426B305DA9C0}"
|
||||
EndProject
|
||||
|
|
@ -83,7 +69,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||
SolutionAssemblyInfo.cs = SolutionAssemblyInfo.cs
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PreSolutionBuild", "PreSolutionBuild\PreSolutionBuild.vcxproj", "{88731DA8-C020-476E-B79A-3ADEF65ACA9F}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldCSharp", "Plugins\HelloWorldCSharp\HelloWorldCSharp.csproj", "{03FFA443-5F50-48D5-8869-F3DF316803AA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -312,18 +298,18 @@ Global
|
|||
{230AE83F-E92E-4E69-8355-426B305DA9C0}.Release|x64.Build.0 = Release|Any CPU
|
||||
{230AE83F-E92E-4E69-8355-426B305DA9C0}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{230AE83F-E92E-4E69-8355-426B305DA9C0}.Release|x86.Build.0 = Release|Any CPU
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Debug|Any CPU.ActiveCfg = Debug|Win32
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Debug|Any CPU.Build.0 = Debug|Win32
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Debug|x64.Build.0 = Debug|x64
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Debug|x86.Build.0 = Debug|Win32
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|Any CPU.Build.0 = Release|x64
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|x64.ActiveCfg = Release|x64
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|x64.Build.0 = Release|x64
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|x86.ActiveCfg = Release|Win32
|
||||
{88731DA8-C020-476E-B79A-3ADEF65ACA9F}.Release|x86.Build.0 = Release|Win32
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA}.Release|x64.Build.0 = Release|Any CPU
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -341,5 +327,6 @@ Global
|
|||
{A3DCCBCA-ACC1-421D-B16E-210896234C26} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
|
||||
{F35190AA-4758-4D9E-A193-E3BDF6AD3567} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
|
||||
{230AE83F-E92E-4E69-8355-426B305DA9C0} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
|
||||
{03FFA443-5F50-48D5-8869-F3DF316803AA} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
|
|
@ -1,24 +1,20 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using Squirrel;
|
||||
using Wox.Core;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure.Image;
|
||||
using Wox.ViewModel;
|
||||
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
public partial class App : ISingleInstanceApp, IDisposable
|
||||
public partial class App : IDisposable, ISingleInstanceApp
|
||||
{
|
||||
private const string Unique = "Wox_Unique_Application_Mutex";
|
||||
public static MainWindow Window { get; private set; }
|
||||
public static PublicAPIInstance API { get; private set; }
|
||||
private const string Unique = "Wox_Unique_Application_Mutex";
|
||||
private static bool _disposed;
|
||||
public static UpdateManager Updater;
|
||||
|
||||
[STAThread]
|
||||
public static void Main()
|
||||
|
|
@ -42,43 +38,23 @@ namespace Wox
|
|||
|
||||
ImageLoader.PreloadImages();
|
||||
|
||||
MainViewModel mainVM = new MainViewModel();
|
||||
var pluginsSettings = mainVM._settings.PluginSettings;
|
||||
API = new PublicAPIInstance(mainVM, mainVM._settings);
|
||||
var vm = new MainViewModel();
|
||||
var pluginsSettings = vm._settings.PluginSettings;
|
||||
var window = new MainWindow(vm._settings, vm);
|
||||
API = new PublicAPIInstance(vm._settings, vm);
|
||||
PluginManager.InitializePlugins(API, pluginsSettings);
|
||||
|
||||
Window = new MainWindow(mainVM._settings, mainVM);
|
||||
var _notifyIconManager = new NotifyIconManager(API);
|
||||
|
||||
RegisterExitEvents();
|
||||
|
||||
Current.MainWindow = window;
|
||||
Current.MainWindow.Title = Infrastructure.Wox.Name;
|
||||
window.Show();
|
||||
});
|
||||
}
|
||||
|
||||
private async void OnActivated(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Updater = await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github))
|
||||
{
|
||||
await Updater.UpdateApp();
|
||||
}
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
Log.Error(ex);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
const string info = "Update.exe not found, not a Squirrel-installed app?";
|
||||
if (exception.Message == info)
|
||||
{
|
||||
Log.Warn(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
Updater.UpdateApp();
|
||||
}
|
||||
|
||||
private void RegisterExitEvents()
|
||||
|
|
@ -101,31 +77,20 @@ namespace Wox
|
|||
AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle;
|
||||
}
|
||||
|
||||
public void OnActivate()
|
||||
{
|
||||
API.ShowApp();
|
||||
}
|
||||
|
||||
private static void Save()
|
||||
{
|
||||
var vm = (MainViewModel)Window.DataContext;
|
||||
vm.Save();
|
||||
PluginManager.Save();
|
||||
ImageLoader.Save();
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// if sessionending is called, exit proverbially be called when log off / shutdown
|
||||
// but if sessionending is not called, exit won't be called when log off / shutdown
|
||||
if (!_disposed)
|
||||
{
|
||||
Save();
|
||||
Updater?.Dispose();
|
||||
SingleInstance<App>.Cleanup();
|
||||
((MainViewModel)Current.MainWindow?.DataContext)?.Save();
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSecondAppStarted()
|
||||
{
|
||||
API.ShowApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using Wox.Infrastructure.Exception;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
|
@ -16,7 +17,7 @@ namespace Wox.Helper
|
|||
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
//handle non-ui thread exceptions
|
||||
App.Window.Dispatcher.Invoke(() =>
|
||||
Application.Current.MainWindow.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Report((Exception)e.ExceptionObject);
|
||||
if (!(e.ExceptionObject is WoxException))
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ namespace Wox.Helper
|
|||
|
||||
public interface ISingleInstanceApp
|
||||
{
|
||||
void OnActivate();
|
||||
void OnSecondAppStarted();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -416,7 +416,7 @@ namespace Wox.Helper
|
|||
return;
|
||||
}
|
||||
|
||||
((TApplication)Application.Current).OnActivate();
|
||||
((TApplication)Application.Current).OnSecondAppStarted();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -437,8 +437,7 @@ namespace Wox.Helper
|
|||
if (Application.Current != null)
|
||||
{
|
||||
// Do an asynchronous call to ActivateFirstInstance function
|
||||
Application.Current.Dispatcher.BeginInvoke(
|
||||
DispatcherPriority.Normal, new DispatcherOperationCallback(ActivateFirstInstanceCallback));
|
||||
Application.Current.Dispatcher.Invoke(ActivateFirstInstance);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,11 @@ using Wox.Core.UserSettings;
|
|||
using Wox.Helper;
|
||||
using Wox.Infrastructure.Hotkey;
|
||||
using Wox.ViewModel;
|
||||
using ContextMenu = System.Windows.Forms.ContextMenu;
|
||||
using DataFormats = System.Windows.DataFormats;
|
||||
using DragEventArgs = System.Windows.DragEventArgs;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using MenuItem = System.Windows.Forms.MenuItem;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
namespace Wox
|
||||
|
|
@ -25,6 +27,7 @@ namespace Wox
|
|||
|
||||
private readonly Storyboard _progressBarStoryboard = new Storyboard();
|
||||
private Settings _settings;
|
||||
private NotifyIcon _notifyIcon;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -40,16 +43,33 @@ namespace Wox
|
|||
}
|
||||
private void OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
_notifyIcon.Visible = false;
|
||||
_settings.WindowLeft = Left;
|
||||
_settings.WindowTop = Top;
|
||||
var vm = (MainViewModel)DataContext;
|
||||
vm.Save();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs _)
|
||||
{
|
||||
InitProgressbarAnimation();
|
||||
WindowIntelopHelper.DisableControlBox(this);
|
||||
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
||||
InitializeNotifyIcon();
|
||||
|
||||
var vm = (MainViewModel)DataContext;
|
||||
RegisterEvents(vm);
|
||||
|
||||
// happlebao todo delete
|
||||
vm.Left = GetWindowsLeft();
|
||||
vm.Top = GetWindowsTop();
|
||||
vm.MainWindowVisibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void RegisterEvents(MainViewModel vm)
|
||||
{
|
||||
vm.TextBoxSelected += (o, e) => QueryTextBox.SelectAll();
|
||||
vm.CursorMovedToEnd += (o, e) =>
|
||||
{
|
||||
|
|
@ -72,11 +92,22 @@ namespace Wox
|
|||
_settings.WindowTop = Top;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// happlebao todo delete
|
||||
vm.Left = GetWindowsLeft();
|
||||
vm.Top = GetWindowsTop();
|
||||
vm.MainWindowVisibility = Visibility.Visible;
|
||||
private void InitializeNotifyIcon()
|
||||
{
|
||||
_notifyIcon = new NotifyIcon { Text = Infrastructure.Wox.Name, Icon = Properties.Resources.app, Visible = true };
|
||||
_notifyIcon.Click += (o, e) => App.API.ShowApp();
|
||||
var open = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTrayOpen"));
|
||||
open.Click += (o, e) => App.API.ShowApp();
|
||||
var setting = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTraySettings"));
|
||||
setting.Click += (o, e) => App.API.OpenSettingDialog();
|
||||
var about = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTrayAbout"));
|
||||
about.Click += (o, e) => App.API.OpenSettingDialog("about");
|
||||
var exit = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTrayExit"));
|
||||
exit.Click += (o, e) => Close();
|
||||
MenuItem[] childen = { open, setting, about, exit };
|
||||
_notifyIcon.ContextMenu = new ContextMenu(childen);
|
||||
}
|
||||
|
||||
private double GetWindowsLeft()
|
||||
|
|
@ -241,10 +272,6 @@ namespace Wox
|
|||
e.Handled = true;
|
||||
break;
|
||||
|
||||
case Key.Back:
|
||||
vm.BackCommand.Execute(e);
|
||||
break;
|
||||
|
||||
case Key.F1:
|
||||
vm.StartHelpCommand.Execute(null);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
using System.Windows.Forms;
|
||||
using Wox.Core.Resource;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
public class NotifyIconManager
|
||||
{
|
||||
|
||||
private NotifyIcon notifyIcon;
|
||||
private IPublicAPI _api;
|
||||
|
||||
public NotifyIconManager(IPublicAPI api)
|
||||
{
|
||||
InitialTray();
|
||||
_api = api;
|
||||
}
|
||||
|
||||
private void InitialTray()
|
||||
{
|
||||
notifyIcon = new NotifyIcon { Text = "Wox", Icon = Properties.Resources.app, Visible = true };
|
||||
notifyIcon.Click += (o, e) => _api.ShowApp();
|
||||
var open = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTrayOpen"));
|
||||
open.Click += (o, e) => _api.ShowApp();
|
||||
var setting = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTraySettings"));
|
||||
setting.Click += (o, e) => _api.OpenSettingDialog();
|
||||
var about = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTrayAbout"));
|
||||
about.Click += (o, e) => _api.OpenSettingDialog("about");
|
||||
var exit = new MenuItem(InternationalizationManager.Instance.GetTranslation("iconTrayExit"));
|
||||
exit.Click += (o, e) => _api.CloseApp();
|
||||
MenuItem[] childen = { open, setting, about, exit };
|
||||
notifyIcon.ContextMenu = new ContextMenu(childen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20,17 +20,17 @@ namespace Wox
|
|||
{
|
||||
public class PublicAPIInstance : IPublicAPI
|
||||
{
|
||||
private Settings _settings;
|
||||
private readonly Settings _settings;
|
||||
|
||||
#region Constructor
|
||||
|
||||
public PublicAPIInstance(MainViewModel mainVM, Settings settings)
|
||||
public PublicAPIInstance(Settings settings, MainViewModel mainVM)
|
||||
{
|
||||
MainVM = mainVM;
|
||||
_settings = settings;
|
||||
MainVM = mainVM;
|
||||
//_settings = settings;
|
||||
GlobalHotkey.Instance.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
|
||||
WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
|
||||
SetHotkey(_settings.Hotkey, OnHotkey);
|
||||
SetCustomPluginHotkey();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -63,16 +63,17 @@ namespace Wox
|
|||
public void CloseApp()
|
||||
{
|
||||
//notifyIcon.Visible = false;
|
||||
Application.Current.Shutdown();
|
||||
Application.Current.MainWindow.Close();
|
||||
}
|
||||
|
||||
public void RestarApp()
|
||||
{
|
||||
HideWox();
|
||||
// we must force dispose application
|
||||
// we must manually save
|
||||
// UpdateManager.RestartApp() will call Environment.Exit(0)
|
||||
// which will cause ungraceful exit
|
||||
((IDisposable) Application.Current).Dispose();
|
||||
var vm = (MainViewModel) Application.Current.MainWindow.DataContext;
|
||||
vm.Save();
|
||||
UpdateManager.RestartApp();
|
||||
}
|
||||
|
||||
|
|
@ -169,83 +170,6 @@ namespace Wox
|
|||
MainVM.MainWindowVisibility = Visibility.Visible;
|
||||
MainVM.OnTextBoxSelected();
|
||||
}
|
||||
|
||||
internal void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
|
||||
{
|
||||
var hotkey = new HotkeyModel(hotkeyStr);
|
||||
SetHotkey(hotkey, action);
|
||||
}
|
||||
|
||||
public void SetHotkey(HotkeyModel hotkey, EventHandler<HotkeyEventArgs> action)
|
||||
{
|
||||
string hotkeyStr = hotkey.ToString();
|
||||
try
|
||||
{
|
||||
HotkeyManager.Current.AddOrReplace(hotkeyStr, hotkey.CharKey, hotkey.ModifierKeys, action);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
|
||||
MessageBox.Show(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveHotkey(string hotkeyStr)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(hotkeyStr))
|
||||
{
|
||||
HotkeyManager.Current.Remove(hotkeyStr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if Wox should ignore any hotkeys
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool ShouldIgnoreHotkeys()
|
||||
{
|
||||
//double if to omit calling win32 function
|
||||
if (_settings.IgnoreHotkeysOnFullscreen)
|
||||
if (WindowIntelopHelper.IsWindowFullscreen())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal void SetCustomPluginHotkey()
|
||||
{
|
||||
if (_settings.CustomPluginHotkeys == null) return;
|
||||
foreach (CustomPluginHotkey hotkey in _settings.CustomPluginHotkeys)
|
||||
{
|
||||
CustomPluginHotkey hotkey1 = hotkey;
|
||||
SetHotkey(hotkey.Hotkey, delegate
|
||||
{
|
||||
if (ShouldIgnoreHotkeys()) return;
|
||||
ShowApp();
|
||||
ChangeQuery(hotkey1.ActionKeyword, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected internal void OnHotkey(object sender, HotkeyEventArgs e)
|
||||
{
|
||||
if (ShouldIgnoreHotkeys()) return;
|
||||
ToggleWox();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void ToggleWox()
|
||||
{
|
||||
if (!MainVM.MainWindowVisibility.IsVisible())
|
||||
{
|
||||
ShowWox();
|
||||
}
|
||||
else
|
||||
{
|
||||
HideWox();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,44 +4,30 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NHotkey;
|
||||
using NHotkey.Wpf;
|
||||
using Squirrel;
|
||||
using Wox.Core;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Core.Resource;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure.Hotkey;
|
||||
using Wox.Infrastructure.Http;
|
||||
using Wox.Infrastructure.Image;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Plugin;
|
||||
using Wox.ViewModel;
|
||||
using Application = System.Windows.Forms.Application;
|
||||
using CheckBox = System.Windows.Controls.CheckBox;
|
||||
using Control = System.Windows.Controls.Control;
|
||||
using Cursors = System.Windows.Input.Cursors;
|
||||
using HorizontalAlignment = System.Windows.HorizontalAlignment;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
||||
|
||||
namespace Wox
|
||||
{
|
||||
public partial class SettingWindow : Window
|
||||
public partial class SettingWindow
|
||||
{
|
||||
public readonly IPublicAPI _api;
|
||||
bool settingsLoaded;
|
||||
|
|
@ -233,7 +219,7 @@ namespace Wox
|
|||
RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
|
||||
true))
|
||||
{
|
||||
key.SetValue("Wox", "\"" + Application.ExecutablePath + "\" --hidestart");
|
||||
key.SetValue("Wox", "\"" + Infrastructure.Wox.ProgramPath + "\" --hidestart");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -259,7 +245,7 @@ namespace Wox
|
|||
|
||||
private void SelectPythonDirectoryOnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dlg = new FolderBrowserDialog
|
||||
var dlg = new System.Windows.Forms.FolderBrowserDialog
|
||||
{
|
||||
SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
|
||||
};
|
||||
|
|
@ -295,7 +281,7 @@ namespace Wox
|
|||
{
|
||||
SetHotkey(ctlHotkey.CurrentHotkey, delegate
|
||||
{
|
||||
if (!App.Window.IsVisible)
|
||||
if (!System.Windows.Application.Current.MainWindow.IsVisible)
|
||||
{
|
||||
_api.ShowApp();
|
||||
}
|
||||
|
|
@ -439,48 +425,48 @@ namespace Wox
|
|||
Title = "Wox is an effective launcher for windows",
|
||||
SubTitle = "Wox provide bundles of features let you access infomations quickly.",
|
||||
IcoPath = "Images/app.png",
|
||||
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath)
|
||||
},
|
||||
new Result
|
||||
{
|
||||
Title = "Search applications",
|
||||
SubTitle = "Search applications, files (via everything plugin) and browser bookmarks",
|
||||
IcoPath = "Images/app.png",
|
||||
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath)
|
||||
},
|
||||
new Result
|
||||
{
|
||||
Title = "Search web contents with shortcuts",
|
||||
SubTitle = "e.g. search google with g keyword or youtube keyword)",
|
||||
IcoPath = "Images/app.png",
|
||||
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath)
|
||||
},
|
||||
new Result
|
||||
{
|
||||
Title = "clipboard history ",
|
||||
IcoPath = "Images/app.png",
|
||||
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath)
|
||||
},
|
||||
new Result
|
||||
{
|
||||
Title = "Themes support",
|
||||
SubTitle = "get more themes from http://www.getwox.com/theme",
|
||||
IcoPath = "Images/app.png",
|
||||
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath)
|
||||
},
|
||||
new Result
|
||||
{
|
||||
Title = "Plugins support",
|
||||
SubTitle = "get more plugins from http://www.getwox.com/plugin",
|
||||
IcoPath = "Images/app.png",
|
||||
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath)
|
||||
},
|
||||
new Result
|
||||
{
|
||||
Title = "Wox is an open-source software",
|
||||
SubTitle = "Wox benefits from the open-source community a lot",
|
||||
IcoPath = "Images/app.png",
|
||||
PluginDirectory = Path.GetDirectoryName(Application.ExecutablePath)
|
||||
PluginDirectory = Path.GetDirectoryName(Infrastructure.Wox.ProgramPath)
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -834,15 +820,6 @@ namespace Wox
|
|||
|
||||
#endregion
|
||||
|
||||
#region About
|
||||
|
||||
private void tbWebsite_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Process.Start(Infrastructure.Wox.Github);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
// Hide window with ESC, but make sure it is not pressed as a hotkey
|
||||
|
|
@ -854,78 +831,20 @@ namespace Wox
|
|||
|
||||
private async void OnCheckUpdates(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var version = await NewVersion();
|
||||
var version = await Updater.NewVersion();
|
||||
if (!string.IsNullOrEmpty(version))
|
||||
{
|
||||
var newVersion = NumericVersion(version);
|
||||
var oldVersion = NumericVersion(Infrastructure.Wox.Version);
|
||||
var newVersion = Updater.NumericVersion(version);
|
||||
var oldVersion = Updater.NumericVersion(Infrastructure.Wox.Version);
|
||||
if (newVersion > oldVersion)
|
||||
{
|
||||
NewVersionTips.Text = string.Format(NewVersionTips.Text, version);
|
||||
NewVersionTips.Visibility = Visibility.Visible;
|
||||
UpdateApp();
|
||||
Updater.UpdateApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void UpdateApp()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var updater = await UpdateManager.GitHubUpdateManager(Infrastructure.Wox.Github))
|
||||
{
|
||||
// todo 5/9 the return value of UpdateApp() is NULL, fucking useless!
|
||||
await updater.UpdateApp();
|
||||
}
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
Log.Error(ex);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex);
|
||||
}
|
||||
}
|
||||
private async Task<string> NewVersion()
|
||||
{
|
||||
const string githubAPI = @"https://api.github.com/repos/wox-launcher/wox/releases/latest";
|
||||
var response = await HttpRequest.Get(githubAPI, HttpProxy.Instance);
|
||||
|
||||
if (!string.IsNullOrEmpty(response))
|
||||
{
|
||||
JContainer json;
|
||||
try
|
||||
{
|
||||
json = (JContainer)JsonConvert.DeserializeObject(response);
|
||||
}
|
||||
catch (JsonSerializationException e)
|
||||
{
|
||||
Log.Error(e);
|
||||
return string.Empty;
|
||||
}
|
||||
var version = json?["tag_name"]?.ToString();
|
||||
if (!string.IsNullOrEmpty(version))
|
||||
{
|
||||
return version;
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private
|
||||
int NumericVersion(string version)
|
||||
{
|
||||
var newVersion = version.Replace("v", ".").Replace(".", "").Replace("*", "");
|
||||
return int.Parse(newVersion);
|
||||
}
|
||||
private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
|
||||
|
|
|
|||
|
|
@ -5,12 +5,15 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using NHotkey;
|
||||
using NHotkey.Wpf;
|
||||
using Wox.Core.Plugin;
|
||||
using Wox.Core.Resource;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Hotkey;
|
||||
using Wox.Infrastructure.Image;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Plugin;
|
||||
using Wox.Storage;
|
||||
|
|
@ -47,6 +50,7 @@ namespace Wox.ViewModel
|
|||
|
||||
private CancellationTokenSource _updateSource;
|
||||
private CancellationToken _updateToken;
|
||||
private bool _saved;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -54,6 +58,7 @@ namespace Wox.ViewModel
|
|||
|
||||
public MainViewModel()
|
||||
{
|
||||
_saved = false;
|
||||
_queryTextBeforeLoadContextMenu = "";
|
||||
_queryText = "";
|
||||
_lastQuery = new Query();
|
||||
|
|
@ -66,7 +71,6 @@ namespace Wox.ViewModel
|
|||
InternationalizationManager.Instance.Settings = _settings;
|
||||
InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
|
||||
ThemeManager.Instance.Settings = _settings;
|
||||
ThemeManager.Instance.ChangeTheme(_settings.Theme);
|
||||
|
||||
_queryHistoryStorage = new JsonStrorage<QueryHistory>();
|
||||
_userSelectedRecordStorage = new JsonStrorage<UserSelectedRecord>();
|
||||
|
|
@ -79,13 +83,16 @@ namespace Wox.ViewModel
|
|||
InitializeContextMenu();
|
||||
InitializeKeyCommands();
|
||||
RegisterResultsUpdatedEvent();
|
||||
|
||||
SetHotkey(_settings.Hotkey, OnHotkey);
|
||||
SetCustomPluginHotkey();
|
||||
}
|
||||
|
||||
private void RegisterResultsUpdatedEvent()
|
||||
{
|
||||
foreach (var pair in PluginManager.GetPluginsForInterface<IResultUpdated>())
|
||||
{
|
||||
var plugin = (IResultUpdated)pair.Plugin;
|
||||
var plugin = (IResultUpdated) pair.Plugin;
|
||||
plugin.ResultsUpdated += (s, e) =>
|
||||
{
|
||||
Task.Run(() =>
|
||||
|
|
@ -224,10 +231,6 @@ namespace Wox.ViewModel
|
|||
}
|
||||
});
|
||||
|
||||
BackCommand = new RelayCommand(_ =>
|
||||
{
|
||||
ListeningKeyPressed?.Invoke(this, new ListeningKeyPressedEventArgs(_ as KeyEventArgs));
|
||||
});
|
||||
}
|
||||
|
||||
private void InitializeResultListBox()
|
||||
|
|
@ -270,6 +273,7 @@ namespace Wox.ViewModel
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ViewModel Properties
|
||||
|
|
@ -280,10 +284,7 @@ namespace Wox.ViewModel
|
|||
|
||||
public string QueryText
|
||||
{
|
||||
get
|
||||
{
|
||||
return _queryText;
|
||||
}
|
||||
get { return _queryText; }
|
||||
set
|
||||
{
|
||||
_queryText = value;
|
||||
|
|
@ -302,10 +303,7 @@ namespace Wox.ViewModel
|
|||
|
||||
public double Left
|
||||
{
|
||||
get
|
||||
{
|
||||
return _left;
|
||||
}
|
||||
get { return _left; }
|
||||
set
|
||||
{
|
||||
_left = value;
|
||||
|
|
@ -315,10 +313,7 @@ namespace Wox.ViewModel
|
|||
|
||||
public double Top
|
||||
{
|
||||
get
|
||||
{
|
||||
return _top;
|
||||
}
|
||||
get { return _top; }
|
||||
set
|
||||
{
|
||||
_top = value;
|
||||
|
|
@ -329,10 +324,7 @@ namespace Wox.ViewModel
|
|||
public Visibility ContextMenuVisibility
|
||||
|
||||
{
|
||||
get
|
||||
{
|
||||
return _contextMenuVisibility;
|
||||
}
|
||||
get { return _contextMenuVisibility; }
|
||||
set
|
||||
{
|
||||
_contextMenuVisibility = value;
|
||||
|
|
@ -356,10 +348,7 @@ namespace Wox.ViewModel
|
|||
|
||||
public Visibility ProgressBarVisibility
|
||||
{
|
||||
get
|
||||
{
|
||||
return _progressBarVisibility;
|
||||
}
|
||||
get { return _progressBarVisibility; }
|
||||
set
|
||||
{
|
||||
_progressBarVisibility = value;
|
||||
|
|
@ -369,10 +358,7 @@ namespace Wox.ViewModel
|
|||
|
||||
public Visibility ResultListBoxVisibility
|
||||
{
|
||||
get
|
||||
{
|
||||
return _resultListBoxVisibility;
|
||||
}
|
||||
get { return _resultListBoxVisibility; }
|
||||
set
|
||||
{
|
||||
_resultListBoxVisibility = value;
|
||||
|
|
@ -382,10 +368,7 @@ namespace Wox.ViewModel
|
|||
|
||||
public Visibility MainWindowVisibility
|
||||
{
|
||||
get
|
||||
{
|
||||
return _mainWindowVisibility;
|
||||
}
|
||||
get { return _mainWindowVisibility; }
|
||||
set
|
||||
{
|
||||
_mainWindowVisibility = value;
|
||||
|
|
@ -404,7 +387,7 @@ namespace Wox.ViewModel
|
|||
public ICommand StartHelpCommand { get; set; }
|
||||
public ICommand LoadContextMenuCommand { get; set; }
|
||||
public ICommand OpenResultCommand { get; set; }
|
||||
public ICommand BackCommand { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
|
@ -523,10 +506,11 @@ namespace Wox.ViewModel
|
|||
};
|
||||
Task.Run(() =>
|
||||
{
|
||||
Results.AddResults(new List<Result> { result }, historyMetadata.ID);
|
||||
Results.AddResults(new List<Result> {result}, historyMetadata.ID);
|
||||
}, _updateToken);
|
||||
}
|
||||
}
|
||||
|
||||
private Result ContextMenuTopMost(Result result)
|
||||
{
|
||||
Result menu;
|
||||
|
|
@ -586,16 +570,106 @@ namespace Wox.ViewModel
|
|||
};
|
||||
return menu;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Hotkey
|
||||
|
||||
internal void SetHotkey(string hotkeyStr, EventHandler<HotkeyEventArgs> action)
|
||||
{
|
||||
var hotkey = new HotkeyModel(hotkeyStr);
|
||||
SetHotkey(hotkey, action);
|
||||
}
|
||||
|
||||
public void SetHotkey(HotkeyModel hotkey, EventHandler<HotkeyEventArgs> action)
|
||||
{
|
||||
string hotkeyStr = hotkey.ToString();
|
||||
try
|
||||
{
|
||||
HotkeyManager.Current.AddOrReplace(hotkeyStr, hotkey.CharKey, hotkey.ModifierKeys, action);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
string errorMsg =
|
||||
string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
|
||||
MessageBox.Show(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveHotkey(string hotkeyStr)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(hotkeyStr))
|
||||
{
|
||||
HotkeyManager.Current.Remove(hotkeyStr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if Wox should ignore any hotkeys
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool ShouldIgnoreHotkeys()
|
||||
{
|
||||
//double if to omit calling win32 function
|
||||
if (_settings.IgnoreHotkeysOnFullscreen)
|
||||
if (WindowIntelopHelper.IsWindowFullscreen())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SetCustomPluginHotkey()
|
||||
{
|
||||
if (_settings.CustomPluginHotkeys == null) return;
|
||||
foreach (CustomPluginHotkey hotkey in _settings.CustomPluginHotkeys)
|
||||
{
|
||||
CustomPluginHotkey hotkey1 = hotkey;
|
||||
SetHotkey(hotkey.Hotkey, delegate
|
||||
{
|
||||
if (ShouldIgnoreHotkeys()) return;
|
||||
App.API.ShowApp();
|
||||
App.API.ChangeQuery(hotkey1.ActionKeyword, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void OnHotkey(object sender, HotkeyEventArgs e)
|
||||
{
|
||||
if (ShouldIgnoreHotkeys()) return;
|
||||
ToggleWox();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void ToggleWox()
|
||||
{
|
||||
if (!MainWindowVisibility.IsVisible())
|
||||
{
|
||||
MainWindowVisibility = Visibility.Visible;
|
||||
OnTextBoxSelected();
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindowVisibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_settingsStorage.Save();
|
||||
_queryHistoryStorage.Save();
|
||||
_userSelectedRecordStorage.Save();
|
||||
_topMostRecordStorage.Save();
|
||||
if (!_saved)
|
||||
{
|
||||
_settingsStorage.Save();
|
||||
_queryHistoryStorage.Save();
|
||||
_userSelectedRecordStorage.Save();
|
||||
_topMostRecordStorage.Save();
|
||||
|
||||
PluginManager.Save();
|
||||
ImageLoader.Save();
|
||||
|
||||
_saved = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -614,7 +688,7 @@ namespace Wox.ViewModel
|
|||
}
|
||||
else
|
||||
{
|
||||
result.Score += _userSelectedRecord.GetSelectedCount(result) * 5;
|
||||
result.Score += _userSelectedRecord.GetSelectedCount(result)*5;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -631,29 +705,19 @@ namespace Wox.ViewModel
|
|||
|
||||
#endregion
|
||||
|
||||
public event EventHandler<ListeningKeyPressedEventArgs> ListeningKeyPressed;
|
||||
public event EventHandler MainWindowVisibilityChanged;
|
||||
|
||||
public event EventHandler CursorMovedToEnd;
|
||||
|
||||
public void OnCursorMovedToEnd()
|
||||
{
|
||||
CursorMovedToEnd?.Invoke(this, new EventArgs());
|
||||
}
|
||||
|
||||
public event EventHandler TextBoxSelected;
|
||||
|
||||
public void OnTextBoxSelected()
|
||||
{
|
||||
TextBoxSelected?.Invoke(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
public class ListeningKeyPressedEventArgs : EventArgs
|
||||
{
|
||||
public KeyEventArgs KeyEventArgs { get; private set; }
|
||||
|
||||
public ListeningKeyPressedEventArgs(KeyEventArgs keyEventArgs)
|
||||
{
|
||||
KeyEventArgs = keyEventArgs;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -159,7 +159,6 @@
|
|||
</Compile>
|
||||
<Compile Include="Helper\VisibilityExtensions.cs" />
|
||||
<Compile Include="Helper\SingletonWindowOpener.cs" />
|
||||
<Compile Include="NotifyIconManager.cs" />
|
||||
<Compile Include="PublicAPIInstance.cs" />
|
||||
<Compile Include="ResultListBox.xaml.cs">
|
||||
<DependentUpon>ResultListBox.xaml</DependentUpon>
|
||||
|
|
@ -432,8 +431,7 @@
|
|||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
<PreBuildEvent>taskkill /f /fi "IMAGENAME eq Wox.exe</PreBuildEvent>
|
||||
</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.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
version: 1.2.{build}
|
||||
version: 1.3.{build}
|
||||
os: Visual Studio 2015
|
||||
configuration: Release
|
||||
platform: Any CPU
|
||||
|
|
|
|||
Loading…
Reference in a new issue