├── .gitattributes
├── .gitignore
├── LICENSE
├── NativeMultiFileArchiveLib
├── ArchiveFile.cs
├── DeflateStreamExtension.cs
├── NativeMultiFileArchiveLib.csproj
├── Properties
│ └── AssemblyInfo.cs
├── StreamingArchiveFile.cs
├── TinyArchive.cs
├── TinySerializer.cs
├── Tree.cs
└── TreeNode.cs
├── README.md
├── WGInstall
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Strings.wxl
├── WGInstall.csproj
├── banner-left.jpg
├── banner.png
├── lic.rtf
├── logo.ico
└── packages.config
├── WGestures.App
├── App.config
├── AppSettings.cs
├── ConfigKeys.cs
├── Constants.cs
├── Gui
│ ├── CommandViewFactory.cs
│ ├── ICommandView.cs
│ ├── ICommandViewFactory.cs
│ ├── ITargetAppAware.cs
│ ├── Model
│ │ ├── OrderableExeApp.cs
│ │ └── OrderableIntent.cs
│ └── Windows
│ │ ├── CommandViews
│ │ ├── CmdCommandView.Designer.cs
│ │ ├── CmdCommandView.cs
│ │ ├── CmdCommandView.resx
│ │ ├── CommandViewUserControl.Designer.cs
│ │ ├── CommandViewUserControl.cs
│ │ ├── CommandViewUserControl.resx
│ │ ├── GeneralNoParameterCommandView.Designer.cs
│ │ ├── GeneralNoParameterCommandView.cs
│ │ ├── GeneralNoParameterCommandView.resx
│ │ ├── GotoUrlCommandView.Designer.cs
│ │ ├── GotoUrlCommandView.cs
│ │ ├── GotoUrlCommandView.resx
│ │ ├── HotKeyCommandView.Designer.cs
│ │ ├── HotKeyCommandView.cs
│ │ ├── HotKeyCommandView.resx
│ │ ├── OpenFileCommandView.Designer.cs
│ │ ├── OpenFileCommandView.cs
│ │ ├── OpenFileCommandView.resx
│ │ ├── ScriptCommandView.Designer.cs
│ │ ├── ScriptCommandView.cs
│ │ ├── ScriptCommandView.resx
│ │ ├── SendTextCommandView.Designer.cs
│ │ ├── SendTextCommandView.cs
│ │ ├── SendTextCommandView.resx
│ │ ├── TaskSwitcherCommandView.cs
│ │ ├── TaskSwitcherCommandView.resx
│ │ ├── WebSearchCommandView.Designer.cs
│ │ ├── WebSearchCommandView.cs
│ │ ├── WebSearchCommandView.resx
│ │ ├── WindowControlCommandView.Designer.cs
│ │ ├── WindowControlCommandView.cs
│ │ └── WindowControlCommandView.resx
│ │ ├── Controls
│ │ ├── AlwaysSelectedListView.cs
│ │ ├── ColorButton.cs
│ │ ├── InstantNumericUpDown.cs
│ │ ├── LazyPaintButton.cs
│ │ ├── LineFlowLayout.cs
│ │ ├── LineLabel.cs
│ │ ├── MacGroupBox.cs
│ │ ├── MetroButton.cs
│ │ ├── ReorderableListView
│ │ │ ├── CancelListViewItemDragEventArgs.cs
│ │ │ ├── EventsListBox.cs
│ │ │ ├── InsertionMode.cs
│ │ │ ├── ListViewItemDragEventArgs.cs
│ │ │ └── ReorderableListView.cs
│ │ └── ShortcutRecordButton.cs
│ │ ├── EditAppForm.Designer.cs
│ │ ├── EditAppForm.cs
│ │ ├── EditAppForm.resx
│ │ ├── EditGestureForm.Designer.cs
│ │ ├── EditGestureForm.cs
│ │ ├── EditGestureForm.resx
│ │ ├── ElevatedDragDropManager.cs
│ │ ├── ErrorForm.Designer.cs
│ │ ├── ErrorForm.cs
│ │ ├── ErrorForm.resx
│ │ ├── IconHelper.cs
│ │ ├── ImportForm.Designer.cs
│ │ ├── ImportForm.cs
│ │ ├── ImportForm.resx
│ │ ├── SettingsForm.Designer.cs
│ │ ├── SettingsForm.cs
│ │ ├── SettingsForm.resx
│ │ ├── SettingsFormController.cs
│ │ ├── SuspendDrawing.cs
│ │ ├── UpdateInfoForm.Designer.cs
│ │ ├── UpdateInfoForm.cs
│ │ └── UpdateInfoForm.resx
├── Migrate
│ ├── ConfigAndGestures.cs
│ ├── MigrateException.cs
│ └── MigrateService.cs
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── DataSources
│ │ └── WGestures.App.Gui.Windows.SettingsFormController.datasource
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── QuickStartGuide
│ ├── QuickStartGuideForm.Designer.cs
│ ├── QuickStartGuideForm.cs
│ ├── QuickStartGuideForm.resx
│ ├── img
│ │ ├── next-default.png
│ │ ├── next.png
│ │ ├── pagination.png
│ │ ├── pagination_.png
│ │ ├── prev-default.png
│ │ └── prev.png
│ ├── index.html
│ ├── js
│ │ ├── jquery-1.11.1.min.js
│ │ └── jquery.slides.min.js
│ └── slides
│ │ ├── 0.png
│ │ ├── 1.png
│ │ ├── 2.png
│ │ ├── 3.png
│ │ ├── 4.png
│ │ └── 5.png
├── Resources
│ ├── 128.png
│ ├── Alert.png
│ ├── Edit.png
│ ├── add.png
│ ├── alipay.png
│ ├── block.png
│ ├── checking.gif
│ ├── cross.png
│ ├── cross_empty.png
│ ├── dropTarget.png
│ ├── forbidden.png
│ ├── help.jpg
│ ├── icon.ico
│ ├── icon_bw.ico
│ ├── info_icon.png
│ ├── logo_error.png
│ ├── menuBtn.png
│ ├── menuBtn_down.png
│ ├── menuBtnr.png
│ ├── remove.png
│ ├── trayIcon.ico
│ ├── trayIcon_bw.ico
│ ├── triangle.png
│ └── unknown.png
├── UpdateLog.txt
├── WGestures.App.csproj
├── Warn360.Designer.cs
├── Warn360.cs
├── Warn360.resx
├── app.debug.manifest
├── app.manifest
├── defaults
│ ├── config.plist
│ └── gestures.wg2
├── externalResource
│ ├── Icon
│ │ ├── 128.png
│ │ ├── 16.png
│ │ ├── 192.png
│ │ ├── 24.png
│ │ ├── 256.png
│ │ ├── 32.png
│ │ ├── 48.png
│ │ ├── 64.png
│ │ └── convertToIco.bat
│ └── slides.ai
└── packages.config
├── WGestures.Common
├── Annotation
│ └── NamedAttribute.cs
├── Config
│ ├── AbstractDictConfig.cs
│ ├── IConfig.cs
│ ├── Impl
│ │ └── PlistConfig.cs
│ └── Plist.cs
├── DetailedDebugListener.cs
├── NumberUtil.cs
├── OsSpecific
│ └── Windows
│ │ ├── AutoStarter.cs
│ │ ├── CanvasForm.cs
│ │ ├── CanvasWindow.cs
│ │ ├── ClipboardMonitor.cs
│ │ ├── DiBitmap.cs
│ │ ├── GlobalHotKeyManager.cs
│ │ ├── GlobalKeyboardHook.cs
│ │ ├── Native.cs
│ │ ├── Screen.cs
│ │ ├── TCDTouchInjection.cs
│ │ └── Win32
│ │ ├── GDI32.cs
│ │ ├── Kernel32.cs
│ │ ├── Kernel32Desktop.cs
│ │ ├── Shell32.cs
│ │ └── User32.cs
├── Product
│ ├── VersionChecker.cs
│ └── VersionInfo.cs
├── Properties
│ └── AssemblyInfo.cs
├── WGestures.Common.csproj
└── packages.config
├── WGestures.Core
├── App.cs
├── Commands
│ ├── AbstractCommand.cs
│ ├── IGestureContextAware.cs
│ ├── IGestureModifiersAware.cs
│ ├── IGestureParserAware.cs
│ ├── INeedInit.cs
│ └── Impl
│ │ ├── ChangeAudioVolumeCommand.cs
│ │ ├── CmdCommand.cs
│ │ ├── DoNothingCommand.cs
│ │ ├── GotoUrlCommand.cs
│ │ ├── HotKeyCommand.cs
│ │ ├── OpenFileCommand.cs
│ │ ├── PauseWGesturesCommand.cs
│ │ ├── ScriptCommand.cs
│ │ ├── SearchBox.Designer.cs
│ │ ├── SearchBox.cs
│ │ ├── SearchBox.resx
│ │ ├── SendTextCommand.cs
│ │ ├── Sim.cs
│ │ ├── TaskSwitcherCommand.cs
│ │ ├── WebSearchCommand.cs
│ │ └── WindowControlCommand.cs
├── Gesture.cs
├── GestureButton.cs
├── GestureContext.cs
├── GestureIntent.cs
├── GestureModifier.cs
├── GestureParser.cs
├── IGestureIntentFinder.cs
├── IPathTracker.cs
├── Impl
│ └── Windows
│ │ ├── MouseHook.cs
│ │ ├── ScreenEdgeInteractDetector.cs
│ │ ├── TouchHook.cs
│ │ ├── Win32GestureContext.cs
│ │ └── Win32MousePathTracker2.cs
├── Persistence
│ ├── AbstractGestureIntentFinder.cs
│ ├── IGestureIntentStore.cs
│ └── Impl
│ │ ├── JsonGestureIntentStore.cs
│ │ └── Windows
│ │ └── Win32GestrueIntentFinder.cs
├── Properties
│ ├── Annotations.cs
│ └── AssemblyInfo.cs
├── ScreenCornerAndEdge.cs
├── WGestures.Core.csproj
└── packages.config
├── WGestures.View
├── Impl
│ └── Windows
│ │ └── CanvasWindowGestureView.cs
├── Properties
│ └── AssemblyInfo.cs
├── WGestures.View.csproj
└── packages.config
├── WGestures.sln
├── WindowsInput
├── IInputDeviceStateAdaptor.cs
├── IInputMessageDispatcher.cs
├── IInputSimulator.cs
├── IKeyboardSimulator.cs
├── IMouseSimulator.cs
├── InputBuilder.cs
├── InputSimulator.cs
├── KeyboardSimulator.cs
├── MouseButton.cs
├── MouseSimulator.cs
├── Native
│ ├── HARDWAREINPUT.cs
│ ├── INPUT.cs
│ ├── InputType.cs
│ ├── KEYBDINPUT.cs
│ ├── KeyboardFlag.cs
│ ├── MOUSEINPUT.cs
│ ├── MOUSEKEYBDHARDWAREINPUT.cs
│ ├── MouseFlag.cs
│ ├── NativeMethods.cs
│ ├── VirtualKeyCode.cs
│ └── XButton.cs
├── Properties
│ └── AssemblyInfo.cs
├── WindowsInput.csproj
├── WindowsInput.nuspec
├── WindowsInput.snk
├── WindowsInputDeviceStateAdaptor.cs
└── WindowsInputMessageDispatcher.cs
└── makeTestCert.bat
/.gitattributes:
--------------------------------------------------------------------------------
1 | * -text
2 |
--------------------------------------------------------------------------------
/.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 | *.userosscache
8 | *.sln.docstates
9 |
10 | SIGNPASS.bat
11 |
12 | # Build results
13 | [Dd]ebug/
14 | [Dd]ebugPublic/
15 | [Rr]elease/
16 | [Rr]eleases/
17 | x64/
18 | x86/
19 | !WGestures.Install/msvcr/x64
20 | !WGestures.Install/msvcr/x86
21 | build/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 |
26 | # Roslyn cache directories
27 | *.ide/
28 |
29 | # MSTest test Results
30 | [Tt]est[Rr]esult*/
31 | [Bb]uild[Ll]og.*
32 |
33 | #NUNIT
34 | *.VisualState.xml
35 | TestResult.xml
36 |
37 | # Build Results of an ATL Project
38 | [Dd]ebugPS/
39 | [Rr]eleasePS/
40 | dlldata.c
41 |
42 | *_i.c
43 | *_p.c
44 | *_i.h
45 | *.ilk
46 | *.meta
47 | *.obj
48 | *.pch
49 | *.pdb
50 | *.pgc
51 | *.pgd
52 | *.rsp
53 | *.sbr
54 | *.tlb
55 | *.tli
56 | *.tlh
57 | *.tmp
58 | *.tmp_proj
59 | *.log
60 | *.vspscc
61 | *.vssscc
62 | .builds
63 | *.pidb
64 | *.svclog
65 | *.scc
66 |
67 | # Chutzpah Test files
68 | _Chutzpah*
69 |
70 | # Visual C++ cache files
71 | ipch/
72 | *.aps
73 | *.ncb
74 | *.opensdf
75 | *.sdf
76 | *.cachefile
77 |
78 | # Visual Studio profiler
79 | *.psess
80 | *.vsp
81 | *.vspx
82 |
83 | # TFS 2012 Local Workspace
84 | $tf/
85 |
86 | # Guidance Automation Toolkit
87 | *.gpState
88 |
89 | # ReSharper is a .NET coding add-in
90 | _ReSharper*/
91 | *.[Rr]e[Ss]harper
92 | *.DotSettings.user
93 |
94 | # JustCode is a .NET coding addin-in
95 | .JustCode
96 |
97 | # TeamCity is a build add-in
98 | _TeamCity*
99 |
100 | # DotCover is a Code Coverage Tool
101 | *.dotCover
102 |
103 | # NCrunch
104 | _NCrunch_*
105 | .*crunch*.local.xml
106 |
107 | # MightyMoose
108 | *.mm.*
109 | AutoTest.Net/
110 |
111 | # Web workbench (sass)
112 | .sass-cache/
113 |
114 | # Installshield output folder
115 | [Ee]xpress/
116 |
117 | # DocProject is a documentation generator add-in
118 | DocProject/buildhelp/
119 | DocProject/Help/*.HxT
120 | DocProject/Help/*.HxC
121 | DocProject/Help/*.hhc
122 | DocProject/Help/*.hhk
123 | DocProject/Help/*.hhp
124 | DocProject/Help/Html2
125 | DocProject/Help/html
126 |
127 | # Click-Once directory
128 | publish/
129 |
130 | # Publish Web Output
131 | *.[Pp]ublish.xml
132 | *.azurePubxml
133 | # TODO: Comment the next line if you want to checkin your web deploy settings
134 | # but database connection strings (with potential passwords) will be unencrypted
135 | *.pubxml
136 | *.publishproj
137 |
138 | # NuGet Packages
139 | *.nupkg
140 | # The packages folder can be ignored because of Package Restore
141 | **/packages/*
142 | # except build/, which is used as an MSBuild target.
143 | !**/packages/build/
144 | # If using the old MSBuild-Integrated Package Restore, uncomment this:
145 | #!**/packages/repositories.config
146 |
147 | # Windows Azure Build Output
148 | csx/
149 | *.build.csdef
150 |
151 | # Windows Store app package directory
152 | AppPackages/
153 |
154 | # Others
155 | sql/
156 | *.Cache
157 | ClientBin/
158 | [Ss]tyle[Cc]op.*
159 | ~$*
160 | *~
161 | *.dbmdl
162 | *.dbproj.schemaview
163 | *.pfx
164 | *.cer
165 | *.publishsettings
166 | node_modules/
167 |
168 | # RIA/Silverlight projects
169 | Generated_Code/
170 |
171 | # Backup & report files from converting an old project file
172 | # to a newer Visual Studio version. Backup files are not needed,
173 | # because we have git ;-)
174 | _UpgradeReport_Files/
175 | Backup*/
176 | UpgradeLog*.XML
177 | UpgradeLog*.htm
178 |
179 | # SQL Server files
180 | *.mdf
181 | *.ldf
182 |
183 | # Business Intelligence projects
184 | *.rdl.data
185 | *.bim.layout
186 | *.bim_*.settings
187 |
188 | # Microsoft Fakes
189 | FakesAssemblies/
190 | WGInstall/wix
191 | .msi
192 |
193 |
--------------------------------------------------------------------------------
/NativeMultiFileArchiveLib/DeflateStreamExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.IO.Compression;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace NativeMultiFileArchiveLib
9 | {
10 | static internal class DeflateStreamExtension
11 | {
12 |
13 | public static void CopyTo(this Stream thiz, Stream destination, int bufferSize)
14 | {
15 | if (destination == null)
16 | throw new ArgumentNullException("destination");
17 | if (bufferSize <= 0)
18 | throw new ArgumentOutOfRangeException("bufferSize");
19 | if (!thiz.CanRead && !thiz.CanWrite)
20 | throw new ObjectDisposedException("");
21 | if (!destination.CanRead && !destination.CanWrite)
22 | throw new ObjectDisposedException("destination");
23 | if (!thiz.CanRead)
24 | throw new NotSupportedException();
25 | if (!destination.CanWrite)
26 | throw new NotSupportedException();
27 |
28 | thiz.InternalCopyTo(destination, bufferSize);
29 | }
30 |
31 | private static void InternalCopyTo(this Stream thiz, Stream destination, int bufferSize)
32 | {
33 | byte[] buffer = new byte[bufferSize];
34 | int read;
35 | while ((read = thiz.Read(buffer, 0, buffer.Length)) != 0)
36 | destination.Write(buffer, 0, read);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/NativeMultiFileArchiveLib/NativeMultiFileArchiveLib.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {457BBCAF-3F8C-4F65-B34E-547F57A0D877}
9 | Library
10 | Properties
11 | NativeMultiFileArchiveLib
12 | NativeMultiFileArchiveLib
13 | v4.8
14 | 512
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | false
26 |
27 |
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 | false
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
64 |
--------------------------------------------------------------------------------
/NativeMultiFileArchiveLib/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("NativeMultiFileArchiveLib")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("NativeMultiFileArchiveLib")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("099b9edc-b941-4564-b21e-862c082a2f77")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WGestures
2 | WGestures鼠标手势 for Windows.
3 | 一个更简单, 更现代的全局鼠标手势, 支持Windows 7/8/10。
4 | 官方网站 [www.yingDev.com/projects/wgestures](http://www.yingdev.com/projects/wgestures)
5 |
6 | 
7 |
8 | 
9 |
10 | by Ying Yuandong. 有问题请提issue或联系我: Ying@YingDev.com
11 |
12 | _______________________
13 | ## 改进 WGestures...
14 | ### 环境
15 | * Visual Studio 2013, .Net Framework 3.5 SDK
16 | * WGestures.Install 项目(安装程序)需要Wix: http://wixtoolset.org/releases/v4-0-3729-0/
17 |
18 | ### Build
19 | 首次Build请先运行 `/makeTestCert.bat` 并按提示生成测试证书(根证书和签名证书分别自动拷贝到了 `/WGestures.App/cert/YingDevCA.cer` 和 `/YingDevSPC.pfx` ), 该证书会在BuildEvent中用于对生成的exe进行签名。要正确运行此脚本,请打开"VS开发人员命令提示" > cd `WGestures所在目录` > makeTestCert.bat
20 |
--------------------------------------------------------------------------------
/WGInstall/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/WGInstall/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("WGInstall")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WGInstall")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("44555887-c439-470c-944d-8866ec3d7067")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/WGInstall/Strings.wxl:
--------------------------------------------------------------------------------
1 |
2 |
3 | WGestures只支持Windows 7以及更新版本的系统。
4 | 您已经安装过较新的版本的WGestures,如果确实需要安装此版本,请先卸载已安装的版本。
5 | 立即运行WGestures
6 | WGestures鼠标手势
7 | 项目主页
8 | 卸载WGestures
9 | 从您的电脑中删除WGestures
10 |
--------------------------------------------------------------------------------
/WGInstall/banner-left.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGInstall/banner-left.jpg
--------------------------------------------------------------------------------
/WGInstall/banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGInstall/banner.png
--------------------------------------------------------------------------------
/WGInstall/logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGInstall/logo.ico
--------------------------------------------------------------------------------
/WGInstall/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/WGestures.App/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/WGestures.App/AppSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows.Forms;
7 | using WGestures.Common.Product;
8 |
9 | namespace WGestures.App
10 | {
11 | internal static class AppSettings
12 | {
13 | public static string CheckForUpdateUrl
14 | {
15 | get
16 | {
17 |
18 | #if DEBUG
19 | return ConfigurationManager.AppSettings.Get(Constants.CheckForUpdateUrlAppSettingKey);// "http://localhost:1226/projects/latestVersion?product=WGestures";
20 |
21 | #else
22 | return ConfigurationManager.AppSettings.Get(Constants.CheckForUpdateUrlAppSettingKey);
23 |
24 | #endif
25 | }
26 | }
27 |
28 | public static string ProductHomePage
29 | {
30 | get { return ConfigurationManager.AppSettings.Get(Constants.ProductHomePageAppSettingKey); }
31 | }
32 |
33 | public static string UserDataDirectory
34 | {
35 | get { return Application.LocalUserAppDataPath; }
36 | }
37 |
38 |
39 |
40 | public static string ConfigFilePath
41 | {
42 | get { return UserDataDirectory + @"\config.plist"; }
43 | }
44 |
45 | public static string GesturesFilePath
46 | {
47 | get { return UserDataDirectory + @"\gestures.wg2"; }
48 | }
49 |
50 | public static string DefaultGesturesFilePath
51 | {
52 | get { return Application.StartupPath + @"\defaults\gestures.wg2"; }
53 | }
54 |
55 |
56 | public static string ConfigFileVersion
57 | {
58 | get { return "1"; }
59 | }
60 |
61 | public static string GesturesFileVersion
62 | {
63 | get { return "3"; }
64 | }
65 |
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/WGestures.App/ConfigKeys.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WGestures.App
7 | {
8 | public static class ConfigKeys
9 | {
10 | public const string AutoStart = "AutoStart";
11 | public const string AutoCheckForUpdate = "AutoCheckForUpdate";
12 |
13 | public const string PathTrackerTriggerButton = "PathTrackerTriggerButton";
14 | public const string PathTrackerInitialValidMove = "PathTrackerInitialValidMove";
15 | public const string PathTrackerStayTimeout = "PathTrackerStayTimeout";
16 | public const string PathTrackerStayTimeoutMillis = "PathTrackerStayTimeoutMillis";
17 | public const string PathTrackerInitialStayTimeout = "PathTrackerInitialStayTimeout";
18 | public const string PathTrackerInitialStayTimoutMillis = "PathTrackerInitialStayTimoutMillis";
19 | public const string PathTrackerPreferCursorWindow = "PathTrackerPreferCursorWindow";
20 |
21 | //历史原因, 字符串不变
22 | public const string PathTrackerDisableInFullScreen = "GestureParserDisableInFullScreenMode";
23 |
24 | public const string GestureViewShowPath = "GestureViewShowPath";
25 | public const string GestureViewShowCommandName = "GestureViewShowCommandName";
26 | public const string GestureViewFadeOut = "GestureViewFadeOut";
27 | public const string GestureViewMainPathColor = "GestureViewMainPathColor";
28 | public const string GestureViewMiddleBtnMainColor = "GestureViewMiddleBtnMainColor";
29 | public const string GestureViewAlternativePathColor = "GestureViewAlternativePathColor";
30 | public const string GestureViewXBtnPathColor = "GestureViewXBtnPathColor";
31 |
32 |
33 | public const string IsFirstRun = "IsFirstRun";
34 | public const string Is360EverDected = "Is360EverDected";
35 |
36 | public const string TrayIconVisible = "TrayIconVisible";
37 |
38 | public const string GestureParserEnableHotCorners = "GestureParserEnableHotCorners";
39 | public const string GestureParserEnable8DirGesture = "GestureParserEnable8DirGesture";
40 |
41 | public const string GestureParserEnableRubEdges = "GestureParserEnableRubEdges";
42 |
43 | public const string PauseResumeHotKey = "PauseResumeHotKey";
44 | public const string EnableWindowsKeyGesturing = "EnableWindowsKeyGesturing";
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/WGestures.App/Constants.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace WGestures.App
3 | {
4 | internal static class Constants
5 | {
6 | public const string Identifier = "com.yingdev.WGestures";
7 | public const string CheckForUpdateUrlAppSettingKey = "CheckForUpdateUrl";
8 |
9 | public const string ProductHomePageAppSettingKey = "ProductHomePage";
10 |
11 | #if DEBUG
12 | public const int AutoCheckForUpdateInterval = 1000 * 3;
13 | #else
14 | public const int AutoCheckForUpdateInterval = 1000*30;
15 | #endif
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/ICommandView.cs:
--------------------------------------------------------------------------------
1 | using WGestures.Core.Commands;
2 |
3 | namespace WGestures.App.Gui
4 | {
5 | public interface ICommandView
6 | {
7 | AbstractCommand Command { get; set; }
8 |
9 | bool Validate();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/ICommandViewFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using WGestures.Core.Commands;
3 |
4 | namespace WGestures.App.Gui
5 | {
6 | public interface ICommandViewFactory : IDisposable where TBaseViewType : ICommandView
7 | {
8 | TBaseViewType GetCommandView(AbstractCommand command);
9 | TBaseViewType GetCommandView(Type commandType);
10 |
11 |
12 | void Register()
13 | where TC : AbstractCommand
14 | where TV : TBaseViewType;
15 | void UnRegisterFor() where TC : AbstractCommand;
16 | void UnRegisterAll();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/ITargetAppAware.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using WGestures.Core;
6 | using WGestures.Core.Persistence;
7 |
8 | namespace WGestures.App.Gui
9 | {
10 | ///
11 | /// 用于注入“作用于”的应用程序
12 | ///
13 | interface ITargetAppAware
14 | {
15 | AbstractApp TargetApp { set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Model/OrderableExeApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Reflection;
5 | using System.Windows.Forms;
6 | using WGestures.Core;
7 |
8 | namespace WGestures.App.Gui.Model
9 | {
10 | [Serializable]
11 | internal class OrderableExeApp : ExeApp,IComparable
12 | {
13 | //显示顺序
14 | public int Order { get; set; }
15 |
16 | public bool Exists
17 | {
18 | get { return System.IO.File.Exists(ExecutablePath); }
19 | }
20 |
21 | public OrderableExeApp()
22 | {
23 |
24 | }
25 |
26 | public OrderableExeApp(ExeApp from)
27 | {
28 | var t = from.GetType();
29 | foreach (var fieldInf in t.GetFields())
30 | {
31 | fieldInf.SetValue(this, fieldInf.GetValue(from));
32 | }
33 | foreach (var propInf in t.GetProperties())
34 | {
35 | propInf.SetValue(this, propInf.GetValue(from,null),null);
36 | }
37 | }
38 |
39 |
40 | public int CompareTo(OrderableExeApp other)
41 | {
42 | if (other.Order == Order) return 0;
43 | if (other.Order > Order) return -1;
44 |
45 | return 1;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Model/OrderableIntent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using WGestures.Core;
6 |
7 | namespace WGestures.App.Gui.Model
8 | {
9 | [Serializable]
10 | class OrderableIntent : GestureIntent
11 | {
12 | public int Order { get; set; }
13 |
14 |
15 | public OrderableIntent()
16 | {
17 |
18 | }
19 |
20 |
21 | public OrderableIntent(GestureIntent from)
22 | {
23 | var t = from.GetType();
24 | foreach (var fieldInf in t.GetFields())
25 | {
26 | fieldInf.SetValue(this, fieldInf.GetValue(from));
27 | }
28 | foreach (var propInf in t.GetProperties())
29 | {
30 | propInf.SetValue(this, propInf.GetValue(from,null),null);
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/CmdCommandView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using System.Linq;
5 | using WGestures.Core.Commands;
6 | using WGestures.Core.Commands.Impl;
7 | using WGestures.Core.Persistence;
8 |
9 | namespace WGestures.App.Gui.Windows.CommandViews
10 | {
11 | public partial class CmdCommandView : CommandViewUserControl
12 | {
13 | private readonly static string explorerPath = Environment.GetEnvironmentVariable("windir") + Path.DirectorySeparatorChar + "explorer.exe";
14 |
15 | private CmdCommand _command;
16 |
17 | public override AbstractCommand Command
18 | {
19 | get { return _command; }
20 | set
21 | {
22 | _command = (CmdCommand) value;
23 | check_ShowWindow.Checked = _command.ShowWindow;
24 | check_setWorkingDir.Checked = _command.AutoSetWorkingDir;
25 | txt_CmdLine.Text = _command.Code ?? "echo Hello";
26 | }
27 | }
28 |
29 |
30 | public CmdCommandView()
31 | {
32 | InitializeComponent();
33 | }
34 |
35 | private void check_ShowWindow_CheckedChanged(object sender, System.EventArgs e)
36 | {
37 | _command.ShowWindow = check_ShowWindow.Checked;
38 |
39 | }
40 |
41 | private void txt_CmdLine_TextChanged(object sender, System.EventArgs e)
42 | {
43 | _command.Code = txt_CmdLine.Text;
44 |
45 | OnCommandValueChanged();
46 | }
47 |
48 |
49 |
50 | private void check_setWorkingDir_CheckedChanged(object sender, EventArgs e)
51 | {
52 | _command.AutoSetWorkingDir = check_setWorkingDir.Checked;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/CommandViewUserControl.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WGestures.App.Gui.Windows.CommandViews
2 | {
3 | partial class CommandViewUserControl
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.SuspendLayout();
32 | //
33 | // CommandViewUserControl
34 | //
35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
37 | this.AutoSize = true;
38 | this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
39 | this.BackColor = System.Drawing.Color.Transparent;
40 | this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
41 | this.Name = "CommandViewUserControl";
42 | this.Size = new System.Drawing.Size(0, 0);
43 | this.ResumeLayout(false);
44 |
45 | }
46 |
47 | #endregion
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/CommandViewUserControl.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 | using WGestures.Core.Commands;
3 |
4 | namespace WGestures.App.Gui.Windows.CommandViews
5 | {
6 | public partial class CommandViewUserControl : UserControl,ICommandView
7 | {
8 | public CommandViewUserControl()
9 | {
10 | InitializeComponent();
11 | }
12 |
13 | public virtual AbstractCommand Command { get; set; }
14 |
15 | public event CommandValueChangedEventHandler CommandValueChanged;
16 |
17 | protected virtual void OnCommandValueChanged()
18 | {
19 | if (CommandValueChanged != null) CommandValueChanged(Command);
20 | }
21 |
22 | public delegate void CommandValueChangedEventHandler(AbstractCommand command);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/GeneralNoParameterCommandView.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WGestures.App.Gui.Windows.CommandViews
2 | {
3 | partial class GeneralNoParameterCommandView
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.label1 = new System.Windows.Forms.Label();
32 | this.SuspendLayout();
33 | //
34 | // label1
35 | //
36 | this.label1.AutoSize = true;
37 | this.label1.ForeColor = System.Drawing.Color.Silver;
38 | this.label1.Location = new System.Drawing.Point(3, 5);
39 | this.label1.Margin = new System.Windows.Forms.Padding(3);
40 | this.label1.Name = "label1";
41 | this.label1.Size = new System.Drawing.Size(113, 12);
42 | this.label1.TabIndex = 0;
43 | this.label1.Text = "此操作没有额外选项";
44 | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
45 | //
46 | // GeneralNoParameterCommandView
47 | //
48 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
49 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
50 | this.CausesValidation = false;
51 | this.Controls.Add(this.label1);
52 | this.Margin = new System.Windows.Forms.Padding(1, 1, 1, 1);
53 | this.Name = "GeneralNoParameterCommandView";
54 | this.Size = new System.Drawing.Size(119, 20);
55 | this.ResumeLayout(false);
56 | this.PerformLayout();
57 |
58 | }
59 |
60 | #endregion
61 |
62 | private System.Windows.Forms.Label label1;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/GeneralNoParameterCommandView.cs:
--------------------------------------------------------------------------------
1 | using WGestures.Core.Commands;
2 |
3 | namespace WGestures.App.Gui.Windows.CommandViews
4 | {
5 | public partial class GeneralNoParameterCommandView : CommandViewUserControl
6 | {
7 | public GeneralNoParameterCommandView()
8 | {
9 | InitializeComponent();
10 | }
11 |
12 | public override AbstractCommand Command { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/GotoUrlCommandView.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WGestures.App.Gui.Windows.CommandViews
2 | {
3 | partial class GotoUrlCommandView
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.tb_url = new System.Windows.Forms.TextBox();
32 | this.label1 = new System.Windows.Forms.Label();
33 | this.SuspendLayout();
34 | //
35 | // tb_url
36 | //
37 | this.tb_url.Location = new System.Drawing.Point(38, 2);
38 | this.tb_url.Name = "tb_url";
39 | this.tb_url.Size = new System.Drawing.Size(219, 21);
40 | this.tb_url.TabIndex = 1;
41 | this.tb_url.TextChanged += new System.EventHandler(this.tb_url_TextChanged);
42 | //
43 | // label1
44 | //
45 | this.label1.AutoSize = true;
46 | this.label1.Location = new System.Drawing.Point(3, 5);
47 | this.label1.Margin = new System.Windows.Forms.Padding(3);
48 | this.label1.Name = "label1";
49 | this.label1.Size = new System.Drawing.Size(29, 12);
50 | this.label1.TabIndex = 0;
51 | this.label1.Text = "网址";
52 | //
53 | // GotoUrlCommandView
54 | //
55 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
56 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
57 | this.Controls.Add(this.tb_url);
58 | this.Controls.Add(this.label1);
59 | this.Margin = new System.Windows.Forms.Padding(1);
60 | this.Name = "GotoUrlCommandView";
61 | this.Size = new System.Drawing.Size(260, 26);
62 | this.ResumeLayout(false);
63 | this.PerformLayout();
64 |
65 | }
66 |
67 | #endregion
68 |
69 | private System.Windows.Forms.Label label1;
70 | private System.Windows.Forms.TextBox tb_url;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/GotoUrlCommandView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using WGestures.Core.Commands;
3 | using WGestures.Core.Commands.Impl;
4 |
5 | namespace WGestures.App.Gui.Windows.CommandViews
6 | {
7 | public partial class GotoUrlCommandView : CommandViewUserControl
8 | {
9 | public GotoUrlCommandView()
10 | {
11 | InitializeComponent();
12 | }
13 |
14 | private GotoUrlCommand _command;
15 | public override AbstractCommand Command
16 | {
17 | get { return _command; }
18 | set
19 | {
20 | _command = (GotoUrlCommand) value;
21 | tb_url.Text = _command.Url ?? "";
22 | }
23 | }
24 |
25 | private void tb_url_TextChanged(object sender, EventArgs e)
26 | {
27 | _command.Url = tb_url.Text;
28 | OnCommandValueChanged();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/HotKeyCommandView.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WGestures.App.Gui.Windows.CommandViews
2 | {
3 | partial class HotKeyCommandView
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | if (disposing)
21 | {
22 | hook.unhook();
23 | hook = null;
24 | }
25 | base.Dispose(disposing);
26 | }
27 |
28 | #region Component Designer generated code
29 |
30 | ///
31 | /// Required method for Designer support - do not modify
32 | /// the contents of this method with the code editor.
33 | ///
34 | private void InitializeComponent()
35 | {
36 | this.btn_recordHotkey = new System.Windows.Forms.Button();
37 | this.lb_shortcut = new System.Windows.Forms.Label();
38 | this.SuspendLayout();
39 | //
40 | // btn_recordHotkey
41 | //
42 | this.btn_recordHotkey.Location = new System.Drawing.Point(3, 5);
43 | this.btn_recordHotkey.Name = "btn_recordHotkey";
44 | this.btn_recordHotkey.Size = new System.Drawing.Size(75, 23);
45 | this.btn_recordHotkey.TabIndex = 1;
46 | this.btn_recordHotkey.Text = "录入快捷键";
47 | this.btn_recordHotkey.UseVisualStyleBackColor = true;
48 | this.btn_recordHotkey.Click += new System.EventHandler(this.btn_recordHotkey_Click);
49 | //
50 | // lb_shortcut
51 | //
52 | this.lb_shortcut.AutoSize = true;
53 | this.lb_shortcut.Location = new System.Drawing.Point(84, 10);
54 | this.lb_shortcut.Margin = new System.Windows.Forms.Padding(3);
55 | this.lb_shortcut.Name = "lb_shortcut";
56 | this.lb_shortcut.Size = new System.Drawing.Size(77, 12);
57 | this.lb_shortcut.TabIndex = 2;
58 | this.lb_shortcut.Text = "未指定快捷键";
59 | this.lb_shortcut.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
60 | //
61 | // HotKeyCommandView
62 | //
63 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
64 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
65 | this.Controls.Add(this.btn_recordHotkey);
66 | this.Controls.Add(this.lb_shortcut);
67 | this.Margin = new System.Windows.Forms.Padding(1, 2, 1, 2);
68 | this.Name = "HotKeyCommandView";
69 | this.Size = new System.Drawing.Size(164, 31);
70 | this.ResumeLayout(false);
71 | this.PerformLayout();
72 |
73 | }
74 |
75 | #endregion
76 |
77 | //private MouseKeyboardActivityMonitor.Controls.MouseKeyEventProvider mouseKeyEventProvider;
78 | private System.Windows.Forms.Button btn_recordHotkey;
79 | private System.Windows.Forms.Label lb_shortcut;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/OpenFileCommandView.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WGestures.App.Gui.Windows.CommandViews
2 | {
3 | partial class OpenFileCommandView
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.label1 = new System.Windows.Forms.Label();
32 | this.tb_path = new System.Windows.Forms.TextBox();
33 | this.btn_selectFile = new System.Windows.Forms.Button();
34 | this.SuspendLayout();
35 | //
36 | // label1
37 | //
38 | this.label1.AutoSize = true;
39 | this.label1.Location = new System.Drawing.Point(3, 5);
40 | this.label1.Margin = new System.Windows.Forms.Padding(3);
41 | this.label1.Name = "label1";
42 | this.label1.Size = new System.Drawing.Size(29, 12);
43 | this.label1.TabIndex = 0;
44 | this.label1.Text = "文件";
45 | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
46 | //
47 | // tb_path
48 | //
49 | this.tb_path.Location = new System.Drawing.Point(37, 2);
50 | this.tb_path.Margin = new System.Windows.Forms.Padding(2);
51 | this.tb_path.Multiline = true;
52 | this.tb_path.Name = "tb_path";
53 | this.tb_path.ReadOnly = true;
54 | this.tb_path.RightToLeft = System.Windows.Forms.RightToLeft.No;
55 | this.tb_path.Size = new System.Drawing.Size(150, 21);
56 | this.tb_path.TabIndex = 1;
57 | this.tb_path.WordWrap = false;
58 | //
59 | // btn_selectFile
60 | //
61 | this.btn_selectFile.Location = new System.Drawing.Point(194, 0);
62 | this.btn_selectFile.Margin = new System.Windows.Forms.Padding(2);
63 | this.btn_selectFile.Name = "btn_selectFile";
64 | this.btn_selectFile.Size = new System.Drawing.Size(64, 23);
65 | this.btn_selectFile.TabIndex = 2;
66 | this.btn_selectFile.Text = "选择...";
67 | this.btn_selectFile.UseVisualStyleBackColor = true;
68 | this.btn_selectFile.Click += new System.EventHandler(this.btn_selectFile_Click);
69 | //
70 | // OpenFileCommandView
71 | //
72 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
73 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
74 | this.Controls.Add(this.tb_path);
75 | this.Controls.Add(this.label1);
76 | this.Controls.Add(this.btn_selectFile);
77 | this.Margin = new System.Windows.Forms.Padding(1);
78 | this.Name = "OpenFileCommandView";
79 | this.Size = new System.Drawing.Size(260, 25);
80 | this.ResumeLayout(false);
81 | this.PerformLayout();
82 |
83 | }
84 |
85 | #endregion
86 |
87 | private System.Windows.Forms.Label label1;
88 | private System.Windows.Forms.TextBox tb_path;
89 | private System.Windows.Forms.Button btn_selectFile;
90 |
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/OpenFileCommandView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 | using WGestures.Core.Commands;
4 | using WGestures.Core.Commands.Impl;
5 |
6 | namespace WGestures.App.Gui.Windows.CommandViews
7 | {
8 | public partial class OpenFileCommandView : CommandViewUserControl
9 | {
10 | private OpenFileCommand _command;
11 |
12 | public OpenFileCommandView()
13 | {
14 | InitializeComponent();
15 | }
16 |
17 |
18 | public override AbstractCommand Command
19 | {
20 | get { return _command; }
21 | set
22 | {
23 | _command = (OpenFileCommand)value;
24 | tb_path.Text = _command.FilePath ?? "";
25 | }
26 | }
27 |
28 | private void btn_selectFile_Click(object sender, EventArgs e)
29 | {
30 | using (var fileDlg = new OpenFileDialog())
31 | {
32 | fileDlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
33 |
34 |
35 | var result = fileDlg.ShowDialog();
36 | if (result == DialogResult.OK)
37 | {
38 | var path = fileDlg.FileName;
39 | tb_path.Text = path;
40 | _command.FilePath = path;
41 |
42 | OnCommandValueChanged();
43 | }
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/ScriptCommandView.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.Windows.Forms;
3 | using WGestures.Core.Commands;
4 | using WGestures.Core.Commands.Impl;
5 |
6 | namespace WGestures.App.Gui.Windows.CommandViews
7 | {
8 | public partial class ScriptCommandView : CommandViewUserControl
9 | {
10 | ScriptCommand _cmd;
11 |
12 | public ScriptCommandView()
13 | {
14 | InitializeComponent();
15 | }
16 |
17 | public override AbstractCommand Command
18 | {
19 | get { return _cmd; }
20 | set
21 | {
22 | _cmd = (ScriptCommand)value;
23 | txt_initScript.Text = _cmd.InitScript;
24 | txt_script.Text = _cmd.Script;
25 | check_handleModifiers.Checked = _cmd.HandleModifiers;
26 | txt_modifierRecognized.Text = _cmd.GestureRecognizedScript;
27 | txt_modifierTriggered.Text = _cmd.ModifierTriggeredScript;
28 | txt_gestureEnded.Text = _cmd.GestureEndedScript;
29 | }
30 | }
31 |
32 | private void txt_script_TextChanged(object sender, System.EventArgs e)
33 | {
34 | _cmd.Script = txt_script.Text;
35 | }
36 |
37 | private void txt_initScript_TextChanged(object sender, System.EventArgs e)
38 | {
39 | _cmd.InitScript = txt_initScript.Text;
40 | }
41 |
42 | private void check_handleModifiers_CheckedChanged(object sender, System.EventArgs e)
43 | {
44 | _cmd.HandleModifiers = check_handleModifiers.Checked;
45 | }
46 |
47 | private void txt_modifierRecognized_TextChanged(object sender, System.EventArgs e)
48 | {
49 | _cmd.GestureRecognizedScript = txt_modifierRecognized.Text;
50 | }
51 |
52 | private void txt_modifierTriggered_TextChanged(object sender, System.EventArgs e)
53 | {
54 | _cmd.ModifierTriggeredScript = txt_modifierTriggered.Text;
55 | }
56 |
57 | private void txt_gestureEnded_TextChanged(object sender, System.EventArgs e)
58 | {
59 | _cmd.GestureEndedScript = txt_gestureEnded.Text;
60 | }
61 |
62 | private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
63 | {
64 | var start = new ProcessStartInfo("explorer", "https://github.com/yingDev/WGestures/wiki/Lua-%E8%84%9A%E6%9C%AC%E6%95%99%E7%A8%8B");
65 | Process.Start(start);
66 | }
67 |
68 | private void txt_initScript_KeyDown(object sender, KeyEventArgs e)
69 | {
70 | if(e.KeyCode == Keys.Tab)
71 | {
72 | SendKeys.Send(" "); //tab -> spaces
73 | e.Handled = true;
74 | }
75 | }
76 |
77 | private void txt_initScript_KeyPress(object sender, KeyPressEventArgs e)
78 | {
79 | if(e.KeyChar == '\t')
80 | {
81 | e.Handled = true;
82 | }
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/SendTextCommandView.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WGestures.App.Gui.Windows.CommandViews
2 | {
3 | partial class SendTextCommandView
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.txt_text = new System.Windows.Forms.TextBox();
32 | this.SuspendLayout();
33 | //
34 | // txt_text
35 | //
36 | this.txt_text.Location = new System.Drawing.Point(3, 5);
37 | this.txt_text.Multiline = true;
38 | this.txt_text.Name = "txt_text";
39 | this.txt_text.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
40 | this.txt_text.Size = new System.Drawing.Size(254, 50);
41 | this.txt_text.TabIndex = 0;
42 | this.txt_text.TextChanged += new System.EventHandler(this.txt_text_TextChanged);
43 | //
44 | // SendTextCommandView
45 | //
46 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
47 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
48 | this.Controls.Add(this.txt_text);
49 | this.Margin = new System.Windows.Forms.Padding(1);
50 | this.Name = "SendTextCommandView";
51 | this.Size = new System.Drawing.Size(260, 58);
52 | this.ResumeLayout(false);
53 | this.PerformLayout();
54 |
55 | }
56 |
57 | #endregion
58 |
59 | private System.Windows.Forms.TextBox txt_text;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/SendTextCommandView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Windows.Forms;
8 | using WGestures.Core.Commands;
9 | using WGestures.Core.Commands.Impl;
10 |
11 | namespace WGestures.App.Gui.Windows.CommandViews
12 | {
13 | public partial class SendTextCommandView : CommandViewUserControl
14 | {
15 | private SendTextCommand _command;
16 |
17 | public override AbstractCommand Command
18 | {
19 | get { return _command; }
20 | set
21 | {
22 | _command = (SendTextCommand) value;
23 | txt_text.Text = _command.Text;
24 | }
25 | }
26 |
27 | public SendTextCommandView()
28 | {
29 | InitializeComponent();
30 | }
31 |
32 | private void txt_text_TextChanged(object sender, EventArgs e)
33 | {
34 | _command.Text = txt_text.Text;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/TaskSwitcherCommandView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using WGestures.Core.Commands;
6 | using WGestures.Core.Commands.Impl;
7 |
8 | namespace WGestures.App.Gui.Windows.CommandViews
9 | {
10 | class TaskSwitcherCommandView : CommandViewUserControl
11 | {
12 | public TaskSwitcherCommandView()
13 | {
14 | InitializeComponent();
15 | }
16 | private TaskSwitcherCommand _command;
17 |
18 | public override AbstractCommand Command
19 | {
20 | get { return _command; }
21 | set
22 | {
23 | _command = (TaskSwitcherCommand) value;
24 | }
25 | }
26 |
27 | private void InitializeComponent()
28 | {
29 | this.SuspendLayout();
30 | //
31 | // TaskSwitcherCommandView
32 | //
33 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
34 | this.Name = "TaskSwitcherCommandView";
35 | this.ResumeLayout(false);
36 |
37 | }
38 |
39 | private void check_prevTask_CheckedChanged(object sender, EventArgs e)
40 | {
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/WindowControlCommandView.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WGestures.App.Gui.Windows.CommandViews
2 | {
3 | partial class WindowControlCommandView
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.label1 = new System.Windows.Forms.Label();
32 | this.combo_operation = new System.Windows.Forms.ComboBox();
33 | this.SuspendLayout();
34 | //
35 | // label1
36 | //
37 | this.label1.AutoSize = true;
38 | this.label1.Location = new System.Drawing.Point(4, 6);
39 | this.label1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
40 | this.label1.Name = "label1";
41 | this.label1.Size = new System.Drawing.Size(67, 15);
42 | this.label1.TabIndex = 0;
43 | this.label1.Text = "窗口操作";
44 | //
45 | // combo_operation
46 | //
47 | this.combo_operation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
48 | this.combo_operation.FormattingEnabled = true;
49 | this.combo_operation.Items.AddRange(new object[] {
50 | "最大化/复原",
51 | "最小化",
52 | "关闭",
53 | "置顶/取消置顶"});
54 | this.combo_operation.Location = new System.Drawing.Point(83, 2);
55 | this.combo_operation.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
56 | this.combo_operation.Name = "combo_operation";
57 | this.combo_operation.Size = new System.Drawing.Size(160, 23);
58 | this.combo_operation.TabIndex = 1;
59 | this.combo_operation.SelectedIndexChanged += new System.EventHandler(this.combo_operation_SelectedIndexChanged);
60 | //
61 | // WindowControlCommandView
62 | //
63 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
64 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
65 | this.Controls.Add(this.label1);
66 | this.Controls.Add(this.combo_operation);
67 | this.Margin = new System.Windows.Forms.Padding(1);
68 | this.Name = "WindowControlCommandView";
69 | this.Size = new System.Drawing.Size(247, 27);
70 | this.ResumeLayout(false);
71 | this.PerformLayout();
72 |
73 | }
74 |
75 | #endregion
76 |
77 | private System.Windows.Forms.Label label1;
78 | private System.Windows.Forms.ComboBox combo_operation;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/CommandViews/WindowControlCommandView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Windows.Forms;
8 | using WGestures.Core.Commands;
9 | using WGestures.Core.Commands.Impl;
10 |
11 | namespace WGestures.App.Gui.Windows.CommandViews
12 | {
13 | public partial class WindowControlCommandView : CommandViewUserControl
14 | {
15 | private WindowControlCommand _command;
16 |
17 |
18 | public WindowControlCommandView()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 |
24 | public override AbstractCommand Command
25 | {
26 | get { return _command; }
27 | set
28 | {
29 | _command = (WindowControlCommand) value;
30 | combo_operation.SelectedIndex = (int) _command.ChangeWindowStateTo;
31 | }
32 | }
33 |
34 | private void combo_operation_SelectedIndexChanged(object sender, EventArgs e)
35 | {
36 | _command.ChangeWindowStateTo = (WindowControlCommand.WindowOperation) combo_operation.SelectedIndex;
37 | OnCommandValueChanged();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/Controls/AlwaysSelectedListView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Runtime.InteropServices;
4 | using System.Windows.Forms;
5 |
6 | namespace WGestures.App.Gui.Windows.Controls
7 | {
8 |
9 | internal class AlwaysSelectedListView : ReorderableListView
10 | {
11 | public AlwaysSelectedListView()
12 | {
13 | //SetStyle(ControlStyles.UserPaint,true);
14 |
15 | }
16 |
17 |
18 | protected override void WndProc(ref Message m)
19 | {
20 | // Swallow mouse messages that are not in the client area
21 | if (m.Msg >= 0x201 && m.Msg <= 0x209)
22 | {
23 | Point pos = new Point((int) (m.LParam.ToInt64() & 0xffff), (int) (m.LParam.ToInt64() >> 16));
24 | var hit = this.HitTest(pos);
25 | switch (hit.Location)
26 | {
27 | case ListViewHitTestLocations.AboveClientArea:
28 | case ListViewHitTestLocations.BelowClientArea:
29 | case ListViewHitTestLocations.LeftOfClientArea:
30 | case ListViewHitTestLocations.RightOfClientArea:
31 | case ListViewHitTestLocations.None:
32 | return;
33 | }
34 | }
35 |
36 | //hide scroll
37 | switch (m.Msg)
38 | {
39 | case 0x83: // WM_NCCALCSIZE
40 | int style = (int)GetWindowLong(this.Handle, GWL_STYLE);
41 | if ((style & WS_HSCROLL) == WS_HSCROLL)
42 | SetWindowLong(this.Handle, GWL_STYLE, style & ~WS_HSCROLL);
43 | base.WndProc(ref m);
44 | break;
45 | default:
46 | base.WndProc(ref m);
47 | break;
48 | }
49 |
50 |
51 | }
52 |
53 | private const int GWL_STYLE = -16;
54 | private const int WS_VSCROLL = 0x00200000;
55 | private const int WS_HSCROLL = 0x00100000;
56 |
57 | public static int GetWindowLong(IntPtr hWnd, int nIndex)
58 | {
59 | if (IntPtr.Size == 4)
60 | return (int)GetWindowLong32(hWnd, nIndex);
61 | else
62 | return (int)(long)GetWindowLongPtr64(hWnd, nIndex);
63 | }
64 |
65 | public static int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong)
66 | {
67 | if (IntPtr.Size == 4)
68 | return (int)SetWindowLongPtr32(hWnd, nIndex, dwNewLong);
69 | else
70 | return (int)(long)SetWindowLongPtr64(hWnd, nIndex, dwNewLong);
71 | }
72 |
73 | [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
74 | public static extern IntPtr GetWindowLong32(IntPtr hWnd, int nIndex);
75 |
76 | [DllImport("user32.dll", EntryPoint = "GetWindowLongPtr", CharSet = CharSet.Auto)]
77 | public static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
78 |
79 | [DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)]
80 | public static extern IntPtr SetWindowLongPtr32(IntPtr hWnd, int nIndex, int dwNewLong);
81 |
82 | [DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", CharSet = CharSet.Auto)]
83 | public static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, int dwNewLong);
84 |
85 |
86 | protected override void OnQueryContinueDrag(QueryContinueDragEventArgs qcdevent)
87 | {
88 | var pos = Parent.PointToClient(MousePosition);
89 |
90 | if (!Bounds.Contains(pos))
91 | {
92 | qcdevent.Action = DragAction.Cancel;
93 | return;
94 | }
95 |
96 | base.OnQueryContinueDrag(qcdevent);
97 | }
98 |
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/Controls/ColorButton.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Drawing.Drawing2D;
4 | using System.Windows.Forms;
5 | using WGestures.Common.OsSpecific.Windows;
6 |
7 | namespace WGestures.App.Gui.Windows.Controls
8 | {
9 | internal class ColorButton : LazyPaintButton
10 | {
11 | private float _dpiFactor = Native.GetScreenDpi() / 96.0f;
12 |
13 | private Color _color = Color.Transparent;
14 | public Color Color
15 | {
16 | get { return _color; }
17 | set
18 | {
19 | _color = value;
20 | mainPen.Color = _color;
21 | Invalidate();
22 | if (ColorChanged != null) ColorChanged(this, new EventArgs());
23 | }
24 | }
25 |
26 | private Pen mainPen;
27 | private Pen borderPen;
28 | private Pen shadowPen;
29 |
30 | public event EventHandler ColorChanged;
31 |
32 | public ColorButton()
33 | {
34 | mainPen = new Pen(Color, 2.0f * _dpiFactor);
35 | borderPen = new Pen(Color.FromArgb(255, 255, 255, 255), 4.5f * _dpiFactor);
36 | shadowPen = new Pen(Color.FromArgb(80, 0, 0, 0), 5.0f * _dpiFactor);
37 | }
38 |
39 | protected override void OnPaint(PaintEventArgs pevent)
40 | {
41 |
42 | base.OnPaint(pevent);
43 | var g = pevent.Graphics;
44 |
45 | g.SetClip(pevent.ClipRectangle);
46 |
47 | g.CompositingQuality = CompositingQuality.HighQuality;
48 | g.SmoothingMode = SmoothingMode.AntiAlias;
49 |
50 | //g.Clear(BackColor);
51 |
52 | var bias = 5 * _dpiFactor;
53 |
54 | var rect = Rectangle.Inflate(Bounds, (int)-bias, (int)-bias);
55 | rect.X = (int)bias;
56 | rect.Y = (int)bias;
57 |
58 | /*g.DrawEllipse(shadowPen, rect);
59 | g.DrawEllipse(borderPen, rect);
60 | g.DrawEllipse(mainPen, rect);*/
61 |
62 | var p0 = new Point((int) rect.Left, (int) rect.Bottom);
63 | var p1 = new Point((int) rect.Right, (int) rect.Bottom);
64 | g.DrawLine(shadowPen, p0, p1);
65 | g.DrawLine(borderPen, p0, p1);
66 | g.DrawLine(mainPen, p0, p1);
67 | /*g.DrawRectangle(shadowPen, rect);
68 | g.DrawRectangle(borderPen, rect);
69 | g.DrawRectangle(mainPen, rect);*/
70 | }
71 |
72 | protected override void OnClick(EventArgs e)
73 | {
74 | base.OnClick(e);
75 |
76 | using (var colorDlg = new ColorDialog())
77 | {
78 | colorDlg.AnyColor = true;
79 | colorDlg.FullOpen = true;
80 |
81 | colorDlg.Color = Color;
82 |
83 | var ok = colorDlg.ShowDialog();
84 | if (ok == DialogResult.OK)
85 | {
86 | Color = colorDlg.Color;
87 | }
88 | }
89 |
90 | }
91 |
92 |
93 |
94 | protected override void Dispose(bool disposing)
95 | {
96 | if (disposing)
97 | {
98 | mainPen.Dispose();
99 | borderPen.Dispose();
100 | shadowPen.Dispose();
101 | }
102 |
103 | base.Dispose(disposing);
104 |
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/Controls/InstantNumericUpDown.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace WGestures.App.Gui.Windows.Controls
5 | {
6 | class InstantNumericUpDown : NumericUpDown
7 | {
8 | protected override void OnTextBoxTextChanged(object source, EventArgs e)
9 | {
10 | base.OnTextBoxTextChanged(source, e);
11 | ParseEditText();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/Controls/LazyPaintButton.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace WGestures.App.Gui.Windows.Controls
5 | {
6 | internal class LazyPaintButton : Button
7 | {
8 | protected override void OnMouseMove(MouseEventArgs mevent)
9 | {
10 | //base.OnMouseMove(mevent);
11 | }
12 |
13 | protected override void OnMouseEnter(EventArgs e)
14 | {
15 |
16 | //base.OnMouseEnter(e);
17 | }
18 |
19 | protected override void OnMouseLeave(EventArgs e)
20 | {
21 | //base.OnMouseLeave(e);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/Controls/LineFlowLayout.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Drawing;
3 | using System.Windows.Forms;
4 |
5 | namespace WGestures.App.Gui.Windows.Controls
6 | {
7 | class LineFlowLayout : FlowLayoutPanel
8 | {
9 | [Browsable(true)]
10 | public bool Vertical { get; set; }
11 |
12 | protected override void OnPaintBackground(PaintEventArgs e)
13 | {
14 | base.OnPaintBackground(e);
15 |
16 | using (var pen = new Pen(this.ForeColor))
17 | {
18 | if(!Vertical) e.Graphics.DrawLine(pen, 0, this.Height / 2, this.Width, this.Height / 2);
19 | else
20 | {
21 | e.Graphics.DrawLine(pen,this.Width/2,0,this.Width/2,this.Height);
22 | }
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/Controls/LineLabel.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 | using System.Windows.Forms;
3 |
4 | namespace WGestures.App.Gui.Windows.Controls
5 | {
6 | class LineLabel : Label
7 | {
8 | public bool IsVertical { get; set; }
9 |
10 | protected override void OnPaintBackground(PaintEventArgs pevent)
11 | {
12 | base.OnPaintBackground(pevent);
13 | var g = pevent.Graphics;
14 | g.SetClip(pevent.ClipRectangle);
15 |
16 | using (var pen = new Pen(this.ForeColor))
17 | {
18 | if (IsVertical)
19 | {
20 | g.DrawLine(pen, Width/2,0, this.Width/2, this.Height);
21 |
22 | }
23 |
24 | else g.DrawLine(pen,0,this.Height /2 ,this.Width,this.Height/2);
25 | }
26 |
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/Controls/MacGroupBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Drawing.Drawing2D;
4 | using System.Windows.Forms;
5 | using WGestures.Common.OsSpecific.Windows;
6 |
7 | namespace WGestures.App.Gui.Windows.Controls
8 | {
9 | class MacGroupBox : GroupBox
10 | {
11 | private float _dpiFactor = Native.GetScreenDpi() / 96.0f;
12 |
13 |
14 | protected override void OnPaint(PaintEventArgs e)
15 | {
16 |
17 | const int cornerRadius = 6;
18 | int actualCornerRadius = (int)(cornerRadius * _dpiFactor);
19 | const int distTxtAndBox = 2;
20 | int actualDistTxtAndbox = (int) (distTxtAndBox*_dpiFactor);
21 |
22 |
23 | var g = e.Graphics;
24 | g.SetClip(e.ClipRectangle);
25 | g.Clear(Parent.BackColor);
26 |
27 | var strSize = g.MeasureString(Text, Font);
28 |
29 | g.DrawString(Text, Font, Brushes.Black, 0, 0);
30 | var rect = new Rectangle((int)(1 * _dpiFactor), (int)(strSize.Height + actualDistTxtAndbox), (int)(Width - 2 * _dpiFactor), (int)(Height - strSize.Height - actualDistTxtAndbox));
31 |
32 | using (var pen = new Pen(Color.FromArgb(210, 210, 210), 1 * _dpiFactor))
33 | {
34 | DrawRoundedRectangle(g, rect, actualCornerRadius, pen, BackColor);
35 |
36 | g.SetClip(new Rectangle((int)(2 * _dpiFactor), (int)(3 * _dpiFactor), (int)(Width - 4 * _dpiFactor), Height / 2));
37 | for (int i = 0; i < 4; i++)
38 | {
39 | pen.Color = Color.FromArgb(pen.Color.A - 63, pen.Color);
40 |
41 | rect.Y += (int)(1 * _dpiFactor);
42 |
43 | DrawRoundedRectangle(g, rect, actualCornerRadius, pen, BackColor);
44 | }
45 |
46 | rect = new Rectangle((int)(1 * _dpiFactor), (int)(strSize.Height + actualDistTxtAndbox), (int)(Width - 2 * _dpiFactor), (int)(Height - strSize.Height - actualDistTxtAndbox));
47 |
48 | g.ResetClip();
49 | pen.Color = Color.FromArgb(210, 210, 210);
50 | DrawRoundedRectangle(g, rect, actualCornerRadius, pen, Color.Transparent);
51 |
52 | rect = Rectangle.Inflate(rect, (int) (-1*_dpiFactor), (int) (-1*_dpiFactor));
53 | pen.Color = Color.FromArgb(80, pen.Color);
54 | DrawRoundedRectangle(g,rect,actualCornerRadius,pen,Color.Transparent);
55 |
56 | g.SetClip(new Rectangle(0, Height - actualCornerRadius, Width, Height));
57 | pen.Color = Color.FromArgb(80, Color.White);
58 | DrawRoundedRectangle(g, new Rectangle(0, 0, Width, Height), actualCornerRadius, pen, Color.Transparent);
59 |
60 |
61 | }
62 |
63 |
64 |
65 | //base.OnPaint(e);
66 |
67 | }
68 |
69 | private void DrawRoundedRectangle(Graphics gfx, Rectangle Bounds, int CornerRadius, Pen DrawPen, Color FillColor)
70 | {
71 | int strokeOffset = Convert.ToInt32(Math.Ceiling(DrawPen.Width));
72 | Bounds = Rectangle.Inflate(Bounds, -strokeOffset, -strokeOffset);
73 |
74 | //DrawPen.EndCap = DrawPen.StartCap = LineCap.Round;
75 |
76 | using (var gfxPath = new GraphicsPath())
77 | {
78 | gfxPath.AddArc(Bounds.X, Bounds.Y, CornerRadius, CornerRadius, 180, 90);
79 | gfxPath.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y, CornerRadius, CornerRadius, 270, 90);
80 | gfxPath.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
81 | gfxPath.AddArc(Bounds.X, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
82 | gfxPath.CloseAllFigures();
83 |
84 |
85 | using (var sb = new SolidBrush(FillColor)) gfx.FillPath(sb, gfxPath);
86 | gfx.DrawPath(DrawPen, gfxPath);
87 | }
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/Controls/MetroButton.cs:
--------------------------------------------------------------------------------
1 | using System.Drawing;
2 | using System.Drawing.Imaging;
3 | using System.Windows.Forms;
4 |
5 | namespace WGestures.App.Gui.Windows.Controls
6 | {
7 | class MetroButton : LazyPaintButton
8 | {
9 | private static readonly Color normalBgColor = Color.FromArgb(240, 240, 240);
10 | private static readonly Color pressedBgColor = Color.FromArgb(220, 220, 220);
11 | private Color _bgColor = normalBgColor;
12 |
13 |
14 | protected override void OnMouseDown(MouseEventArgs mevent)
15 | {
16 | _bgColor = pressedBgColor;
17 | base.OnMouseDown(mevent);
18 | }
19 |
20 | protected override void OnMouseUp(MouseEventArgs mevent)
21 | {
22 | _bgColor = normalBgColor;
23 | base.OnMouseUp(mevent);
24 | }
25 |
26 | protected override void OnPaint(PaintEventArgs pevent)
27 | {
28 | var g = pevent.Graphics;
29 | g.SetClip(pevent.ClipRectangle);
30 |
31 |
32 | g.Clear(_bgColor);
33 | using (var b = new SolidBrush(Color.FromArgb(130, Color.White)))
34 | {
35 | g.FillRectangle(b, new Rectangle(0, 0, Width, Height / 2));
36 | }
37 |
38 | if (Image != null)
39 | {
40 | var limitW = Width * 0.8f;
41 | var limitH = Height * 0.8f;
42 |
43 | var scale = 1.0f;
44 | SizeF newSize = Image.Size;
45 |
46 |
47 | if (newSize.Width >= limitW)
48 | {
49 | scale = limitW / newSize.Width;
50 | newSize.Width = limitW;
51 | newSize.Height *= scale;
52 | }
53 |
54 | if (newSize.Height >= limitH)
55 | {
56 | scale = limitH / newSize.Height;
57 | newSize.Height = limitH;
58 | newSize.Width *= scale;
59 | }
60 |
61 | if (Enabled)
62 | {
63 | g.DrawImage(Image, (Width - newSize.Width) / 2, (Height - newSize.Height) / 2, newSize.Width, newSize.Height);
64 | }
65 | else
66 | {
67 | using (var attr = new ImageAttributes())
68 | {
69 | attr.SetGamma(0.2f);
70 |
71 | g.DrawImage(Image, new Rectangle(new Point((int) ((Width - newSize.Width) / 2),
72 | (int) ((Height - newSize.Height) / 2)),Size.Round(newSize)),
73 | 0,0,Image.Width,Image.Height,GraphicsUnit.Pixel,attr);
74 | }
75 |
76 | }
77 |
78 |
79 |
80 | }
81 |
82 | if (Text != null && Text.Length > 0)
83 | {
84 | var txtSize = g.MeasureString(Text, Font);
85 | using (var b = new SolidBrush(Enabled?ForeColor:Color.DarkGray))
86 | {
87 | g.DrawString(Text, Font, b, new Point((int)((Width - txtSize.Width) / 2), (int)((Height - txtSize.Height) / 2)));
88 | }
89 |
90 | }
91 |
92 | //g.DrawRectangle(Pens.WhiteSmoke,new Rectangle(1,1,Width-2,Height-2));
93 | if(Enabled) g.DrawRectangle(Pens.Gray, new Rectangle(0, 0, Width - 1, Height - 2));
94 | else g.DrawRectangle(Pens.DarkGray, new Rectangle(0, 0, Width - 1, Height - 2));
95 |
96 | g.DrawLine(Pens.White, 0, Height - 1, Width, Height - 1);
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/Controls/ReorderableListView/CancelListViewItemDragEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Windows.Forms;
3 |
4 | // Dragging items in a ListView control with visual insertion guides
5 | // http://www.cyotek.com/blog/dragging-items-in-a-listview-control-with-visual-insertion-guides
6 |
7 | namespace WGestures.App.Gui.Windows.Controls
8 | {
9 | ///
10 | /// Provides data for the event of the control.
11 | ///
12 | public class CancelListViewItemDragEventArgs : CancelEventArgs
13 | {
14 | #region Public Constructors
15 |
16 | ///
17 | /// Initializes a new instance of the class.
18 | ///
19 | /// The source the event data relates to.
20 | public CancelListViewItemDragEventArgs(ListViewItem item)
21 | {
22 | this.Item = item;
23 | }
24 |
25 | #endregion
26 |
27 | #region Protected Constructors
28 |
29 | ///
30 | /// Initializes a new instance of the class.
31 | ///
32 | protected CancelListViewItemDragEventArgs()
33 | { }
34 |
35 | #endregion
36 |
37 | #region Public Properties
38 |
39 | ///
40 | /// Gets the that is the source of the drag operation.
41 | ///
42 | /// The that initiated the drag operation.
43 | public ListViewItem Item { get; protected set; }
44 |
45 | #endregion
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/Controls/ReorderableListView/EventsListBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Text;
4 | using System.Windows.Forms;
5 |
6 | // Dragging items in a ListView control with visual insertion guides
7 | // http://www.cyotek.com/blog/dragging-items-in-a-listview-control-with-visual-insertion-guides
8 |
9 | namespace WGestures.App.Gui.Windows.Controls
10 | {
11 | internal class EventsListBox : ListBox
12 | {
13 | #region Public Members
14 |
15 | public void AddEvent(Control sender, string eventName)
16 | {
17 | this.AddEvent(sender, eventName, null);
18 | }
19 |
20 | public void AddEvent(Control sender, string eventName, EventArgs args)
21 | {
22 | StringBuilder eventData;
23 | PropertyInfo[] properties;
24 |
25 | eventData = new StringBuilder();
26 |
27 | eventData.Append(DateTime.Now.ToLongTimeString());
28 | eventData.Append("\t");
29 | eventData.Append(sender.Name);
30 | eventData.Append(".");
31 | eventData.Append(eventName);
32 | eventData.Append(" (");
33 |
34 | properties = args.GetType().GetProperties();
35 | for (int i = 0; i < properties.Length; i++)
36 | {
37 | PropertyInfo property;
38 | string value;
39 |
40 | property = properties[i];
41 |
42 | try
43 | {
44 | object rawValue;
45 |
46 | rawValue = property.GetValue(args, null);
47 |
48 | value = rawValue != null ? rawValue.ToString() : null;
49 | }
50 | catch
51 | {
52 | value = null;
53 | }
54 |
55 | eventData.AppendFormat("{0} = {1}", property.Name, value);
56 |
57 | if (i < properties.Length - 1)
58 | {
59 | eventData.Append(", ");
60 | }
61 | }
62 |
63 | eventData.Append(")");
64 |
65 | this.Items.Add(eventData.ToString());
66 | this.TopIndex = this.Items.Count - (this.ClientSize.Height / this.ItemHeight);
67 | }
68 |
69 | #endregion
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/Controls/ReorderableListView/InsertionMode.cs:
--------------------------------------------------------------------------------
1 | // Dragging items in a ListView control with visual insertion guides
2 | // http://www.cyotek.com/blog/dragging-items-in-a-listview-control-with-visual-insertion-guides
3 |
4 | namespace WGestures.App.Gui.Windows.Controls
5 | {
6 | ///
7 | /// Determines the insertion mode of a drag operation
8 | ///
9 | public enum InsertionMode
10 | {
11 | ///
12 | /// The source item will be inserted before the destination item
13 | ///
14 | Before,
15 |
16 | ///
17 | /// The source item will be inserted after the destination item
18 | ///
19 | After
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/Controls/ReorderableListView/ListViewItemDragEventArgs.cs:
--------------------------------------------------------------------------------
1 | // Dragging items in a ListView control with visual insertion guides
2 | // http://www.cyotek.com/blog/dragging-items-in-a-listview-control-with-visual-insertion-guides
3 | using System.Windows.Forms;
4 |
5 | namespace WGestures.App.Gui.Windows.Controls
6 | {
7 | ///
8 | /// Provides data for the event of the control.
9 | ///
10 | public class ListViewItemDragEventArgs : CancelListViewItemDragEventArgs
11 | {
12 | #region Public Constructors
13 |
14 | ///
15 | /// Initializes a new instance of the class.
16 | ///
17 | /// The that initiated the drag operation.
18 | /// The located at the mouse coordinates.
19 | /// The index of the the that is the target of the drag operation.
20 | /// The relation of the .
21 | /// The x-coordinate of a mouse click, in pixels.
22 | /// The y-coordinate of a mouse click, in pixels.
23 | public ListViewItemDragEventArgs(ListViewItem sourceItem, ListViewItem dropItem, int insertionIndex, InsertionMode insertionMode, int x, int y)
24 | : this()
25 | {
26 | this.Item = sourceItem;
27 | this.DropItem = dropItem;
28 | this.X = x;
29 | this.Y = y;
30 | this.InsertionIndex = insertionIndex;
31 | this.InsertionMode = insertionMode;
32 | }
33 |
34 | #endregion
35 |
36 | #region Protected Constructors
37 |
38 | ///
39 | /// Initializes a new instance of the class.
40 | ///
41 | protected ListViewItemDragEventArgs()
42 | { }
43 |
44 | #endregion
45 |
46 | #region Public Properties
47 |
48 | ///
49 | /// Gets the located at the and coordinates.
50 | ///
51 | /// The located at the mouse coordinates.
52 | public ListViewItem DropItem { get; protected set; }
53 |
54 | ///
55 | /// Gets the insertion index of the drag operation.
56 | ///
57 | /// The index of the the that is the target of the drag operation.
58 | public int InsertionIndex { get; protected set; }
59 |
60 | ///
61 | /// Gets the relation of the
62 | ///
63 | /// The relation of the .
64 | public InsertionMode InsertionMode { get; protected set; }
65 |
66 | ///
67 | /// Gets the x-coordinate of the mouse during the generating event.
68 | ///
69 | /// The x-coordinate of the mouse, in pixels.
70 | public int X { get; protected set; }
71 |
72 | ///
73 | /// Gets the y-coordinate of the mouse during the generating event.
74 | ///
75 | /// The y-coordinate of the mouse, in pixels.
76 | public int Y { get; protected set; }
77 |
78 | #endregion
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/ErrorForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Windows.Forms;
4 |
5 | namespace WGestures.App.Gui.Windows
6 | {
7 | public partial class ErrorForm : Form
8 | {
9 | public string ErrorText
10 | {
11 | get { return tb_Detail.Text; }
12 | set { tb_Detail.Text = GetProductInfo() + value; }
13 | }
14 |
15 | public ErrorForm()
16 | {
17 | InitializeComponent();
18 |
19 |
20 | /*tb_Detail.MouseEnter += (sender, args) =>
21 | {
22 | tb_Detail.Focus();
23 | tb_Detail.SelectAll();
24 | };
25 |
26 | tb_mail.MouseEnter += (sender, args) =>
27 | {
28 | tb_mail.Focus();
29 | tb_mail.SelectAll();
30 | };*/
31 | }
32 |
33 | private void btn_close_Click(object sender, System.EventArgs e)
34 | {
35 | Close();
36 | Environment.Exit(1);
37 | }
38 |
39 | private static string GetProductInfo()
40 | {
41 | return "WGestures Version:" +
42 | Application.ProductVersion + "\r\nOS:" +
43 | Environment.OSVersion + "\r\nAppPath:" +
44 | Application.ExecutablePath + "\r\n=======================\r\n";
45 | }
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/IconHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Drawing.Imaging;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using WGestures.App.Properties;
10 | using WGestures.Core;
11 |
12 | namespace WGestures.App.Gui.Windows
13 | {
14 | public static class IconHelper
15 | {
16 | public static Bitmap ExtractIconForPath(string path, Size size, bool enabled = true, int bias=2)
17 | {
18 | var bmp = new Bitmap(size.Width, size.Height);
19 |
20 | using (var g = Graphics.FromImage(bmp))
21 | {
22 | if (!File.Exists(path))
23 | {
24 | g.DrawImage(Resources.unknown, new Rectangle(bias, bias, bmp.Width - 2 * bias, bmp.Height - 2 * bias));
25 | }
26 | else
27 | {
28 | var icon = Icon.ExtractAssociatedIcon(path);
29 | g.DrawIcon(icon, new Rectangle(bias, bias, bmp.Width - 2 * bias, bmp.Height - 2 * bias));
30 | }
31 |
32 | if (enabled) return bmp;
33 | }
34 |
35 | //如果禁用了,则灰度处理
36 | using (bmp)
37 | {
38 | var grayed = MakeGrayscale3(bmp);
39 | using (var g = Graphics.FromImage(grayed))
40 | using (var forbidSymbol = Properties.Resources.forbidden)
41 | {
42 | var fordibSize = bmp.Width / 3;
43 | g.DrawImage(forbidSymbol, bmp.Width - fordibSize - bias, bmp.Height - fordibSize - bias, fordibSize, fordibSize);
44 | }
45 |
46 | return grayed;
47 | }
48 | }
49 |
50 | public static Bitmap MakeGrayscale3(Bitmap original)
51 | {
52 | //create a blank bitmap the same size as original
53 | Bitmap newBitmap = new Bitmap(original.Width, original.Height);
54 |
55 | //get a graphics object from the new image
56 | Graphics g = Graphics.FromImage(newBitmap);
57 |
58 | //create the grayscale ColorMatrix
59 | ColorMatrix colorMatrix = new ColorMatrix(
60 | new float[][] {
61 | new float[] {.3f, .3f, .3f, 0, 0},
62 | new float[] {.59f, .59f, .59f, 0, 0},
63 | new float[] {.11f, .11f, .11f, 0, 0},
64 | new float[] {0, 0, 0, 1, 0},
65 | new float[] {0, 0, 0, 0, 1}});
66 |
67 | //create some image attributes
68 | ImageAttributes attributes = new ImageAttributes();
69 |
70 | //set the color matrix attribute
71 | attributes.SetColorMatrix(colorMatrix);
72 |
73 | //draw the original image on the new image
74 | //using the grayscale color matrix
75 | g.DrawImage(original, new Rectangle(0, 0, original.Width, original.Height),
76 | 0, 0, original.Width, original.Height, GraphicsUnit.Pixel, attributes);
77 |
78 | //dispose the Graphics object
79 | g.Dispose();
80 | return newBitmap;
81 | }
82 |
83 | public static bool AppExists(this ExeApp app)
84 | {
85 | return File.Exists(app.ExecutablePath);
86 | }
87 |
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/SuspendDrawing.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Windows.Forms;
7 |
8 | namespace WGestures.App.Gui.Windows
9 | {
10 | internal static class SuspendDrawingControl
11 | {
12 | [DllImport("user32.dll")]
13 | static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
14 |
15 | private const int WM_SETREDRAW = 11;
16 |
17 | public static void SuspendDrawing(Control parent)
18 | {
19 | SendMessage(parent.Handle, WM_SETREDRAW, false, 0);
20 | }
21 |
22 | public static void ResumeDrawing(Control parent)
23 | {
24 | SendMessage(parent.Handle, WM_SETREDRAW, true, 0);
25 | parent.Refresh();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/WGestures.App/Gui/Windows/UpdateInfoForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Diagnostics;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using WGestures.Common.Product;
10 |
11 | namespace WGestures.App.Gui.Windows
12 | {
13 | public partial class UpdateInfoForm : Form
14 | {
15 | private string _gotoUrl;
16 |
17 | public UpdateInfoForm(string gotoUrl, VersionInfo versionInfo)
18 | {
19 | InitializeComponent();
20 |
21 | _gotoUrl = gotoUrl;
22 | lb_newVersion.Text = versionInfo.Version;
23 | tb_whatsNew.Text = versionInfo.WhatsNew;
24 |
25 | lb_currentVersion.Text = Application.ProductVersion;
26 | }
27 |
28 | private void btn_ok_Click(object sender, EventArgs e)
29 | {
30 | Close();
31 | }
32 |
33 | private void lnk_gotoUrl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
34 | {
35 | var startInfo = new ProcessStartInfo("explorer.exe", _gotoUrl);
36 | using (Process.Start(startInfo)) { } ;
37 |
38 | Close();
39 | }
40 |
41 | protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
42 | {
43 | if (Keys.W == (keyData & Keys.W) && Keys.Control == (keyData & Keys.Control))
44 | {
45 | Close();
46 |
47 | return true;
48 | }
49 |
50 | return base.ProcessCmdKey(ref msg, keyData);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/WGestures.App/Migrate/ConfigAndGestures.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using WGestures.Common.Config;
6 | using WGestures.Common.Config.Impl;
7 | using WGestures.Core.Persistence;
8 | using WGestures.Core.Persistence.Impl;
9 |
10 | namespace WGestures.App.Migrate
11 | {
12 | internal class ConfigAndGestures
13 | {
14 | public PlistConfig Config { get; private set; }
15 |
16 | public JsonGestureIntentStore GestureIntentStore { get; private set; }
17 |
18 | public ConfigAndGestures(PlistConfig config, JsonGestureIntentStore gestures)
19 | {
20 | Config = config;
21 | GestureIntentStore = gestures;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/WGestures.App/Migrate/MigrateException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WGestures.App.Migrate
7 | {
8 | internal class MigrateException : Exception
9 | {
10 | public MigrateException(string message, Exception innerException)
11 | : base(message, innerException)
12 | {
13 |
14 | }
15 |
16 | public MigrateException(string message): base(message)
17 | {
18 |
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/WGestures.App/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("WGestures")]
9 | [assembly: AssemblyDescription("WGestures 鼠标手势")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("YingDev.com")]
12 | [assembly: AssemblyProduct("WGestures")]
13 | [assembly: AssemblyCopyright("Copyright © 2014-2021")]
14 | [assembly: AssemblyTrademark("WGestures")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("90141283-4c50-4deb-80f4-75e5665f838f")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.8.5.0")]
36 | [assembly: AssemblyFileVersion("1.8.5.0")]
37 |
--------------------------------------------------------------------------------
/WGestures.App/Properties/DataSources/WGestures.App.Gui.Windows.SettingsFormController.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | WGestures.App.Gui.Windows.SettingsFormController, WGestures, Version=1.3.1.10, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/WGestures.App/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WGestures.App.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.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 |
--------------------------------------------------------------------------------
/WGestures.App/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/QuickStartGuideForm.Designer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WGestures.App.Gui.Windows
4 | {
5 | partial class QuickStartGuideForm
6 | {
7 | ///
8 | /// Required designer variable.
9 | ///
10 | private System.ComponentModel.IContainer components = null;
11 |
12 | ///
13 | /// Clean up any resources being used.
14 | ///
15 | /// true if managed resources should be disposed; otherwise, false.
16 | protected override void Dispose(bool disposing)
17 | {
18 | if (disposing && (components != null))
19 | {
20 | components.Dispose();
21 | }
22 | if (web_container != null)
23 | {
24 | web_container.Dispose();
25 | web_container = null;
26 | }
27 |
28 |
29 | base.Dispose(disposing);
30 | }
31 |
32 | #region Windows Form Designer generated code
33 |
34 | ///
35 | /// Required method for Designer support - do not modify
36 | /// the contents of this method with the code editor.
37 | ///
38 | private void InitializeComponent()
39 | {
40 | this.web_container = new System.Windows.Forms.WebBrowser();
41 | this.SuspendLayout();
42 | //
43 | // web_container
44 | //
45 | this.web_container.AllowNavigation = false;
46 | this.web_container.AllowWebBrowserDrop = false;
47 | this.web_container.Dock = System.Windows.Forms.DockStyle.Fill;
48 | this.web_container.IsWebBrowserContextMenuEnabled = false;
49 | this.web_container.Location = new System.Drawing.Point(0, 0);
50 | this.web_container.Margin = new System.Windows.Forms.Padding(0);
51 | this.web_container.MinimumSize = new System.Drawing.Size(13, 13);
52 | this.web_container.Name = "web_container";
53 | this.web_container.ScriptErrorsSuppressed = true;
54 | this.web_container.ScrollBarsEnabled = false;
55 | this.web_container.Size = new System.Drawing.Size(920, 496);
56 | this.web_container.TabIndex = 0;
57 | this.web_container.WebBrowserShortcutsEnabled = false;
58 | this.web_container.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.web_container_PreviewKeyDown);
59 | //
60 | // QuickStartGuideForm
61 | //
62 | this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
63 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
64 | this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
65 | this.BackColor = System.Drawing.Color.White;
66 | this.ClientSize = new System.Drawing.Size(920, 496);
67 | this.Controls.Add(this.web_container);
68 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
69 | this.KeyPreview = true;
70 | this.Margin = new System.Windows.Forms.Padding(2);
71 | this.MaximizeBox = false;
72 | this.MinimizeBox = false;
73 | this.Name = "QuickStartGuideForm";
74 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
75 | this.Text = "WGestures快速入门";
76 | this.Load += new System.EventHandler(this.QuickStartGuidForm_Load);
77 | this.MouseEnter += new System.EventHandler(this.QuickStartGuideForm_MouseEnter);
78 | this.ResumeLayout(false);
79 |
80 | }
81 |
82 | #endregion
83 |
84 | private System.Windows.Forms.WebBrowser web_container;
85 |
86 | }
87 | }
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/QuickStartGuideForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using System.Threading;
5 | using System.Windows.Forms;
6 | using WGestures.App.Properties;
7 | using WGestures.Common.OsSpecific.Windows;
8 |
9 | namespace WGestures.App.Gui.Windows
10 | {
11 | public partial class QuickStartGuideForm : Form
12 | {
13 | public QuickStartGuideForm()
14 | {
15 | try
16 | {
17 | InitializeComponent();
18 | }catch(Exception e)
19 | {
20 | //IGNORE
21 | Debug.WriteLine(e);
22 | }
23 |
24 | var dpiScale = Native.GetScreenDpi() / 96;
25 | ClientSize = new System.Drawing.Size(936 * dpiScale, 525 * dpiScale);
26 | Icon = Resources.icon;
27 |
28 | //TopMost = true;
29 |
30 | }
31 |
32 | private void QuickStartGuidForm_Load(object sender, EventArgs e)
33 | {
34 | web_container.Navigate(new Uri(
35 | string.Format(@"{0}\QuickStartGuide\index.html",
36 | Path.GetDirectoryName(Application.ExecutablePath))));
37 |
38 |
39 |
40 | Activate();
41 |
42 | }
43 |
44 |
45 | private void web_container_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
46 | {
47 | if(web_container.Document == null) return;
48 |
49 | if (e.KeyData == (Keys.Alt | Keys.Right) || e.KeyData == (Keys.Control | Keys.Tab))
50 | {
51 | web_container.Document.InvokeScript("performNext");
52 | }else if (e.KeyData == (Keys.Alt | Keys.Left) || e.KeyData == (Keys.Control | Keys.Tab | Keys.Shift))
53 | {
54 | web_container.Document.InvokeScript("performPrev");
55 | }else if (e.KeyData == (Keys.Control | Keys.W))
56 | {
57 | Close();
58 | }
59 |
60 | }
61 |
62 | protected override void OnClosed(EventArgs e)
63 | {
64 | web_container.PreviewKeyDown -= web_container_PreviewKeyDown;
65 |
66 | //web_container.Navigate("about:blank");
67 | while (web_container.IsBusy)
68 | {
69 | Thread.Sleep(100);
70 | //Console.WriteLine("buuuusy");
71 | }
72 |
73 | base.OnClosed(e);
74 | }
75 |
76 | private void QuickStartGuideForm_MouseEnter(object sender, EventArgs e)
77 | {
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/img/next-default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/QuickStartGuide/img/next-default.png
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/img/next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/QuickStartGuide/img/next.png
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/img/pagination.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/QuickStartGuide/img/pagination.png
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/img/pagination_.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/QuickStartGuide/img/pagination_.png
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/img/prev-default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/QuickStartGuide/img/prev-default.png
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/img/prev.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/QuickStartGuide/img/prev.png
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/slides/0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/QuickStartGuide/slides/0.png
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/slides/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/QuickStartGuide/slides/1.png
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/slides/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/QuickStartGuide/slides/2.png
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/slides/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/QuickStartGuide/slides/3.png
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/slides/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/QuickStartGuide/slides/4.png
--------------------------------------------------------------------------------
/WGestures.App/QuickStartGuide/slides/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/QuickStartGuide/slides/5.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/128.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/Alert.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/Alert.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/Edit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/Edit.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/add.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/alipay.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/alipay.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/block.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/block.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/checking.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/checking.gif
--------------------------------------------------------------------------------
/WGestures.App/Resources/cross.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/cross.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/cross_empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/cross_empty.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/dropTarget.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/dropTarget.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/forbidden.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/forbidden.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/help.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/help.jpg
--------------------------------------------------------------------------------
/WGestures.App/Resources/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/icon.ico
--------------------------------------------------------------------------------
/WGestures.App/Resources/icon_bw.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/icon_bw.ico
--------------------------------------------------------------------------------
/WGestures.App/Resources/info_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/info_icon.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/logo_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/logo_error.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/menuBtn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/menuBtn.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/menuBtn_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/menuBtn_down.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/menuBtnr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/menuBtnr.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/remove.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/remove.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/trayIcon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/trayIcon.ico
--------------------------------------------------------------------------------
/WGestures.App/Resources/trayIcon_bw.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/trayIcon_bw.ico
--------------------------------------------------------------------------------
/WGestures.App/Resources/triangle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/triangle.png
--------------------------------------------------------------------------------
/WGestures.App/Resources/unknown.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/Resources/unknown.png
--------------------------------------------------------------------------------
/WGestures.App/UpdateLog.txt:
--------------------------------------------------------------------------------
1 | 1.8.5.0 2022/1/1
2 | // 一年又一年,新年快乐!WGestures 2 已发布,WG1 将继续修复 BUG 并 优化性能
3 | * 使用与 WG2 相同的证书, 不再安装自签名根证书
4 | * 使用 .NET 4.8 框架 (较老的系统可能需要安装框架后才能使用)
5 | # 修正一些 UI 细节
6 |
7 | 1.8.4.0 2017/4/29
8 | # 修正 Windows 10 1703 Edge 兼容问题
9 | # 好久不见!劳动节快乐!
10 |
11 | 1.8.3.0 2016/2/24
12 | # 修正鼠标交换左右键情况下无法弹出菜单的问题
13 | # 修正托盘菜单显示暂停快捷键不同步问题
14 | # 避免意外失效
15 | + 为cmd增加预设的“标记”、“复制”和“粘贴”手势
16 | * 低调恢复隐藏图标功能(只通过 Shift+左键+中键)
17 |
18 | 1.8.2.0 2016/2/23
19 | # 修正空快捷键导致启动时崩溃问题
20 |
21 | 1.8.1.0 2016/2/23
22 | * Win键触发变为可选
23 |
24 | 1.8.0.0 2016/2/22
25 | + 增加 “摩擦边” 功能
26 | + 增加 X键 触发和修饰功能
27 | + 增加 Win键 触发功能
28 | + 自定义暂停快捷键(默认 Ctrl-Alt-Shift + W)
29 | + 按键序列延迟支持: {sleep 100} (毫秒)
30 | * 增加预设手势:缩放(↑▲/▼/●),切换虚拟桌面(x1→/←)
31 | * 更细腻的轨迹显示,手势执行时标签颜色匹配系统主题色
32 | * “命令行”自动提取首行注释(::/rem)为描述信息
33 | * 显示标签:修饰符置于手势名称之后
34 | # 修正当命令行代码包含注释符时不正常运行的问题
35 | - 删除“隐藏托盘图标”功能
36 | - 删除“左键+中键”暂停,避免与其他软件冲突
37 |
38 | 1.7.4.0 2016/2/13
39 | + 触发角支持执行命令行操作
40 | # 修正Win10上自启动后以低权限运行问题(表现为无法作用于“以管理员权限运行”的程序)
41 |
42 | 1.7.3.0 2015/12/27
43 | # 修正命令行“隐藏窗口”仍出现cmd窗口闪过
44 | # 修正Web搜索设置在某些系统上出错
45 |
46 | 1.7.2.0 2015/10/23
47 | + 增加窗口置顶操作
48 | + 增加2个预设手势: 窗口置顶(↑→↑), 强制退出(↓←◐)
49 | * “输出文本”改为“按键序列”, 比如 hello{enter}
50 | * Cmd支持相关的环境变量 (WG_PROCID, WG_WINID等), Lua加入Context对象
51 | * 更新的快速入门
52 | * 优化轨迹显示效果
53 | # 修正使用默认浏览器搜索被360阻止问题
54 | # 修正win7显示Web搜索设置报错
55 | # 修正添加ModernApp识别错误问题
56 | # 修正1.7.1引入的多屏轨迹未显示Bug
57 | # 修正添加/编辑手势错误地提示“已存在”问题
58 |
59 | 1.7.1.0 2015/10/15
60 | * Web搜索内置引擎使用https; 支持选择浏览器
61 | * 允许无聊人士画更长的轨迹 ( ^ω^)
62 | * 设置界面细节调整
63 | * 细粒度的音量调整
64 | * 性能优化
65 | # 修正一些小bug
66 |
67 | 1.7.0.0 2015/10/8
68 | + Lua脚本支持
69 | + 自定义触发角
70 | + 恢复默认手势
71 | * 触发角支持多显示器
72 | # 修正编辑手势保存按钮不可点击问题
73 | # 修正高dpi屏幕上设置界面显示问题
74 |
75 | 1.6.4.0 2015/6/7
76 | # 修正Web搜索可能无法打开浏览器
77 | # 图标隐藏提示信息修正
78 | * 如果已经在运行,再次运行将打开设置
79 |
80 | 1.6.3.0 2015/5/3
81 | # 修正手势无效时仍激活窗口问题
82 | # 修正exe路径大小写引起的识别错误
83 |
84 | 1.6.2.0 2015/5/1
85 | # 修正“总是作用于指针下方窗口”相关的bug
86 | # 修正在“全屏自动禁用”时,触发角在全屏下依然被触发的问题
87 |
88 | 1.6.1.0 2015/5/1
89 | + 增加选项"总是作用于指针下方窗口"
90 |
91 | 1.6.0 2015/3/8
92 | + 触发角
93 | + 增加 允许使用斜线 选项
94 | # 修正64位系统上可能无法正常工作问题
95 | # 修正应用程序安装在RamDisk的情况下获取进程信息错误的问题
96 |
97 | 1.5.2 2015/2/24
98 | # 修正导入1.4版本wgb文件错误(1.5.2.2)
99 | * 优化手势存储格式
100 | * 手势列表允许拖拽排序
101 | * 轨迹更平滑
102 | * 统一暂停/继续、托盘显示/隐藏控制方式
103 | # 修正多显示器路径显示问题
104 |
105 | 1.5.1 2015/2/22
106 | + 隐藏/显示托盘图标(左键+右键)
107 | + 手势名称支持显示执行状态反馈(目前 音量控制 能反馈音量+/-)
108 | # 修正添加/修改手势无法录入纯修饰键手势问题
109 |
110 | 1.5.0 2015/2/19 (春节快乐!)
111 | + 增加手势触发键选项(右键/中键/右+中)
112 | + 编辑手势
113 | * Win10兼容
114 | * 性能优化,降低内存占用
115 | * 启动速度提升
116 | # 修正长期以来的“右键点击卡死”Bug
117 |
118 | 1.4.1
119 | # 修正shift+delete删除不会强制删除的问题(以及相似问题)
120 | * 改善容错能力,减少在与其他软件冲突时崩溃的几率 并尽可能 恢复键盘状态
121 |
122 |
123 | 1.4.0 2014/9/22
124 | # 修正“起始超时”和“停留超时”冲突的问题
125 | # 修正偶然崩溃的问题
126 | # 修正禁用手势程序上,修饰键被拦截的问题(比如SublimeText上的右键+滚轮切换tab)
127 | + 支持中键手势
128 | + 支持 [左键+中键] 在任何地方暂停/继续WGestures(左手习惯用户为 右键+中键)
129 | + "继承全局手势"选项,允许应用程序不使用全局手势
130 | * 设置界面Tweak
131 | * 右键拖拽的准确性
132 |
133 | 1.3.1 2014/9/16
134 | # 修正被禁用手势的程序上“修饰键”被拦截的问题
135 | # 修正由于第三方库引起的可能使ALT键处于“按下”状态的问题(表现为点击桌面图标,显示“属性”)
136 | + 增加手势修饰键,并允许使用修饰键“立即执行”
137 | + 支持多显示器
138 | + 支持右键拖拽(起始超时)
139 | + “全屏模式禁用”选项
140 | + “执行命令行代码”支持“自动设置工作目录”(比如当前打开的文件夹)
141 | + 音量控制操作
142 | + 支持左手使用习惯
143 | + 导入/导出
144 | * 改善“禁用手势”应用程序上鼠标操作延迟的问题
145 | * 程序列表和手势列表允许拖拽排序
146 | * 设置界面改进
147 | * 改善与部分国产软件的兼容问题(搜狗浏览器等)
148 | * 优化响应速度
149 | * 安装程序简化
150 |
151 | 1.2.0.0 2014/7/7
152 | 新增: “执行命令行”和“输出文本”操作
153 | 修正: 解决UIPI限制,并支持Metro应用程序,支持Alt+Tab切换程序(默认手势:右下右)
154 | 修正: 使用注册表自启动,不再需要管理员权限
155 | 改进: 使用独立线程执行命令,提高性能减少崩溃卡顿
156 |
157 |
158 | 1.1.1.0 2014/6/27
159 | 修正: 某些情况下在迅雷上不能正常显示轨迹的问题; 提高优先级,减少了系统繁忙时手势卡顿的几率
160 |
161 | 1.1.0.0 2014/6/24
162 | 新增: 现在可以使用8个基本方向。预设↗最大化,↙最小化,↘显示桌面
163 |
164 | 1.0.0.1 2014/5/22
165 | 改进: 减少内存占用。以及其他小问题。
166 |
167 | 1.0.0.0 2014/5/20
168 | 第一个正式版。
169 |
170 |
171 |
--------------------------------------------------------------------------------
/WGestures.App/Warn360.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Windows.Forms;
4 | using WGestures.App.Properties;
5 |
6 | namespace WGestures.App
7 | {
8 | public partial class Warn360 : Form
9 | {
10 | public Warn360()
11 | {
12 | InitializeComponent();
13 | Icon = Resources.icon;
14 | }
15 |
16 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
17 | {
18 | Process.Start("http://tieba.baidu.com/p/3275239932");
19 | }
20 |
21 | private void Warn360_Load(object sender, EventArgs e)
22 | {
23 | tb_wgPath.Text = Application.ExecutablePath;
24 | Activate();
25 | }
26 |
27 | private void button1_Click(object sender, EventArgs e)
28 | {
29 | Close();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/WGestures.App/app.debug.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
42 |
--------------------------------------------------------------------------------
/WGestures.App/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
42 |
--------------------------------------------------------------------------------
/WGestures.App/defaults/config.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | $$FileVersion
6 | 1
7 | IsFirstRun
8 |
9 | AutoCheckForUpdate
10 |
11 | AutoStart
12 |
13 | PathTrackerTriggerButton
14 | 15
15 | PathTrackerStayTimeout
16 |
17 | PathTrackerInitialStayTimoutMillis
18 | 200
19 | GestureViewMainPathColor
20 | -14165512
21 | GestureViewMiddleBtnMainColor
22 | -13771520
23 | GestureViewAlternativePathColor
24 | -10061415
25 | GestureViewShowPath
26 |
27 | GestureViewFadeOut
28 |
29 | GestureViewShowCommandName
30 |
31 | TrayIconVisible
32 |
33 | GestureParserEnableHotCorners
34 |
35 | PathTrackerPreferCursorWindow
36 |
37 | GestureParserDisableInFullScreenMode
38 |
39 | PauseResumeHotKey
40 | VwAAAAcAAAA=
41 | PathTrackerInitialStayTimeout
42 |
43 | GestureViewXBtnPathColor
44 | -32704
45 | GestureParserEnableRubEdges
46 |
47 |
48 |
--------------------------------------------------------------------------------
/WGestures.App/externalResource/Icon/128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/externalResource/Icon/128.png
--------------------------------------------------------------------------------
/WGestures.App/externalResource/Icon/16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/externalResource/Icon/16.png
--------------------------------------------------------------------------------
/WGestures.App/externalResource/Icon/192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/externalResource/Icon/192.png
--------------------------------------------------------------------------------
/WGestures.App/externalResource/Icon/24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/externalResource/Icon/24.png
--------------------------------------------------------------------------------
/WGestures.App/externalResource/Icon/256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/externalResource/Icon/256.png
--------------------------------------------------------------------------------
/WGestures.App/externalResource/Icon/32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/externalResource/Icon/32.png
--------------------------------------------------------------------------------
/WGestures.App/externalResource/Icon/48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/externalResource/Icon/48.png
--------------------------------------------------------------------------------
/WGestures.App/externalResource/Icon/64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/externalResource/Icon/64.png
--------------------------------------------------------------------------------
/WGestures.App/externalResource/Icon/convertToIco.bat:
--------------------------------------------------------------------------------
1 | convert 128.png 24.png 192.png 32.png 48.png icon.ico
--------------------------------------------------------------------------------
/WGestures.App/externalResource/slides.ai:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.App/externalResource/slides.ai
--------------------------------------------------------------------------------
/WGestures.App/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/WGestures.Common/Annotation/NamedAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WGestures.Common.Annotation
7 | {
8 | ///
9 | /// 用于给一个类命名
10 | ///
11 | [AttributeUsage(AttributeTargets.Class)]
12 | public class NamedAttribute : Attribute
13 | {
14 | public string Name { get; set; }
15 |
16 | public NamedAttribute(string name)
17 | {
18 | Name = name;
19 | }
20 |
21 | public static string GetNameOf(Type t)
22 | {
23 | var attr = t.GetCustomAttributes(typeof (NamedAttribute), false).FirstOrDefault() as NamedAttribute;
24 | if (attr != null)
25 | {
26 | return attr.Name;
27 | }
28 |
29 | return t.Name;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/WGestures.Common/Config/AbstractDictConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 |
6 | namespace WGestures.Common.Config
7 | {
8 | public abstract class AbstractDictConfig : IConfig
9 | {
10 | private Dictionary _dict =
11 | new Dictionary();
12 | protected Dictionary Dict
13 | {
14 | get { return _dict; }
15 | set { _dict = value; }
16 | }
17 |
18 | public bool IsSet(string key)
19 | {
20 | return _dict.ContainsKey(key);
21 | }
22 |
23 | public T Get(string key)
24 | {
25 | object val;
26 | if (_dict.TryGetValue(key, out val))
27 | {
28 | return (T) val;
29 | }
30 |
31 | var t = Nullable.GetUnderlyingType(typeof(T));
32 | if (t != null)
33 | {
34 | return default(T);
35 | }
36 |
37 | throw new KeyNotFoundException(key);
38 | }
39 |
40 | public T Get(string key, T defaultValue)
41 | {
42 | try
43 | {
44 | return Get(key);
45 | }
46 | catch (KeyNotFoundException)
47 | {
48 |
49 | return defaultValue;
50 | }
51 |
52 | }
53 |
54 | public void Set(string key, T value)
55 | {
56 | _dict[key] = value;
57 | }
58 |
59 | public abstract void Save();
60 |
61 | public void Import(params IConfig[] from)
62 | {
63 | if (from == null || !@from.Any()) return;
64 |
65 | foreach (var config in from)
66 | {
67 | if(config == null) continue;
68 |
69 | foreach (var kv in config)
70 | {
71 | Set(kv.Key, kv.Value);
72 | }
73 | }
74 |
75 | }
76 |
77 | public IEnumerator> GetEnumerator()
78 | {
79 | return Dict.GetEnumerator();
80 | }
81 |
82 | IEnumerator IEnumerable.GetEnumerator()
83 | {
84 | return Dict.GetEnumerator();
85 | }
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/WGestures.Common/Config/IConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 |
5 | namespace WGestures.Common.Config
6 | {
7 | public interface IConfig : IEnumerable>
8 | {
9 | T Get(string key);
10 | T Get(string key, T defaultValue);
11 | void Set(string key, T value);
12 | void Save();
13 |
14 | void Import(params IConfig[] from);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/WGestures.Common/Config/Impl/PlistConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Windows.Forms.VisualStyles;
5 |
6 | namespace WGestures.Common.Config.Impl
7 | {
8 | public class PlistConfig : AbstractDictConfig
9 | {
10 | public string FileVersion
11 | {
12 | get { return Get("$$FileVersion", null); }
13 | set
14 | {
15 | Set("$$FileVersion",value);
16 | }
17 | }
18 |
19 | public string PlistPath { get; set; }
20 |
21 | ///
22 | /// 创建一个空的Config
23 | ///
24 | public PlistConfig(){}
25 |
26 | ///
27 | /// 创建并指定要加载或保存的plist文件位置
28 | ///
29 | /// Plist path.
30 | public PlistConfig(string plistPath)
31 | {
32 | PlistPath = plistPath;
33 | Load();
34 | }
35 |
36 | public PlistConfig(Stream stream, bool closeStream)
37 | {
38 | Load(stream,closeStream);
39 | }
40 |
41 | private void Load()
42 | {
43 | if (PlistPath == null)
44 | throw new InvalidOperationException("未指定需要加载的plist文件路径");
45 | if (!File.Exists(PlistPath))
46 | {
47 | return;
48 | }
49 | Dict = (Dictionary)Plist.readPlist(PlistPath);
50 | }
51 |
52 | private void Load(Stream stream, bool closeStream = false)
53 | {
54 | if(stream == null || !stream.CanRead) throw new ArgumentException("stream");
55 |
56 | try
57 | {
58 | Dict = (Dictionary)Plist.readPlist(stream, plistType.Auto);
59 | }
60 | catch (Exception)
61 | {
62 | if (closeStream && stream != null) stream.Close();
63 | throw;
64 | }
65 |
66 |
67 |
68 |
69 | }
70 |
71 | public override void Save()
72 | {
73 | if (PlistPath == null)
74 | throw new InvalidOperationException("未指定需要保存到的plist文件路径(PlistPath属性)");
75 | Plist.writeXml(Dict, PlistPath);
76 | }
77 |
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/WGestures.Common/DetailedDebugListener.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Diagnostics;
6 | using System.Threading;
7 |
8 | namespace WGestures.Common
9 | {
10 | public class DetailedConsoleListener : ConsoleTraceListener
11 | {
12 | public override void WriteLine(string message)
13 | {
14 | var mth = new StackTrace().GetFrame(2).GetMethod();
15 |
16 | this.Writer.WriteLine(">>" + mth.ReflectedType.Name +"[" + Thread.CurrentThread.ManagedThreadId +
17 | "] " + Thread.CurrentThread.Name);
18 |
19 | base.WriteLine(message);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/WGestures.Common/NumberUtil.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 |
7 | namespace WGestures.Common
8 | {
9 | [StructLayout(LayoutKind.Explicit)]
10 | public struct HiLoWord
11 | {
12 | [FieldOffset(0)]
13 | public uint Number;
14 |
15 | [FieldOffset(0)]
16 | public ushort Low;
17 |
18 | [FieldOffset(2)]
19 | public ushort High;
20 |
21 | public HiLoWord(uint number) : this()
22 | {
23 | Number = number;
24 | }
25 |
26 | public static implicit operator uint(HiLoWord val)
27 | {
28 | return val.Number;
29 | }
30 |
31 | public static implicit operator HiLoWord(uint val)
32 | {
33 | return new HiLoWord(val);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/WGestures.Common/OsSpecific/Windows/ClipboardMonitor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.CodeDom;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 | using System.Windows.Forms;
8 |
9 | namespace WGestures.Common.OsSpecific.Windows
10 | {
11 | public class ClipboardMonitor : NativeWindow
12 | {
13 | public ClipboardMonitor()
14 | {
15 | var cp = new CreateParams();
16 |
17 | CreateHandle(cp);
18 | }
19 |
20 | private bool _listenerAdded;
21 |
22 | public class ClipbardUpdatedEventArgs : EventArgs
23 | {
24 | public bool Handled { get; set; }
25 | }
26 |
27 | public event Action ClipboardUpdated;
28 | public event Action MonitorRegistered;
29 |
30 | protected virtual void OnMonitorRegistered()
31 | {
32 | var handler = MonitorRegistered;
33 | if (handler != null) handler();
34 | }
35 |
36 | protected virtual void OnClipboardUpdated(ClipbardUpdatedEventArgs args)
37 | {
38 | var handler = ClipboardUpdated;
39 | if (handler != null) handler(args);
40 | }
41 |
42 | public void StartMonitor()
43 | {
44 | var ok = AddClipboardFormatListener(this.Handle);
45 | if (!_listenerAdded && !ok) throw new Exception("未能注册剪贴板监听器");
46 |
47 | _listenerAdded = true;
48 | OnMonitorRegistered();
49 | }
50 |
51 | public void StopMonitor()
52 | {
53 | var ok = RemoveClipboardFormatListener(this.Handle);
54 | if (_listenerAdded && !ok) throw new Exception("未能移除剪贴板监听器");
55 |
56 | _listenerAdded = false;
57 |
58 | }
59 |
60 | protected override void WndProc(ref Message m)
61 | {
62 | switch (m.Msg)
63 | {
64 | case WM_CLIPBOARDUPDATE:
65 | var args = new ClipbardUpdatedEventArgs();
66 | OnClipboardUpdated(args);
67 | if (args.Handled) m.Result = IntPtr.Zero;
68 | return;
69 | case WM_DESTROY:
70 | #if DEBUG
71 | Console.WriteLine("ClipboardMonitor: WM_DESTROY");
72 | #endif
73 | StopMonitor();
74 | break;
75 | case WM_CLOSE:
76 | #if DEBUG
77 | Console.WriteLine("ClipboardMonitor: WM_CLOSE");
78 | #endif
79 | StopMonitor();
80 | break;
81 | }
82 |
83 | base.WndProc(ref m);
84 | }
85 |
86 |
87 | private const int WM_CLIPBOARDUPDATE = 0x031D;
88 | private const int WM_DESTROY = 0x0002;
89 | private const int WM_CLOSE = 0x0010;
90 |
91 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
92 | static extern bool AddClipboardFormatListener(IntPtr hwnd);
93 |
94 | [DllImport("User32.dll", CharSet = CharSet.Auto)]
95 | static extern bool RemoveClipboardFormatListener(IntPtr hwnd);
96 |
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/WGestures.Common/OsSpecific/Windows/GlobalKeyboardHook.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WGestures.Common/OsSpecific/Windows/GlobalKeyboardHook.cs
--------------------------------------------------------------------------------
/WGestures.Common/OsSpecific/Windows/Win32/Kernel32Desktop.cs:
--------------------------------------------------------------------------------
1 |
2 | //This file contains the Win32 API that are specific to the desktop Windows.
3 |
4 | //Created by Warren Tang on 8/28/2008
5 |
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Linq;
9 | using System.Text;
10 |
11 | using System.Runtime.InteropServices;
12 |
13 | namespace Win32
14 | {
15 | public partial class Kernel32
16 | {
17 |
18 |
19 | #region Time
20 |
21 | ///
22 | /// Equal to Environment.TickCount which is in milliseconds though.
23 | ///
24 | ///
25 | [DllImport(Kernel32Dll)]
26 | public static extern uint GetTickCount();
27 |
28 | [DllImport(Kernel32Dll, SetLastError = true)]
29 | public static extern bool GetSystemTimes(
30 | out System.Runtime.InteropServices.ComTypes.FILETIME lpIdleTime,
31 | out System.Runtime.InteropServices.ComTypes.FILETIME lpKernelTime,
32 | out System.Runtime.InteropServices.ComTypes.FILETIME lpUserTime
33 | );
34 |
35 |
36 | ///
37 | /// Get system idle time in milliseconds.(Wrapper)
38 | ///
39 | /// System idle time in milliseconds
40 | public static int GetIdleTime()
41 | {
42 |
43 | System.Runtime.InteropServices.ComTypes.FILETIME idleTime, kernelTime, userTime;
44 | GetSystemTimes(out idleTime, out kernelTime, out userTime);
45 | ulong idleTimeLong = ((ulong)idleTime.dwHighDateTime << 32) + (uint)idleTime.dwLowDateTime;
46 | return (int)(idleTimeLong / TimeSpan.TicksPerMillisecond);
47 | }
48 |
49 | ///
50 | /// Get system kernel time in milliseconds.(Wrapper)
51 | ///
52 | /// System kernel time in milliseconds.
53 | public static int GetKernelTime()
54 | {
55 |
56 | System.Runtime.InteropServices.ComTypes.FILETIME idleTime, kernelTime, userTime;
57 | GetSystemTimes(out idleTime, out kernelTime, out userTime);
58 | ulong kernelTimeLong = ((ulong)kernelTime.dwHighDateTime << 32) + (uint)kernelTime.dwLowDateTime;
59 | return (int)(kernelTimeLong / TimeSpan.TicksPerMillisecond);
60 | }
61 |
62 | ///
63 | /// Get system user time in milliseconds.(Wrapper)
64 | ///
65 | /// System user time in milliseconds.
66 | public static int GetUserTime()
67 | {
68 | System.Runtime.InteropServices.ComTypes.FILETIME idleTime, kernelTime, userTime;
69 | GetSystemTimes(out idleTime, out kernelTime, out userTime);
70 | ulong userTimeLong = ((ulong)userTime.dwHighDateTime << 32) + (uint)userTime.dwLowDateTime;
71 | return (int)(userTimeLong / TimeSpan.TicksPerMillisecond);
72 | }
73 | #endregion
74 |
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/WGestures.Common/Product/VersionInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WGestures.Common.Product
7 | {
8 | public class VersionInfo
9 | {
10 | public string Version { get; set; }
11 |
12 | public string WhatsNew { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/WGestures.Common/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("WGestures.Common")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WGestures.Common")]
13 | [assembly: AssemblyCopyright("Copyright © 2014-2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("4d5d48c7-351c-47e6-b6b2-7b11fa664af3")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.8.3.0")]
36 | [assembly: AssemblyFileVersion("1.8.3.0")]
37 |
--------------------------------------------------------------------------------
/WGestures.Common/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/WGestures.Core/Commands/AbstractCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using WGestures.Common.Annotation;
4 | using WGestures.Core.Annotations;
5 |
6 | namespace WGestures.Core.Commands
7 | {
8 | [Serializable]
9 | public abstract class AbstractCommand
10 | {
11 | public abstract void Execute();
12 |
13 | public virtual string Description()
14 | {
15 | return NamedAttribute.GetNameOf(this.GetType());
16 | }
17 |
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/WGestures.Core/Commands/IGestureContextAware.cs:
--------------------------------------------------------------------------------
1 | namespace WGestures.Core.Commands
2 | {
3 | internal interface IGestureContextAware
4 | {
5 | GestureContext Context { set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/WGestures.Core/Commands/IGestureModifiersAware.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WGestures.Core.Commands
7 | {
8 | ///
9 | /// 实现此接口的命令将可实现多步执行(一旦触发,便可“接管”特定的Modifier改变事件)
10 | /// 此接口可行的原因包括:
11 | /// *PathTracker允许指定不hook的Modifier
12 | /// *实现该接口的命令不会被中断(只能被end)
13 | /// *没有被禁止hook的Modifier通过ModifierTriggered方法告知目标命令
14 | ///
15 | public interface IGestureModifiersAware
16 | {
17 | ///
18 | /// 当手势被识别,且首次执行
19 | ///
20 | /// 表明感兴趣的修饰符事件,GestureModifier是一个Flags枚举
21 | void GestureRecognized(out GestureModifier observeModifiers);
22 |
23 | ///
24 | /// 当感兴趣的修饰符发生改变(比如滚轮上滚)
25 | ///
26 | /// 发生的修饰符事件
27 | void ModifierTriggered(GestureModifier modifier);
28 | void GestureEnded();
29 |
30 | event Action ReportStatus;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/WGestures.Core/Commands/IGestureParserAware.cs:
--------------------------------------------------------------------------------
1 | namespace WGestures.Core.Commands
2 | {
3 | internal interface IGestureParserAware
4 | {
5 | GestureParser Parser { set; }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/WGestures.Core/Commands/INeedInit.cs:
--------------------------------------------------------------------------------
1 | namespace WGestures.Core.Commands
2 | {
3 | interface INeedInit
4 | {
5 | void Init();
6 | bool IsInitialized { get; }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/WGestures.Core/Commands/Impl/ChangeAudioVolumeCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using WindowsInput;
3 | using WindowsInput.Native;
4 | using WGestures.Common.Annotation;
5 | using WGestures.Common.OsSpecific.Windows;
6 |
7 | namespace WGestures.Core.Commands.Impl
8 | {
9 | [Named("音量控制"),Serializable]
10 | public class ChangeAudioVolumeCommand : AbstractCommand, IGestureModifiersAware
11 | {
12 | public int Delta { get; set; } = 1;
13 |
14 | public override void Execute()
15 | {
16 | try
17 | {
18 | Sim.KeyPress(VirtualKeyCode.VOLUME_MUTE);
19 |
20 | }
21 | catch (Exception)
22 | {
23 | Native.TryResetKeys(new[] { VirtualKeyCode.VOLUME_MUTE });
24 | }
25 | }
26 |
27 | public void GestureRecognized(out GestureModifier observeModifiers)
28 | {
29 | try
30 | {
31 | Sim.KeyPress(VirtualKeyCode.VOLUME_UP);
32 | Sim.KeyPress(VirtualKeyCode.VOLUME_DOWN);
33 | }
34 | catch (Exception)
35 | {
36 |
37 | Native.TryResetKeys(new[] { VirtualKeyCode.VOLUME_UP, VirtualKeyCode.VOLUME_DOWN });
38 | }
39 |
40 |
41 | observeModifiers = GestureModifier.Scroll | GestureModifier.MiddleButtonDown;
42 | }
43 |
44 | public void ModifierTriggered(GestureModifier modifier)
45 | {
46 | if (Delta < 1) Delta = 1;
47 | try
48 | {
49 | switch (modifier)
50 | {
51 | case GestureModifier.WheelForward:
52 | ReportStatus("+");
53 | Delta.Times(() => Sim.KeyPress(VirtualKeyCode.VOLUME_UP));
54 | break;
55 | case GestureModifier.WheelBackward:
56 | ReportStatus("-");
57 | Delta.Times(() => Sim.KeyPress(VirtualKeyCode.VOLUME_DOWN));
58 | break;
59 | case GestureModifier.MiddleButtonDown:
60 | ReportStatus("x");
61 | Sim.KeyPress(VirtualKeyCode.VOLUME_MUTE);
62 | break;
63 |
64 | }
65 | }
66 | catch (Exception)
67 | {
68 | Native.TryResetKeys(new[] { VirtualKeyCode.VOLUME_UP, VirtualKeyCode.VOLUME_DOWN, VirtualKeyCode.VOLUME_MUTE });
69 | }
70 |
71 | }
72 |
73 | public void GestureEnded()
74 | {
75 | //do nothing
76 |
77 | GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
78 | }
79 |
80 | public event Action ReportStatus;
81 | }
82 |
83 | static class IntExtension
84 | {
85 | public static void Times(this int n, Action act)
86 | {
87 | if (n <= 0) return;
88 |
89 | for (var i = 0; i < n; i++)
90 | {
91 | act();
92 | }
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/WGestures.Core/Commands/Impl/DoNothingCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using WGestures.Common.Annotation;
6 |
7 | namespace WGestures.Core.Commands.Impl
8 | {
9 | [Named("(什么也不做)"), Serializable]
10 | public class DoNothingCommand : AbstractCommand
11 | {
12 | public override void Execute()
13 | {
14 | //啥也不做~
15 | }
16 |
17 | public override string Description()
18 | {
19 | return "";
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/WGestures.Core/Commands/Impl/GotoUrlCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using WGestures.Common.Annotation;
7 |
8 | namespace WGestures.Core.Commands.Impl
9 | {
10 | [Named("打开网址"), Serializable]
11 | public class GotoUrlCommand : AbstractCommand
12 | {
13 | private string _url;
14 |
15 | public string Url
16 | {
17 | get { return _url; }
18 | set
19 | {
20 | _url = value;
21 | }
22 | }
23 |
24 | public GotoUrlCommand()
25 | {
26 | Url = "";
27 | }
28 |
29 | public override void Execute()
30 | {
31 | if (Url != null)
32 | {
33 | if (!Url.Contains("://"))
34 | {
35 | Url = "http://" + Url;
36 | }
37 | }
38 | using(Process.Start(Url));
39 |
40 | GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/WGestures.Core/Commands/Impl/OpenFileCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using WGestures.Common.Annotation;
5 |
6 | namespace WGestures.Core.Commands.Impl
7 | {
8 | [Named("打开文件或应用程序"), Serializable]
9 | public class OpenFileCommand : Commands.AbstractCommand
10 | {
11 | private string _filePath;
12 |
13 | public string FilePath
14 | {
15 | get { return _filePath; }
16 | set
17 | {
18 | _filePath = value;
19 | }
20 | }
21 |
22 | public OpenFileCommand()
23 | {
24 | FilePath = "";
25 | }
26 |
27 | public override void Execute()
28 | {
29 | var info = new ProcessStartInfo(FilePath);
30 | info.UseShellExecute = true;
31 |
32 | var p = Process.Start(info);
33 | if(p != null) p.Close();
34 | }
35 |
36 | public override string Description()
37 | {
38 | if (File.Exists(FilePath))
39 | {
40 | return "打开 "+Path.GetFileName(FilePath);
41 | }
42 |
43 | return "";
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/WGestures.Core/Commands/Impl/PauseWGesturesCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using WGestures.Common.Annotation;
6 |
7 | namespace WGestures.Core.Commands.Impl
8 | {
9 | [Named("暂停WGestures"), Serializable]
10 | public class PauseWGesturesCommand : AbstractCommand,IGestureParserAware
11 | {
12 | public override void Execute()
13 | {
14 | Parser.Pause();
15 | }
16 |
17 | public GestureParser Parser { set; private get; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/WGestures.Core/Commands/Impl/SearchBox.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 |
3 | namespace WGestures.Core.Commands.Impl
4 | {
5 | public partial class SearchBox : Form
6 | {
7 | protected override CreateParams CreateParams
8 | {
9 | get
10 | {
11 | const int CS_DROPSHADOW = 0x20000;
12 | CreateParams cp = base.CreateParams;
13 | cp.ClassStyle |= CS_DROPSHADOW;
14 | return cp;
15 | }
16 | }
17 |
18 | public SearchBox()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | private void SearchBox_Shown(object sender, System.EventArgs e)
24 | {
25 | Activate();
26 | }
27 |
28 | public void SetSearchText(string txt)
29 | {
30 | txt_content.Text = txt;
31 | txt_content.SelectAll();
32 | }
33 |
34 | private void SearchBox_Deactivate(object sender, System.EventArgs e)
35 | {
36 | Close();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/WGestures.Core/Commands/Impl/SendTextCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading;
7 | using WindowsInput;
8 | using WGestures.Common.Annotation;
9 | using WGestures.Common.OsSpecific.Windows;
10 | using Win32;
11 | using System.Windows.Forms;
12 | using System.Text.RegularExpressions;
13 |
14 | namespace WGestures.Core.Commands.Impl
15 | {
16 | [Named("按键序列"), Serializable]
17 | public class SendTextCommand : AbstractCommand
18 | {
19 | public string Text { get; set; }
20 |
21 | public override void Execute()
22 | {
23 | if (!string.IsNullOrEmpty(Text))
24 | {
25 | var lines = new Regex(@"({(?i)sleep(?-i) *[0-9]*})").Split(Text);
26 | var timeExtract = new Regex("{(?i)sleep(?-i) *([0-9]*)}");
27 |
28 | foreach(var l in lines)
29 | {
30 | var match = timeExtract.Match(l);
31 | if (match.Success)
32 | {
33 | int delayMs;
34 | if(int.TryParse(match.Groups[1].Value, out delayMs))
35 | {
36 | Thread.Sleep(delayMs);
37 | continue;
38 | }
39 | }
40 |
41 | SendKeys.SendWait(l);
42 | }
43 |
44 | }
45 |
46 | GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/WGestures.Core/Commands/Impl/Sim.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using WindowsInput;
6 | using WindowsInput.Native;
7 |
8 | namespace WGestures.Core.Commands.Impl
9 | {
10 | static internal class Sim
11 | {
12 | public static InputSimulator Simulator = new InputSimulator() { ExtraInfo = new IntPtr(19900620) };
13 |
14 | public static void KeyDown(VirtualKeyCode k)
15 | {
16 | Simulator.Keyboard.KeyDown(k);
17 | }
18 |
19 | public static void KeyUp(VirtualKeyCode k)
20 | {
21 | Simulator.Keyboard.KeyUp(k);
22 | }
23 |
24 | public static void KeyPress(VirtualKeyCode k)
25 | {
26 | Simulator.Keyboard.KeyPress(k);
27 | }
28 |
29 | public static void TextEntry(string s)
30 | {
31 | Simulator.Keyboard.TextEntry(s);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/WGestures.Core/Commands/Impl/TaskSwitcherCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Diagnostics;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading;
8 | using System.Windows.Forms;
9 | using WindowsInput;
10 | using WindowsInput.Native;
11 | using WGestures.Common.Annotation;
12 | using WGestures.Common.OsSpecific.Windows;
13 | using Win32;
14 |
15 | namespace WGestures.Core.Commands.Impl
16 | {
17 | [Named("任务切换"), Serializable]
18 | public class TaskSwitcherCommand : AbstractCommand, IGestureModifiersAware
19 | {
20 |
21 | public override void Execute()
22 | {
23 |
24 | try
25 | {
26 | Sim.KeyDown(VirtualKeyCode.LMENU);
27 |
28 | //Thread.Sleep(50);
29 | Sim.KeyDown(VirtualKeyCode.TAB);
30 |
31 | //如果不延迟,foxitreader等ctrl+C可能失效!
32 | Thread.Sleep(20);
33 |
34 | Sim.KeyUp(VirtualKeyCode.TAB);
35 |
36 | Sim.KeyUp(VirtualKeyCode.LMENU);
37 | }
38 | catch (Exception ex)
39 | {
40 | Debug.WriteLine("发送alt + tab失败: " + ex);
41 | TryRecoverAltTab();
42 | #if TEST
43 | throw;
44 | #endif
45 | }
46 |
47 | GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
48 |
49 | }
50 |
51 |
52 | public void GestureRecognized(out GestureModifier observeModifiers)
53 | {
54 | //直接交由系统的任务切换机制处理,不需要订阅任何事件
55 | observeModifiers = GestureModifier.None;
56 |
57 | try
58 | {
59 | Sim.KeyDown(VirtualKeyCode.LMENU);
60 | Sim.KeyPress(VirtualKeyCode.TAB);
61 |
62 |
63 | }
64 | catch (Exception ex)
65 | {
66 | Debug.WriteLine("发送按键失败: " + ex);
67 | TryRecoverAltTab();
68 | }
69 |
70 |
71 | }
72 |
73 | public void ModifierTriggered(GestureModifier modifier)
74 | {
75 |
76 | }
77 |
78 | public void GestureEnded()
79 | {
80 | try
81 | {
82 | Sim.KeyUp(VirtualKeyCode.LMENU);
83 |
84 | }
85 | catch (Exception ex)
86 | {
87 | Debug.WriteLine("发送按键失败: "+ex);
88 | TryRecoverAltTab();
89 | }
90 | }
91 |
92 | public event Action ReportStatus;
93 |
94 | private void TryRecoverAltTab()
95 | {
96 | Debug.WriteLine("尝试恢复Alt Tab的状态...");
97 | Native.TryResetKeys(new []{VirtualKeyCode.LMENU, VirtualKeyCode.TAB });
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/WGestures.Core/Gesture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WGestures.Core
7 | {
8 |
9 | ///
10 | /// 表示一个手势实例
11 | ///
12 | [Serializable]
13 | public class Gesture
14 | {
15 | private static readonly char[] dirs = { '↑', '↗', '→', '↘', '↓', '↙', '←', '↖' };
16 |
17 | public GestureTriggerButton GestureButton { get; set; }
18 |
19 | public List Dirs { get; set; }
20 | public GestureModifier Modifier { get; set; }
21 |
22 |
23 | public Gesture(GestureTriggerButton gestureBtn = GestureTriggerButton.Right, int defaultCapacity=16)
24 | {
25 | GestureButton = gestureBtn;
26 | Dirs = new List(defaultCapacity);
27 | Modifier = GestureModifier.None;
28 | }
29 |
30 | public void Add(params GestureDir[] newDirs)
31 | {
32 | foreach (var d in newDirs)
33 | {
34 | Dirs.Add(d);
35 | }
36 | }
37 |
38 | public int Count()
39 | {
40 | return Dirs.Count;
41 | }
42 |
43 | internal GestureDir? Last()
44 | {
45 | return Dirs.Count == 0 ? (GestureDir?)null : Dirs.Last();
46 | }
47 |
48 | public override string ToString()
49 | {
50 | var sb = new StringBuilder(Count() + 4);
51 |
52 | sb.Append(GestureButton.ToMnemonic());
53 |
54 | foreach (var d in Dirs)
55 | {
56 | sb.Append(dirs[(byte)d]);
57 | }
58 |
59 | sb.Append(Modifier.ToMnemonic());
60 |
61 |
62 | return sb.ToString();
63 |
64 | }
65 |
66 | public override int GetHashCode()
67 | {
68 | var hash = 19;
69 | hash += hash*31 + GestureButton.GetHashCode();
70 | foreach (var d in Dirs)
71 | {
72 | hash = hash * 31 + (int)d;
73 | }
74 | hash = hash * 31 + (int)Modifier;
75 |
76 |
77 | return hash;
78 | }
79 |
80 | public override bool Equals(object obj)
81 | {
82 |
83 | var o = obj as Gesture;
84 | return o != null &&
85 | o.GestureButton == GestureButton &&
86 | Dirs.SequenceEqual(o.Dirs) && Modifier == o.Modifier;
87 | }
88 |
89 |
90 |
91 | public enum GestureDir
92 | {
93 | Up = 0, RightUp, Right, RightDown, Down, LeftDown, Left, LeftUp
94 | }
95 |
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/WGestures.Core/GestureButton.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WGestures.Core
7 | {
8 | [Flags]
9 | public enum GestureTriggerButton
10 | {
11 | None =0, Right = 1, Middle = 2, X1 = 4, X2 = 8,
12 | X = X1 | X2
13 | }
14 |
15 | public static class GestureTriggerButtonExtension
16 | {
17 | public static string ToMnemonic(this GestureTriggerButton gestureBtn)
18 | {
19 | switch (gestureBtn)
20 | {
21 | case GestureTriggerButton.Middle:
22 | return "●";
23 | case GestureTriggerButton.Right:
24 | return "◑";
25 | case GestureTriggerButton.X1:
26 | return "X1";
27 | case GestureTriggerButton.X2:
28 | return "X2";
29 |
30 | default:
31 | return string.Empty;
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/WGestures.Core/GestureContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 |
4 | namespace WGestures.Core
5 | {
6 | public abstract class GestureContext// : MarshalByRefObject
7 | {
8 | public Point StartPoint;
9 | public Point EndPoint;
10 |
11 | public uint ProcId;
12 | public IntPtr WinId;
13 |
14 | public GestureTriggerButton GestureButton;
15 |
16 | public abstract void ActivateTargetWindow();
17 |
18 | }
19 | }
--------------------------------------------------------------------------------
/WGestures.Core/GestureIntent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using WGestures.Common.OsSpecific.Windows;
4 | using WGestures.Core.Commands;
5 |
6 | namespace WGestures.Core
7 | {
8 | ///
9 | /// Gesture + Command + Context
10 | ///
11 | [Serializable]
12 | public class GestureIntent
13 | {
14 | public class ExecutionResult
15 | {
16 | public Exception Exception { get; private set; }
17 | public bool IsOk { get; private set; }
18 |
19 | public ExecutionResult(Exception e, bool isOk)
20 | {
21 | this.Exception = e;
22 | this.IsOk = isOk;
23 | }
24 | }
25 |
26 | public Gesture Gesture { get; set; }
27 | public AbstractCommand Command { get; set; }
28 |
29 | public bool ExecuteOnModifier { get; set; }
30 |
31 | public bool CanExecuteOnModifier()
32 | {
33 | return Gesture.Modifier != GestureModifier.None && ExecuteOnModifier;
34 | }
35 |
36 |
37 | public string Name { get; set; }
38 |
39 | public ExecutionResult Execute(GestureContext context, GestureParser gestureParser)
40 | {
41 | //Aware接口依赖注入
42 | var contextAware = Command as IGestureContextAware;
43 | if (contextAware != null) contextAware.Context = context;
44 |
45 | var parserAware = this.Command as IGestureParserAware;
46 | if (parserAware != null) parserAware.Parser = gestureParser;
47 |
48 | var shouldInit = this.Command as INeedInit;
49 | if (shouldInit != null && !shouldInit.IsInitialized)
50 | {
51 | shouldInit.Init();
52 | }
53 |
54 | //在独立线程中运行
55 | //new Thread似乎反应快一点,ThreadPool似乎有延迟
56 | //ThreadPool.QueueUserWorkItem((s) =>
57 | //new Thread(() =>
58 | {
59 | try
60 | {
61 | context.ActivateTargetWindow();
62 | Command.Execute();
63 | using (var proc = Process.GetCurrentProcess())
64 | {
65 | Native.SetProcessWorkingSetSize(proc.Handle, -1, -1);
66 | }
67 | }
68 | catch (Exception)
69 | {
70 | //ignore errors for now
71 | #if DEBUG
72 | throw;
73 | #endif
74 | }
75 | }//) { IsBackground = false}.Start();
76 |
77 | return new ExecutionResult(null, true);
78 |
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/WGestures.Core/GestureModifier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace WGestures.Core
7 | {
8 |
9 | [Flags]
10 | public enum GestureModifier
11 | {
12 | None = 0,
13 | WheelForward = 1,
14 | WheelBackward = 2,
15 | MiddleButtonDown = 4,
16 | LeftButtonDown = 8,
17 | RightButtonDown = 16,
18 | X1 = 32,
19 | X2 = 64,
20 |
21 | Scroll = WheelBackward | WheelForward,
22 | All = WheelForward | WheelBackward | MiddleButtonDown | LeftButtonDown | RightButtonDown
23 | }
24 |
25 | public static class GestureModifierHelper
26 | {
27 | public static string ToMnemonic(this GestureModifier modifier)
28 | {
29 | switch (modifier)
30 | {
31 | case GestureModifier.WheelForward:
32 | return "▲";
33 | case GestureModifier.WheelBackward:
34 | return "▼";
35 | case GestureModifier.MiddleButtonDown:
36 | return "●";
37 | case GestureModifier.LeftButtonDown:
38 | return "◐";
39 | case GestureModifier.RightButtonDown:
40 | return "◑";
41 | case GestureModifier.X1:
42 | return "X1";
43 | case GestureModifier.X2:
44 | return "X2";
45 | default:
46 |
47 | return String.Empty;
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/WGestures.Core/IGestureIntentFinder.cs:
--------------------------------------------------------------------------------
1 |
2 | using WGestures.Core.Persistence;
3 |
4 | namespace WGestures.Core
5 | {
6 | public interface IGestureIntentFinder
7 | {
8 | /*bool IntentExists(Gesture gesture, GestureContext context);
9 | GestureIntent GetIntent();*/
10 |
11 | bool IsGesturingEnabledForContext(GestureContext context, out ExeApp app);
12 |
13 | GestureIntent Find(Gesture gesture, GestureContext context);
14 | GestureIntent Find(Gesture gesture, ExeApp inApp);
15 |
16 | IGestureIntentStore IntentStore { get; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/WGestures.Core/IPathTracker.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.IO;
4 |
5 | namespace WGestures.Core
6 | {
7 | public class PathEventArgs : EventArgs
8 | {
9 | public Point Location{get; set;}
10 | public GestureTriggerButton Button;
11 | public GestureModifier Modifier { get; set; }
12 | public GestureContext Context { get; set; }
13 |
14 | public PathEventArgs(Point location, GestureContext context)
15 | {
16 | Location = location;
17 | Context = context;
18 | }
19 |
20 | public PathEventArgs()
21 | {
22 |
23 | }
24 | }
25 |
26 | public class BeforePathStartEventArgs
27 | {
28 | public PathEventArgs PathEventArgs { get; private set; }
29 | public bool ShouldPathStart { get; set; }
30 | public GestureContext Context { get; private set; }
31 |
32 | public BeforePathStartEventArgs(PathEventArgs pathEventArgs)
33 | {
34 | PathEventArgs = pathEventArgs;
35 | Context = pathEventArgs.Context;
36 | ShouldPathStart = true;
37 | }
38 | }
39 |
40 |
41 | public delegate void PathTrackEventHandler(PathEventArgs args);
42 |
43 | public delegate void BeforePathStartEventHandler(BeforePathStartEventArgs args);
44 |
45 | public interface IPathTracker : IDisposable
46 | {
47 | bool Paused { get; set; }
48 | void Start();
49 | void Stop();
50 |
51 | void SuspendTemprarily(GestureModifier filteredModifiers);
52 | bool IsSuspended { get; }
53 |
54 | event BeforePathStartEventHandler BeforePathStart;
55 |
56 | event PathTrackEventHandler PathStart;
57 | event PathTrackEventHandler PathGrow;
58 | event PathTrackEventHandler EffectivePathGrow;
59 | event PathTrackEventHandler PathEnd;
60 | event PathTrackEventHandler PathTimeout;
61 | event PathTrackEventHandler PathModifier;
62 |
63 | //TODO: 按照接口隔离原则重构
64 | event Action HotCornerTriggered;
65 | event Action EdgeRubbed;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/WGestures.Core/Impl/Windows/Win32GestureContext.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.Security.Cryptography;
7 | using System.Text;
8 | using WGestures.Common.OsSpecific.Windows;
9 | using Win32;
10 |
11 | namespace WGestures.Core.Impl.Windows
12 | {
13 | internal class Win32GestureContext : GestureContext
14 | {
15 | //todo: 活动窗口时shell的情况
16 |
17 | bool IsTopMostWindow(IntPtr hwnd)
18 | {
19 | User32.WINDOWINFO info = new User32.WINDOWINFO();
20 | info.cbSize = (uint)Marshal.SizeOf(info);
21 | User32.GetWindowInfo(hwnd, ref info);
22 |
23 | const uint TOP_MOST = (uint) User32.WS_EX.WS_EX_TOPMOST;
24 |
25 | return (info.dwExStyle & TOP_MOST) == TOP_MOST;
26 | }
27 |
28 |
29 |
30 | public override void ActivateTargetWindow()
31 | {
32 | var rootWindow = Native.GetAncestor(WinId, Native.GetAncestorFlags.GetRoot);
33 |
34 | var fgWin = User32.GetForegroundWindow();
35 | if(fgWin != rootWindow)
36 | User32.SetForegroundWindow(rootWindow);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/WGestures.Core/Persistence/AbstractGestureIntentFinder.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace WGestures.Core.Persistence
3 | {
4 | ///
5 | /// 实现查找算法
6 | ///
7 | public abstract class AbstractGestureIntentFinder : IGestureIntentFinder
8 | {
9 | public IGestureIntentStore IntentStore { get; private set; }
10 |
11 | protected AbstractGestureIntentFinder(IGestureIntentStore intentStore)
12 | {
13 | IntentStore = intentStore;
14 | }
15 |
16 | ///
17 | /// 判断是否在当前的应用程序上禁用的鼠标手势
18 | /// 如果应用程序没有添加到记录中,则检查全局手是否可用
19 | ///
20 | ///
21 | ///
22 | public bool IsGesturingEnabledForContext(GestureContext context, out ExeApp foundApp)
23 | {
24 | foundApp = GetExeAppByContext(context);
25 |
26 | return foundApp != null ?
27 | foundApp.IsGesturingEnabled : IntentStore.GlobalApp.IsGesturingEnabled;
28 | }
29 |
30 | ///
31 | /// 查找Intent
32 | ///
33 | ///
34 | ///
35 | ///
36 | public GestureIntent Find(Gesture gesture, GestureContext context)
37 | {
38 | var exeApp = GetExeAppByContext(context);
39 | var globalApp = IntentStore.GlobalApp;
40 |
41 | GestureIntent found;
42 |
43 | if (exeApp != null)
44 | {
45 | found = exeApp.Find(gesture);
46 | if (found == null && exeApp.InheritGlobalGestures) //是否继承了全局手势
47 | {
48 | found = globalApp.Find(gesture);
49 | }
50 | }else
51 | {
52 | found = globalApp.Find(gesture);
53 | }
54 |
55 | return found;
56 | }
57 |
58 | public GestureIntent Find(Gesture gesture, ExeApp inApp)
59 | {
60 | GestureIntent found;
61 |
62 | if (inApp != null)
63 | {
64 | found = inApp.Find(gesture);
65 | if (found == null && inApp.InheritGlobalGestures) //是否继承了全局手势
66 | {
67 | found = IntentStore.GlobalApp.Find(gesture);
68 | }
69 | }
70 | else
71 | {
72 | found = IntentStore.GlobalApp.Find(gesture);
73 | }
74 |
75 | return found;
76 | }
77 |
78 |
79 | ///
80 | /// 实现平台相关的查找
81 | ///
82 | ///
83 | ///
84 | public abstract ExeApp GetExeAppByContext(GestureContext context);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/WGestures.Core/Persistence/IGestureIntentStore.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using WGestures.Core.Commands;
3 |
4 | namespace WGestures.Core.Persistence
5 | {
6 | public interface IGestureIntentStore : IEnumerable
7 | {
8 | GlobalApp GlobalApp { get; }
9 | bool TryGetExeApp(string key, out ExeApp found );
10 | ExeApp GetExeApp(string key);
11 | AbstractCommand[] HotCornerCommands { get; set; }
12 |
13 | void Remove(string app);
14 | void Remove(ExeApp app);
15 | void Add(ExeApp app);
16 | void Save();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/WGestures.Core/Persistence/Impl/Windows/Win32GestrueIntentFinder.cs:
--------------------------------------------------------------------------------
1 |
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Diagnostics;
5 | using System.Text;
6 | using WGestures.Common.OsSpecific.Windows;
7 |
8 | namespace WGestures.Core.Persistence.Impl.Windows
9 | {
10 | public class Win32GestrueIntentFinder : AbstractGestureIntentFinder
11 | {
12 | public Win32GestrueIntentFinder(IGestureIntentStore intentStore)
13 | : base(intentStore)
14 | {
15 | }
16 |
17 | //private Dictionary _procFileNameDict = new Dictionary(64);
18 |
19 | ///
20 | /// Native下以进程文件名为key查找。
21 | ///
22 | ///
23 | ///
24 | public override ExeApp GetExeAppByContext(GestureContext context)
25 | {
26 | //全屏模式下禁用
27 |
28 | string str;
29 | ExeApp found = null;
30 |
31 | var procId = context.ProcId;//Native.GetActiveProcessId();
32 |
33 | Debug.WriteLine("procId="+procId);
34 |
35 |
36 | //if (!_procFileNameDict.TryGetValue(procId, out str))
37 | //{
38 | str = Native.GetProcessFile(procId);
39 | //_procFileNameDict[procId] = str;
40 | // }
41 |
42 | Debug.WriteLine("Image="+str);
43 | if (str == null) return null;
44 |
45 | IntentStore.TryGetExeApp(str, out found);
46 |
47 | return found;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/WGestures.Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("WGestures.Core")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WGestures.Core")]
13 | [assembly: AssemblyCopyright("Copyright © 2014-2022")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("a1686e8c-40da-472b-bf94-fe03518b8c21")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.8.5.0")]
36 | [assembly: AssemblyFileVersion("1.8.5.0")]
37 |
--------------------------------------------------------------------------------
/WGestures.Core/ScreenCornerAndEdge.cs:
--------------------------------------------------------------------------------
1 | namespace WGestures.Core
2 | {
3 | public enum ScreenCorner
4 | {
5 | LeftBottom = 0, LeftTop = 1, RightTop = 2, RightBottom = 3
6 | }
7 |
8 | public enum ScreenEdge : uint
9 | {
10 | Left = 0, Top, Right, Bottom
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/WGestures.Core/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/WGestures.View/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("WGestures.View")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WGestures.View")]
13 | [assembly: AssemblyCopyright("Copyright © 2014-2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("f14ceb06-ac40-4ab4-9d74-a2c61d1dd8e6")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.8.3.0")]
36 | [assembly: AssemblyFileVersion("1.8.3.0")]
--------------------------------------------------------------------------------
/WGestures.View/WGestures.View.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {62FB7A5C-E917-4405-942C-677A265685D6}
8 | Library
9 | Properties
10 | WGestures.View
11 | WGestures.View
12 | v4.8
13 | 512
14 |
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 | false
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 |
31 |
32 | prompt
33 | 4
34 | AnyCPU
35 | false
36 |
37 |
38 |
39 |
40 |
41 |
42 | false
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | {BB6528EB-C4EA-49B5-AC7F-A0645126F1A8}
61 | WGestures.Common
62 |
63 |
64 | {F26BE916-F318-47B5-87EB-1D67B7F30FDC}
65 | WGestures.Core
66 |
67 |
68 |
69 |
70 | Designer
71 |
72 |
73 |
74 |
81 |
--------------------------------------------------------------------------------
/WGestures.View/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/WindowsInput/IInputDeviceStateAdaptor.cs:
--------------------------------------------------------------------------------
1 | using WindowsInput.Native;
2 |
3 | namespace WindowsInput
4 | {
5 | ///
6 | /// The contract for a service that interprets the state of input devices.
7 | ///
8 | public interface IInputDeviceStateAdaptor
9 | {
10 | ///
11 | /// Determines whether the specified key is up or down.
12 | ///
13 | /// The for the key.
14 | ///
15 | /// true if the key is down; otherwise, false.
16 | ///
17 | bool IsKeyDown(VirtualKeyCode keyCode);
18 |
19 | ///
20 | /// Determines whether the specified key is up or down.
21 | ///
22 | /// The for the key.
23 | ///
24 | /// true if the key is up; otherwise, false.
25 | ///
26 | bool IsKeyUp(VirtualKeyCode keyCode);
27 |
28 | ///
29 | /// Determines whether the physical key is up or down at the time the function is called regardless of whether the application thread has read the keyboard event from the message pump.
30 | ///
31 | /// The for the key.
32 | ///
33 | /// true if the key is down; otherwise, false.
34 | ///
35 | bool IsHardwareKeyDown(VirtualKeyCode keyCode);
36 |
37 | ///
38 | /// Determines whether the physical key is up or down at the time the function is called regardless of whether the application thread has read the keyboard event from the message pump.
39 | ///
40 | /// The for the key.
41 | ///
42 | /// true if the key is up; otherwise, false.
43 | ///
44 | bool IsHardwareKeyUp(VirtualKeyCode keyCode);
45 |
46 | ///
47 | /// Determines whether the toggling key is toggled on (in-effect) or not.
48 | ///
49 | /// The for the key.
50 | ///
51 | /// true if the toggling key is toggled on (in-effect); otherwise, false.
52 | ///
53 | bool IsTogglingKeyInEffect(VirtualKeyCode keyCode);
54 | }
55 | }
--------------------------------------------------------------------------------
/WindowsInput/IInputMessageDispatcher.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using WindowsInput.Native;
3 |
4 | namespace WindowsInput
5 | {
6 | ///
7 | /// The contract for a service that dispatches messages to the appropriate destination.
8 | ///
9 | internal interface IInputMessageDispatcher
10 | {
11 | ///
12 | /// Dispatches the specified list of messages in their specified order.
13 | ///
14 | /// The list of messages to be dispatched.
15 | /// If the array is empty.
16 | /// If the array is null.
17 | /// If the any of the commands in the array could not be sent successfully.
18 | void DispatchInput(INPUT[] inputs);
19 |
20 | unsafe void DispatchInput(INPUT* inputs, uint count);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/WindowsInput/IInputSimulator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput
4 | {
5 | ///
6 | /// The contract for a service that simulates Keyboard and Mouse input and Hardware Input Device state detection for the Windows Platform.
7 | ///
8 | public interface IInputSimulator
9 | {
10 | ///
11 | /// Gets the instance for simulating Keyboard input.
12 | ///
13 | /// The instance.
14 | IKeyboardSimulator Keyboard { get; }
15 |
16 | ///
17 | /// Gets the instance for simulating Mouse input.
18 | ///
19 | /// The instance.
20 | IMouseSimulator Mouse { get; }
21 |
22 | ///
23 | /// Gets the instance for determining the state of the various input devices.
24 | ///
25 | /// The instance.
26 | IInputDeviceStateAdaptor InputDeviceState { get; }
27 |
28 | ///
29 | /// ExtraInfo
30 | ///
31 | IntPtr ExtraInfo { get; set; }
32 | }
33 | }
--------------------------------------------------------------------------------
/WindowsInput/InputSimulator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput
4 | {
5 | ///
6 | /// Implements the interface to simulate Keyboard and Mouse input and provide the state of those input devices.
7 | ///
8 | public class InputSimulator : IInputSimulator
9 | {
10 | ///
11 | /// Tag to mark events
12 | ///
13 | public IntPtr ExtraInfo
14 | {
15 | get; set;
16 | }
17 | ///
18 | /// The instance to use for simulating keyboard input.
19 | ///
20 | private readonly IKeyboardSimulator _keyboardSimulator;
21 |
22 | ///
23 | /// The instance to use for simulating mouse input.
24 | ///
25 | private readonly IMouseSimulator _mouseSimulator;
26 |
27 | ///
28 | /// The instance to use for interpreting the state of the input devices.
29 | ///
30 | private readonly IInputDeviceStateAdaptor _inputDeviceState;
31 |
32 | ///
33 | /// Initializes a new instance of the class using the specified , and instances.
34 | ///
35 | /// The instance to use for simulating keyboard input.
36 | /// The instance to use for simulating mouse input.
37 | /// The instance to use for interpreting the state of input devices.
38 | public InputSimulator(IKeyboardSimulator keyboardSimulator, IMouseSimulator mouseSimulator, IInputDeviceStateAdaptor inputDeviceStateAdaptor)
39 | {
40 | _keyboardSimulator = keyboardSimulator;
41 | _mouseSimulator = mouseSimulator;
42 | _inputDeviceState = inputDeviceStateAdaptor;
43 | }
44 |
45 | ///
46 | /// Initializes a new instance of the class using the default , and instances.
47 | ///
48 | public InputSimulator()
49 | {
50 | _keyboardSimulator = new KeyboardSimulator(this);
51 | _mouseSimulator = new MouseSimulator(this);
52 | _inputDeviceState = new WindowsInputDeviceStateAdaptor();
53 | }
54 |
55 | ///
56 | /// Gets the instance for simulating Keyboard input.
57 | ///
58 | /// The instance.
59 | public IKeyboardSimulator Keyboard
60 | {
61 | get { return _keyboardSimulator; }
62 | }
63 |
64 | ///
65 | /// Gets the instance for simulating Mouse input.
66 | ///
67 | /// The instance.
68 | public IMouseSimulator Mouse
69 | {
70 | get { return _mouseSimulator; }
71 | }
72 |
73 | ///
74 | /// Gets the instance for determining the state of the various input devices.
75 | ///
76 | /// The instance.
77 | public IInputDeviceStateAdaptor InputDeviceState
78 | {
79 | get { return _inputDeviceState; }
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/WindowsInput/MouseButton.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsInput
2 | {
3 | ///
4 | /// The mouse button
5 | ///
6 | public enum MouseButton
7 | {
8 | ///
9 | /// Left mouse button
10 | ///
11 | LeftButton,
12 |
13 | ///
14 | /// Middle mouse button
15 | ///
16 | MiddleButton,
17 |
18 | ///
19 | /// Right moust button
20 | ///
21 | RightButton,
22 | }
23 | }
--------------------------------------------------------------------------------
/WindowsInput/Native/HARDWAREINPUT.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | #pragma warning disable 649
6 | ///
7 | /// The HARDWAREINPUT structure contains information about a simulated message generated by an input device other than a keyboard or mouse. (see: http://msdn.microsoft.com/en-us/library/ms646269(VS.85).aspx)
8 | /// Declared in Winuser.h, include Windows.h
9 | ///
10 | internal struct HARDWAREINPUT
11 | {
12 | ///
13 | /// Value specifying the message generated by the input hardware.
14 | ///
15 | public UInt32 Msg;
16 |
17 | ///
18 | /// Specifies the low-order word of the lParam parameter for uMsg.
19 | ///
20 | public UInt16 ParamL;
21 |
22 | ///
23 | /// Specifies the high-order word of the lParam parameter for uMsg.
24 | ///
25 | public UInt16 ParamH;
26 | }
27 | #pragma warning restore 649
28 | }
29 |
--------------------------------------------------------------------------------
/WindowsInput/Native/INPUT.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | #pragma warning disable 649
6 | ///
7 | /// The INPUT structure is used by SendInput to store information for synthesizing input events such as keystrokes, mouse movement, and mouse clicks. (see: http://msdn.microsoft.com/en-us/library/ms646270(VS.85).aspx)
8 | /// Declared in Winuser.h, include Windows.h
9 | ///
10 | ///
11 | /// This structure contains information identical to that used in the parameter list of the keybd_event or mouse_event function.
12 | /// Windows 2000/XP: INPUT_KEYBOARD supports nonkeyboard input methods, such as handwriting recognition or voice recognition, as if it were text input by using the KEYEVENTF_UNICODE flag. For more information, see the remarks section of KEYBDINPUT.
13 | ///
14 | internal struct INPUT
15 | {
16 | ///
17 | /// Specifies the type of the input event. This member can be one of the following values.
18 | /// - The event is a mouse event. Use the mi structure of the union.
19 | /// - The event is a keyboard event. Use the ki structure of the union.
20 | /// - Windows 95/98/Me: The event is from input hardware other than a keyboard or mouse. Use the hi structure of the union.
21 | ///
22 | public UInt32 Type;
23 |
24 | ///
25 | /// The data structure that contains information about the simulated Mouse, Keyboard or Hardware event.
26 | ///
27 | public MOUSEKEYBDHARDWAREINPUT Data;
28 | }
29 | #pragma warning restore 649
30 | }
31 |
--------------------------------------------------------------------------------
/WindowsInput/Native/InputType.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsInput.Native
2 | {
3 | ///
4 | /// Specifies the type of the input event. This member can be one of the following values.
5 | ///
6 | internal enum InputType : uint // UInt32
7 | {
8 | ///
9 | /// INPUT_MOUSE = 0x00 (The event is a mouse event. Use the mi structure of the union.)
10 | ///
11 | Mouse = 0,
12 |
13 | ///
14 | /// INPUT_KEYBOARD = 0x01 (The event is a keyboard event. Use the ki structure of the union.)
15 | ///
16 | Keyboard = 1,
17 |
18 | ///
19 | /// INPUT_HARDWARE = 0x02 (Windows 95/98/Me: The event is from input hardware other than a keyboard or mouse. Use the hi structure of the union.)
20 | ///
21 | Hardware = 2,
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/WindowsInput/Native/KEYBDINPUT.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | #pragma warning disable 649
6 | ///
7 | /// The KEYBDINPUT structure contains information about a simulated keyboard event. (see: http://msdn.microsoft.com/en-us/library/ms646271(VS.85).aspx)
8 | /// Declared in Winuser.h, include Windows.h
9 | ///
10 | ///
11 | /// Windows 2000/XP: INPUT_KEYBOARD supports nonkeyboard-input methodssuch as handwriting recognition or voice recognitionas if it were text input by using the KEYEVENTF_UNICODE flag. If KEYEVENTF_UNICODE is specified, SendInput sends a WM_KEYDOWN or WM_KEYUP message to the foreground thread's message queue with wParam equal to VK_PACKET. Once GetMessage or PeekMessage obtains this message, passing the message to TranslateMessage posts a WM_CHAR message with the Unicode character originally specified by wScan. This Unicode character will automatically be converted to the appropriate ANSI value if it is posted to an ANSI window.
12 | /// Windows 2000/XP: Set the KEYEVENTF_SCANCODE flag to define keyboard input in terms of the scan code. This is useful to simulate a physical keystroke regardless of which keyboard is currently being used. The virtual key value of a key may alter depending on the current keyboard layout or what other keys were pressed, but the scan code will always be the same.
13 | ///
14 | internal struct KEYBDINPUT
15 | {
16 | ///
17 | /// Specifies a virtual-key code. The code must be a value in the range 1 to 254. The Winuser.h header file provides macro definitions (VK_*) for each value. If the dwFlags member specifies KEYEVENTF_UNICODE, wVk must be 0.
18 | ///
19 | public UInt16 KeyCode;
20 |
21 | ///
22 | /// Specifies a hardware scan code for the key. If dwFlags specifies KEYEVENTF_UNICODE, wScan specifies a Unicode character which is to be sent to the foreground application.
23 | ///
24 | public UInt16 Scan;
25 |
26 | ///
27 | /// Specifies various aspects of a keystroke. This member can be certain combinations of the following values.
28 | /// KEYEVENTF_EXTENDEDKEY - If specified, the scan code was preceded by a prefix byte that has the value 0xE0 (224).
29 | /// KEYEVENTF_KEYUP - If specified, the key is being released. If not specified, the key is being pressed.
30 | /// KEYEVENTF_SCANCODE - If specified, wScan identifies the key and wVk is ignored.
31 | /// KEYEVENTF_UNICODE - Windows 2000/XP: If specified, the system synthesizes a VK_PACKET keystroke. The wVk parameter must be zero. This flag can only be combined with the KEYEVENTF_KEYUP flag. For more information, see the Remarks section.
32 | ///
33 | public UInt32 Flags;
34 |
35 | ///
36 | /// Time stamp for the event, in milliseconds. If this parameter is zero, the system will provide its own time stamp.
37 | ///
38 | public UInt32 Time;
39 |
40 | ///
41 | /// Specifies an additional value associated with the keystroke. Use the GetMessageExtraInfo function to obtain this information.
42 | ///
43 | public IntPtr ExtraInfo;
44 | }
45 | #pragma warning restore 649
46 | }
47 |
--------------------------------------------------------------------------------
/WindowsInput/Native/KeyboardFlag.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | ///
6 | /// Specifies various aspects of a keystroke. This member can be certain combinations of the following values.
7 | ///
8 | [Flags]
9 | internal enum KeyboardFlag : uint // UInt32
10 | {
11 | ///
12 | /// KEYEVENTF_EXTENDEDKEY = 0x0001 (If specified, the scan code was preceded by a prefix byte that has the value 0xE0 (224).)
13 | ///
14 | ExtendedKey = 0x0001,
15 |
16 | ///
17 | /// KEYEVENTF_KEYUP = 0x0002 (If specified, the key is being released. If not specified, the key is being pressed.)
18 | ///
19 | KeyUp = 0x0002,
20 |
21 | ///
22 | /// KEYEVENTF_UNICODE = 0x0004 (If specified, wScan identifies the key and wVk is ignored.)
23 | ///
24 | Unicode = 0x0004,
25 |
26 | ///
27 | /// KEYEVENTF_SCANCODE = 0x0008 (Windows 2000/XP: If specified, the system synthesizes a VK_PACKET keystroke. The wVk parameter must be zero. This flag can only be combined with the KEYEVENTF_KEYUP flag. For more information, see the Remarks section.)
28 | ///
29 | ScanCode = 0x0008,
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/WindowsInput/Native/MOUSEKEYBDHARDWAREINPUT.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | #pragma warning disable 649
6 | ///
7 | /// The combined/overlayed structure that includes Mouse, Keyboard and Hardware Input message data (see: http://msdn.microsoft.com/en-us/library/ms646270(VS.85).aspx)
8 | ///
9 | [StructLayout(LayoutKind.Explicit)]
10 | internal struct MOUSEKEYBDHARDWAREINPUT
11 | {
12 | ///
13 | /// The definition.
14 | ///
15 | [FieldOffset(0)]
16 | public MOUSEINPUT Mouse;
17 |
18 | ///
19 | /// The definition.
20 | ///
21 | [FieldOffset(0)]
22 | public KEYBDINPUT Keyboard;
23 |
24 | ///
25 | /// The definition.
26 | ///
27 | [FieldOffset(0)]
28 | public HARDWAREINPUT Hardware;
29 | }
30 | #pragma warning restore 649
31 | }
32 |
--------------------------------------------------------------------------------
/WindowsInput/Native/MouseFlag.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WindowsInput.Native
4 | {
5 | ///
6 | /// The set of MouseFlags for use in the Flags property of the structure. (See: http://msdn.microsoft.com/en-us/library/ms646273(VS.85).aspx)
7 | ///
8 | [Flags]
9 | internal enum MouseFlag : uint // UInt32
10 | {
11 | ///
12 | /// Specifies that movement occurred.
13 | ///
14 | Move = 0x0001,
15 |
16 | ///
17 | /// Specifies that the left button was pressed.
18 | ///
19 | LeftDown = 0x0002,
20 |
21 | ///
22 | /// Specifies that the left button was released.
23 | ///
24 | LeftUp = 0x0004,
25 |
26 | ///
27 | /// Specifies that the right button was pressed.
28 | ///
29 | RightDown = 0x0008,
30 |
31 | ///
32 | /// Specifies that the right button was released.
33 | ///
34 | RightUp = 0x0010,
35 |
36 | ///
37 | /// Specifies that the middle button was pressed.
38 | ///
39 | MiddleDown = 0x0020,
40 |
41 | ///
42 | /// Specifies that the middle button was released.
43 | ///
44 | MiddleUp = 0x0040,
45 |
46 | ///
47 | /// Windows 2000/XP: Specifies that an X button was pressed.
48 | ///
49 | XDown = 0x0080,
50 |
51 | ///
52 | /// Windows 2000/XP: Specifies that an X button was released.
53 | ///
54 | XUp = 0x0100,
55 |
56 | ///
57 | /// Windows NT/2000/XP: Specifies that the wheel was moved, if the mouse has a wheel. The amount of movement is specified in mouseData.
58 | ///
59 | VerticalWheel = 0x0800,
60 |
61 | ///
62 | /// Specifies that the wheel was moved horizontally, if the mouse has a wheel. The amount of movement is specified in mouseData. Windows 2000/XP: Not supported.
63 | ///
64 | HorizontalWheel = 0x1000,
65 |
66 | ///
67 | /// Windows 2000/XP: Maps coordinates to the entire desktop. Must be used with MOUSEEVENTF_ABSOLUTE.
68 | ///
69 | VirtualDesk = 0x4000,
70 |
71 | ///
72 | /// Specifies that the dx and dy members contain normalized absolute coordinates. If the flag is not set, dxand dy contain relative data (the change in position since the last reported position). This flag can be set, or not set, regardless of what kind of mouse or other pointing device, if any, is connected to the system. For further information about relative mouse motion, see the following Remarks section.
73 | ///
74 | Absolute = 0x8000,
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/WindowsInput/Native/XButton.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsInput.Native
2 | {
3 | ///
4 | /// XButton definitions for use in the MouseData property of the structure. (See: http://msdn.microsoft.com/en-us/library/ms646273(VS.85).aspx)
5 | ///
6 | internal enum XButton : uint
7 | {
8 | ///
9 | /// Set if the first X button is pressed or released.
10 | ///
11 | XButton1 = 0x0001,
12 |
13 | ///
14 | /// Set if the second X button is pressed or released.
15 | ///
16 | XButton2 = 0x0002,
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/WindowsInput/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("WindowsInput")]
10 | [assembly: AssemblyDescription("Provides a useful wrapper around the User32 SendInput and related native Windows functions for simulating Input Devices in Windows including Keyboard and Mouse.")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("michaelnoonan")]
13 | [assembly: AssemblyProduct("WindowsInput")]
14 | [assembly: AssemblyCopyright("Copyright © michaelnoonan 2010")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: CLSCompliant(true)]
18 | [assembly: InternalsVisibleTo("WindowsInput.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100737a78808b105748ff1251c1eb68752c2eb02dea580cade31d04fbc4081d7f420c639de2f3081461f734d48499c50133adb9dab02d828031cdec7d2941652233aefadf961658f948c13d43da9860d76ded6e959eebec0ddae03cc67dabf1aa83973602690e228c5b2d9434e62760d325d4c46a1fdf71971bb7a22f0de55b7bf0")]
19 |
20 | // Setting ComVisible to false makes the types in this assembly not visible
21 | // to COM components. If you need to access a type in this assembly from
22 | // COM, set the ComVisible attribute to true on that type.
23 | [assembly: ComVisible(false)]
24 |
25 | // The following GUID is for the ID of the typelib if this project is exposed to COM
26 | [assembly: Guid("25871eb0-27d6-42da-a3fe-cb60eb01f15a")]
27 |
28 | // Version information for an assembly consists of the following four values:
29 | //
30 | // Major Version
31 | // Minor Version
32 | // Build Number
33 | // Revision
34 | //
35 | // You can specify all the values or you can default the Build and Revision Numbers
36 | // by using the '*' as shown below:
37 | // [assembly: AssemblyVersion("1.0.*")]
38 | [assembly: AssemblyVersion("0.2.2.0")]
39 | [assembly: AssemblyFileVersion("0.2.2.0")]
40 |
--------------------------------------------------------------------------------
/WindowsInput/WindowsInput.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | InputSimulator
5 | 0.2.0.0
6 | Windows Input Simulator
7 | Michael Noonan
8 | Michael Noonan
9 | http://inputsimulator.codeplex.com/license
10 | http://inputsimulator.codeplex.com
11 | false
12 | The Windows Input Simulator provides a simple .NET (C#) interface to simulate Keyboard or Mouse input using the Win32 SendInput method. All of the Interop is done for you and there's a simple programming model for sending multiple keystrokes.
13 | This version introduces more comprehensive Unicode tests and support for Mouse Simulation.
14 | Copyright 2009-2013
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/WindowsInput/WindowsInput.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yingDev/WGestures/9b24d57d9c9a730183e20fe153c342396a61e0bb/WindowsInput/WindowsInput.snk
--------------------------------------------------------------------------------
/WindowsInput/WindowsInputMessageDispatcher.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using WindowsInput.Native;
4 |
5 | namespace WindowsInput
6 | {
7 | ///
8 | /// Implements the .
9 | ///
10 | internal class WindowsInputMessageDispatcher : IInputMessageDispatcher
11 | {
12 | ///
13 | /// Dispatches the specified list of messages.
14 | ///
15 | /// The list of messages to be dispatched.
16 | /// If the array is empty.
17 | /// If the array is null.
18 | /// If the any of the commands in the array could not be sent successfully.
19 | public void DispatchInput(INPUT[] inputs)
20 | {
21 | if (inputs == null) throw new ArgumentNullException("inputs");
22 | if (inputs.Length == 0) throw new ArgumentException("The input array was empty", "inputs");
23 | var successful = NativeMethods.SendInput((UInt32)inputs.Length, inputs, Marshal.SizeOf(typeof (INPUT)));
24 | if (successful != inputs.Length)
25 | throw new Exception("Some simulated input commands were not sent successfully. The most common reason for this happening are the security features of Windows including User Interface Privacy Isolation (UIPI). Your application can only send commands to applications of the same or lower elevation. Similarly certain commands are restricted to Accessibility/UIAutomation applications. Refer to the project home page and the code samples for more information.");
26 | }
27 |
28 | public unsafe void DispatchInput(INPUT* inputs, uint count)
29 | {
30 | var successful = NativeMethods.SendInput(count, inputs, Marshal.SizeOf(typeof(INPUT)));
31 | if (successful != count)
32 | throw new Exception("Some simulated input commands were not sent successfully. The most common reason for this happening are the security features of Windows including User Interface Privacy Isolation (UIPI). Your application can only send commands to applications of the same or lower elevation. Similarly certain commands are restricted to Accessibility/UIAutomation applications. Refer to the project home page and the code samples for more information.");
33 |
34 | }
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/makeTestCert.bat:
--------------------------------------------------------------------------------
1 | makecert -r -pe -n "CN=WGestures Test CA" -ss CA -sr CurrentUser -a sha256 -cy authority -sky signature -sv WGesturesTestCA.pvk WGesturesTestCA.cer
2 |
3 | makecert -pe -n "CN=WGestures Test SPC" -a sha256 -cy end -sky signature -ic WGesturesTestCA.cer -iv WGesturesTestCA.pvk -sv WGesturesTestSPC.pvk WGesturesTestSPC.cer
4 |
5 | pvk2pfx -pvk WGesturesTestSPC.pvk -spc WGesturesTestSPC.cer -pfx WGesturesTestSPC.pfx
6 |
7 | move WGesturesTestSPC.pfx YingDevSPC.pfx
8 | move WGesturesTestCA.cer WGestures.App\cert\YingdevCA.cer
9 |
10 | del WGesturesTestCA.cer WGesturesTestCA.pvk WGesturesTestSPC.cer WGesturesTestSPC.pvk
11 |
12 | pause
--------------------------------------------------------------------------------