Merge branch 'master' into dev
3
.gitignore
vendored
|
|
@ -113,6 +113,9 @@ _UpgradeReport_Files/
|
||||||
Backup*/
|
Backup*/
|
||||||
UpgradeLog*.XML
|
UpgradeLog*.XML
|
||||||
|
|
||||||
|
# Temporary caches used by Roslyn.
|
||||||
|
.vs
|
||||||
|
|
||||||
*.DotSettings
|
*.DotSettings
|
||||||
/Python.Runtime.dll
|
/Python.Runtime.dll
|
||||||
Wox/Images/websearch/Thumbs.db
|
Wox/Images/websearch/Thumbs.db
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using JsonProperty = Newtonsoft.Json.JsonPropertyAttribute;
|
|
||||||
using Wox.Infrastructure.Storage;
|
using Wox.Infrastructure.Storage;
|
||||||
|
using JsonProperty = Newtonsoft.Json.JsonPropertyAttribute;
|
||||||
|
|
||||||
namespace Wox.Plugin.Everything
|
namespace Wox.Plugin.Everything
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ namespace Wox.Plugin.Folder
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.API.ChangeQuery(item.Path);
|
context.API.ChangeQuery(item.Path + (item.Path.EndsWith("\\")? "": "\\"));
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
ContextData = item
|
ContextData = item
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
|
|
||||||
namespace Wox.Plugin.Program
|
namespace Wox.Plugin.Program
|
||||||
{
|
{
|
||||||
internal class FileChangeWatcher
|
internal class FileChangeWatcher
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Wox.Plugin.Program.ProgramSources;
|
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
|
using Wox.Plugin.Program.ProgramSources;
|
||||||
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
||||||
|
|
||||||
namespace Wox.Plugin.Program
|
namespace Wox.Plugin.Program
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,13 @@ using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Forms;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using FormsApplication = System.Windows.Forms.Application;
|
using Application = System.Windows.Application;
|
||||||
using PowerState = System.Windows.Forms.PowerState;
|
|
||||||
using Control = System.Windows.Controls.Control;
|
using Control = System.Windows.Controls.Control;
|
||||||
|
using FormsApplication = System.Windows.Forms.Application;
|
||||||
|
using MessageBox = System.Windows.MessageBox;
|
||||||
|
|
||||||
namespace Wox.Plugin.Sys
|
namespace Wox.Plugin.Sys
|
||||||
{
|
{
|
||||||
|
|
|
||||||
BIN
Plugins/Wox.Plugin.WebSearch/Images/bing.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
Plugins/Wox.Plugin.WebSearch/Images/duckduckgo.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
Plugins/Wox.Plugin.WebSearch/Images/facebook.png
Normal file
|
After Width: | Height: | Size: 986 B |
BIN
Plugins/Wox.Plugin.WebSearch/Images/gist.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
Plugins/Wox.Plugin.WebSearch/Images/github.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
Plugins/Wox.Plugin.WebSearch/Images/gmail.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
Plugins/Wox.Plugin.WebSearch/Images/google_drive.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
Plugins/Wox.Plugin.WebSearch/Images/google_maps.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
Plugins/Wox.Plugin.WebSearch/Images/google_translate.png
Normal file
|
After Width: | Height: | Size: 7.3 KiB |
BIN
Plugins/Wox.Plugin.WebSearch/Images/stackoverflow.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
Plugins/Wox.Plugin.WebSearch/Images/twitter.png
Normal file
|
After Width: | Height: | Size: 6 KiB |
BIN
Plugins/Wox.Plugin.WebSearch/Images/wolframalpha.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Plugins/Wox.Plugin.WebSearch/Images/yahoo.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
Plugins/Wox.Plugin.WebSearch/Images/youtube.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -79,10 +78,7 @@ namespace Wox.Plugin.WebSearch
|
||||||
|
|
||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
this.Context = context;
|
Context = context;
|
||||||
|
|
||||||
if (WebSearchStorage.Instance.WebSearches == null)
|
|
||||||
WebSearchStorage.Instance.WebSearches = WebSearchStorage.Instance.LoadDefaultWebSearches();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region ISettingProvider Members
|
#region ISettingProvider Members
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ using Wox.Infrastructure.Storage;
|
||||||
|
|
||||||
namespace Wox.Plugin.WebSearch
|
namespace Wox.Plugin.WebSearch
|
||||||
{
|
{
|
||||||
public class WebSearchStorage :JsonStrorage<WebSearchStorage>
|
public class WebSearchStorage : JsonStrorage<WebSearchStorage>
|
||||||
{
|
{
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public List<WebSearch> WebSearches { get; set; }
|
public List<WebSearch> WebSearches { get; set; }
|
||||||
|
|
@ -26,49 +26,5 @@ namespace Wox.Plugin.WebSearch
|
||||||
{
|
{
|
||||||
get { return "setting"; }
|
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",
|
|
||||||
ActionKeyword = "g",
|
|
||||||
IconPath = @"Images\google.png",
|
|
||||||
Url = "https://www.google.com/search?q={q}",
|
|
||||||
Enabled = true
|
|
||||||
};
|
|
||||||
webSearches.Add(googleWebSearch);
|
|
||||||
|
|
||||||
|
|
||||||
WebSearch wikiWebSearch = new WebSearch()
|
|
||||||
{
|
|
||||||
Title = "Wikipedia",
|
|
||||||
ActionKeyword = "wiki",
|
|
||||||
IconPath = @"Images\wiki.png",
|
|
||||||
Url = "http://en.wikipedia.org/wiki/{q}",
|
|
||||||
Enabled = true
|
|
||||||
};
|
|
||||||
webSearches.Add(wikiWebSearch);
|
|
||||||
|
|
||||||
WebSearch findIcon = new WebSearch()
|
|
||||||
{
|
|
||||||
Title = "FindIcon",
|
|
||||||
ActionKeyword = "findicon",
|
|
||||||
IconPath = @"Images\pictures.png",
|
|
||||||
Url = "http://findicons.com/search/{q}",
|
|
||||||
Enabled = true
|
|
||||||
};
|
|
||||||
webSearches.Add(findIcon);
|
|
||||||
|
|
||||||
return webSearches;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,48 @@
|
||||||
<None Include="Images\wiki.png">
|
<None Include="Images\wiki.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="Images\bing.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\duckduckgo.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\facebook.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\gist.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\github.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\gmail.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\google_drive.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\google_maps.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\google_translate.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\stackoverflow.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\twitter.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\wolframalpha.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\yahoo.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Include="Images\youtube.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<Content Include="Languages\en.xaml">
|
<Content Include="Languages\en.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|
@ -94,6 +136,9 @@
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="setting.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<Page Include="WebSearchesSetting.xaml">
|
<Page Include="WebSearchesSetting.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,32 @@
|
||||||
{
|
{
|
||||||
"ID":"565B73353DBF4806919830B9202EE3BF",
|
"ID": "565B73353DBF4806919830B9202EE3BF",
|
||||||
"ActionKeywords": ["g", "wiki", "findicon"],
|
"ActionKeywords": [
|
||||||
"Name":"Web Searches",
|
"g",
|
||||||
"Description":"Provide the web search ability",
|
"wiki",
|
||||||
"Author":"qianlifeng",
|
"findicon",
|
||||||
"Version":"1.0.0",
|
"facebook",
|
||||||
"Language":"csharp",
|
"twitter",
|
||||||
"Website":"http://www.getwox.com/plugin",
|
"maps",
|
||||||
"ExecuteFileName":"Wox.Plugin.WebSearch.dll",
|
"translate",
|
||||||
"IcoPath":"Images\\web_search.png"
|
"duckduckgo",
|
||||||
|
"github",
|
||||||
|
"gist",
|
||||||
|
"gmail",
|
||||||
|
"drive",
|
||||||
|
"wolframalpha",
|
||||||
|
"stackoverflow",
|
||||||
|
"lucky",
|
||||||
|
"image",
|
||||||
|
"youtube",
|
||||||
|
"bing",
|
||||||
|
"yahoo"
|
||||||
|
],
|
||||||
|
"Name": "Web Searches",
|
||||||
|
"Description": "Provide the web search ability",
|
||||||
|
"Author": "qianlifeng",
|
||||||
|
"Version": "1.0.0",
|
||||||
|
"Language": "csharp",
|
||||||
|
"Website": "http://www.getwox.com/plugin",
|
||||||
|
"ExecuteFileName": "Wox.Plugin.WebSearch.dll",
|
||||||
|
"IcoPath": "Images\\web_search.png"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
139
Plugins/Wox.Plugin.WebSearch/setting.json
Normal file
|
|
@ -0,0 +1,139 @@
|
||||||
|
{
|
||||||
|
"WebSearches": [
|
||||||
|
{
|
||||||
|
"Title": "Google",
|
||||||
|
"ActionKeyword": "g",
|
||||||
|
"IconPath": "Images\\google.png",
|
||||||
|
"Url": "https://www.google.com/search?q={q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Wikipedia",
|
||||||
|
"ActionKeyword": "wiki",
|
||||||
|
"IconPath": "Images\\wiki.png",
|
||||||
|
"Url": "http://en.wikipedia.org/wiki/{q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "FindIcon",
|
||||||
|
"ActionKeyword": "findicon",
|
||||||
|
"IconPath": "Images\\pictures.png",
|
||||||
|
"Url": "http://findicons.com/search/{q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Facebook",
|
||||||
|
"ActionKeyword": "facebook",
|
||||||
|
"IconPath": "Images\\facebook.png",
|
||||||
|
"Url": "http://www.facebook.com/search/?q={q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Twitter",
|
||||||
|
"ActionKeyword": "twitter",
|
||||||
|
"IconPath": "Images\\twitter.png",
|
||||||
|
"Url": "http://twitter.com/search?q={q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Google Maps",
|
||||||
|
"ActionKeyword": "maps",
|
||||||
|
"IconPath": "Images\\google_maps.png",
|
||||||
|
"Url": "http://maps.google.com/maps?q={q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Google Translate",
|
||||||
|
"ActionKeyword": "translate",
|
||||||
|
"IconPath": "Images\\google_translate.png",
|
||||||
|
"Url": "http://translate.google.com/#auto|en|{q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Duckduckgo",
|
||||||
|
"ActionKeyword": "duckduckgo",
|
||||||
|
"IconPath": "Images\\duckduckgo.png",
|
||||||
|
"Url": "https://duckduckgo.com/?q={q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Github",
|
||||||
|
"ActionKeyword": "github",
|
||||||
|
"IconPath": "Images\\github.png",
|
||||||
|
"Url": "https://github.com/search?q={q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Github Gist",
|
||||||
|
"ActionKeyword": "gist",
|
||||||
|
"IconPath": "Images\\gist.png",
|
||||||
|
"Url": "https://gist.github.com/search?q={q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Gmail",
|
||||||
|
"ActionKeyword": "gmail",
|
||||||
|
"IconPath": "Images\\gmail.png",
|
||||||
|
"Url": "https://mail.google.com/mail/ca/u/0/#apps/{q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Google Drive",
|
||||||
|
"ActionKeyword": "drive",
|
||||||
|
"IconPath": "Images\\google_drive.png",
|
||||||
|
"Url": "http://drive.google.com/?hl=en&tab=bo#search/{q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Wolframalpha",
|
||||||
|
"ActionKeyword": "wolframalpha",
|
||||||
|
"IconPath": "Images\\wolframalpha.png",
|
||||||
|
"Url": "http://www.wolframalpha.com/input/?i={q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Stackoverflow",
|
||||||
|
"ActionKeyword": "stackoverflow",
|
||||||
|
"IconPath": "Images\\stackoverflow.png",
|
||||||
|
"Url": "http://stackoverflow.com/search?q={q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "I'm Feeling Lucky",
|
||||||
|
"ActionKeyword": "lucky",
|
||||||
|
"IconPath": "Images\\google.png",
|
||||||
|
"Url": "http://google.com/search?q={q}&btnI=I",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Google Image",
|
||||||
|
"ActionKeyword": "image",
|
||||||
|
"IconPath": "Images\\google.png",
|
||||||
|
"Url": "https://www.google.com/search?q={q}&tbm=isch",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Youtube",
|
||||||
|
"ActionKeyword": "youtube",
|
||||||
|
"IconPath": "Images\\youtube.png",
|
||||||
|
"Url": "http://www.youtube.com/results?search_query={q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Bing",
|
||||||
|
"ActionKeyword": "bing",
|
||||||
|
"IconPath": "Images\\bing.png",
|
||||||
|
"URL": "https://www.bing.com/search?q={q}",
|
||||||
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Title": "Yahoo",
|
||||||
|
"ActionKeyword": "yahoo",
|
||||||
|
"IconPath": "Images\\yahoo.png",
|
||||||
|
"URL": "http://www.search.yahoo.com/search?p={q}",
|
||||||
|
"Enabled": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"EnableWebSearchSuggestion": false,
|
||||||
|
"WebSearchSuggestionSource": "Google"
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Windows;
|
||||||
using ICSharpCode.SharpZipLib.Zip;
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using System.Windows;
|
|
||||||
|
|
||||||
namespace Wox.Core.Plugin
|
namespace Wox.Core.Plugin
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Wox.Core.i18n
|
namespace Wox.Core.i18n
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
using Wox.Plugin;
|
namespace Wox.Infrastructure.Exception
|
||||||
|
|
||||||
namespace Wox.Infrastructure.Exception
|
|
||||||
{
|
{
|
||||||
public class WoxPluginException : WoxException
|
public class WoxPluginException : WoxException
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Diagnostics;
|
using NLog;
|
||||||
using NLog;
|
|
||||||
using Wox.Infrastructure.Exception;
|
using Wox.Infrastructure.Exception;
|
||||||
|
|
||||||
namespace Wox.Infrastructure.Logger
|
namespace Wox.Infrastructure.Logger
|
||||||
|
|
|
||||||
|
|
@ -1,565 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Wox.Infrastructure
|
|
||||||
{
|
|
||||||
// Source: http://code.cheesydesign.com/?p=572
|
|
||||||
/// <summary>
|
|
||||||
/// Reads in the header information of the Portable Executable format.
|
|
||||||
/// Provides information such as the date the assembly was compiled.
|
|
||||||
/// </summary>
|
|
||||||
public class PeHeaderReader
|
|
||||||
{
|
|
||||||
#region File Header Structures
|
|
||||||
|
|
||||||
public struct IMAGE_DOS_HEADER
|
|
||||||
{ // DOS .EXE header
|
|
||||||
public UInt16 e_magic; // Magic number
|
|
||||||
public UInt16 e_cblp; // Bytes on last page of file
|
|
||||||
public UInt16 e_cp; // Pages in file
|
|
||||||
public UInt16 e_crlc; // Relocations
|
|
||||||
public UInt16 e_cparhdr; // Size of header in paragraphs
|
|
||||||
public UInt16 e_minalloc; // Minimum extra paragraphs needed
|
|
||||||
public UInt16 e_maxalloc; // Maximum extra paragraphs needed
|
|
||||||
public UInt16 e_ss; // Initial (relative) SS value
|
|
||||||
public UInt16 e_sp; // Initial SP value
|
|
||||||
public UInt16 e_csum; // Checksum
|
|
||||||
public UInt16 e_ip; // Initial IP value
|
|
||||||
public UInt16 e_cs; // Initial (relative) CS value
|
|
||||||
public UInt16 e_lfarlc; // File address of relocation table
|
|
||||||
public UInt16 e_ovno; // Overlay number
|
|
||||||
public UInt16 e_res_0; // Reserved words
|
|
||||||
public UInt16 e_res_1; // Reserved words
|
|
||||||
public UInt16 e_res_2; // Reserved words
|
|
||||||
public UInt16 e_res_3; // Reserved words
|
|
||||||
public UInt16 e_oemid; // OEM identifier (for e_oeminfo)
|
|
||||||
public UInt16 e_oeminfo; // OEM information; e_oemid specific
|
|
||||||
public UInt16 e_res2_0; // Reserved words
|
|
||||||
public UInt16 e_res2_1; // Reserved words
|
|
||||||
public UInt16 e_res2_2; // Reserved words
|
|
||||||
public UInt16 e_res2_3; // Reserved words
|
|
||||||
public UInt16 e_res2_4; // Reserved words
|
|
||||||
public UInt16 e_res2_5; // Reserved words
|
|
||||||
public UInt16 e_res2_6; // Reserved words
|
|
||||||
public UInt16 e_res2_7; // Reserved words
|
|
||||||
public UInt16 e_res2_8; // Reserved words
|
|
||||||
public UInt16 e_res2_9; // Reserved words
|
|
||||||
public UInt32 e_lfanew; // File address of new exe header
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
public struct IMAGE_DATA_DIRECTORY
|
|
||||||
{
|
|
||||||
public UInt32 VirtualAddress;
|
|
||||||
public UInt32 Size;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
||||||
public struct IMAGE_OPTIONAL_HEADER32
|
|
||||||
{
|
|
||||||
public UInt16 Magic;
|
|
||||||
public Byte MajorLinkerVersion;
|
|
||||||
public Byte MinorLinkerVersion;
|
|
||||||
public UInt32 SizeOfCode;
|
|
||||||
public UInt32 SizeOfInitializedData;
|
|
||||||
public UInt32 SizeOfUninitializedData;
|
|
||||||
public UInt32 AddressOfEntryPoint;
|
|
||||||
public UInt32 BaseOfCode;
|
|
||||||
public UInt32 BaseOfData;
|
|
||||||
public UInt32 ImageBase;
|
|
||||||
public UInt32 SectionAlignment;
|
|
||||||
public UInt32 FileAlignment;
|
|
||||||
public UInt16 MajorOperatingSystemVersion;
|
|
||||||
public UInt16 MinorOperatingSystemVersion;
|
|
||||||
public UInt16 MajorImageVersion;
|
|
||||||
public UInt16 MinorImageVersion;
|
|
||||||
public UInt16 MajorSubsystemVersion;
|
|
||||||
public UInt16 MinorSubsystemVersion;
|
|
||||||
public UInt32 Win32VersionValue;
|
|
||||||
public UInt32 SizeOfImage;
|
|
||||||
public UInt32 SizeOfHeaders;
|
|
||||||
public UInt32 CheckSum;
|
|
||||||
public UInt16 Subsystem;
|
|
||||||
public UInt16 DllCharacteristics;
|
|
||||||
public UInt32 SizeOfStackReserve;
|
|
||||||
public UInt32 SizeOfStackCommit;
|
|
||||||
public UInt32 SizeOfHeapReserve;
|
|
||||||
public UInt32 SizeOfHeapCommit;
|
|
||||||
public UInt32 LoaderFlags;
|
|
||||||
public UInt32 NumberOfRvaAndSizes;
|
|
||||||
|
|
||||||
public IMAGE_DATA_DIRECTORY ExportTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY ImportTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY ResourceTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY ExceptionTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY CertificateTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY BaseRelocationTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY Debug;
|
|
||||||
public IMAGE_DATA_DIRECTORY Architecture;
|
|
||||||
public IMAGE_DATA_DIRECTORY GlobalPtr;
|
|
||||||
public IMAGE_DATA_DIRECTORY TLSTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY LoadConfigTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY BoundImport;
|
|
||||||
public IMAGE_DATA_DIRECTORY IAT;
|
|
||||||
public IMAGE_DATA_DIRECTORY DelayImportDescriptor;
|
|
||||||
public IMAGE_DATA_DIRECTORY CLRRuntimeHeader;
|
|
||||||
public IMAGE_DATA_DIRECTORY Reserved;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
||||||
public struct IMAGE_OPTIONAL_HEADER64
|
|
||||||
{
|
|
||||||
public UInt16 Magic;
|
|
||||||
public Byte MajorLinkerVersion;
|
|
||||||
public Byte MinorLinkerVersion;
|
|
||||||
public UInt32 SizeOfCode;
|
|
||||||
public UInt32 SizeOfInitializedData;
|
|
||||||
public UInt32 SizeOfUninitializedData;
|
|
||||||
public UInt32 AddressOfEntryPoint;
|
|
||||||
public UInt32 BaseOfCode;
|
|
||||||
public UInt64 ImageBase;
|
|
||||||
public UInt32 SectionAlignment;
|
|
||||||
public UInt32 FileAlignment;
|
|
||||||
public UInt16 MajorOperatingSystemVersion;
|
|
||||||
public UInt16 MinorOperatingSystemVersion;
|
|
||||||
public UInt16 MajorImageVersion;
|
|
||||||
public UInt16 MinorImageVersion;
|
|
||||||
public UInt16 MajorSubsystemVersion;
|
|
||||||
public UInt16 MinorSubsystemVersion;
|
|
||||||
public UInt32 Win32VersionValue;
|
|
||||||
public UInt32 SizeOfImage;
|
|
||||||
public UInt32 SizeOfHeaders;
|
|
||||||
public UInt32 CheckSum;
|
|
||||||
public UInt16 Subsystem;
|
|
||||||
public UInt16 DllCharacteristics;
|
|
||||||
public UInt64 SizeOfStackReserve;
|
|
||||||
public UInt64 SizeOfStackCommit;
|
|
||||||
public UInt64 SizeOfHeapReserve;
|
|
||||||
public UInt64 SizeOfHeapCommit;
|
|
||||||
public UInt32 LoaderFlags;
|
|
||||||
public UInt32 NumberOfRvaAndSizes;
|
|
||||||
|
|
||||||
public IMAGE_DATA_DIRECTORY ExportTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY ImportTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY ResourceTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY ExceptionTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY CertificateTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY BaseRelocationTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY Debug;
|
|
||||||
public IMAGE_DATA_DIRECTORY Architecture;
|
|
||||||
public IMAGE_DATA_DIRECTORY GlobalPtr;
|
|
||||||
public IMAGE_DATA_DIRECTORY TLSTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY LoadConfigTable;
|
|
||||||
public IMAGE_DATA_DIRECTORY BoundImport;
|
|
||||||
public IMAGE_DATA_DIRECTORY IAT;
|
|
||||||
public IMAGE_DATA_DIRECTORY DelayImportDescriptor;
|
|
||||||
public IMAGE_DATA_DIRECTORY CLRRuntimeHeader;
|
|
||||||
public IMAGE_DATA_DIRECTORY Reserved;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
||||||
public struct IMAGE_FILE_HEADER
|
|
||||||
{
|
|
||||||
public UInt16 Machine;
|
|
||||||
public UInt16 NumberOfSections;
|
|
||||||
public UInt32 TimeDateStamp;
|
|
||||||
public UInt32 PointerToSymbolTable;
|
|
||||||
public UInt32 NumberOfSymbols;
|
|
||||||
public UInt16 SizeOfOptionalHeader;
|
|
||||||
public UInt16 Characteristics;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grabbed the following 2 definitions from http://www.pinvoke.net/default.aspx/Structures/IMAGE_SECTION_HEADER.html
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
|
||||||
public struct IMAGE_SECTION_HEADER
|
|
||||||
{
|
|
||||||
[FieldOffset(0)]
|
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
|
||||||
public char[] Name;
|
|
||||||
[FieldOffset(8)]
|
|
||||||
public UInt32 VirtualSize;
|
|
||||||
[FieldOffset(12)]
|
|
||||||
public UInt32 VirtualAddress;
|
|
||||||
[FieldOffset(16)]
|
|
||||||
public UInt32 SizeOfRawData;
|
|
||||||
[FieldOffset(20)]
|
|
||||||
public UInt32 PointerToRawData;
|
|
||||||
[FieldOffset(24)]
|
|
||||||
public UInt32 PointerToRelocations;
|
|
||||||
[FieldOffset(28)]
|
|
||||||
public UInt32 PointerToLinenumbers;
|
|
||||||
[FieldOffset(32)]
|
|
||||||
public UInt16 NumberOfRelocations;
|
|
||||||
[FieldOffset(34)]
|
|
||||||
public UInt16 NumberOfLinenumbers;
|
|
||||||
[FieldOffset(36)]
|
|
||||||
public DataSectionFlags Characteristics;
|
|
||||||
|
|
||||||
public string Section
|
|
||||||
{
|
|
||||||
get { return new string(Name); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum DataSectionFlags : uint
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Reserved for future use.
|
|
||||||
/// </summary>
|
|
||||||
TypeReg = 0x00000000,
|
|
||||||
/// <summary>
|
|
||||||
/// Reserved for future use.
|
|
||||||
/// </summary>
|
|
||||||
TypeDsect = 0x00000001,
|
|
||||||
/// <summary>
|
|
||||||
/// Reserved for future use.
|
|
||||||
/// </summary>
|
|
||||||
TypeNoLoad = 0x00000002,
|
|
||||||
/// <summary>
|
|
||||||
/// Reserved for future use.
|
|
||||||
/// </summary>
|
|
||||||
TypeGroup = 0x00000004,
|
|
||||||
/// <summary>
|
|
||||||
/// The section should not be padded to the next boundary. This flag is obsolete and is replaced by IMAGE_SCN_ALIGN_1BYTES. This is valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
TypeNoPadded = 0x00000008,
|
|
||||||
/// <summary>
|
|
||||||
/// Reserved for future use.
|
|
||||||
/// </summary>
|
|
||||||
TypeCopy = 0x00000010,
|
|
||||||
/// <summary>
|
|
||||||
/// The section contains executable code.
|
|
||||||
/// </summary>
|
|
||||||
ContentCode = 0x00000020,
|
|
||||||
/// <summary>
|
|
||||||
/// The section contains initialized data.
|
|
||||||
/// </summary>
|
|
||||||
ContentInitializedData = 0x00000040,
|
|
||||||
/// <summary>
|
|
||||||
/// The section contains uninitialized data.
|
|
||||||
/// </summary>
|
|
||||||
ContentUninitializedData = 0x00000080,
|
|
||||||
/// <summary>
|
|
||||||
/// Reserved for future use.
|
|
||||||
/// </summary>
|
|
||||||
LinkOther = 0x00000100,
|
|
||||||
/// <summary>
|
|
||||||
/// The section contains comments or other information. The .drectve section has this type. This is valid for object files only.
|
|
||||||
/// </summary>
|
|
||||||
LinkInfo = 0x00000200,
|
|
||||||
/// <summary>
|
|
||||||
/// Reserved for future use.
|
|
||||||
/// </summary>
|
|
||||||
TypeOver = 0x00000400,
|
|
||||||
/// <summary>
|
|
||||||
/// The section will not become part of the image. This is valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
LinkRemove = 0x00000800,
|
|
||||||
/// <summary>
|
|
||||||
/// The section contains COMDAT data. For more information, see section 5.5.6, COMDAT Sections (Object Only). This is valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
LinkComDat = 0x00001000,
|
|
||||||
/// <summary>
|
|
||||||
/// Reset speculative exceptions handling bits in the TLB entries for this section.
|
|
||||||
/// </summary>
|
|
||||||
NoDeferSpecExceptions = 0x00004000,
|
|
||||||
/// <summary>
|
|
||||||
/// The section contains data referenced through the global pointer (GP).
|
|
||||||
/// </summary>
|
|
||||||
RelativeGP = 0x00008000,
|
|
||||||
/// <summary>
|
|
||||||
/// Reserved for future use.
|
|
||||||
/// </summary>
|
|
||||||
MemPurgeable = 0x00020000,
|
|
||||||
/// <summary>
|
|
||||||
/// Reserved for future use.
|
|
||||||
/// </summary>
|
|
||||||
Memory16Bit = 0x00020000,
|
|
||||||
/// <summary>
|
|
||||||
/// Reserved for future use.
|
|
||||||
/// </summary>
|
|
||||||
MemoryLocked = 0x00040000,
|
|
||||||
/// <summary>
|
|
||||||
/// Reserved for future use.
|
|
||||||
/// </summary>
|
|
||||||
MemoryPreload = 0x00080000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on a 1-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align1Bytes = 0x00100000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on a 2-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align2Bytes = 0x00200000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on a 4-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align4Bytes = 0x00300000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on an 8-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align8Bytes = 0x00400000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on a 16-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align16Bytes = 0x00500000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on a 32-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align32Bytes = 0x00600000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on a 64-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align64Bytes = 0x00700000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on a 128-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align128Bytes = 0x00800000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on a 256-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align256Bytes = 0x00900000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on a 512-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align512Bytes = 0x00A00000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on a 1024-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align1024Bytes = 0x00B00000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on a 2048-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align2048Bytes = 0x00C00000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on a 4096-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align4096Bytes = 0x00D00000,
|
|
||||||
/// <summary>
|
|
||||||
/// Align data on an 8192-byte boundary. Valid only for object files.
|
|
||||||
/// </summary>
|
|
||||||
Align8192Bytes = 0x00E00000,
|
|
||||||
/// <summary>
|
|
||||||
/// The section contains extended relocations.
|
|
||||||
/// </summary>
|
|
||||||
LinkExtendedRelocationOverflow = 0x01000000,
|
|
||||||
/// <summary>
|
|
||||||
/// The section can be discarded as needed.
|
|
||||||
/// </summary>
|
|
||||||
MemoryDiscardable = 0x02000000,
|
|
||||||
/// <summary>
|
|
||||||
/// The section cannot be cached.
|
|
||||||
/// </summary>
|
|
||||||
MemoryNotCached = 0x04000000,
|
|
||||||
/// <summary>
|
|
||||||
/// The section is not pageable.
|
|
||||||
/// </summary>
|
|
||||||
MemoryNotPaged = 0x08000000,
|
|
||||||
/// <summary>
|
|
||||||
/// The section can be shared in memory.
|
|
||||||
/// </summary>
|
|
||||||
MemoryShared = 0x10000000,
|
|
||||||
/// <summary>
|
|
||||||
/// The section can be executed as code.
|
|
||||||
/// </summary>
|
|
||||||
MemoryExecute = 0x20000000,
|
|
||||||
/// <summary>
|
|
||||||
/// The section can be read.
|
|
||||||
/// </summary>
|
|
||||||
MemoryRead = 0x40000000,
|
|
||||||
/// <summary>
|
|
||||||
/// The section can be written to.
|
|
||||||
/// </summary>
|
|
||||||
MemoryWrite = 0x80000000
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion File Header Structures
|
|
||||||
|
|
||||||
#region Private Fields
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The DOS header
|
|
||||||
/// </summary>
|
|
||||||
private IMAGE_DOS_HEADER dosHeader;
|
|
||||||
/// <summary>
|
|
||||||
/// The file header
|
|
||||||
/// </summary>
|
|
||||||
private IMAGE_FILE_HEADER fileHeader;
|
|
||||||
/// <summary>
|
|
||||||
/// Optional 32 bit file header
|
|
||||||
/// </summary>
|
|
||||||
private IMAGE_OPTIONAL_HEADER32 optionalHeader32;
|
|
||||||
/// <summary>
|
|
||||||
/// Optional 64 bit file header
|
|
||||||
/// </summary>
|
|
||||||
private IMAGE_OPTIONAL_HEADER64 optionalHeader64;
|
|
||||||
/// <summary>
|
|
||||||
/// Image Section headers. Number of sections is in the file header.
|
|
||||||
/// </summary>
|
|
||||||
private IMAGE_SECTION_HEADER[] imageSectionHeaders;
|
|
||||||
|
|
||||||
#endregion Private Fields
|
|
||||||
|
|
||||||
#region Public Methods
|
|
||||||
|
|
||||||
public PeHeaderReader(string filePath)
|
|
||||||
{
|
|
||||||
// Read in the DLL or EXE and get the timestamp
|
|
||||||
using (FileStream stream = new FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
|
|
||||||
{
|
|
||||||
BinaryReader reader = new BinaryReader(stream);
|
|
||||||
dosHeader = FromBinaryReader<IMAGE_DOS_HEADER>(reader);
|
|
||||||
|
|
||||||
// Add 4 bytes to the offset
|
|
||||||
stream.Seek(dosHeader.e_lfanew, SeekOrigin.Begin);
|
|
||||||
|
|
||||||
UInt32 ntHeadersSignature = reader.ReadUInt32();
|
|
||||||
fileHeader = FromBinaryReader<IMAGE_FILE_HEADER>(reader);
|
|
||||||
if (this.Is32BitHeader)
|
|
||||||
{
|
|
||||||
optionalHeader32 = FromBinaryReader<IMAGE_OPTIONAL_HEADER32>(reader);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
optionalHeader64 = FromBinaryReader<IMAGE_OPTIONAL_HEADER64>(reader);
|
|
||||||
}
|
|
||||||
|
|
||||||
imageSectionHeaders = new IMAGE_SECTION_HEADER[fileHeader.NumberOfSections];
|
|
||||||
for (int headerNo = 0; headerNo < imageSectionHeaders.Length; ++headerNo)
|
|
||||||
{
|
|
||||||
imageSectionHeaders[headerNo] = FromBinaryReader<IMAGE_SECTION_HEADER>(reader);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the header of the .NET assembly that called this function
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static PeHeaderReader GetCallingAssemblyHeader()
|
|
||||||
{
|
|
||||||
// Get the path to the calling assembly, which is the path to the
|
|
||||||
// DLL or EXE that we want the time of
|
|
||||||
string filePath = System.Reflection.Assembly.GetCallingAssembly().Location;
|
|
||||||
|
|
||||||
// Get and return the timestamp
|
|
||||||
return new PeHeaderReader(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the header of the .NET assembly that called this function
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static PeHeaderReader GetAssemblyHeader()
|
|
||||||
{
|
|
||||||
// Get the path to the calling assembly, which is the path to the
|
|
||||||
// DLL or EXE that we want the time of
|
|
||||||
string filePath = System.Reflection.Assembly.GetAssembly(typeof(PeHeaderReader)).Location;
|
|
||||||
|
|
||||||
// Get and return the timestamp
|
|
||||||
return new PeHeaderReader(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reads in a block from a file and converts it to the struct
|
|
||||||
/// type specified by the template parameter
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="reader"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static T FromBinaryReader<T>(BinaryReader reader)
|
|
||||||
{
|
|
||||||
// Read in a byte array
|
|
||||||
byte[] bytes = reader.ReadBytes(Marshal.SizeOf(typeof(T)));
|
|
||||||
|
|
||||||
// Pin the managed memory while, copy it out the data, then unpin it
|
|
||||||
GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
|
||||||
T theStructure = (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T));
|
|
||||||
handle.Free();
|
|
||||||
|
|
||||||
return theStructure;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Public Methods
|
|
||||||
|
|
||||||
#region Properties
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets if the file header is 32 bit or not
|
|
||||||
/// </summary>
|
|
||||||
public bool Is32BitHeader
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
UInt16 IMAGE_FILE_32BIT_MACHINE = 0x0100;
|
|
||||||
return (IMAGE_FILE_32BIT_MACHINE & FileHeader.Characteristics) == IMAGE_FILE_32BIT_MACHINE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the file header
|
|
||||||
/// </summary>
|
|
||||||
public IMAGE_FILE_HEADER FileHeader
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return fileHeader;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the optional header
|
|
||||||
/// </summary>
|
|
||||||
public IMAGE_OPTIONAL_HEADER32 OptionalHeader32
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return optionalHeader32;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the optional header
|
|
||||||
/// </summary>
|
|
||||||
public IMAGE_OPTIONAL_HEADER64 OptionalHeader64
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return optionalHeader64;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMAGE_SECTION_HEADER[] ImageSectionHeaders
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return imageSectionHeaders;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the timestamp from the file header
|
|
||||||
/// </summary>
|
|
||||||
public DateTime TimeStamp
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// Timestamp is a date offset from 1970
|
|
||||||
DateTime returnValue = new DateTime(1970, 1, 1, 0, 0, 0);
|
|
||||||
|
|
||||||
// Add in the number of seconds since 1970/1/1
|
|
||||||
returnValue = returnValue.AddSeconds(fileHeader.TimeDateStamp);
|
|
||||||
// Adjust to local timezone
|
|
||||||
returnValue += TimeZone.CurrentTimeZone.GetUtcOffset(returnValue);
|
|
||||||
|
|
||||||
return returnValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Properties
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
|
|
||||||
namespace Wox.Infrastructure
|
namespace Wox.Infrastructure
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System.IO;
|
||||||
using System.IO;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@
|
||||||
<Compile Include="Hotkey\InterceptKeys.cs" />
|
<Compile Include="Hotkey\InterceptKeys.cs" />
|
||||||
<Compile Include="Hotkey\KeyEvent.cs" />
|
<Compile Include="Hotkey\KeyEvent.cs" />
|
||||||
<Compile Include="Logger\Log.cs" />
|
<Compile Include="Logger\Log.cs" />
|
||||||
<Compile Include="PeHeaderReader.cs" />
|
|
||||||
<Compile Include="Stopwatch.cs" />
|
<Compile Include="Stopwatch.cs" />
|
||||||
<Compile Include="Storage\BinaryStorage.cs" />
|
<Compile Include="Storage\BinaryStorage.cs" />
|
||||||
<Compile Include="Storage\IStorage.cs" />
|
<Compile Include="Storage\IStorage.cs" />
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Wox.Plugin
|
namespace Wox.Plugin
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Wox.Plugin.Features
|
namespace Wox.Plugin.Features
|
||||||
{
|
{
|
||||||
[Obsolete("Delete Wox.Plugin.Features using directive, " +
|
[Obsolete("Delete Wox.Plugin.Features using directive, " +
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Wox.Plugin
|
namespace Wox.Plugin
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
using System;
|
using System.Windows;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Windows;
|
|
||||||
using Wox.Core.i18n;
|
using Wox.Core.i18n;
|
||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Windows.Threading;
|
|
||||||
|
|
||||||
namespace Wox
|
|
||||||
{
|
|
||||||
public static class DispatcherExtensions
|
|
||||||
{
|
|
||||||
private static Dictionary<string, DispatcherTimer> timers =
|
|
||||||
new Dictionary<string, DispatcherTimer>();
|
|
||||||
private static readonly object syncRoot = new object();
|
|
||||||
|
|
||||||
public static void DelayInvoke(this Dispatcher dispatcher, string namedInvocation,
|
|
||||||
Action action, TimeSpan delay,
|
|
||||||
DispatcherPriority priority = DispatcherPriority.Normal)
|
|
||||||
{
|
|
||||||
lock (syncRoot)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(namedInvocation))
|
|
||||||
{
|
|
||||||
namedInvocation = Guid.NewGuid().ToString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RemoveTimer(namedInvocation);
|
|
||||||
}
|
|
||||||
var timer = new DispatcherTimer(delay, priority, (s, e) =>
|
|
||||||
{
|
|
||||||
RemoveTimer(namedInvocation);
|
|
||||||
action();
|
|
||||||
}, dispatcher);
|
|
||||||
timer.Start();
|
|
||||||
timers.Add(namedInvocation, timer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void CancelNamedInvocation(this Dispatcher dispatcher, string namedInvocation)
|
|
||||||
{
|
|
||||||
lock (syncRoot)
|
|
||||||
{
|
|
||||||
RemoveTimer(namedInvocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void RemoveTimer(string namedInvocation)
|
|
||||||
{
|
|
||||||
if (!timers.ContainsKey(namedInvocation)) return;
|
|
||||||
timers[namedInvocation].Stop();
|
|
||||||
timers.Remove(namedInvocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Wox.Helper
|
||||||
List<Result> itemsToRemove = Items.Where(x => predicate(x)).ToList();
|
List<Result> itemsToRemove = Items.Where(x => predicate(x)).ToList();
|
||||||
if (itemsToRemove.Count > 0)
|
if (itemsToRemove.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
itemsToRemove.ForEach(item => Items.Remove(item));
|
itemsToRemove.ForEach(item => Items.Remove(item));
|
||||||
|
|
||||||
OnPropertyChanged(new PropertyChangedEventArgs("Count"));
|
OnPropertyChanged(new PropertyChangedEventArgs("Count"));
|
||||||
|
|
@ -40,10 +40,14 @@ namespace Wox.Helper
|
||||||
{
|
{
|
||||||
Result oldItem = Items[i];
|
Result oldItem = Items[i];
|
||||||
Result newItem = newItems[i];
|
Result newItem = newItems[i];
|
||||||
if (!Equals(oldItem, newItem))
|
if (!oldItem.Equals(newItem))
|
||||||
{
|
{
|
||||||
this[i] = newItem;
|
this[i] = newItem;
|
||||||
}
|
}
|
||||||
|
else if (oldItem.Score != newItem.Score)
|
||||||
|
{
|
||||||
|
this[i].Score = newItem.Score;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newCount > oldCount)
|
if (newCount > oldCount)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
@ -39,10 +40,10 @@ namespace Wox
|
||||||
SpecialKeyState specialKeyState = GlobalHotkey.Instance.CheckModifiers();
|
SpecialKeyState specialKeyState = GlobalHotkey.Instance.CheckModifiers();
|
||||||
|
|
||||||
var hotkeyModel = new HotkeyModel(
|
var hotkeyModel = new HotkeyModel(
|
||||||
specialKeyState.AltPressed,
|
specialKeyState.AltPressed,
|
||||||
specialKeyState.ShiftPressed,
|
specialKeyState.ShiftPressed,
|
||||||
specialKeyState.WinPressed,
|
specialKeyState.WinPressed,
|
||||||
specialKeyState.CtrlPressed,
|
specialKeyState.CtrlPressed,
|
||||||
key);
|
key);
|
||||||
|
|
||||||
var hotkeyString = hotkeyModel.ToString();
|
var hotkeyString = hotkeyModel.ToString();
|
||||||
|
|
@ -52,12 +53,11 @@ namespace Wox
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dispatcher.DelayInvoke("HotkeyAvailabilityTest",
|
Dispatcher.InvokeAsync(async () =>
|
||||||
() =>
|
{
|
||||||
{
|
await Task.Delay(500);
|
||||||
SetHotkey(hotkeyModel);
|
SetHotkey(hotkeyModel);
|
||||||
},
|
});
|
||||||
TimeSpan.FromMilliseconds(500));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHotkey(HotkeyModel keyModel, bool triggerValidate = true)
|
public void SetHotkey(HotkeyModel keyModel, bool triggerValidate = true)
|
||||||
|
|
@ -94,7 +94,7 @@ namespace Wox
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HotkeyManager.Current.AddOrReplace("HotkeyAvailabilityTest", CurrentHotkey.CharKey, CurrentHotkey.ModifierKeys, (sender, e) => {});
|
HotkeyManager.Current.AddOrReplace("HotkeyAvailabilityTest", CurrentHotkey.CharKey, CurrentHotkey.ModifierKeys, (sender, e) => { });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
@ -8,7 +7,6 @@ using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using Wox.Infrastructure;
|
using Wox.Infrastructure;
|
||||||
using Stopwatch = Wox.Infrastructure.Stopwatch;
|
|
||||||
|
|
||||||
namespace Wox.ImageLoader
|
namespace Wox.ImageLoader
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
@ -484,13 +485,14 @@ namespace Wox
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_lastQuery = query;
|
_lastQuery = query;
|
||||||
Dispatcher.DelayInvoke("ShowProgressbar", () =>
|
Dispatcher.InvokeAsync(async () =>
|
||||||
{
|
{
|
||||||
|
await Task.Delay(150);
|
||||||
if (!string.IsNullOrEmpty(query.RawQuery) && query.RawQuery == _lastQuery.RawQuery && !_queryHasReturn)
|
if (!string.IsNullOrEmpty(query.RawQuery) && query.RawQuery == _lastQuery.RawQuery && !_queryHasReturn)
|
||||||
{
|
{
|
||||||
StartProgress();
|
StartProgress();
|
||||||
}
|
}
|
||||||
}, TimeSpan.FromMilliseconds(150));
|
});
|
||||||
PluginManager.QueryForAllPlugins(query);
|
PluginManager.QueryForAllPlugins(query);
|
||||||
}
|
}
|
||||||
StopProgress();
|
StopProgress();
|
||||||
|
|
@ -829,6 +831,7 @@ namespace Wox
|
||||||
|
|
||||||
private void UpdateResultView(List<Result> list, PluginMetadata metadata, Query originQuery)
|
private void UpdateResultView(List<Result> list, PluginMetadata metadata, Query originQuery)
|
||||||
{
|
{
|
||||||
|
Thread.Sleep(3000);
|
||||||
_queryHasReturn = true;
|
_queryHasReturn = true;
|
||||||
progressBar.Dispatcher.Invoke(new Action(StopProgress));
|
progressBar.Dispatcher.Invoke(new Action(StopProgress));
|
||||||
|
|
||||||
|
|
|
||||||
124
Wox/Msg.xaml.cs
|
|
@ -7,71 +7,81 @@ using System.Windows.Media.Animation;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using Wox.Helper;
|
using Wox.Helper;
|
||||||
|
|
||||||
namespace Wox {
|
namespace Wox
|
||||||
public partial class Msg : Window {
|
{
|
||||||
Storyboard fadeOutStoryboard = new Storyboard();
|
public partial class Msg : Window
|
||||||
private bool closing = false;
|
{
|
||||||
|
Storyboard fadeOutStoryboard = new Storyboard();
|
||||||
|
private bool closing = false;
|
||||||
|
|
||||||
public Msg() {
|
public Msg()
|
||||||
InitializeComponent();
|
{
|
||||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
InitializeComponent();
|
||||||
var dipWorkingArea = WindowIntelopHelper.TransformPixelsToDIP(this,
|
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||||
|
var dipWorkingArea = WindowIntelopHelper.TransformPixelsToDIP(this,
|
||||||
screen.WorkingArea.Width,
|
screen.WorkingArea.Width,
|
||||||
screen.WorkingArea.Height);
|
screen.WorkingArea.Height);
|
||||||
Left = dipWorkingArea.X - this.Width;
|
Left = dipWorkingArea.X - this.Width;
|
||||||
Top = dipWorkingArea.Y;
|
Top = dipWorkingArea.Y;
|
||||||
showAnimation.From = dipWorkingArea.Y;
|
showAnimation.From = dipWorkingArea.Y;
|
||||||
showAnimation.To = dipWorkingArea.Y - Height;
|
showAnimation.To = dipWorkingArea.Y - Height;
|
||||||
|
|
||||||
// Create the fade out storyboard
|
// Create the fade out storyboard
|
||||||
fadeOutStoryboard.Completed += new EventHandler(fadeOutStoryboard_Completed);
|
fadeOutStoryboard.Completed += new EventHandler(fadeOutStoryboard_Completed);
|
||||||
DoubleAnimation fadeOutAnimation = new DoubleAnimation(dipWorkingArea.Y - Height, dipWorkingArea.Y, new Duration(TimeSpan.FromSeconds(0.3))) {
|
DoubleAnimation fadeOutAnimation = new DoubleAnimation(dipWorkingArea.Y - Height, dipWorkingArea.Y, new Duration(TimeSpan.FromSeconds(0.3)))
|
||||||
AccelerationRatio = 0.2
|
{
|
||||||
};
|
AccelerationRatio = 0.2
|
||||||
Storyboard.SetTarget(fadeOutAnimation, this);
|
};
|
||||||
Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty));
|
Storyboard.SetTarget(fadeOutAnimation, this);
|
||||||
fadeOutStoryboard.Children.Add(fadeOutAnimation);
|
Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty));
|
||||||
|
fadeOutStoryboard.Children.Add(fadeOutAnimation);
|
||||||
|
|
||||||
|
|
||||||
imgClose.Source = new BitmapImage(new Uri("Images\\close.pn", UriKind.Relative));
|
imgClose.Source = new BitmapImage(new Uri("Images\\close.pn", UriKind.Relative));
|
||||||
//imgClose.Source = new BitmapImage(new Uri(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Images\\close.png")));
|
//imgClose.Source = new BitmapImage(new Uri(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Images\\close.png")));
|
||||||
imgClose.MouseUp += imgClose_MouseUp;
|
imgClose.MouseUp += imgClose_MouseUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void imgClose_MouseUp(object sender, MouseButtonEventArgs e) {
|
void imgClose_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
if (!closing) {
|
{
|
||||||
closing = true;
|
if (!closing)
|
||||||
fadeOutStoryboard.Begin();
|
{
|
||||||
}
|
closing = true;
|
||||||
}
|
fadeOutStoryboard.Begin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void fadeOutStoryboard_Completed(object sender, EventArgs e) {
|
private void fadeOutStoryboard_Completed(object sender, EventArgs e)
|
||||||
Close();
|
{
|
||||||
}
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
public void Show(string title, string subTitle, string icopath) {
|
public void Show(string title, string subTitle, string icopath)
|
||||||
tbTitle.Text = title;
|
{
|
||||||
tbSubTitle.Text = subTitle;
|
tbTitle.Text = title;
|
||||||
if (string.IsNullOrEmpty(subTitle))
|
tbSubTitle.Text = subTitle;
|
||||||
{
|
if (string.IsNullOrEmpty(subTitle))
|
||||||
tbSubTitle.Visibility = Visibility.Collapsed;
|
{
|
||||||
}
|
tbSubTitle.Visibility = Visibility.Collapsed;
|
||||||
if (!File.Exists(icopath)) {
|
}
|
||||||
imgIco.Source = new BitmapImage(new Uri("Images\\app.png", UriKind.Relative));
|
if (!File.Exists(icopath))
|
||||||
}
|
{
|
||||||
else {
|
imgIco.Source = new BitmapImage(new Uri("Images\\app.png", UriKind.Relative));
|
||||||
imgIco.Source = new BitmapImage(new Uri(icopath));
|
}
|
||||||
}
|
else {
|
||||||
|
imgIco.Source = new BitmapImage(new Uri(icopath));
|
||||||
|
}
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
|
|
||||||
Dispatcher.DelayInvoke("ShowMsg",
|
Dispatcher.InvokeAsync(async () =>
|
||||||
() => {
|
{
|
||||||
if (!closing) {
|
if (!closing)
|
||||||
closing = true;
|
{
|
||||||
Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin));
|
closing = true;
|
||||||
}
|
await Dispatcher.InvokeAsync(fadeOutStoryboard.Begin);
|
||||||
}, TimeSpan.FromSeconds(3));
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Linq;
|
||||||
using System.Diagnostics;
|
using System.Runtime.Remoting.Contexts;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Remoting.Contexts;
|
|
||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
using Wox.Helper;
|
using Wox.Helper;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
|
|
@ -266,10 +263,10 @@ namespace Wox
|
||||||
if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
|
if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
|
||||||
{
|
{
|
||||||
lbResults.ScrollIntoView(e.AddedItems[0]);
|
lbResults.ScrollIntoView(e.AddedItems[0]);
|
||||||
Dispatcher.DelayInvoke("UpdateItemNumber", () =>
|
//Dispatcher.DelayInvoke("UpdateItemNumber", () =>
|
||||||
{
|
//{
|
||||||
UpdateItemNumber();
|
//UpdateItemNumber();
|
||||||
}, TimeSpan.FromMilliseconds(3));
|
//}, TimeSpan.FromMilliseconds(3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,209 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Wox.ShellContext
|
|
||||||
{
|
|
||||||
[Flags()]
|
|
||||||
public enum SHCONTF
|
|
||||||
{
|
|
||||||
FOLDERS = 0x20,
|
|
||||||
NONFOLDERS = 0x40,
|
|
||||||
INCLUDEHIDDEN = 0x80,
|
|
||||||
INIT_ON_FIRST_NEXT = 0x100,
|
|
||||||
NETPRINTERSRCH = 0x200,
|
|
||||||
SHAREABLE = 0x400,
|
|
||||||
STORAGE = 0x800
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags()]
|
|
||||||
public enum SFGAO
|
|
||||||
{
|
|
||||||
CANCOPY = 0x1,
|
|
||||||
CANMOVE = 0x2,
|
|
||||||
CANLINK = 0x4,
|
|
||||||
STORAGE = 0x8,
|
|
||||||
CANRENAME = 0x10,
|
|
||||||
CANDELETE = 0x20,
|
|
||||||
HASPROPSHEET = 0x40,
|
|
||||||
DROPTARGET = 0x100,
|
|
||||||
CAPABILITYMASK = 0x177,
|
|
||||||
ENCRYPTED = 0x2000,
|
|
||||||
ISSLOW = 0x4000,
|
|
||||||
GHOSTED = 0x8000,
|
|
||||||
LINK = 0x10000,
|
|
||||||
SHARE = 0x20000,
|
|
||||||
READONLY = 0x40000,
|
|
||||||
HIDDEN = 0x80000,
|
|
||||||
DISPLAYATTRMASK = 0xFC000,
|
|
||||||
FILESYSANCESTOR = 0x10000000,
|
|
||||||
FOLDER = 0x20000000,
|
|
||||||
FILESYSTEM = 0x40000000,
|
|
||||||
HASSUBFOLDER = unchecked((int)0x80000000),
|
|
||||||
CONTENTSMASK = unchecked((int)0x80000000),
|
|
||||||
VALIDATE = 0x1000000,
|
|
||||||
REMOVABLE = 0x2000000,
|
|
||||||
COMPRESSED = 0x4000000,
|
|
||||||
BROWSABLE = 0x8000000,
|
|
||||||
NONENUMERATED = 0x100000,
|
|
||||||
NEWCONTENT = 0x200000,
|
|
||||||
CANMONIKER = 0x400000,
|
|
||||||
HASSTORAGE = 0x400000,
|
|
||||||
STREAM = 0x400000,
|
|
||||||
STORAGEANCESTOR = 0x800000,
|
|
||||||
STORAGECAPMASK = 0x70C50008
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags()]
|
|
||||||
public enum SHGNO
|
|
||||||
{
|
|
||||||
NORMAL = 0x0,
|
|
||||||
INFOLDER = 0x1,
|
|
||||||
FOREDITING = 0x1000,
|
|
||||||
FORADDRESSBAR = 0x4000,
|
|
||||||
FORPARSING = 0x8000,
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags()]
|
|
||||||
public enum CSIDL
|
|
||||||
{
|
|
||||||
ADMINTOOLS = 0x30,
|
|
||||||
ALTSTARTUP = 0x1d,
|
|
||||||
APPDATA = 0x1a,
|
|
||||||
BITBUCKET = 10,
|
|
||||||
CDBURN_AREA = 0x3b,
|
|
||||||
COMMON_ADMINTOOLS = 0x2f,
|
|
||||||
COMMON_ALTSTARTUP = 30,
|
|
||||||
COMMON_APPDATA = 0x23,
|
|
||||||
COMMON_DESKTOPDIRECTORY = 0x19,
|
|
||||||
COMMON_DOCUMENTS = 0x2e,
|
|
||||||
COMMON_FAVORITES = 0x1f,
|
|
||||||
COMMON_MUSIC = 0x35,
|
|
||||||
COMMON_PICTURES = 0x36,
|
|
||||||
COMMON_PROGRAMS = 0x17,
|
|
||||||
COMMON_STARTMENU = 0x16,
|
|
||||||
COMMON_STARTUP = 0x18,
|
|
||||||
COMMON_TEMPLATES = 0x2d,
|
|
||||||
COMMON_VIDEO = 0x37,
|
|
||||||
CONTROLS = 3,
|
|
||||||
COOKIES = 0x21,
|
|
||||||
DESKTOP = 0,
|
|
||||||
DESKTOPDIRECTORY = 0x10,
|
|
||||||
DRIVES = 0x11,
|
|
||||||
FAVORITES = 6,
|
|
||||||
FLAG_CREATE = 0x8000,
|
|
||||||
FONTS = 20,
|
|
||||||
HISTORY = 0x22,
|
|
||||||
INTERNET = 1,
|
|
||||||
INTERNET_CACHE = 0x20,
|
|
||||||
LOCAL_APPDATA = 0x1c,
|
|
||||||
MYDOCUMENTS = 12,
|
|
||||||
MYMUSIC = 13,
|
|
||||||
MYPICTURES = 0x27,
|
|
||||||
MYVIDEO = 14,
|
|
||||||
NETHOOD = 0x13,
|
|
||||||
NETWORK = 0x12,
|
|
||||||
PERSONAL = 5,
|
|
||||||
PRINTERS = 4,
|
|
||||||
PRINTHOOD = 0x1b,
|
|
||||||
PROFILE = 40,
|
|
||||||
PROFILES = 0x3e,
|
|
||||||
PROGRAM_FILES = 0x26,
|
|
||||||
PROGRAM_FILES_COMMON = 0x2b,
|
|
||||||
PROGRAMS = 2,
|
|
||||||
RECENT = 8,
|
|
||||||
SENDTO = 9,
|
|
||||||
STARTMENU = 11,
|
|
||||||
STARTUP = 7,
|
|
||||||
SYSTEM = 0x25,
|
|
||||||
TEMPLATES = 0x15,
|
|
||||||
WINDOWS = 0x24
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags()]
|
|
||||||
public enum SHGFI : uint
|
|
||||||
{
|
|
||||||
ADDOVERLAYS = 0x20,
|
|
||||||
ATTR_SPECIFIED = 0x20000,
|
|
||||||
ATTRIBUTES = 0x800,
|
|
||||||
DISPLAYNAME = 0x200,
|
|
||||||
EXETYPE = 0x2000,
|
|
||||||
ICON = 0x100,
|
|
||||||
ICONLOCATION = 0x1000,
|
|
||||||
LARGEICON = 0,
|
|
||||||
LINKOVERLAY = 0x8000,
|
|
||||||
OPENICON = 2,
|
|
||||||
OVERLAYINDEX = 0x40,
|
|
||||||
PIDL = 8,
|
|
||||||
SELECTED = 0x10000,
|
|
||||||
SHELLICONSIZE = 4,
|
|
||||||
SMALLICON = 1,
|
|
||||||
SYSICONINDEX = 0x4000,
|
|
||||||
TYPENAME = 0x400,
|
|
||||||
USEFILEATTRIBUTES = 0x10
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum FILE_ATTRIBUTE
|
|
||||||
{
|
|
||||||
READONLY = 0x00000001,
|
|
||||||
HIDDEN = 0x00000002,
|
|
||||||
SYSTEM = 0x00000004,
|
|
||||||
DIRECTORY = 0x00000010,
|
|
||||||
ARCHIVE = 0x00000020,
|
|
||||||
DEVICE = 0x00000040,
|
|
||||||
NORMAL = 0x00000080,
|
|
||||||
TEMPORARY = 0x00000100,
|
|
||||||
SPARSE_FILE = 0x00000200,
|
|
||||||
REPARSE_POINT = 0x00000400,
|
|
||||||
COMPRESSED = 0x00000800,
|
|
||||||
OFFLINE = 0x00001000,
|
|
||||||
NOT_CONTENT_INDEXED = 0x00002000,
|
|
||||||
ENCRYPTED = 0x00004000
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum GetCommandStringInformations
|
|
||||||
{
|
|
||||||
VERB = 0x00000004,
|
|
||||||
HELPTEXT = 0x00000005,
|
|
||||||
VALIDATE = 0x00000006,
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum CMF : uint
|
|
||||||
{
|
|
||||||
NORMAL = 0x00000000,
|
|
||||||
DEFAULTONLY = 0x00000001,
|
|
||||||
VERBSONLY = 0x00000002,
|
|
||||||
EXPLORE = 0x00000004,
|
|
||||||
NOVERBS = 0x00000008,
|
|
||||||
CANRENAME = 0x00000010,
|
|
||||||
NODEFAULT = 0x00000020,
|
|
||||||
INCLUDESTATIC = 0x00000040,
|
|
||||||
EXTENDEDVERBS = 0x00000100,
|
|
||||||
RESERVED = 0xffff0000
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum TPM : uint
|
|
||||||
{
|
|
||||||
LEFTBUTTON = 0x0000,
|
|
||||||
RIGHTBUTTON = 0x0002,
|
|
||||||
LEFTALIGN = 0x0000,
|
|
||||||
CENTERALIGN = 0x0004,
|
|
||||||
RIGHTALIGN = 0x0008,
|
|
||||||
TOPALIGN = 0x0000,
|
|
||||||
VCENTERALIGN = 0x0010,
|
|
||||||
BOTTOMALIGN = 0x0020,
|
|
||||||
HORIZONTAL = 0x0000,
|
|
||||||
VERTICAL = 0x0040,
|
|
||||||
NONOTIFY = 0x0080,
|
|
||||||
RETURNCMD = 0x0100,
|
|
||||||
RECURSE = 0x0001,
|
|
||||||
HORPOSANIMATION = 0x0400,
|
|
||||||
HORNEGANIMATION = 0x0800,
|
|
||||||
VERPOSANIMATION = 0x1000,
|
|
||||||
VERNEGANIMATION = 0x2000,
|
|
||||||
NOANIMATION = 0x4000,
|
|
||||||
LAYOUTRTL = 0x8000
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Wox.ShellContext
|
|
||||||
{
|
|
||||||
public class Guids
|
|
||||||
{
|
|
||||||
public static Guid IID_DesktopGUID = new Guid("{00021400-0000-0000-C000-000000000046}");
|
|
||||||
|
|
||||||
public static Guid IID_IShellFolder = new Guid("{000214E6-0000-0000-C000-000000000046}");
|
|
||||||
public static Guid IID_IContextMenu = new Guid("{000214e4-0000-0000-c000-000000000046}");
|
|
||||||
public static Guid IID_IContextMenu2 = new Guid("{000214f4-0000-0000-c000-000000000046}");
|
|
||||||
public static Guid IID_IContextMenu3 = new Guid("{bcfce0a0-ec17-11d0-8d10-00a0c90f2719}");
|
|
||||||
|
|
||||||
public static Guid IID_IDropTarget = new Guid("{00000122-0000-0000-C000-000000000046}");
|
|
||||||
public static Guid IID_IDataObject = new Guid("{0000010e-0000-0000-C000-000000000046}");
|
|
||||||
|
|
||||||
public static Guid IID_IQueryInfo = new Guid("{00021500-0000-0000-C000-000000000046}");
|
|
||||||
public static Guid IID_IPersistFile = new Guid("{0000010b-0000-0000-C000-000000000046}");
|
|
||||||
|
|
||||||
public static Guid CLSID_DragDropHelper = new Guid("{4657278A-411B-11d2-839A-00C04FD918D0}");
|
|
||||||
public static Guid CLSID_NewMenu = new Guid("{D969A300-E7FF-11d0-A93B-00A0C90F2719}");
|
|
||||||
public static Guid IID_IDragSourceHelper = new Guid("{DE5BF786-477A-11d2-839D-00C04FD918D0}");
|
|
||||||
public static Guid IID_IDropTargetHelper = new Guid("{4657278B-411B-11d2-839A-00C04FD918D0}");
|
|
||||||
|
|
||||||
public static Guid IID_IShellExtInit = new Guid("{000214e8-0000-0000-c000-000000000046}");
|
|
||||||
public static Guid IID_IStream = new Guid("{0000000c-0000-0000-c000-000000000046}");
|
|
||||||
public static Guid IID_IStorage = new Guid("{0000000B-0000-0000-C000-000000000046}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Wox.ShellContext
|
|
||||||
{
|
|
||||||
[ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214e4-0000-0000-c000-000000000046")]
|
|
||||||
public interface IContextMenu
|
|
||||||
{
|
|
||||||
[PreserveSig()]
|
|
||||||
Int32 QueryContextMenu(
|
|
||||||
IntPtr hmenu,
|
|
||||||
uint iMenu,
|
|
||||||
uint idCmdFirst,
|
|
||||||
uint idCmdLast,
|
|
||||||
CMF uFlags);
|
|
||||||
|
|
||||||
[PreserveSig()]
|
|
||||||
Int32 InvokeCommand(
|
|
||||||
ref CMINVOKECOMMANDINFOEX info);
|
|
||||||
|
|
||||||
[PreserveSig()]
|
|
||||||
void GetCommandString(
|
|
||||||
int idcmd,
|
|
||||||
GetCommandStringInformations uflags,
|
|
||||||
int reserved,
|
|
||||||
StringBuilder commandstring,
|
|
||||||
int cch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Wox.ShellContext
|
|
||||||
{
|
|
||||||
[ComImport(),
|
|
||||||
Guid("000214F2-0000-0000-C000-000000000046"),
|
|
||||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
|
||||||
public interface IEnumIDList
|
|
||||||
{
|
|
||||||
[PreserveSig()]
|
|
||||||
uint Next(
|
|
||||||
uint celt,
|
|
||||||
out IntPtr rgelt,
|
|
||||||
out int pceltFetched);
|
|
||||||
|
|
||||||
void Skip(
|
|
||||||
uint celt);
|
|
||||||
|
|
||||||
void Reset();
|
|
||||||
|
|
||||||
IEnumIDList Clone();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Wox.ShellContext
|
|
||||||
{
|
|
||||||
[ComImport]
|
|
||||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
|
||||||
[Guid("000214E6-0000-0000-C000-000000000046")]
|
|
||||||
public interface IShellFolder
|
|
||||||
{
|
|
||||||
void ParseDisplayName(
|
|
||||||
IntPtr hwnd,
|
|
||||||
IntPtr pbc,
|
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] string pszDisplayName,
|
|
||||||
out uint pchEaten,
|
|
||||||
out IntPtr ppidl,
|
|
||||||
ref uint pdwAttributes);
|
|
||||||
|
|
||||||
[PreserveSig]
|
|
||||||
int EnumObjects(IntPtr hWnd, SHCONTF flags, out IntPtr enumIDList);
|
|
||||||
|
|
||||||
void BindToObject(
|
|
||||||
IntPtr pidl,
|
|
||||||
IntPtr pbc,
|
|
||||||
[In()] ref Guid riid,
|
|
||||||
out IShellFolder ppv);
|
|
||||||
|
|
||||||
void BindToStorage(
|
|
||||||
IntPtr pidl,
|
|
||||||
IntPtr pbc,
|
|
||||||
[In()] ref Guid riid,
|
|
||||||
[MarshalAs(UnmanagedType.Interface)] out object ppv);
|
|
||||||
|
|
||||||
[PreserveSig()]
|
|
||||||
uint CompareIDs(
|
|
||||||
int lParam,
|
|
||||||
IntPtr pidl1,
|
|
||||||
IntPtr pidl2);
|
|
||||||
|
|
||||||
void CreateViewObject(
|
|
||||||
IntPtr hwndOwner,
|
|
||||||
[In()] ref Guid riid,
|
|
||||||
[MarshalAs(UnmanagedType.Interface)] out object ppv);
|
|
||||||
|
|
||||||
void GetAttributesOf(
|
|
||||||
uint cidl,
|
|
||||||
[In(), MarshalAs(UnmanagedType.LPArray)] IntPtr[] apidl,
|
|
||||||
ref SFGAO rgfInOut);
|
|
||||||
|
|
||||||
//[PreserveSig]
|
|
||||||
//Int32 GetUIObjectOf(
|
|
||||||
// IntPtr hwndOwner,
|
|
||||||
// uint cidl,
|
|
||||||
// [MarshalAs(UnmanagedType.LPArray)]
|
|
||||||
// IntPtr[] apidl,
|
|
||||||
// Guid riid,
|
|
||||||
// IntPtr rgfReserved,
|
|
||||||
// out IntPtr ppv);
|
|
||||||
IntPtr GetUIObjectOf(
|
|
||||||
IntPtr hwndOwner,
|
|
||||||
uint cidl,
|
|
||||||
[MarshalAs(UnmanagedType.LPArray)] IntPtr[] apidl,
|
|
||||||
[In()] ref Guid riid,
|
|
||||||
out IntPtr rgfReserved);
|
|
||||||
|
|
||||||
void GetDisplayNameOf(
|
|
||||||
IntPtr pidl,
|
|
||||||
SHGNO uFlags,
|
|
||||||
IntPtr lpName);
|
|
||||||
|
|
||||||
IntPtr SetNameOf(
|
|
||||||
IntPtr hwnd,
|
|
||||||
IntPtr pidl,
|
|
||||||
[MarshalAs(UnmanagedType.LPWStr)] string pszName,
|
|
||||||
SHGNO uFlags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,195 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Wox.ShellContext
|
|
||||||
{
|
|
||||||
public class ShellAPI
|
|
||||||
{
|
|
||||||
#region API 导入
|
|
||||||
|
|
||||||
|
|
||||||
public const int MAX_PATH = 260;
|
|
||||||
public const int S_OK = 0;
|
|
||||||
public const int S_FALSE = 1;
|
|
||||||
public const uint CMD_FIRST = 1;
|
|
||||||
public const uint CMD_LAST = 30000;
|
|
||||||
|
|
||||||
public const Int32 MF_BYPOSITION = 0x400;
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
public static extern bool DeleteMenu(IntPtr hMenu, uint uPosition, uint uFlags);
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
public static extern int GetMenuItemCount(IntPtr hMenu);
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
|
||||||
public class MENUITEMINFO
|
|
||||||
{
|
|
||||||
public int cbSize = Marshal.SizeOf(typeof(MENUITEMINFO));
|
|
||||||
public int fMask;
|
|
||||||
public int fType;
|
|
||||||
public int fState;
|
|
||||||
public int wID;
|
|
||||||
public IntPtr hSubMenu;
|
|
||||||
public IntPtr hbmpChecked;
|
|
||||||
public IntPtr hbmpUnchecked;
|
|
||||||
public IntPtr dwItemData;
|
|
||||||
public string dwTypeData;
|
|
||||||
public int cch;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
|
||||||
public static extern bool GetMenuItemInfo(HandleRef hMenu, int uItem, bool fByPosition, [In, Out] MENUITEMINFO lpmii);
|
|
||||||
|
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
public static extern int GetMenuString(IntPtr hMenu, uint uIDItem, [Out, MarshalAs(UnmanagedType.LPStr)] StringBuilder lpString, int nMaxCount, uint uFlag);
|
|
||||||
|
|
||||||
|
|
||||||
[DllImport("shell32.dll")]
|
|
||||||
public static extern Int32 SHGetDesktopFolder(out IntPtr ppshf);
|
|
||||||
|
|
||||||
[DllImport("Shlwapi.Dll", CharSet = CharSet.Auto)]
|
|
||||||
public static extern Int32 StrRetToBuf(IntPtr pstr, IntPtr pidl, StringBuilder pszBuf, int cchBuf);
|
|
||||||
|
|
||||||
[DllImport("shell32.dll")]
|
|
||||||
public static extern int SHGetSpecialFolderLocation(IntPtr handle, CSIDL nFolder, out IntPtr ppidl);
|
|
||||||
|
|
||||||
[DllImport("shell32",
|
|
||||||
EntryPoint = "SHGetFileInfo",
|
|
||||||
ExactSpelling = false,
|
|
||||||
CharSet = CharSet.Auto,
|
|
||||||
SetLastError = true)]
|
|
||||||
public static extern IntPtr SHGetFileInfo(
|
|
||||||
IntPtr ppidl,
|
|
||||||
FILE_ATTRIBUTE dwFileAttributes,
|
|
||||||
ref SHFILEINFO sfi,
|
|
||||||
int cbFileInfo,
|
|
||||||
SHGFI uFlags);
|
|
||||||
|
|
||||||
[DllImport("user32",
|
|
||||||
SetLastError = true,
|
|
||||||
CharSet = CharSet.Auto)]
|
|
||||||
public static extern IntPtr CreatePopupMenu();
|
|
||||||
|
|
||||||
[DllImport("user32.dll",
|
|
||||||
ExactSpelling = true,
|
|
||||||
CharSet = CharSet.Auto)]
|
|
||||||
public static extern uint TrackPopupMenuEx(
|
|
||||||
IntPtr hmenu,
|
|
||||||
TPM flags,
|
|
||||||
int x,
|
|
||||||
int y,
|
|
||||||
IntPtr hwnd,
|
|
||||||
IntPtr lptpm);
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获得桌面 Shell
|
|
||||||
/// </summary>
|
|
||||||
public static IShellFolder GetDesktopFolder(out IntPtr ppshf)
|
|
||||||
{
|
|
||||||
SHGetDesktopFolder(out ppshf);
|
|
||||||
Object obj = Marshal.GetObjectForIUnknown(ppshf);
|
|
||||||
return (IShellFolder)obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取显示名称
|
|
||||||
/// </summary>
|
|
||||||
public static string GetNameByIShell(IShellFolder Root, IntPtr pidlSub)
|
|
||||||
{
|
|
||||||
IntPtr strr = Marshal.AllocCoTaskMem(MAX_PATH * 2 + 4);
|
|
||||||
Marshal.WriteInt32(strr, 0, 0);
|
|
||||||
StringBuilder buf = new StringBuilder(MAX_PATH);
|
|
||||||
Root.GetDisplayNameOf(pidlSub, SHGNO.INFOLDER, strr);
|
|
||||||
ShellAPI.StrRetToBuf(strr, pidlSub, buf, MAX_PATH);
|
|
||||||
return buf.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 根据 PIDL 获取显示名称
|
|
||||||
/// </summary>
|
|
||||||
public static string GetNameByPIDL(IntPtr pidl)
|
|
||||||
{
|
|
||||||
SHFILEINFO info = new SHFILEINFO();
|
|
||||||
ShellAPI.SHGetFileInfo(pidl, 0, ref info, Marshal.SizeOf(typeof(SHFILEINFO)),
|
|
||||||
SHGFI.PIDL | SHGFI.DISPLAYNAME | SHGFI.TYPENAME);
|
|
||||||
return info.szDisplayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PIDLShellFolder GetPIDLAndParentIShellFolder(string path)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (Directory.Exists(path))
|
|
||||||
{
|
|
||||||
return GetPIDLAndParentIshellFolderForFolder(path);
|
|
||||||
}
|
|
||||||
else if (File.Exists(path))
|
|
||||||
{
|
|
||||||
return GetPIDLAndParentIshellFolderForFile(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PIDLShellFolder GetPIDLAndParentIshellFolderForFolder(string folderPath)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get PIDL and parent shellfolder for given file path
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filePath"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static PIDLShellFolder GetPIDLAndParentIshellFolderForFile(string filePath)
|
|
||||||
{
|
|
||||||
//get desktopPtr first
|
|
||||||
IntPtr desktopPtr;
|
|
||||||
IShellFolder desktop = GetDesktopFolder(out desktopPtr);
|
|
||||||
|
|
||||||
string fileName = Path.GetFileName(filePath);
|
|
||||||
IShellFolder parentShellFolder;
|
|
||||||
string FolderPath = Directory.GetParent(filePath).FullName;
|
|
||||||
IntPtr Pidl = IntPtr.Zero;
|
|
||||||
uint i, j = 0;
|
|
||||||
desktop.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, FolderPath, out i, out Pidl, ref j);
|
|
||||||
desktop.BindToObject(Pidl, IntPtr.Zero, ref Guids.IID_IShellFolder, out parentShellFolder);
|
|
||||||
Marshal.ReleaseComObject(desktop);
|
|
||||||
|
|
||||||
IEnumIDList fileEnum = null;
|
|
||||||
IEnumIDList folderEnum = null;
|
|
||||||
IntPtr fileEnumPtr = IntPtr.Zero;
|
|
||||||
IntPtr folderEnumPtr = IntPtr.Zero;
|
|
||||||
IntPtr pidlSub;
|
|
||||||
int celtFetched;
|
|
||||||
|
|
||||||
if (parentShellFolder.EnumObjects(IntPtr.Zero, SHCONTF.NONFOLDERS | SHCONTF.INCLUDEHIDDEN, out folderEnumPtr) == ShellAPI.S_OK)
|
|
||||||
{
|
|
||||||
folderEnum = (IEnumIDList)Marshal.GetObjectForIUnknown(folderEnumPtr);
|
|
||||||
while (folderEnum.Next(1, out pidlSub, out celtFetched) == 0 && celtFetched == ShellAPI.S_FALSE)
|
|
||||||
{
|
|
||||||
string name = ShellAPI.GetNameByPIDL(pidlSub);
|
|
||||||
if (name == fileName)
|
|
||||||
{
|
|
||||||
PIDLShellFolder ps = new PIDLShellFolder { PIDL = pidlSub, ShellFolder = parentShellFolder };
|
|
||||||
Marshal.ReleaseComObject(parentShellFolder);
|
|
||||||
return ps;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Marshal.ReleaseComObject(parentShellFolder);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PIDLShellFolder
|
|
||||||
{
|
|
||||||
public IShellFolder ShellFolder { get; set; }
|
|
||||||
public IntPtr PIDL { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,98 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Wox.ShellContext
|
|
||||||
{
|
|
||||||
public class ShellContextMenuManager
|
|
||||||
{
|
|
||||||
public void GetContextMenus(string path)
|
|
||||||
{
|
|
||||||
IntPtr desktopPtr;
|
|
||||||
IShellFolder desktop = ShellAPI.GetDesktopFolder(out desktopPtr);
|
|
||||||
|
|
||||||
IntPtr ownerHwnd = IntPtr.Zero;
|
|
||||||
IShellFolder Root;
|
|
||||||
string FolderPath = Directory.GetParent(path).FullName;
|
|
||||||
IntPtr Pidl = IntPtr.Zero;
|
|
||||||
IShellFolder parent;
|
|
||||||
uint i, j = 0;
|
|
||||||
desktop.ParseDisplayName(ownerHwnd, IntPtr.Zero, FolderPath, out i, out Pidl, ref j);
|
|
||||||
desktop.BindToObject(Pidl, IntPtr.Zero, ref Guids.IID_IShellFolder, out Root);
|
|
||||||
Marshal.ReleaseComObject(desktop);
|
|
||||||
|
|
||||||
IEnumIDList fileEnum = null;
|
|
||||||
IEnumIDList folderEnum = null;
|
|
||||||
IntPtr fileEnumPtr = IntPtr.Zero;
|
|
||||||
IntPtr folderEnumPtr = IntPtr.Zero;
|
|
||||||
IntPtr pidlSub;
|
|
||||||
int celtFetched;
|
|
||||||
|
|
||||||
if (Root.EnumObjects(ownerHwnd, SHCONTF.FOLDERS | SHCONTF.INCLUDEHIDDEN, out fileEnumPtr) == ShellAPI.S_OK)
|
|
||||||
{
|
|
||||||
fileEnum = (IEnumIDList)Marshal.GetObjectForIUnknown(fileEnumPtr);
|
|
||||||
while (fileEnum.Next(1, out pidlSub, out celtFetched) == 0 && celtFetched == ShellAPI.S_FALSE)
|
|
||||||
{
|
|
||||||
string name = ShellAPI.GetNameByPIDL(pidlSub);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Root.EnumObjects(ownerHwnd, SHCONTF.NONFOLDERS | SHCONTF.INCLUDEHIDDEN, out folderEnumPtr) == ShellAPI.S_OK)
|
|
||||||
{
|
|
||||||
folderEnum = (IEnumIDList)Marshal.GetObjectForIUnknown(folderEnumPtr);
|
|
||||||
while (folderEnum.Next(1, out pidlSub, out celtFetched) == 0 && celtFetched == ShellAPI.S_FALSE)
|
|
||||||
{
|
|
||||||
string name = ShellAPI.GetNameByPIDL(pidlSub);
|
|
||||||
if (Path.GetFileName(path) == name)
|
|
||||||
{
|
|
||||||
IntPtr PIDL = pidlSub;
|
|
||||||
IShellFolder IParent = Root;
|
|
||||||
IntPtr[] pidls = new IntPtr[1];
|
|
||||||
pidls[0] = PIDL;
|
|
||||||
|
|
||||||
//get IContextMenu interface
|
|
||||||
IntPtr iContextMenuPtr = IntPtr.Zero;
|
|
||||||
iContextMenuPtr = IParent.GetUIObjectOf(IntPtr.Zero, (uint)pidls.Length,
|
|
||||||
pidls, ref Guids.IID_IContextMenu, out iContextMenuPtr);
|
|
||||||
IContextMenu iContextMenu = (IContextMenu)Marshal.GetObjectForIUnknown(iContextMenuPtr);
|
|
||||||
|
|
||||||
IntPtr contextMenu = ShellAPI.CreatePopupMenu();
|
|
||||||
iContextMenu.QueryContextMenu(contextMenu, 0, ShellAPI.CMD_FIRST, ShellAPI.CMD_LAST, CMF.NORMAL | CMF.EXPLORE);
|
|
||||||
ParseMenu(contextMenu);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Marshal.ReleaseComObject(Root);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ParseMenu(IntPtr contextMenu)
|
|
||||||
{
|
|
||||||
var menuItemCount = ShellAPI.GetMenuItemCount(contextMenu);
|
|
||||||
for (uint k = 0; k < menuItemCount - 1; k++)
|
|
||||||
{
|
|
||||||
StringBuilder menuName = new StringBuilder(320);
|
|
||||||
ShellAPI.GetMenuString(contextMenu, k, menuName, 320, ShellAPI.MF_BYPOSITION);
|
|
||||||
Debug.WriteLine(menuName.Replace("&", ""));
|
|
||||||
|
|
||||||
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms647578(v=vs.85).aspx
|
|
||||||
ShellAPI.MENUITEMINFO menuiteminfo_t;
|
|
||||||
int MIIM_SUBMENU = 0x00000004;
|
|
||||||
int MIIM_STRING = 0x00000040;
|
|
||||||
int MIIM_FTYPE = 0x00000100;
|
|
||||||
menuiteminfo_t = new ShellAPI.MENUITEMINFO();
|
|
||||||
menuiteminfo_t.fMask = MIIM_SUBMENU | MIIM_STRING | MIIM_FTYPE;
|
|
||||||
menuiteminfo_t.dwTypeData = new string('\0', 320);
|
|
||||||
menuiteminfo_t.cch = menuiteminfo_t.dwTypeData.Length - 1;
|
|
||||||
bool result = ShellAPI.GetMenuItemInfo(new HandleRef(null, contextMenu), (int)k, true, menuiteminfo_t);
|
|
||||||
if (menuiteminfo_t.hSubMenu != IntPtr.Zero)
|
|
||||||
{
|
|
||||||
ParseMenu(menuiteminfo_t.hSubMenu);
|
|
||||||
}
|
|
||||||
ShellAPI.DeleteMenu(contextMenu, k, ShellAPI.MF_BYPOSITION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Wox.ShellContext
|
|
||||||
{
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
|
||||||
public struct SHFILEINFO
|
|
||||||
{
|
|
||||||
public IntPtr hIcon;
|
|
||||||
public int iIcon;
|
|
||||||
public SFGAO dwAttributes;
|
|
||||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = ShellAPI.MAX_PATH)]
|
|
||||||
public string szDisplayName;
|
|
||||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
|
|
||||||
public string szTypeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
|
||||||
public struct CMINVOKECOMMANDINFO
|
|
||||||
{
|
|
||||||
public int cbSize; // sizeof(CMINVOKECOMMANDINFO)
|
|
||||||
public int fMask; // any combination of CMIC_MASK_*
|
|
||||||
public IntPtr hwnd; // might be NULL (indicating no owner window)
|
|
||||||
public IntPtr lpVerb; // either a string or MAKEINTRESOURCE(idOffset)
|
|
||||||
public IntPtr lpParameters; // might be NULL (indicating no parameter)
|
|
||||||
public IntPtr lpDirectory; // might be NULL (indicating no specific directory)
|
|
||||||
public int nShow; // one of SW_ values for ShowWindow() API
|
|
||||||
public int dwHotKey;
|
|
||||||
public IntPtr hIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
||||||
public struct CMINVOKECOMMANDINFOEX
|
|
||||||
{
|
|
||||||
public int cbSize;
|
|
||||||
public uint fMask;
|
|
||||||
public IntPtr hwnd;
|
|
||||||
public IntPtr lpVerb;
|
|
||||||
[MarshalAs(UnmanagedType.LPStr)]
|
|
||||||
public string lpParameters;
|
|
||||||
[MarshalAs(UnmanagedType.LPStr)]
|
|
||||||
public string lpDirectory;
|
|
||||||
public int nShow;
|
|
||||||
public int dwHotKey;
|
|
||||||
public IntPtr hIcon;
|
|
||||||
[MarshalAs(UnmanagedType.LPStr)]
|
|
||||||
public string lpTitle;
|
|
||||||
public IntPtr lpVerbW;
|
|
||||||
[MarshalAs(UnmanagedType.LPWStr)]
|
|
||||||
public string lpParametersW;
|
|
||||||
[MarshalAs(UnmanagedType.LPWStr)]
|
|
||||||
public string lpDirectoryW;
|
|
||||||
[MarshalAs(UnmanagedType.LPWStr)]
|
|
||||||
public string lpTitleW;
|
|
||||||
public POINT ptInvoke;
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
|
||||||
public struct POINT
|
|
||||||
{
|
|
||||||
public POINT(int x, int y)
|
|
||||||
{
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int x;
|
|
||||||
public int y;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -126,14 +126,6 @@
|
||||||
<Compile Include="Helper\ListBoxItems.cs" />
|
<Compile Include="Helper\ListBoxItems.cs" />
|
||||||
<Compile Include="Helper\SingletonWindowOpener.cs" />
|
<Compile Include="Helper\SingletonWindowOpener.cs" />
|
||||||
<Compile Include="ImageLoader\ImageCacheStroage.cs" />
|
<Compile Include="ImageLoader\ImageCacheStroage.cs" />
|
||||||
<Compile Include="ShellContext\ShellContextMenuManager.cs" />
|
|
||||||
<Compile Include="ShellContext\ShellAPI.cs" />
|
|
||||||
<Compile Include="ShellContext\Enums.cs" />
|
|
||||||
<Compile Include="ShellContext\Guids.cs" />
|
|
||||||
<Compile Include="ShellContext\IContextMenu.cs" />
|
|
||||||
<Compile Include="ShellContext\IEnumIDList.cs" />
|
|
||||||
<Compile Include="ShellContext\IShellFolder.cs" />
|
|
||||||
<Compile Include="ShellContext\Structs.cs" />
|
|
||||||
<Compile Include="Storage\QueryHistoryStorage.cs" />
|
<Compile Include="Storage\QueryHistoryStorage.cs" />
|
||||||
<Compile Include="Storage\TopMostRecordStorage.cs" />
|
<Compile Include="Storage\TopMostRecordStorage.cs" />
|
||||||
<Compile Include="Storage\UserSelectedRecordStorage.cs" />
|
<Compile Include="Storage\UserSelectedRecordStorage.cs" />
|
||||||
|
|
@ -163,7 +155,6 @@
|
||||||
<Compile Include="CustomQueryHotkeySetting.xaml.cs">
|
<Compile Include="CustomQueryHotkeySetting.xaml.cs">
|
||||||
<DependentUpon>CustomQueryHotkeySetting.xaml</DependentUpon>
|
<DependentUpon>CustomQueryHotkeySetting.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Helper\DispatcherExtensions.cs" />
|
|
||||||
<Compile Include="Helper\DWMDropShadow.cs" />
|
<Compile Include="Helper\DWMDropShadow.cs" />
|
||||||
<Compile Include="HotkeyControl.xaml.cs">
|
<Compile Include="HotkeyControl.xaml.cs">
|
||||||
<DependentUpon>HotkeyControl.xaml</DependentUpon>
|
<DependentUpon>HotkeyControl.xaml</DependentUpon>
|
||||||
|
|
|
||||||