diff --git a/.gitignore b/.gitignore index 57103cd78..ed408abb7 100644 --- a/.gitignore +++ b/.gitignore @@ -113,6 +113,9 @@ _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML +# Temporary caches used by Roslyn. +.vs + *.DotSettings /Python.Runtime.dll Wox/Images/websearch/Thumbs.db diff --git a/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs b/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs index 1971cf95a..ac5c1bab1 100644 --- a/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs +++ b/Plugins/Wox.Plugin.Everything/ContextMenuStorage.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.IO; using System.Reflection; -using JsonProperty = Newtonsoft.Json.JsonPropertyAttribute; using Wox.Infrastructure.Storage; +using JsonProperty = Newtonsoft.Json.JsonPropertyAttribute; namespace Wox.Plugin.Everything { diff --git a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs index 269904467..638ac756f 100644 --- a/Plugins/Wox.Plugin.Folder/FolderPlugin.cs +++ b/Plugins/Wox.Plugin.Folder/FolderPlugin.cs @@ -109,7 +109,7 @@ namespace Wox.Plugin.Folder return false; } } - context.API.ChangeQuery(item.Path); + context.API.ChangeQuery(item.Path + (item.Path.EndsWith("\\")? "": "\\")); return false; }, ContextData = item diff --git a/Plugins/Wox.Plugin.PluginManagement/Main.cs b/Plugins/Wox.Plugin.PluginManagement/Main.cs index 785d28017..45585db05 100644 --- a/Plugins/Wox.Plugin.PluginManagement/Main.cs +++ b/Plugins/Wox.Plugin.PluginManagement/Main.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Net; diff --git a/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs b/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs index cb3b315aa..6119abdb1 100644 --- a/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs +++ b/Plugins/Wox.Plugin.Program/FileChangeWatcher.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Threading; using Wox.Infrastructure.Logger; + namespace Wox.Plugin.Program { internal class FileChangeWatcher diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs index b73173a22..80323029d 100644 --- a/Plugins/Wox.Plugin.Program/Programs.cs +++ b/Plugins/Wox.Plugin.Program/Programs.cs @@ -6,8 +6,8 @@ using System.Linq; using System.Reflection; using System.Windows; using Wox.Infrastructure; -using Wox.Plugin.Program.ProgramSources; using Wox.Infrastructure.Logger; +using Wox.Plugin.Program.ProgramSources; using Stopwatch = Wox.Infrastructure.Stopwatch; namespace Wox.Plugin.Program diff --git a/Plugins/Wox.Plugin.Sys/Sys.cs b/Plugins/Wox.Plugin.Sys/Sys.cs index 9b2f838e6..2f68e3c99 100644 --- a/Plugins/Wox.Plugin.Sys/Sys.cs +++ b/Plugins/Wox.Plugin.Sys/Sys.cs @@ -5,11 +5,13 @@ using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Windows; +using System.Windows.Forms; using System.Windows.Interop; using Wox.Infrastructure; -using FormsApplication = System.Windows.Forms.Application; -using PowerState = System.Windows.Forms.PowerState; +using Application = System.Windows.Application; using Control = System.Windows.Controls.Control; +using FormsApplication = System.Windows.Forms.Application; +using MessageBox = System.Windows.MessageBox; namespace Wox.Plugin.Sys { diff --git a/Plugins/Wox.Plugin.WebSearch/Images/bing.png b/Plugins/Wox.Plugin.WebSearch/Images/bing.png new file mode 100644 index 000000000..8e4ee8ea2 Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/bing.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/duckduckgo.png b/Plugins/Wox.Plugin.WebSearch/Images/duckduckgo.png new file mode 100644 index 000000000..d4f360817 Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/duckduckgo.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/facebook.png b/Plugins/Wox.Plugin.WebSearch/Images/facebook.png new file mode 100644 index 000000000..75f0a543e Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/facebook.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/gist.png b/Plugins/Wox.Plugin.WebSearch/Images/gist.png new file mode 100644 index 000000000..a804cece0 Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/gist.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/github.png b/Plugins/Wox.Plugin.WebSearch/Images/github.png new file mode 100644 index 000000000..54aa26b8e Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/github.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/gmail.png b/Plugins/Wox.Plugin.WebSearch/Images/gmail.png new file mode 100644 index 000000000..e00e3cd2d Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/gmail.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/google_drive.png b/Plugins/Wox.Plugin.WebSearch/Images/google_drive.png new file mode 100644 index 000000000..ce2346a31 Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/google_drive.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/google_maps.png b/Plugins/Wox.Plugin.WebSearch/Images/google_maps.png new file mode 100644 index 000000000..2413eec58 Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/google_maps.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/google_translate.png b/Plugins/Wox.Plugin.WebSearch/Images/google_translate.png new file mode 100644 index 000000000..63ff5c883 Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/google_translate.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/stackoverflow.png b/Plugins/Wox.Plugin.WebSearch/Images/stackoverflow.png new file mode 100644 index 000000000..a31f6a96d Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/stackoverflow.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/twitter.png b/Plugins/Wox.Plugin.WebSearch/Images/twitter.png new file mode 100644 index 000000000..3c7c61da3 Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/twitter.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/wolframalpha.png b/Plugins/Wox.Plugin.WebSearch/Images/wolframalpha.png new file mode 100644 index 000000000..c45021f0e Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/wolframalpha.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/yahoo.png b/Plugins/Wox.Plugin.WebSearch/Images/yahoo.png new file mode 100644 index 000000000..cf8453c9f Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/yahoo.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/Images/youtube.png b/Plugins/Wox.Plugin.WebSearch/Images/youtube.png new file mode 100644 index 000000000..e044efbef Binary files /dev/null and b/Plugins/Wox.Plugin.WebSearch/Images/youtube.png differ diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs index 68bd9e9c6..0e225df03 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchPlugin.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; @@ -79,10 +78,7 @@ namespace Wox.Plugin.WebSearch public void Init(PluginInitContext context) { - this.Context = context; - - if (WebSearchStorage.Instance.WebSearches == null) - WebSearchStorage.Instance.WebSearches = WebSearchStorage.Instance.LoadDefaultWebSearches(); + Context = context; } #region ISettingProvider Members diff --git a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs index fec8f937a..5a059a238 100644 --- a/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs +++ b/Plugins/Wox.Plugin.WebSearch/WebSearchStorage.cs @@ -6,7 +6,7 @@ using Wox.Infrastructure.Storage; namespace Wox.Plugin.WebSearch { - public class WebSearchStorage :JsonStrorage + public class WebSearchStorage : JsonStrorage { [JsonProperty] public List WebSearches { get; set; } @@ -26,49 +26,5 @@ namespace Wox.Plugin.WebSearch { get { return "setting"; } } - - protected override WebSearchStorage LoadDefault() - { - WebSearches = LoadDefaultWebSearches(); - return this; - } - - public List LoadDefaultWebSearches() - { - List webSearches = new List(); - - 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; - } } } diff --git a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj index 667253e6a..44ccaff99 100644 --- a/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj +++ b/Plugins/Wox.Plugin.WebSearch/Wox.Plugin.WebSearch.csproj @@ -79,6 +79,48 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + MSBuild:Compile Designer @@ -94,6 +136,9 @@ Designer PreserveNewest + + PreserveNewest + MSBuild:Compile Designer diff --git a/Plugins/Wox.Plugin.WebSearch/plugin.json b/Plugins/Wox.Plugin.WebSearch/plugin.json index 6b0182734..751208bc7 100644 --- a/Plugins/Wox.Plugin.WebSearch/plugin.json +++ b/Plugins/Wox.Plugin.WebSearch/plugin.json @@ -1,12 +1,32 @@ { - "ID":"565B73353DBF4806919830B9202EE3BF", - "ActionKeywords": ["g", "wiki", "findicon"], - "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" + "ID": "565B73353DBF4806919830B9202EE3BF", + "ActionKeywords": [ + "g", + "wiki", + "findicon", + "facebook", + "twitter", + "maps", + "translate", + "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" } diff --git a/Plugins/Wox.Plugin.WebSearch/setting.json b/Plugins/Wox.Plugin.WebSearch/setting.json new file mode 100644 index 000000000..c31d02ae6 --- /dev/null +++ b/Plugins/Wox.Plugin.WebSearch/setting.json @@ -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" +} \ No newline at end of file diff --git a/SolutionAssemblyInfo.cs b/SolutionAssemblyInfo.cs index 58182e660..e90020359 100644 --- a/SolutionAssemblyInfo.cs +++ b/SolutionAssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; #if DEBUG diff --git a/Wox.Core/Plugin/PluginInstaller.cs b/Wox.Core/Plugin/PluginInstaller.cs index f20f2fd07..ec022a582 100644 --- a/Wox.Core/Plugin/PluginInstaller.cs +++ b/Wox.Core/Plugin/PluginInstaller.cs @@ -1,10 +1,9 @@ using System; -using System.Diagnostics; using System.IO; +using System.Windows; using ICSharpCode.SharpZipLib.Zip; using Newtonsoft.Json; using Wox.Plugin; -using System.Windows; namespace Wox.Core.Plugin { diff --git a/Wox.Core/i18n/AvailableLanguages.cs b/Wox.Core/i18n/AvailableLanguages.cs index 652382943..30a0dc69d 100644 --- a/Wox.Core/i18n/AvailableLanguages.cs +++ b/Wox.Core/i18n/AvailableLanguages.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace Wox.Core.i18n { diff --git a/Wox.Infrastructure/Exception/WoxPluginException.cs b/Wox.Infrastructure/Exception/WoxPluginException.cs index 0987ca69d..b68af28ab 100644 --- a/Wox.Infrastructure/Exception/WoxPluginException.cs +++ b/Wox.Infrastructure/Exception/WoxPluginException.cs @@ -1,6 +1,4 @@ -using Wox.Plugin; - -namespace Wox.Infrastructure.Exception +namespace Wox.Infrastructure.Exception { public class WoxPluginException : WoxException { diff --git a/Wox.Infrastructure/Logger/Log.cs b/Wox.Infrastructure/Logger/Log.cs index d911e5bcb..92f84cfaa 100644 --- a/Wox.Infrastructure/Logger/Log.cs +++ b/Wox.Infrastructure/Logger/Log.cs @@ -1,5 +1,4 @@ -using System.Diagnostics; -using NLog; +using NLog; using Wox.Infrastructure.Exception; namespace Wox.Infrastructure.Logger diff --git a/Wox.Infrastructure/PeHeaderReader.cs b/Wox.Infrastructure/PeHeaderReader.cs deleted file mode 100644 index ebae5c6a6..000000000 --- a/Wox.Infrastructure/PeHeaderReader.cs +++ /dev/null @@ -1,565 +0,0 @@ -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace Wox.Infrastructure -{ - // Source: http://code.cheesydesign.com/?p=572 - /// - /// Reads in the header information of the Portable Executable format. - /// Provides information such as the date the assembly was compiled. - /// - 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 - { - /// - /// Reserved for future use. - /// - TypeReg = 0x00000000, - /// - /// Reserved for future use. - /// - TypeDsect = 0x00000001, - /// - /// Reserved for future use. - /// - TypeNoLoad = 0x00000002, - /// - /// Reserved for future use. - /// - TypeGroup = 0x00000004, - /// - /// 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. - /// - TypeNoPadded = 0x00000008, - /// - /// Reserved for future use. - /// - TypeCopy = 0x00000010, - /// - /// The section contains executable code. - /// - ContentCode = 0x00000020, - /// - /// The section contains initialized data. - /// - ContentInitializedData = 0x00000040, - /// - /// The section contains uninitialized data. - /// - ContentUninitializedData = 0x00000080, - /// - /// Reserved for future use. - /// - LinkOther = 0x00000100, - /// - /// The section contains comments or other information. The .drectve section has this type. This is valid for object files only. - /// - LinkInfo = 0x00000200, - /// - /// Reserved for future use. - /// - TypeOver = 0x00000400, - /// - /// The section will not become part of the image. This is valid only for object files. - /// - LinkRemove = 0x00000800, - /// - /// The section contains COMDAT data. For more information, see section 5.5.6, COMDAT Sections (Object Only). This is valid only for object files. - /// - LinkComDat = 0x00001000, - /// - /// Reset speculative exceptions handling bits in the TLB entries for this section. - /// - NoDeferSpecExceptions = 0x00004000, - /// - /// The section contains data referenced through the global pointer (GP). - /// - RelativeGP = 0x00008000, - /// - /// Reserved for future use. - /// - MemPurgeable = 0x00020000, - /// - /// Reserved for future use. - /// - Memory16Bit = 0x00020000, - /// - /// Reserved for future use. - /// - MemoryLocked = 0x00040000, - /// - /// Reserved for future use. - /// - MemoryPreload = 0x00080000, - /// - /// Align data on a 1-byte boundary. Valid only for object files. - /// - Align1Bytes = 0x00100000, - /// - /// Align data on a 2-byte boundary. Valid only for object files. - /// - Align2Bytes = 0x00200000, - /// - /// Align data on a 4-byte boundary. Valid only for object files. - /// - Align4Bytes = 0x00300000, - /// - /// Align data on an 8-byte boundary. Valid only for object files. - /// - Align8Bytes = 0x00400000, - /// - /// Align data on a 16-byte boundary. Valid only for object files. - /// - Align16Bytes = 0x00500000, - /// - /// Align data on a 32-byte boundary. Valid only for object files. - /// - Align32Bytes = 0x00600000, - /// - /// Align data on a 64-byte boundary. Valid only for object files. - /// - Align64Bytes = 0x00700000, - /// - /// Align data on a 128-byte boundary. Valid only for object files. - /// - Align128Bytes = 0x00800000, - /// - /// Align data on a 256-byte boundary. Valid only for object files. - /// - Align256Bytes = 0x00900000, - /// - /// Align data on a 512-byte boundary. Valid only for object files. - /// - Align512Bytes = 0x00A00000, - /// - /// Align data on a 1024-byte boundary. Valid only for object files. - /// - Align1024Bytes = 0x00B00000, - /// - /// Align data on a 2048-byte boundary. Valid only for object files. - /// - Align2048Bytes = 0x00C00000, - /// - /// Align data on a 4096-byte boundary. Valid only for object files. - /// - Align4096Bytes = 0x00D00000, - /// - /// Align data on an 8192-byte boundary. Valid only for object files. - /// - Align8192Bytes = 0x00E00000, - /// - /// The section contains extended relocations. - /// - LinkExtendedRelocationOverflow = 0x01000000, - /// - /// The section can be discarded as needed. - /// - MemoryDiscardable = 0x02000000, - /// - /// The section cannot be cached. - /// - MemoryNotCached = 0x04000000, - /// - /// The section is not pageable. - /// - MemoryNotPaged = 0x08000000, - /// - /// The section can be shared in memory. - /// - MemoryShared = 0x10000000, - /// - /// The section can be executed as code. - /// - MemoryExecute = 0x20000000, - /// - /// The section can be read. - /// - MemoryRead = 0x40000000, - /// - /// The section can be written to. - /// - MemoryWrite = 0x80000000 - } - - #endregion File Header Structures - - #region Private Fields - - /// - /// The DOS header - /// - private IMAGE_DOS_HEADER dosHeader; - /// - /// The file header - /// - private IMAGE_FILE_HEADER fileHeader; - /// - /// Optional 32 bit file header - /// - private IMAGE_OPTIONAL_HEADER32 optionalHeader32; - /// - /// Optional 64 bit file header - /// - private IMAGE_OPTIONAL_HEADER64 optionalHeader64; - /// - /// Image Section headers. Number of sections is in the file header. - /// - 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(reader); - - // Add 4 bytes to the offset - stream.Seek(dosHeader.e_lfanew, SeekOrigin.Begin); - - UInt32 ntHeadersSignature = reader.ReadUInt32(); - fileHeader = FromBinaryReader(reader); - if (this.Is32BitHeader) - { - optionalHeader32 = FromBinaryReader(reader); - } - else - { - optionalHeader64 = FromBinaryReader(reader); - } - - imageSectionHeaders = new IMAGE_SECTION_HEADER[fileHeader.NumberOfSections]; - for (int headerNo = 0; headerNo < imageSectionHeaders.Length; ++headerNo) - { - imageSectionHeaders[headerNo] = FromBinaryReader(reader); - } - - } - } - - /// - /// Gets the header of the .NET assembly that called this function - /// - /// - 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); - } - - /// - /// Gets the header of the .NET assembly that called this function - /// - /// - 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); - } - - /// - /// Reads in a block from a file and converts it to the struct - /// type specified by the template parameter - /// - /// - /// - /// - public static T FromBinaryReader(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 - - /// - /// Gets if the file header is 32 bit or not - /// - public bool Is32BitHeader - { - get - { - UInt16 IMAGE_FILE_32BIT_MACHINE = 0x0100; - return (IMAGE_FILE_32BIT_MACHINE & FileHeader.Characteristics) == IMAGE_FILE_32BIT_MACHINE; - } - } - - /// - /// Gets the file header - /// - public IMAGE_FILE_HEADER FileHeader - { - get - { - return fileHeader; - } - } - - /// - /// Gets the optional header - /// - public IMAGE_OPTIONAL_HEADER32 OptionalHeader32 - { - get - { - return optionalHeader32; - } - } - - /// - /// Gets the optional header - /// - public IMAGE_OPTIONAL_HEADER64 OptionalHeader64 - { - get - { - return optionalHeader64; - } - } - - public IMAGE_SECTION_HEADER[] ImageSectionHeaders - { - get - { - return imageSectionHeaders; - } - } - - /// - /// Gets the timestamp from the file header - /// - 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 - } -} \ No newline at end of file diff --git a/Wox.Infrastructure/Stopwatch.cs b/Wox.Infrastructure/Stopwatch.cs index 7387734d5..c58d2088c 100644 --- a/Wox.Infrastructure/Stopwatch.cs +++ b/Wox.Infrastructure/Stopwatch.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using Wox.Infrastructure.Logger; namespace Wox.Infrastructure diff --git a/Wox.Infrastructure/Storage/JsonStorage.cs b/Wox.Infrastructure/Storage/JsonStorage.cs index ceace6000..07f6329ef 100644 --- a/Wox.Infrastructure/Storage/JsonStorage.cs +++ b/Wox.Infrastructure/Storage/JsonStorage.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using System.Threading; using Newtonsoft.Json; diff --git a/Wox.Infrastructure/Wox.Infrastructure.csproj b/Wox.Infrastructure/Wox.Infrastructure.csproj index 08affe03d..ff9276d5a 100644 --- a/Wox.Infrastructure/Wox.Infrastructure.csproj +++ b/Wox.Infrastructure/Wox.Infrastructure.csproj @@ -63,7 +63,6 @@ - diff --git a/Wox.Plugin/Feature.cs b/Wox.Plugin/Feature.cs index 6df0da438..c69e30c4e 100644 --- a/Wox.Plugin/Feature.cs +++ b/Wox.Plugin/Feature.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; -using System; +using System; +using System.Collections.Generic; namespace Wox.Plugin { diff --git a/Wox.Plugin/Features/IContextMenu.cs b/Wox.Plugin/Features/IContextMenu.cs index e6bfc927d..f30b66abf 100644 --- a/Wox.Plugin/Features/IContextMenu.cs +++ b/Wox.Plugin/Features/IContextMenu.cs @@ -1,4 +1,5 @@ using System; + namespace Wox.Plugin.Features { [Obsolete("Delete Wox.Plugin.Features using directive, " + diff --git a/Wox.Plugin/PluginMetadata.cs b/Wox.Plugin/PluginMetadata.cs index 0aa27f6ea..ded094165 100644 --- a/Wox.Plugin/PluginMetadata.cs +++ b/Wox.Plugin/PluginMetadata.cs @@ -1,6 +1,6 @@ using System; -using System.IO; using System.Collections.Generic; +using System.IO; namespace Wox.Plugin { diff --git a/Wox/ActionKeywords.xaml.cs b/Wox/ActionKeywords.xaml.cs index 67d17aa7b..3c2662e1f 100644 --- a/Wox/ActionKeywords.xaml.cs +++ b/Wox/ActionKeywords.xaml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Windows; +using System.Windows; using Wox.Core.i18n; using Wox.Core.Plugin; using Wox.Core.UserSettings; diff --git a/Wox/Helper/DispatcherExtensions.cs b/Wox/Helper/DispatcherExtensions.cs deleted file mode 100644 index 72880e2eb..000000000 --- a/Wox/Helper/DispatcherExtensions.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Windows.Threading; - -namespace Wox -{ - public static class DispatcherExtensions - { - private static Dictionary timers = - new Dictionary(); - 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); - } - - } -} diff --git a/Wox/Helper/ListBoxItems.cs b/Wox/Helper/ListBoxItems.cs index 5d62edf11..bb2bdc2a2 100644 --- a/Wox/Helper/ListBoxItems.cs +++ b/Wox/Helper/ListBoxItems.cs @@ -18,7 +18,7 @@ namespace Wox.Helper List itemsToRemove = Items.Where(x => predicate(x)).ToList(); if (itemsToRemove.Count > 0) { - + itemsToRemove.ForEach(item => Items.Remove(item)); OnPropertyChanged(new PropertyChangedEventArgs("Count")); @@ -40,10 +40,14 @@ namespace Wox.Helper { Result oldItem = Items[i]; Result newItem = newItems[i]; - if (!Equals(oldItem, newItem)) + if (!oldItem.Equals(newItem)) { this[i] = newItem; } + else if (oldItem.Score != newItem.Score) + { + this[i].Score = newItem.Score; + } } if (newCount > oldCount) diff --git a/Wox/HotkeyControl.xaml.cs b/Wox/HotkeyControl.xaml.cs index 783e3e59d..ae38b9f90 100644 --- a/Wox/HotkeyControl.xaml.cs +++ b/Wox/HotkeyControl.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -39,10 +40,10 @@ namespace Wox SpecialKeyState specialKeyState = GlobalHotkey.Instance.CheckModifiers(); var hotkeyModel = new HotkeyModel( - specialKeyState.AltPressed, - specialKeyState.ShiftPressed, - specialKeyState.WinPressed, - specialKeyState.CtrlPressed, + specialKeyState.AltPressed, + specialKeyState.ShiftPressed, + specialKeyState.WinPressed, + specialKeyState.CtrlPressed, key); var hotkeyString = hotkeyModel.ToString(); @@ -52,12 +53,11 @@ namespace Wox return; } - Dispatcher.DelayInvoke("HotkeyAvailabilityTest", - () => - { - SetHotkey(hotkeyModel); - }, - TimeSpan.FromMilliseconds(500)); + Dispatcher.InvokeAsync(async () => + { + await Task.Delay(500); + SetHotkey(hotkeyModel); + }); } public void SetHotkey(HotkeyModel keyModel, bool triggerValidate = true) @@ -94,7 +94,7 @@ namespace Wox { try { - HotkeyManager.Current.AddOrReplace("HotkeyAvailabilityTest", CurrentHotkey.CharKey, CurrentHotkey.ModifierKeys, (sender, e) => {}); + HotkeyManager.Current.AddOrReplace("HotkeyAvailabilityTest", CurrentHotkey.CharKey, CurrentHotkey.ModifierKeys, (sender, e) => { }); return true; } diff --git a/Wox/ImageLoader/ImageLoader.cs b/Wox/ImageLoader/ImageLoader.cs index 63b30514e..9bf59006d 100644 --- a/Wox/ImageLoader/ImageLoader.cs +++ b/Wox/ImageLoader/ImageLoader.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Drawing; using System.IO; using System.Runtime.InteropServices; @@ -8,7 +7,6 @@ using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; using Wox.Infrastructure; -using Stopwatch = Wox.Infrastructure.Stopwatch; namespace Wox.ImageLoader { diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 804e9ccea..466ef5d70 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Net; using System.Reflection; using System.Threading; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -484,13 +485,14 @@ namespace Wox } } _lastQuery = query; - Dispatcher.DelayInvoke("ShowProgressbar", () => + Dispatcher.InvokeAsync(async () => { + await Task.Delay(150); if (!string.IsNullOrEmpty(query.RawQuery) && query.RawQuery == _lastQuery.RawQuery && !_queryHasReturn) { StartProgress(); } - }, TimeSpan.FromMilliseconds(150)); + }); PluginManager.QueryForAllPlugins(query); } StopProgress(); @@ -829,6 +831,7 @@ namespace Wox private void UpdateResultView(List list, PluginMetadata metadata, Query originQuery) { + Thread.Sleep(3000); _queryHasReturn = true; progressBar.Dispatcher.Invoke(new Action(StopProgress)); diff --git a/Wox/Msg.xaml.cs b/Wox/Msg.xaml.cs index 491fa7cb8..734d8c098 100644 --- a/Wox/Msg.xaml.cs +++ b/Wox/Msg.xaml.cs @@ -7,71 +7,81 @@ using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using Wox.Helper; -namespace Wox { - public partial class Msg : Window { - Storyboard fadeOutStoryboard = new Storyboard(); - private bool closing = false; +namespace Wox +{ + public partial class Msg : Window + { + Storyboard fadeOutStoryboard = new Storyboard(); + private bool closing = false; - public Msg() { - InitializeComponent(); - var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); - var dipWorkingArea = WindowIntelopHelper.TransformPixelsToDIP(this, + public Msg() + { + InitializeComponent(); + var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); + var dipWorkingArea = WindowIntelopHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, - screen.WorkingArea.Height); - Left = dipWorkingArea.X - this.Width; - Top = dipWorkingArea.Y; - showAnimation.From = dipWorkingArea.Y; - showAnimation.To = dipWorkingArea.Y - Height; + screen.WorkingArea.Height); + Left = dipWorkingArea.X - this.Width; + Top = dipWorkingArea.Y; + showAnimation.From = dipWorkingArea.Y; + showAnimation.To = dipWorkingArea.Y - Height; - // Create the fade out storyboard - fadeOutStoryboard.Completed += new EventHandler(fadeOutStoryboard_Completed); - DoubleAnimation fadeOutAnimation = new DoubleAnimation(dipWorkingArea.Y - Height, dipWorkingArea.Y, new Duration(TimeSpan.FromSeconds(0.3))) { - AccelerationRatio = 0.2 - }; - Storyboard.SetTarget(fadeOutAnimation, this); - Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(TopProperty)); - fadeOutStoryboard.Children.Add(fadeOutAnimation); + // Create the fade out storyboard + fadeOutStoryboard.Completed += new EventHandler(fadeOutStoryboard_Completed); + DoubleAnimation fadeOutAnimation = new DoubleAnimation(dipWorkingArea.Y - Height, dipWorkingArea.Y, new Duration(TimeSpan.FromSeconds(0.3))) + { + AccelerationRatio = 0.2 + }; + Storyboard.SetTarget(fadeOutAnimation, this); + 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(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Images\\close.png"))); - imgClose.MouseUp += imgClose_MouseUp; - } + 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.MouseUp += imgClose_MouseUp; + } - void imgClose_MouseUp(object sender, MouseButtonEventArgs e) { - if (!closing) { - closing = true; - fadeOutStoryboard.Begin(); - } - } + void imgClose_MouseUp(object sender, MouseButtonEventArgs e) + { + if (!closing) + { + closing = true; + fadeOutStoryboard.Begin(); + } + } - private void fadeOutStoryboard_Completed(object sender, EventArgs e) { - Close(); - } + private void fadeOutStoryboard_Completed(object sender, EventArgs e) + { + Close(); + } - public void Show(string title, string subTitle, string icopath) { - tbTitle.Text = title; - tbSubTitle.Text = subTitle; - if (string.IsNullOrEmpty(subTitle)) - { - tbSubTitle.Visibility = Visibility.Collapsed; - } - if (!File.Exists(icopath)) { - imgIco.Source = new BitmapImage(new Uri("Images\\app.png", UriKind.Relative)); - } - else { - imgIco.Source = new BitmapImage(new Uri(icopath)); - } + public void Show(string title, string subTitle, string icopath) + { + tbTitle.Text = title; + tbSubTitle.Text = subTitle; + if (string.IsNullOrEmpty(subTitle)) + { + tbSubTitle.Visibility = Visibility.Collapsed; + } + if (!File.Exists(icopath)) + { + imgIco.Source = new BitmapImage(new Uri("Images\\app.png", UriKind.Relative)); + } + else { + imgIco.Source = new BitmapImage(new Uri(icopath)); + } - Show(); + Show(); - Dispatcher.DelayInvoke("ShowMsg", - () => { - if (!closing) { - closing = true; - Dispatcher.Invoke(new Action(fadeOutStoryboard.Begin)); - } - }, TimeSpan.FromSeconds(3)); - } - } + Dispatcher.InvokeAsync(async () => + { + if (!closing) + { + closing = true; + await Dispatcher.InvokeAsync(fadeOutStoryboard.Begin); + } + }); + } + } } diff --git a/Wox/ResultPanel.xaml.cs b/Wox/ResultPanel.xaml.cs index 534a561c9..4a622815d 100644 --- a/Wox/ResultPanel.xaml.cs +++ b/Wox/ResultPanel.xaml.cs @@ -1,14 +1,11 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Diagnostics; +using System.Linq; +using System.Runtime.Remoting.Contexts; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; -using System.Linq; -using System.Runtime.Remoting.Contexts; using Wox.Core.UserSettings; using Wox.Helper; using Wox.Plugin; @@ -266,10 +263,10 @@ namespace Wox if (e.AddedItems.Count > 0 && e.AddedItems[0] != null) { lbResults.ScrollIntoView(e.AddedItems[0]); - Dispatcher.DelayInvoke("UpdateItemNumber", () => - { - UpdateItemNumber(); - }, TimeSpan.FromMilliseconds(3)); + //Dispatcher.DelayInvoke("UpdateItemNumber", () => + //{ + //UpdateItemNumber(); + //}, TimeSpan.FromMilliseconds(3)); } } diff --git a/Wox/ShellContext/Enums.cs b/Wox/ShellContext/Enums.cs deleted file mode 100644 index 859c637d4..000000000 --- a/Wox/ShellContext/Enums.cs +++ /dev/null @@ -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 - } - -} diff --git a/Wox/ShellContext/Guids.cs b/Wox/ShellContext/Guids.cs deleted file mode 100644 index d8a44e395..000000000 --- a/Wox/ShellContext/Guids.cs +++ /dev/null @@ -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}"); - } -} diff --git a/Wox/ShellContext/IContextMenu.cs b/Wox/ShellContext/IContextMenu.cs deleted file mode 100644 index 2fe5e67bb..000000000 --- a/Wox/ShellContext/IContextMenu.cs +++ /dev/null @@ -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); - } -} diff --git a/Wox/ShellContext/IEnumIDList.cs b/Wox/ShellContext/IEnumIDList.cs deleted file mode 100644 index e32d22f06..000000000 --- a/Wox/ShellContext/IEnumIDList.cs +++ /dev/null @@ -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(); - } -} diff --git a/Wox/ShellContext/IShellFolder.cs b/Wox/ShellContext/IShellFolder.cs deleted file mode 100644 index cd7812bdc..000000000 --- a/Wox/ShellContext/IShellFolder.cs +++ /dev/null @@ -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); - } -} diff --git a/Wox/ShellContext/ShellAPI.cs b/Wox/ShellContext/ShellAPI.cs deleted file mode 100644 index d1f3d5885..000000000 --- a/Wox/ShellContext/ShellAPI.cs +++ /dev/null @@ -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 - - /// - /// »ñµÃ×ÀÃæ Shell - /// - public static IShellFolder GetDesktopFolder(out IntPtr ppshf) - { - SHGetDesktopFolder(out ppshf); - Object obj = Marshal.GetObjectForIUnknown(ppshf); - return (IShellFolder)obj; - } - - /// - /// »ñÈ¡ÏÔʾÃû³Æ - /// - 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(); - } - - /// - /// ¸ù¾Ý PIDL »ñÈ¡ÏÔʾÃû³Æ - /// - 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; - } - - /// - /// Get PIDL and parent shellfolder for given file path - /// - /// - /// - 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; } - } -} diff --git a/Wox/ShellContext/ShellContextMenuManager.cs b/Wox/ShellContext/ShellContextMenuManager.cs deleted file mode 100644 index 873ce36c5..000000000 --- a/Wox/ShellContext/ShellContextMenuManager.cs +++ /dev/null @@ -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); - } - } - } -} diff --git a/Wox/ShellContext/Structs.cs b/Wox/ShellContext/Structs.cs deleted file mode 100644 index 00dfae400..000000000 --- a/Wox/ShellContext/Structs.cs +++ /dev/null @@ -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; - } - -} diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 52f54db55..d05cf6ffd 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -126,14 +126,6 @@ - - - - - - - - @@ -163,7 +155,6 @@ CustomQueryHotkeySetting.xaml - HotkeyControl.xaml