├── Pluvet.ShortcutMap ├── Resources │ ├── map.ico │ ├── Roboto-Bold.ttf │ ├── Roboto-Thin.ttf │ ├── Roboto-Black.ttf │ ├── Roboto-Light.ttf │ └── Roboto-Regular.ttf ├── app.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── packages.config ├── App.xaml ├── Helper │ ├── WindowHelper.cs │ ├── FullScreenHelper.cs │ ├── Updater.cs │ ├── GlobalHotKey.cs │ └── WindowBlur.cs ├── Entities │ └── ShortcutMapEntity.cs ├── App.xaml.cs ├── MainWindow.xaml.cs ├── Pluvet.ShortcutMap.csproj └── MainWindow.xaml ├── Pluvet.ShortcutMap.sln ├── README.md └── .gitignore /Pluvet.ShortcutMap/Resources/map.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pluveto/ShortcutMap/HEAD/Pluvet.ShortcutMap/Resources/map.ico -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Resources/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pluveto/ShortcutMap/HEAD/Pluvet.ShortcutMap/Resources/Roboto-Bold.ttf -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Resources/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pluveto/ShortcutMap/HEAD/Pluvet.ShortcutMap/Resources/Roboto-Thin.ttf -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Resources/Roboto-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pluveto/ShortcutMap/HEAD/Pluvet.ShortcutMap/Resources/Roboto-Black.ttf -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Resources/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pluveto/ShortcutMap/HEAD/Pluvet.ShortcutMap/Resources/Roboto-Light.ttf -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Resources/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pluveto/ShortcutMap/HEAD/Pluvet.ShortcutMap/Resources/Roboto-Regular.ttf -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Helper/WindowHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Interop; 10 | 11 | namespace Pluvet.ShortcutMap.Helper 12 | { 13 | public class WindowHelper 14 | { 15 | [DllImport("user32.dll")] 16 | public static extern IntPtr GetForegroundWindow(); 17 | 18 | [DllImport("user32.dll", SetLastError = true)] 19 | public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); 20 | public static string GetActiveModuleName() 21 | { 22 | IntPtr hWnd = GetForegroundWindow(); 23 | uint procId = 0; 24 | if (hWnd == IntPtr.Zero) return null; 25 | GetWindowThreadProcessId(hWnd, out procId); 26 | var proc = Process.GetProcessById((int)procId); 27 | if (null == proc) return null; 28 | return (proc.MainModule.ModuleName); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Pluvet.ShortcutMap.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30204.135 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pluvet.ShortcutMap", "Pluvet.ShortcutMap\Pluvet.ShortcutMap.csproj", "{90DC4F94-1E88-4848-930D-69E542F82A96}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {90DC4F94-1E88-4848-930D-69E542F82A96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {90DC4F94-1E88-4848-930D-69E542F82A96}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {90DC4F94-1E88-4848-930D-69E542F82A96}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {90DC4F94-1E88-4848-930D-69E542F82A96}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {619F87FA-9B56-4C62-A12D-9E8D34EBC9FB} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Entities/ShortcutMapEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | using System.Globalization; 5 | using Newtonsoft.Json; 6 | using Newtonsoft.Json.Converters; 7 | 8 | namespace Pluvet.ShortcutMap.Entities 9 | { 10 | 11 | public partial class ShortcutMapEntity 12 | { 13 | 14 | public Uri IconUri { get; set; } 15 | public Uri BackgroundUri { get; set; } 16 | 17 | [JsonProperty("app")] 18 | public string App { get; set; } 19 | 20 | [JsonProperty("moduleName")] 21 | public string ModuleName { get; set; } 22 | 23 | [JsonProperty("author")] 24 | public string Author { get; set; } 25 | 26 | [JsonProperty("version")] 27 | public string Version { get; set; } 28 | 29 | [JsonProperty("description")] 30 | public string Description { get; set; } 31 | 32 | [JsonProperty("groups")] 33 | public Group[] Groups { get; set; } 34 | public string FileLocation { get; internal set; } 35 | } 36 | 37 | public partial class Group 38 | { 39 | [JsonProperty("name")] 40 | public string Name { get; set; } 41 | 42 | [JsonProperty("shortcuts")] 43 | public Shortcut[] Shortcuts { get; set; } 44 | } 45 | 46 | public partial class Shortcut 47 | { 48 | [JsonProperty("keys")] 49 | public string[] Keys { get; set; } 50 | 51 | [JsonProperty("action")] 52 | public string Action { get; set; } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // 有关程序集的一般信息由以下 8 | // 控制。更改这些特性值可修改 9 | // 与程序集关联的信息。 10 | [assembly: AssemblyTitle("Pluvet.ShortcutMap")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("Pluvet.ShortcutMap")] 15 | [assembly: AssemblyCopyright("Copyright © 2020")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // 将 ComVisible 设置为 false 会使此程序集中的类型 20 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 21 | //请将此类型的 ComVisible 特性设置为 true。 22 | [assembly: ComVisible(false)] 23 | 24 | //若要开始生成可本地化的应用程序,请设置 25 | //.csproj 文件中的 CultureYouAreCodingWith 26 | //例如,如果您在源文件中使用的是美国英语, 27 | //使用的是美国英语,请将 设置为 en-US。 然后取消 28 | //对以下 NeutralResourceLanguage 特性的注释。 更新 29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置 36 | //(未在页面中找到资源时使用, 37 | //或应用程序资源字典中找到时使用) 38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 39 | //(未在页面中找到资源时使用, 40 | //、应用程序或任何主题专用资源字典中找到时使用) 41 | )] 42 | 43 | 44 | // 程序集的版本信息由下列四个值组成: 45 | // 46 | // 主版本 47 | // 次版本 48 | // 生成号 49 | // 修订号 50 | // 51 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 52 | //通过使用 "*",如下所示: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.1.0.0")] 55 | [assembly: AssemblyFileVersion("1.1.0.0")] 56 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Pluvet.ShortcutMap.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Pluvet.ShortcutMap.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 重写当前线程的 CurrentUICulture 属性 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Pluvet.ShortcutMap.Entities; 3 | using Pluvet.ShortcutMap.Helper; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Configuration; 7 | using System.Data; 8 | using System.Diagnostics; 9 | using System.IO; 10 | using System.Linq; 11 | using System.Text.RegularExpressions; 12 | using System.Threading.Tasks; 13 | using System.Windows; 14 | 15 | namespace Pluvet.ShortcutMap 16 | { 17 | /// 18 | /// App.xaml 的交互逻辑 19 | /// 20 | public partial class App : Application 21 | { 22 | public static List Maps { get; private set; } 23 | public App() 24 | { 25 | App.LoadMaps(); 26 | CheckUpdate(); 27 | } 28 | 29 | private async void CheckUpdate() 30 | { 31 | Updater.GitHubRepo = "/pluveto/ShortcutMap"; 32 | 33 | await Task.Run(new Action(() => 34 | { 35 | if (Updater.HasUpdate) 36 | { 37 | var ret = MessageBox.Show("Shortcut Map 检查到新版本,是否更新?", "提示", MessageBoxButton.YesNo); 38 | if(ret == MessageBoxResult.Yes) 39 | { 40 | Process.Start("https://github.com/pluveto/ShortcutMap/releases/latest"); 41 | } 42 | } 43 | })); 44 | } 45 | 46 | private static void LoadMaps() 47 | { 48 | Maps = new List(); 49 | var mapDir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "/shortcuts"); 50 | var mapJsons = mapDir.GetFiles("*.json"); 51 | 52 | foreach (var item in mapJsons) 53 | { 54 | var jsonText = File.ReadAllText(item.FullName); 55 | var newMap = JsonConvert.DeserializeObject(jsonText); 56 | 57 | if (null == newMap) continue; 58 | var iconPath = System.AppDomain.CurrentDomain.BaseDirectory + $"/shortcuts/images/icon-{Path.GetFileNameWithoutExtension(item.Name)}.png"; 59 | if (!File.Exists(iconPath)) continue; 60 | var bgPath = System.AppDomain.CurrentDomain.BaseDirectory + $"/shortcuts/images/bg-{Path.GetFileNameWithoutExtension(item.Name)}.png"; 61 | if (File.Exists(bgPath)) 62 | { 63 | newMap.BackgroundUri = new Uri(bgPath); 64 | } 65 | newMap.IconUri = new Uri(iconPath); 66 | newMap.FileLocation = item.FullName; 67 | Maps.Add(newMap); 68 | } 69 | } 70 | public static ShortcutMapEntity MatchMap(List entities, string regex) 71 | { 72 | foreach (var item in entities) 73 | { 74 | if (new Regex(item.ModuleName).IsMatch(regex)) 75 | { 76 | return item; 77 | } 78 | } 79 | return null; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shortcut Map 2 | 3 | 本程序能够帮助你**显示当前使用程序的快捷键**。 4 | 5 | This util helps display **Shortcuts Keys of Current Running Application** 6 | 7 | *推荐使用 `1920x1080` 及以上分辨率。* 8 | 9 | ### 使用方法 Usage 10 | 11 | 运行 `Pluvet.ShortcutMap.exe`,你将看到托盘有一个地图图标。 12 | 13 | Run `Pluvet.ShortcutMap.exe`, you'll see a map icon on windows tray bar. 14 | 15 | **在程序中按下 `Win` `N` 组合键,如果该程序拥有快捷键配置,则会显示出来。** 16 | 17 | **Press `Win` `N` together, if current app has its keymap definition config, key map will display.** 18 | 19 | ### 预览 Preview 20 | 21 | ![预览](https://s1.ax1x.com/2020/07/03/NOTZSs.jpg) 22 | 23 | ### 创建快捷键配置 Create your own key map config 24 | 25 | 下面以创建 `Blender` 的快捷键为例。 26 | 27 | 首先,你在程序的 `shortcuts` 目录下,创建文件 `blender.json`,在 `shortcuts\images\`目录下放置 `png` 格式的图标文件,文件名为 `icon-blender.png`,大小为高度 128 像素及以上。 28 | 29 | 编辑 `blender.json`,基本格式如下: 30 | 31 | Here's an example of creating a shortcut key config file for 'blender'. 32 | 33 | First, you create a file in the program's `shortcuts` directory with name ` blender.json `, place the logo file in PNG format in the directory `shortcuts/images`, and the file name is `icon-blender.png` (The size is 128 pixels and above in height). 34 | 35 | Editor` blender.json `The basic format is as follows: 36 | 37 | ```json 38 | { 39 | "app": "程序名", 40 | "moduleName": "应用程序的模块名,正则表达式", 41 | "author": "本文件编写者", 42 | "version": "本文件版本", 43 | "description": "本文件描述", 44 | "groups": [ 45 | { 46 | "name": "组名", 47 | "shortcuts": [ 48 | { 49 | "keys": ["按键"], 50 | "action": "作用" 51 | } 52 | ] 53 | } 54 | ] 55 | } 56 | ``` 57 | 58 | 对于 Blender 的示例如下: 59 | 60 | ```json 61 | { 62 | "app": "Blender", 63 | "moduleName": "^blender\\.exe$", 64 | "author": "pluveto", 65 | "version": "1.0", 66 | "description": "Shortcuts for Blender", 67 | "groups": [ 68 | { 69 | "name": "Window", 70 | "shortcuts": [ 71 | { "keys": ["Ctrl", "Left"], "action": "Arrow Go to Previous Screen" }, 72 | { "keys": ["Ctrl", "Right"], "action": "Arrow Go to Next Screen" }, 73 | { "keys": ["Ctrl", "Up"], "action": "Arrow Maximize Window" }, 74 | { 75 | "keys": ["Ctrl", "Down"], 76 | "action": "Arrow Retrun to Previous Window Size" 77 | }, 78 | { "keys": ["Shift", "F4"], "action": "Data View" }, 79 | { "keys": ["Shift", "F5"], "action": "3D Window" }, 80 | { "keys": ["Shift", "F6"], "action": "IPO Window" }, 81 | { "keys": ["Shift", "F7"], "action": "Buttons Window" }, 82 | { "keys": ["Shift", "F8"], "action": "Sequence Window" }, 83 | { "keys": ["Shift", "F9"], "action": "Outliner Window" }, 84 | { "keys": ["Shift", "F10"], "action": "Image Window" }, 85 | { "keys": ["Shift", "F11"], "action": "Text Window" }, 86 | { "keys": ["Shift", "F12"], "action": "Action Window" } 87 | ] 88 | } 89 | ] 90 | } 91 | 92 | ``` 93 | 94 | 现在,重启程序,进入 Blender 并按下 `Win` `N`,即可看到快捷键列表。 95 | 96 | Now, restart the program, enter blender and press `win` `n` to see the list of shortcut keys. 97 | 98 | ### 自定义背景的方法 Custom Background Image 99 | 100 | 替换 `bg.png` 文件。 101 | 102 | ### 分享快捷键配置 Share your configs 103 | 104 | 前往 [Issues](https://github.com/pluveto/ShortcutMap/issues?q=label%3AShare+) 区。 105 | 106 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | [Rr]eleases/ 14 | x64/ 15 | build/ 16 | bld/ 17 | [Bb]in/ 18 | [Oo]bj/ 19 | 20 | # Roslyn cache directories 21 | *.ide/ 22 | 23 | # MSTest test Results 24 | [Tt]est[Rr]esult*/ 25 | [Bb]uild[Ll]og.* 26 | 27 | #NUNIT 28 | *.VisualState.xml 29 | TestResult.xml 30 | 31 | # Build Results of an ATL Project 32 | [Dd]ebugPS/ 33 | [Rr]eleasePS/ 34 | dlldata.c 35 | 36 | *_i.c 37 | *_p.c 38 | *_i.h 39 | *.ilk 40 | *.meta 41 | *.obj 42 | *.pch 43 | *.pdb 44 | *.pgc 45 | *.pgd 46 | *.rsp 47 | *.sbr 48 | *.tlb 49 | *.tli 50 | *.tlh 51 | *.tmp 52 | *.tmp_proj 53 | *.log 54 | *.vspscc 55 | *.vssscc 56 | .builds 57 | *.pidb 58 | *.svclog 59 | *.scc 60 | 61 | # Chutzpah Test files 62 | _Chutzpah* 63 | 64 | # Visual C++ cache files 65 | ipch/ 66 | *.aps 67 | *.ncb 68 | *.opensdf 69 | *.sdf 70 | *.cachefile 71 | 72 | # Visual Studio profiler 73 | *.psess 74 | *.vsp 75 | *.vspx 76 | 77 | # TFS 2012 Local Workspace 78 | $tf/ 79 | 80 | # Guidance Automation Toolkit 81 | *.gpState 82 | 83 | # ReSharper is a .NET coding add-in 84 | _ReSharper*/ 85 | *.[Rr]e[Ss]harper 86 | *.DotSettings.user 87 | 88 | # JustCode is a .NET coding addin-in 89 | .JustCode 90 | 91 | # TeamCity is a build add-in 92 | _TeamCity* 93 | 94 | # DotCover is a Code Coverage Tool 95 | *.dotCover 96 | 97 | # NCrunch 98 | _NCrunch_* 99 | .*crunch*.local.xml 100 | 101 | # MightyMoose 102 | *.mm.* 103 | AutoTest.Net/ 104 | 105 | # Web workbench (sass) 106 | .sass-cache/ 107 | 108 | # Installshield output folder 109 | [Ee]xpress/ 110 | 111 | # DocProject is a documentation generator add-in 112 | DocProject/buildhelp/ 113 | DocProject/Help/*.HxT 114 | DocProject/Help/*.HxC 115 | DocProject/Help/*.hhc 116 | DocProject/Help/*.hhk 117 | DocProject/Help/*.hhp 118 | DocProject/Help/Html2 119 | DocProject/Help/html 120 | 121 | # Click-Once directory 122 | publish/ 123 | 124 | # Publish Web Output 125 | *.[Pp]ublish.xml 126 | *.azurePubxml 127 | ## TODO: Comment the next line if you want to checkin your 128 | ## web deploy settings but do note that will include unencrypted 129 | ## passwords 130 | *.pubxml 131 | 132 | # NuGet Packages Directory 133 | packages/* 134 | ## TODO: If the tool you use requires repositories.config 135 | ## uncomment the next line 136 | #!packages/repositories.config 137 | 138 | # Enable "build/" folder in the NuGet Packages folder since 139 | # NuGet packages use it for MSBuild targets. 140 | # This line needs to be after the ignore of the build folder 141 | # (and the packages folder if the line above has been uncommented) 142 | !packages/build/ 143 | 144 | # Windows Azure Build Output 145 | csx/ 146 | *.build.csdef 147 | 148 | # Windows Store app package directory 149 | AppPackages/ 150 | 151 | # Others 152 | sql/ 153 | *.Cache 154 | ClientBin/ 155 | [Ss]tyle[Cc]op.* 156 | ~$* 157 | *~ 158 | *.dbmdl 159 | *.dbproj.schemaview 160 | *.pfx 161 | *.publishsettings 162 | node_modules/ 163 | 164 | # RIA/Silverlight projects 165 | Generated_Code/ 166 | 167 | # Backup & report files from converting an old project file 168 | # to a newer Visual Studio version. Backup files are not needed, 169 | # because we have git ;-) 170 | _UpgradeReport_Files/ 171 | Backup*/ 172 | UpgradeLog*.XML 173 | UpgradeLog*.htm 174 | 175 | # SQL Server files 176 | *.mdf 177 | *.ldf 178 | 179 | # Business Intelligence projects 180 | *.rdl.data 181 | *.bim.layout 182 | *.bim_*.settings 183 | 184 | # Microsoft Fakes 185 | FakesAssemblies/ 186 | 187 | git_stats/* 188 | 189 | *.ncrunchproject 190 | StyleCop.Cache 191 | bin 192 | obj -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Helper/FullScreenHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Forms; 7 | using System.Windows.Interop; 8 | 9 | namespace Pluvet.ShortcutMap.Helper 10 | { 11 | /// 12 | /// 来自:https://www.cnblogs.com/smiler/archive/2013/05/29/3105317.html 13 | /// 14 | public static class FullScreenHelper 15 | { 16 | private static Window _fullWindow; 17 | private static WindowState _windowState; 18 | private static WindowStyle _windowStyle; 19 | private static bool _windowTopMost; 20 | private static ResizeMode _windowResizeMode; 21 | private static Rect _windowRect; 22 | 23 | /// 24 | /// 进入全屏 25 | /// 26 | /// 27 | public static void GoFullscreen(this Window window) 28 | { 29 | //已经是全屏 30 | if (window.IsFullscreen()) return; 31 | 32 | //存储窗体信息 33 | _windowState = window.WindowState; 34 | _windowStyle = window.WindowStyle; 35 | _windowTopMost = window.Topmost; 36 | _windowResizeMode = window.ResizeMode; 37 | _windowRect.X = window.Left; 38 | _windowRect.Y = window.Top; 39 | _windowRect.Width = window.Width; 40 | _windowRect.Height = window.Height; 41 | 42 | 43 | //变成无边窗体 44 | window.WindowState = WindowState.Normal;//假如已经是Maximized,就不能进入全屏,所以这里先调整状态 45 | window.WindowStyle = WindowStyle.None; 46 | window.ResizeMode = ResizeMode.NoResize; 47 | window.Topmost = true;//最大化后总是在最上面 48 | 49 | //获取窗口句柄 50 | var handle = new WindowInteropHelper(window).Handle; 51 | //获取当前显示器屏幕 52 | Screen screen = Screen.FromHandle(handle); 53 | 54 | //调整窗口最大化,全屏的关键代码就是下面3句 55 | window.MaxWidth = screen.Bounds.Width; 56 | window.MaxHeight = screen.Bounds.Height; 57 | window.WindowState = WindowState.Maximized; 58 | 59 | //解决切换应用程序的问题 60 | window.Activated += new EventHandler(window_Activated); 61 | window.Deactivated += new EventHandler(window_Deactivated); 62 | //记住成功最大化的窗体 63 | _fullWindow = window; 64 | } 65 | 66 | static void window_Deactivated(object sender, EventArgs e) 67 | { 68 | var window = sender as Window; 69 | window.Topmost = false; 70 | } 71 | static void window_Activated(object sender, EventArgs e) 72 | { 73 | var window = sender as Window; 74 | window.Topmost = true; 75 | } 76 | 77 | /// 78 | /// 退出全屏 79 | /// 80 | /// 81 | public static void ExitFullscreen(this Window window) 82 | { 83 | //已经不是全屏无操作 84 | if (!window.IsFullscreen()) return; 85 | //恢复窗口先前信息,这样就退出了全屏 86 | window.Topmost = _windowTopMost; 87 | window.WindowStyle = _windowStyle; 88 | window.ResizeMode = ResizeMode.CanResize;//设置为可调整窗体大小 89 | window.Left = _windowRect.Left; 90 | window.Width = _windowRect.Width; 91 | window.Top = _windowRect.Top; 92 | window.Height = _windowRect.Height; 93 | window.WindowState = _windowState;//恢复窗口状态信息 94 | window.ResizeMode = _windowResizeMode;//恢复窗口可调整信息 95 | //移除不需要的事件 96 | window.Activated -= window_Activated; 97 | window.Deactivated -= window_Deactivated; 98 | _fullWindow = null; 99 | } 100 | 101 | /// 102 | /// 窗体是否在全屏状态 103 | /// 104 | /// 105 | /// 106 | public static bool IsFullscreen(this Window window) 107 | { 108 | if (window == null) 109 | throw new ArgumentNullException("window"); 110 | return _fullWindow == window; 111 | } 112 | 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Helper/Updater.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Net; 7 | using System.Reflection; 8 | using System.Text; 9 | using System.Text.RegularExpressions; 10 | using System.Threading.Tasks; 11 | 12 | namespace Pluvet.ShortcutMap.Helper 13 | { 14 | static class Updater 15 | { 16 | static readonly Lazy> _lazyVersionUrls = 17 | new Lazy>(() => _GetVersionUrls()); 18 | 19 | public static bool AutoUpdate(string[] args) 20 | { 21 | if (HasUpdate) 22 | { 23 | Update(args); 24 | return true; 25 | } 26 | else 27 | { 28 | // delete the updater files. We scan the resources so we know what they are 29 | var names = Assembly.GetExecutingAssembly().GetManifestResourceNames(); 30 | for (var i = 0; i < names.Length; i++) 31 | { 32 | var name = names[i]; 33 | if (name.Contains(".ZZupdater0.")) 34 | { 35 | try 36 | { 37 | File.Delete(name.Substring(name.IndexOf('.') + 1)); 38 | } 39 | catch { } 40 | } 41 | } 42 | } 43 | return false; 44 | } 45 | static IDictionary _VersionUrls 46 | { 47 | get 48 | { 49 | return _lazyVersionUrls.Value; 50 | } 51 | } 52 | public static string GitHubRepo { get; set; } 53 | public static string GitHubRepoName 54 | { 55 | get 56 | { 57 | var si = GitHubRepo.LastIndexOf('/'); 58 | return GitHubRepo.Substring(si + 1); 59 | } 60 | } 61 | static IDictionary _GetVersionUrls() 62 | { 63 | System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; 64 | 65 | string pattern = 66 | string.Concat( 67 | Regex.Escape(GitHubRepo), 68 | @"\/releases\/download\/Update.v[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+.*\.zip"); 69 | 70 | Regex urlMatcher = new Regex(pattern, RegexOptions.CultureInvariant | RegexOptions.Compiled); 71 | var result = new Dictionary(); 72 | WebRequest wrq = WebRequest.Create(string.Concat("https://github.com", GitHubRepo, "/releases/latest")); 73 | WebResponse wrs = null; 74 | try 75 | { 76 | wrs = wrq.GetResponse(); 77 | } 78 | catch (Exception ex) 79 | { 80 | Debug.WriteLine("Error fetching repo: " + ex.Message); 81 | return result; 82 | } 83 | using (var sr = new StreamReader(wrs.GetResponseStream())) 84 | { 85 | string line; 86 | while (null != (line = sr.ReadLine())) 87 | { 88 | var match = urlMatcher.Match(line); 89 | if (match.Success) 90 | { 91 | var uri = new Uri(string.Concat("https://github.com", match.Value)); 92 | var vs = match.Value.LastIndexOf("/Update.v"); 93 | var sa = match.Value.Substring(vs + 9).Split('.', '/'); 94 | var v = new Version(int.Parse(sa[0]), int.Parse(sa[1]), int.Parse(sa[2]), int.Parse(sa[3])); 95 | result.Add(v, uri); 96 | } 97 | } 98 | } 99 | return result; 100 | } 101 | public static bool HasUpdate 102 | { 103 | get 104 | { 105 | var v = Assembly.GetEntryAssembly().GetName().Version; 106 | foreach (var e in _VersionUrls) 107 | if (e.Key > v) 108 | return true; 109 | return false; 110 | } 111 | } 112 | public static Version LatestVersion 113 | { 114 | get 115 | { 116 | var v = Assembly.GetEntryAssembly().GetName().Version; 117 | var va = new List(_VersionUrls.Keys); 118 | va.Add(v); 119 | va.Sort(); 120 | return va[va.Count - 1]; 121 | } 122 | } 123 | public static void Update(string[] args = null) 124 | => Update(LatestVersion, args); 125 | public static void Update(Version version, string[] args = null) 126 | { 127 | var ns = typeof(Updater).Namespace; 128 | var names = Assembly.GetExecutingAssembly().GetManifestResourceNames(); 129 | string exename = null; 130 | for (var i = 0; i < names.Length; i++) 131 | { 132 | var name = names[i]; 133 | if (name.Contains(".ZZupdater0.")) 134 | { 135 | var respath = name; 136 | if (string.IsNullOrEmpty(exename) && name.EndsWith(".exe")) 137 | exename = name.Substring(name.IndexOf('.') + 1); 138 | name = name.Substring(name.IndexOf('.') + 1); 139 | using (var stm = Assembly.GetExecutingAssembly().GetManifestResourceStream(respath)) 140 | using (var stm2 = File.OpenWrite(name)) 141 | { 142 | stm2.SetLength(0L); 143 | stm.CopyTo(stm2); 144 | } 145 | 146 | 147 | } 148 | } 149 | if (null != exename) 150 | { 151 | var psi = new ProcessStartInfo(); 152 | var sb = new StringBuilder(); 153 | sb.Append(_Esc(Assembly.GetEntryAssembly().GetModules()[0].Name)); 154 | sb.Append(' '); 155 | sb.Append(_Esc(_VersionUrls[version].ToString())); 156 | if (null != args) 157 | { 158 | for (var i = 0; i < args.Length; ++i) 159 | { 160 | sb.Append(' '); 161 | sb.Append(_Esc(args[i])); 162 | } 163 | } 164 | psi.Arguments = sb.ToString(); 165 | psi.FileName = exename; 166 | var proc = Process.Start(psi); 167 | } 168 | 169 | } 170 | static string _Esc(string arg) 171 | { 172 | return string.Concat("\"", arg.Replace("\"", "\"\""), "\""); 173 | } 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Helper/GlobalHotKey.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Net.Mime; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | using System.Windows; 9 | using System.Windows.Input; 10 | using System.Windows.Interop; 11 | 12 | namespace Pluvet.ShortcutMap.Helper 13 | { 14 | public class GlobalHotKey : IDisposable 15 | { 16 | private static Dictionary _dictHotKeyToCalBackProc; 17 | 18 | [DllImport("user32.dll")] 19 | private static extern bool RegisterHotKey(IntPtr hWnd, int id, UInt32 fsModifiers, UInt32 vlc); 20 | 21 | [DllImport("user32.dll")] 22 | private static extern bool UnregisterHotKey(IntPtr hWnd, int id); 23 | 24 | public const int WmHotKey = 0x0312; 25 | 26 | private bool _disposed = false; 27 | 28 | public Key Key { get; private set; } 29 | public KeyModifier KeyModifiers { get; private set; } 30 | public Action Action { get; private set; } 31 | public int Id { get; set; } 32 | 33 | // ****************************************************************** 34 | public GlobalHotKey(Key k, KeyModifier keyModifiers, Action action, bool register = true) 35 | { 36 | Key = k; 37 | KeyModifiers = keyModifiers; 38 | Action = action; 39 | if (register) 40 | { 41 | Register(); 42 | } 43 | } 44 | 45 | // ****************************************************************** 46 | public bool Register() 47 | { 48 | int virtualKeyCode = KeyInterop.VirtualKeyFromKey(Key); 49 | Id = virtualKeyCode + ((int)KeyModifiers * 0x10000); 50 | bool result = RegisterHotKey(IntPtr.Zero, Id, (UInt32)KeyModifiers, (UInt32)virtualKeyCode); 51 | 52 | if (_dictHotKeyToCalBackProc == null) 53 | { 54 | _dictHotKeyToCalBackProc = new Dictionary(); 55 | ComponentDispatcher.ThreadFilterMessage += new ThreadMessageEventHandler(ComponentDispatcherThreadFilterMessage); 56 | } 57 | 58 | _dictHotKeyToCalBackProc.Add(Id, this); 59 | 60 | Debug.Print(result.ToString() + ", " + Id + ", " + virtualKeyCode); 61 | return result; 62 | } 63 | 64 | // ****************************************************************** 65 | public void Unregister() 66 | { 67 | GlobalHotKey hotKey; 68 | if (_dictHotKeyToCalBackProc.TryGetValue(Id, out hotKey)) 69 | { 70 | UnregisterHotKey(IntPtr.Zero, Id); 71 | } 72 | } 73 | 74 | // ****************************************************************** 75 | private static void ComponentDispatcherThreadFilterMessage(ref MSG msg, ref bool handled) 76 | { 77 | if (!handled) 78 | { 79 | if (msg.message == WmHotKey) 80 | { 81 | GlobalHotKey hotKey; 82 | 83 | if (_dictHotKeyToCalBackProc.TryGetValue((int)msg.wParam, out hotKey)) 84 | { 85 | if (hotKey.Action != null) 86 | { 87 | hotKey.Action.Invoke(hotKey); 88 | } 89 | handled = true; 90 | } 91 | } 92 | } 93 | } 94 | 95 | // ****************************************************************** 96 | // Implement IDisposable. 97 | // Do not make this method virtual. 98 | // A derived class should not be able to override this method. 99 | public void Dispose() 100 | { 101 | Dispose(true); 102 | // This object will be cleaned up by the Dispose method. 103 | // Therefore, you should call GC.SupressFinalize to 104 | // take this object off the finalization queue 105 | // and prevent finalization code for this object 106 | // from executing a second time. 107 | GC.SuppressFinalize(this); 108 | } 109 | 110 | // ****************************************************************** 111 | // Dispose(bool disposing) executes in two distinct scenarios. 112 | // If disposing equals true, the method has been called directly 113 | // or indirectly by a user's code. Managed and unmanaged resources 114 | // can be _disposed. 115 | // If disposing equals false, the method has been called by the 116 | // runtime from inside the finalizer and you should not reference 117 | // other objects. Only unmanaged resources can be _disposed. 118 | protected virtual void Dispose(bool disposing) 119 | { 120 | // Check to see if Dispose has already been called. 121 | if (!this._disposed) 122 | { 123 | // If disposing equals true, dispose all managed 124 | // and unmanaged resources. 125 | if (disposing) 126 | { 127 | // Dispose managed resources. 128 | Unregister(); 129 | } 130 | 131 | // Note disposing has been done. 132 | _disposed = true; 133 | } 134 | } 135 | } 136 | 137 | // ****************************************************************** 138 | [Flags] 139 | public enum KeyModifier 140 | { 141 | None = 0x0000, 142 | Alt = 0x0001, 143 | Ctrl = 0x0002, 144 | NoRepeat = 0x4000, 145 | Shift = 0x0004, 146 | Win = 0x0008 147 | } 148 | 149 | } -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Helper/WindowBlur.cs: -------------------------------------------------------------------------------- 1 | using Pluvet.ShortcutMap.Helper.Native; 2 | using System; 3 | using System.Runtime.InteropServices; 4 | using System.Windows; 5 | using System.Windows.Interop; 6 | namespace Pluvet.ShortcutMap.Helper 7 | { 8 | /// 9 | /// 来自:https://blog.walterlv.com/post/win10/2017/10/02/wpf-transparent-blur-in-windows-10.html 10 | /// 11 | public class WindowBlur 12 | { 13 | public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.RegisterAttached( 14 | "IsEnabled", typeof(bool), typeof(WindowBlur), 15 | new PropertyMetadata(false, OnIsEnabledChanged)); 16 | 17 | public static void SetIsEnabled(DependencyObject element, bool value) 18 | { 19 | element.SetValue(IsEnabledProperty, value); 20 | } 21 | 22 | public static bool GetIsEnabled(DependencyObject element) 23 | { 24 | return (bool)element.GetValue(IsEnabledProperty); 25 | } 26 | 27 | private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 28 | { 29 | if (d is Window window) 30 | { 31 | if (true.Equals(e.OldValue)) 32 | { 33 | GetWindowBlur(window)?.Detach(); 34 | window.ClearValue(WindowBlurProperty); 35 | } 36 | if (true.Equals(e.NewValue)) 37 | { 38 | var blur = new WindowBlur(); 39 | blur.Attach(window); 40 | window.SetValue(WindowBlurProperty, blur); 41 | } 42 | } 43 | } 44 | 45 | public static readonly DependencyProperty WindowBlurProperty = DependencyProperty.RegisterAttached( 46 | "WindowBlur", typeof(WindowBlur), typeof(WindowBlur), 47 | new PropertyMetadata(null, OnWindowBlurChanged)); 48 | 49 | public static void SetWindowBlur(DependencyObject element, WindowBlur value) 50 | { 51 | element.SetValue(WindowBlurProperty, value); 52 | } 53 | 54 | public static WindowBlur GetWindowBlur(DependencyObject element) 55 | { 56 | return (WindowBlur)element.GetValue(WindowBlurProperty); 57 | } 58 | 59 | private static void OnWindowBlurChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 60 | { 61 | if (d is Window window) 62 | { 63 | (e.OldValue as WindowBlur)?.Detach(); 64 | (e.NewValue as WindowBlur)?.Attach(window); 65 | } 66 | } 67 | 68 | private Window _window; 69 | 70 | private void Attach(Window window) 71 | { 72 | _window = window; 73 | var source = (HwndSource)PresentationSource.FromVisual(window); 74 | if (source == null) 75 | { 76 | window.SourceInitialized += OnSourceInitialized; 77 | } 78 | else 79 | { 80 | AttachCore(); 81 | } 82 | } 83 | 84 | private void Detach() 85 | { 86 | try 87 | { 88 | DetachCore(); 89 | } 90 | finally 91 | { 92 | _window = null; 93 | } 94 | } 95 | 96 | private void OnSourceInitialized(object sender, EventArgs e) 97 | { 98 | ((Window)sender).SourceInitialized -= OnSourceInitialized; 99 | AttachCore(); 100 | } 101 | 102 | private void AttachCore() 103 | { 104 | EnableBlur(_window); 105 | } 106 | 107 | private void DetachCore() 108 | { 109 | _window.SourceInitialized += OnSourceInitialized; 110 | } 111 | 112 | private static void EnableBlur(Window window) 113 | { 114 | var windowHelper = new WindowInteropHelper(window); 115 | 116 | var accent = new AccentPolicy 117 | { 118 | AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND 119 | }; 120 | 121 | var accentStructSize = Marshal.SizeOf(accent); 122 | 123 | var accentPtr = Marshal.AllocHGlobal(accentStructSize); 124 | Marshal.StructureToPtr(accent, accentPtr, false); 125 | 126 | var data = new WindowCompositionAttributeData 127 | { 128 | Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY, 129 | SizeOfData = accentStructSize, 130 | Data = accentPtr 131 | }; 132 | 133 | SetWindowCompositionAttribute(windowHelper.Handle, ref data); 134 | 135 | Marshal.FreeHGlobal(accentPtr); 136 | } 137 | 138 | [DllImport("user32.dll")] 139 | internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data); 140 | } 141 | 142 | namespace Native 143 | { 144 | internal enum AccentState 145 | { 146 | ACCENT_DISABLED, 147 | ACCENT_ENABLE_GRADIENT, 148 | ACCENT_ENABLE_TRANSPARENTGRADIENT, 149 | ACCENT_ENABLE_BLURBEHIND, 150 | ACCENT_INVALID_STATE, 151 | } 152 | 153 | [StructLayout(LayoutKind.Sequential)] 154 | internal struct AccentPolicy 155 | { 156 | public AccentState AccentState; 157 | public int AccentFlags; 158 | public int GradientColor; 159 | public int AnimationId; 160 | } 161 | 162 | [StructLayout(LayoutKind.Sequential)] 163 | internal struct WindowCompositionAttributeData 164 | { 165 | public WindowCompositionAttribute Attribute; 166 | public IntPtr Data; 167 | public int SizeOfData; 168 | } 169 | 170 | internal enum WindowCompositionAttribute 171 | { 172 | // 省略其他未使用的字段 173 | WCA_ACCENT_POLICY = 19, 174 | // 省略其他未使用的字段 175 | } 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using Pluvet.ShortcutMap.Entities; 2 | using Pluvet.ShortcutMap.Helper; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Security.Principal; 9 | using System.Text; 10 | using System.Windows; 11 | using System.Windows.Controls; 12 | using System.Windows.Data; 13 | using System.Windows.Documents; 14 | using System.Windows.Forms; 15 | using System.Windows.Input; 16 | using System.Windows.Interop; 17 | using System.Windows.Media; 18 | using System.Windows.Media.Converters; 19 | using System.Windows.Media.Imaging; 20 | using System.Windows.Navigation; 21 | using System.Windows.Shapes; 22 | 23 | namespace Pluvet.ShortcutMap 24 | { 25 | /// 26 | /// MainWindow.xaml 的交互逻辑 27 | /// 28 | public partial class MainWindow : Window 29 | { 30 | 31 | public MainWindow() 32 | { 33 | InitializeComponent(); 34 | 35 | foreach (var item in App.Maps) 36 | { 37 | var menuItem = new System.Windows.Controls.MenuItem { Header = item.App, Tag = item }; 38 | menuItem.Click += MenuItem_Click; 39 | this.LoadedMenuItem.Items.Add(menuItem); 40 | } 41 | 42 | var bgBrush = new ImageBrush(new BitmapImage(new Uri(System.AppDomain.CurrentDomain.BaseDirectory + "/bg.png"))); 43 | this.Background = bgBrush; 44 | 45 | new GlobalHotKey(Key.N, KeyModifier.Win, OnHotKeyHandler); 46 | this.Hide(); 47 | 48 | } 49 | 50 | private void MenuItem_Click(object sender, RoutedEventArgs e) 51 | { 52 | var menuItem = sender as System.Windows.Controls.MenuItem; 53 | var item = menuItem.Tag as ShortcutMapEntity; 54 | Process.Start("explorer.exe", item.FileLocation); 55 | } 56 | 57 | private void OnHotKeyHandler(GlobalHotKey hotKey) 58 | { 59 | if (this.IsFullscreen()) 60 | { 61 | this.Hide(); 62 | this.ExitFullscreen(); 63 | } 64 | else 65 | { 66 | 67 | var activeModule = WindowHelper.GetActiveModuleName(); 68 | if (activeModule == null) return; 69 | var matchedMap = App.MatchMap(App.Maps, activeModule); 70 | if (matchedMap == null) return; 71 | 72 | RenderMap(matchedMap); 73 | 74 | this.Show(); 75 | this.GoFullscreen(); 76 | 77 | } 78 | } 79 | public static ShortcutMapEntity Previous = null; 80 | private void RenderMap(ShortcutMapEntity map) 81 | { 82 | if (Previous == map) { return; } 83 | Previous = map; 84 | MapPanel.Children.RemoveRange(0, MapPanel.Children.Count); 85 | 86 | var logo = new BitmapImage(map.IconUri); 87 | this.Logo.Source = logo; 88 | this.AppName.Text = map.App; 89 | 90 | Style styleItemDockPanel = this.FindResource("ItemDockPanel") as Style; 91 | Style styleShortcutButton = this.FindResource("ShortcutButton") as Style; 92 | Style styleGroupLabel = this.FindResource("GroupLabel") as Style; 93 | Style styleShortcutDescLabel = this.FindResource("ShortcutDescLabel") as Style; 94 | 95 | foreach (var group in map.Groups) 96 | { 97 | if (group.Name == "::linebreak") 98 | { 99 | //MapPanel.Children.Add(new NewLine()); 100 | continue; 101 | } 102 | 103 | var wrapper = new StackPanel() { Margin = new Thickness(0, 0, 60, 20) }; 104 | 105 | var groupLabel = new TextBlock(); 106 | groupLabel.Text = group.Name; 107 | groupLabel.Style = styleGroupLabel; 108 | wrapper.Children.Add(groupLabel); 109 | 110 | 111 | foreach (var shortcut in group.Shortcuts) 112 | { 113 | var itemDockPanel = new DockPanel(); 114 | itemDockPanel.Style = styleItemDockPanel; 115 | 116 | foreach (var key in shortcut.Keys) 117 | { 118 | var button = new System.Windows.Controls.Button(); 119 | button.Style = styleShortcutButton; 120 | button.Content = key; 121 | itemDockPanel.Children.Add(button); 122 | } 123 | var descLabel = new TextBlock(); 124 | descLabel.Text = shortcut.Action; 125 | descLabel.Style = styleShortcutDescLabel; 126 | itemDockPanel.Children.Add(descLabel); 127 | wrapper.Children.Add(itemDockPanel); 128 | } 129 | MapPanel.Children.Add(wrapper); 130 | 131 | } 132 | } 133 | 134 | private void Window_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) 135 | { 136 | if (e.Key == Key.Escape) 137 | { 138 | this.Hide(); 139 | this.ExitFullscreen(); 140 | } 141 | } 142 | 143 | private void ExitMenuItem_Click(object sender, RoutedEventArgs e) 144 | { 145 | System.Windows.Application.Current.Shutdown(); 146 | } 147 | 148 | private void ShareMenuItem_Click(object sender, RoutedEventArgs e) 149 | { 150 | System.Diagnostics.Process.Start("https://github.com/pluveto/ShortcutMap/labels/Share"); 151 | } 152 | } 153 | public class NewLine : FrameworkElement 154 | { 155 | public NewLine() 156 | { 157 | Height = 0; 158 | var binding = new System.Windows.Data.Binding 159 | { 160 | RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(WrapPanel), 1), 161 | Path = new PropertyPath("ActualHeight") 162 | }; 163 | BindingOperations.SetBinding(this, WidthProperty, binding); 164 | } 165 | } 166 | 167 | } 168 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/Pluvet.ShortcutMap.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {90DC4F94-1E88-4848-930D-69E542F82A96} 8 | WinExe 9 | Pluvet.ShortcutMap 10 | Pluvet.ShortcutMap 11 | v4.5 12 | 512 13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 4 15 | true 16 | 17 | publish\ 18 | true 19 | Disk 20 | false 21 | Foreground 22 | 7 23 | Days 24 | false 25 | false 26 | true 27 | 0 28 | 1.0.0.%2a 29 | false 30 | false 31 | true 32 | 33 | 34 | AnyCPU 35 | true 36 | full 37 | false 38 | bin\Debug\ 39 | DEBUG;TRACE 40 | prompt 41 | 4 42 | false 43 | 44 | 45 | AnyCPU 46 | pdbonly 47 | true 48 | bin\Release\ 49 | TRACE 50 | prompt 51 | 4 52 | false 53 | 54 | 55 | 56 | ..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net45\Hardcodet.Wpf.TaskbarNotification.dll 57 | 58 | 59 | ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 4.0 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | MSBuild:Compile 80 | Designer 81 | 82 | 83 | MSBuild:Compile 84 | Designer 85 | 86 | 87 | App.xaml 88 | Code 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | MainWindow.xaml 98 | Code 99 | 100 | 101 | 102 | 103 | Code 104 | 105 | 106 | True 107 | True 108 | Resources.resx 109 | 110 | 111 | True 112 | Settings.settings 113 | True 114 | 115 | 116 | ResXFileCodeGenerator 117 | Resources.Designer.cs 118 | 119 | 120 | 121 | 122 | SettingsSingleFileGenerator 123 | Settings.Designer.cs 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | False 137 | .NET Framework 3.5 SP1 138 | false 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /Pluvet.ShortcutMap/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 17 | 20 | 21 | /resources/Roboto-Light.ttf#Roboto 22 | 50 | 56 | 64 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 79 | 84 | 92 | 93 | 98 | 99 | 100 | Group name 101 | 102 | 103 | 106 | 107 | Description 108 | 109 | 110 | 111 | 112 | 113 | Group name 114 | 115 | 116 | 119 | 120 | Description 121 | 122 | 123 | 124 | 125 | 126 | Group name 127 | 128 | 129 | 132 | 133 | Description 134 | 135 | 136 | 137 | 138 | 139 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 158 | Shortcut Map 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | --------------------------------------------------------------------------------