Do

Merge lp:~do-win/do/keybinding-service into lp:~do-win/do/trunk

Proposed by Chris S.
Status: Superseded
Proposed branch: lp:~do-win/do/keybinding-service
Merge into: lp:~do-win/do/trunk
Diff against target: None lines
To merge this branch: bzr merge lp:~do-win/do/keybinding-service
Reviewer Review Type Date Requested Status
Do Core Team Pending
Review via email: mp+9040@code.launchpad.net
To post a comment you must log in.
lp:~do-win/do/keybinding-service updated
80. By Chris S.

clean up a few things

81. By Chris S.

some initial fixes

82. By Chris S.

rename KeyEvent to KeyBinding

Unmerged revisions

82. By Chris S.

rename KeyEvent to KeyBinding

81. By Chris S.

some initial fixes

80. By Chris S.

clean up a few things

79. By Chris S.

add region comments

78. By Chris S.

clean up and simplify keybinding service

77. By Chris S.

remove ManagedWinAPI

76. By Chris S.

add all new files

75. By Chris S.

remove some old files

74. By Chris S.

massive overhaul of keybindings

73. By Chris S.

begin to add keybinding service

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Do.Platform.Windows/Do.Platform.Windows.csproj'
2--- Do.Platform.Windows/Do.Platform.Windows.csproj 2009-07-17 00:41:31 +0000
3+++ Do.Platform.Windows/Do.Platform.Windows.csproj 2009-07-18 23:45:47 +0000
4@@ -78,6 +78,7 @@
5 <Compile Include="src\Do.Platform\Do.Platform.Windows\ConsoleLogService.cs" />
6 <Compile Include="src\Do.Platform\Do.Platform.Windows\EnvironmentService.cs" />
7 <Compile Include="src\Do.Platform\Do.Platform.Windows\IconExtractor\IconExtractor.cs" />
8+ <Compile Include="src\Do.Platform\Do.Platform.Windows\KeyBindingService.cs" />
9 <Compile Include="src\Do.Platform\Do.Platform.Windows\NotificationService.cs" />
10 <Compile Include="src\Do.Platform\Do.Platform.Windows\RegistryPreferencesService.cs" />
11 <Compile Include="src\Do.Platform\Do.Platform.Windows\SecurePreferencesService.cs" />
12@@ -93,6 +94,7 @@
13 <Compile Include="src\Do.Platform\Do.Platform.Windows\Shell\ShellFileInfo.cs" />
14 <Compile Include="src\Do.Platform\Do.Platform.Windows\Shell\WinAPIFolder.cs" />
15 <Compile Include="src\Do.Platform\Do.Platform.Windows\SystemService.cs" />
16+ <Compile Include="src\Do.Platform\Do.Platform.Windows\EventDispatchingNativeWindow.cs" />
17 <Compile Include="src\Do.Platform\Do.Platform.Windows\Tests\RegistryPreferencesServiceTests.cs" />
18 <Compile Include="src\Do.Platform\Do.Platform.Windows\TrayIconPreferences.cs" />
19 <Compile Include="src\Do.Platform\Do.Platform.Windows\TrayIconService.cs" />
20
21=== modified file 'Do.Platform.Windows/Resources/Do.Platform.Windows.addin.xml'
22--- Do.Platform.Windows/Resources/Do.Platform.Windows.addin.xml 2009-07-17 00:41:31 +0000
23+++ Do.Platform.Windows/Resources/Do.Platform.Windows.addin.xml 2009-07-18 23:45:47 +0000
24@@ -32,5 +32,6 @@
25 <Service type="Do.Platform.Windows.UniverseFactoryService" />
26 <Service type="Do.Platform.Windows.RegistryPreferencesService" />
27 <Service type="Do.Platform.Windows.SecurePreferencesService" />
28+ <Service type="Do.Platform.Windows.KeyBindingService" />
29 </Extension>
30 </Addin>
31\ No newline at end of file
32
33=== added file 'Do.Platform.Windows/src/Do.Platform/Do.Platform.Windows/KeyBindingService.cs'
34--- Do.Platform.Windows/src/Do.Platform/Do.Platform.Windows/KeyBindingService.cs 1970-01-01 00:00:00 +0000
35+++ Do.Platform.Windows/src/Do.Platform/Do.Platform.Windows/KeyBindingService.cs 2009-07-20 05:32:59 +0000
36@@ -0,0 +1,170 @@
37+using System;
38+using System.Linq;
39+using System.Globalization;
40+using System.Windows.Forms;
41+using System.Collections.Generic;
42+using System.Text.RegularExpressions;
43+using System.Runtime.InteropServices;
44+
45+using Mono.Unix;
46+using Gdk;
47+
48+using Do.Platform.Common;
49+using Do.Platform.Windows;
50+
51+namespace Do.Platform.Windows
52+{
53+ class KeyBindingService : AbstractKeyBindingService
54+ {
55+ [Flags]
56+ enum Modifiers : int
57+ {
58+ Alt = 0x1,
59+ Control = 0x02,
60+ Shift = 0x04,
61+ Win = 0x08,
62+ }
63+
64+ class HotKey {
65+ //Occurs when the hotkey is pressed.
66+ public EventCallback PressedEvent { get; set; }
67+ //the keystring
68+ public string KeyString { get; private set; }
69+ //a unique key identifier value in the range 0x0000 through 0xBFFF
70+ public int KeyID { get; private set; }
71+ //the System.Windows.Forms.Keys enum value of this key
72+ public Keys Key { get; private set; }
73+ //the key modifiers to use
74+ public Modifiers Mods { get; private set; }
75+ //constructor
76+ public HotKey (string keyString, Keys key, Modifiers mods, int keyID) {
77+ this.KeyString = keyString;
78+ this.Key = key;
79+ this.Mods = mods;
80+ this.KeyID = keyID;
81+ }
82+
83+ /*
84+ public void HandleEvent () {
85+ if (PressedEvent != null)
86+ PressedEvent (this, EventArgs.Empty);
87+ }
88+ */
89+ }
90+
91+ [DllImport ("user32.dll")]
92+ private static extern bool RegisterHotKey (IntPtr hWnd, int id, int fsModifiers, int vlc);
93+
94+ [DllImport ("user32.dll")]
95+ private static extern bool UnregisterHotKey (IntPtr hWnd, int id);
96+
97+ // the hotkey pressed message identifier
98+ const int WM_HOTKEY = 0x0312;
99+
100+ //this will strip the < > from the keycodes that we use
101+ Regex rexp = new Regex ("<.*>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
102+
103+ //base hotkey index
104+ int hotkeyIndex = 0xA000;
105+
106+ //an IntPtr to our application
107+ IntPtr hWnd { get; set; }
108+
109+ //a dict of OS level bound hot keys, keystring --> hotkey
110+ Dictionary <string, HotKey> BoundKeys;
111+
112+ public KeyBindingService () {
113+ EventDispatchingNativeWindow.Instance.EventHandler += KeyPressEvent;
114+ this.hWnd = EventDispatchingNativeWindow.Instance.Handle;
115+ BoundKeys = new Dictionary<string, HotKey> ();
116+ }
117+
118+ void KeyPressEvent (ref Message m, ref bool handled) {
119+ if (handled) return;
120+ //get the KEY ID. If this isn't a WM_HOTKEY message this won't really be the id of the key,
121+ //but we don't care about that, because we check for WM_HOTKEY messages below.
122+ int keyID = m.WParam.ToInt32 ();
123+ if (m.Msg == WM_HOTKEY && BoundKeys.Values.Where (k => k.KeyID == keyID).Any ()) {
124+ HotKey key = BoundKeys.Values.Where (k => k.KeyID == keyID).First ();
125+ if (key.PressedEvent != null)
126+ key.PressedEvent (null);
127+ //key.HandleEvent ();
128+ handled = true;
129+ }
130+ }
131+
132+ HotKey ProcessKeyString (string keyString) {
133+ Modifiers modKeys = 0;
134+ Keys key;
135+
136+ // determine modifiers to use
137+ if (keyString.ToLower ().Contains ("super"))
138+ modKeys |= Modifiers.Win;
139+
140+ if (keyString.ToLower ().Contains ("shift"))
141+ modKeys |= Modifiers.Shift;
142+
143+ if (keyString.ToLower ().Contains ("alt"))
144+ modKeys |= Modifiers.Alt;
145+
146+ if (keyString.ToLower ().Contains ("control"))
147+ modKeys |= Modifiers.Control;
148+
149+ // figure out what the key is...this is so incredibly hacky but it should work for most cases
150+ // -- ootz0rz
151+ string thekey = rexp.Replace (keyString, "");
152+ thekey = CultureInfo.CurrentCulture.TextInfo.ToTitleCase (thekey);
153+
154+ try {
155+ key = (Keys) Enum.Parse (typeof (Keys), thekey);
156+ } catch (Exception e) {
157+ Log<KeyBindingService>.Error ("Could not register {0} with the OS.", keyString);
158+ Log<KeyBindingService>.Debug (e.StackTrace);
159+ return null;
160+ }
161+
162+ return new HotKey (keyString, key, modKeys, hotkeyIndex + BoundKeys.Keys.Count);
163+ }
164+
165+ public override bool RegisterSummonKey (string keyString, EventCallback cb) {
166+ bool success = false;
167+
168+ //check if we already bound this key
169+ if (!BoundKeys.ContainsKey (keyString)) {
170+ //if not, create the key and add it to the cache of bound keys
171+ HotKey key = ProcessKeyString (keyString);
172+ //if we failed to parse the keystring, bail
173+ if (key == null)
174+ return false;
175+ //assign the callback function
176+ key.PressedEvent = cb;
177+ //key.PressedEvent += handler;
178+ //attempt to register the key
179+ success = RegisterHotKey (this.hWnd, hotkeyIndex, (int) key.Mods, (int) key.Key);
180+ //only add this to our dictionary of bound keys if we were successful at binding it.
181+ if (success)
182+ BoundKeys.Add (keyString, key);
183+ } else {
184+ Log.Debug ("Key {0} is already bound...", keyString);
185+ }
186+
187+ return success;
188+ }
189+
190+ public override bool UnRegisterSummonKey (string keyString) {
191+ bool success = false;
192+
193+ if (BoundKeys.ContainsKey (keyString)) {
194+ HotKey key = BoundKeys [keyString];
195+ //attempt to unregister the key
196+ success = UnregisterHotKey (this.hWnd, key.KeyID);
197+ //remove this key from the cache
198+ BoundKeys.Remove (keyString);
199+ } else {
200+ Log.Debug ("Key {0} isn't bound... ", keyString);
201+ }
202+
203+ return success;
204+ }
205+ }
206+}
207\ No newline at end of file
208
209=== modified file 'Do.Platform/Do.Platform.csproj'
210--- Do.Platform/Do.Platform.csproj 2009-06-23 05:41:21 +0000
211+++ Do.Platform/Do.Platform.csproj 2009-07-19 02:53:52 +0000
212@@ -3,7 +3,7 @@
213 <PropertyGroup>
214 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
215 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
216- <ProductVersion>9.0.21022</ProductVersion>
217+ <ProductVersion>9.0.30729</ProductVersion>
218 <SchemaVersion>2.0</SchemaVersion>
219 <ProjectGuid>{6455647D-BA69-4203-962F-D40BF927B87E}</ProjectGuid>
220 <OutputType>Library</OutputType>
221@@ -49,14 +49,17 @@
222 <Compile Include="src\Do.Platform\AbstractApplicationService.cs" />
223 <Compile Include="src\Do.Platform\AbstractSystemService.cs" />
224 <Compile Include="src\Do.Platform\ActionableNotification.cs" />
225+ <Compile Include="src\Do.Platform\Do.Platform.Common\AbstractKeyBindingService.cs" />
226 <Compile Include="src\Do.Platform\Do.Platform.Common\AbstractLogService.cs" />
227 <Compile Include="src\Do.Platform\Do.Platform.Common\CommonPathsService.cs" />
228 <Compile Include="src\Do.Platform\Do.Platform.Common\DictionaryPreferencesService.cs" />
229+ <Compile Include="src\Do.Platform\Do.Platform.Common\DoKeyEvents.cs" />
230 <Compile Include="src\Do.Platform\Do.Platform.Common\EventsOnlyNotificationsService.cs" />
231 <Compile Include="src\Do.Platform\Do.Platform.Common\FileLogService.cs" />
232 <Compile Include="src\Do.Platform\Do.Platform.Common\Tests\DictionaryPreferencesServiceTests.cs" />
233 <Compile Include="src\Do.Platform\Do.Platform.Default\CoreService.cs" />
234 <Compile Include="src\Do.Platform\Do.Platform.Default\DefaultApplicationService.cs" />
235+ <Compile Include="src\Do.Platform\Do.Platform.Default\KeyBindingService.cs" />
236 <Compile Include="src\Do.Platform\Do.Platform.Default\DefaultPathsService.cs" />
237 <Compile Include="src\Do.Platform\Do.Platform.Default\DefaultSystemService.cs" />
238 <Compile Include="src\Do.Platform\Do.Platform.Default\EnvironmentService.cs" />
239@@ -74,6 +77,7 @@
240 <Compile Include="src\Do.Platform\Do.Platform.ServiceStack\IService.cs" />
241 <Compile Include="src\Do.Platform\ICoreService.cs" />
242 <Compile Include="src\Do.Platform\IEnvironmentService.cs" />
243+ <Compile Include="src\Do.Platform\IKeyBindingService.cs" />
244 <Compile Include="src\Do.Platform\ILogService.cs" />
245 <Compile Include="src\Do.Platform\INetworkService.cs" />
246 <Compile Include="src\Do.Platform\INotificationsService.cs" />
247@@ -82,6 +86,7 @@
248 <Compile Include="src\Do.Platform\ISecurePreferencesService.cs" />
249 <Compile Include="src\Do.Platform\IUniverseFactoryService.cs" />
250 <Compile Include="src\Do.Platform\IWindowingService.cs" />
251+ <Compile Include="src\Do.Platform\KeyEvent.cs" />
252 <Compile Include="src\Do.Platform\Log.cs" />
253 <Compile Include="src\Do.Platform\LogBase.cs" />
254 <Compile Include="src\Do.Platform\LogTSender.cs" />
255@@ -112,6 +117,8 @@
256 </ItemGroup>
257 <ItemGroup>
258 <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
259+ <Reference Include="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
260+ <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
261 <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
262 <Reference Include="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL" />
263 <Reference Include="nunit.framework, Version=2.5.0.9122, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
264@@ -119,6 +126,8 @@
265 <Reference Include="System.Core">
266 <RequiredTargetFramework>3.5</RequiredTargetFramework>
267 </Reference>
268+ <Reference Include="System.Data" />
269+ <Reference Include="System.Xml" />
270 </ItemGroup>
271 <ItemGroup>
272 <WCFMetadata Include="Service References\" />
273
274=== added file 'Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs'
275--- Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs 1970-01-01 00:00:00 +0000
276+++ Do.Platform/src/Do.Platform/Do.Platform.Common/AbstractKeyBindingService.cs 2009-07-20 05:35:09 +0000
277@@ -0,0 +1,120 @@
278+using System;
279+using System.Collections.Generic;
280+using System.Linq;
281+using System.Text;
282+
283+using Do.Platform.Common;
284+
285+namespace Do.Platform.Common
286+{
287+ public abstract class AbstractKeyBindingService : IKeyBindingService
288+ {
289+
290+ public abstract bool RegisterSummonKey (string keyString, EventCallback cb);
291+ public abstract bool UnRegisterSummonKey (string keyString);
292+
293+ IPreferences prefs;
294+
295+ // Platform.Common.DoKeyEvents -> KeyEvent
296+ Dictionary<DoKeyEvents, KeyEvent> KeyEvents;
297+
298+ #region IInitializedService
299+
300+ //internal Do keybinding code here...
301+ public void Initialize () {
302+ KeyEvents = new Dictionary<DoKeyEvents, KeyEvent> ();
303+
304+ prefs = Services.Preferences.Get<AbstractKeyBindingService> ();
305+ }
306+
307+ #endregion
308+
309+ #region IKeyBindingService
310+
311+ public bool RegisterKeyEvent (KeyEvent evnt) {
312+ bool success = true;
313+ //first check if this event is already mapped
314+ if (GetEvent (evnt.EventName) != null) {
315+ Log<AbstractKeyBindingService>.Error ("{0} is already mapped.", evnt.EventName);
316+ return false;
317+ }
318+
319+ //try to get the keystring from the prefs. We default to the doEvent.KeyString, so we can later check
320+ //if the prefs value matches that, we're using the default, otherwise we're using a user specified value
321+ string prefsKeyString = prefs.Get (evnt.EventName.ToString (), evnt.KeyString);
322+ //if these values don't match then the user has specified a new keystring
323+ //update the KeyEvent then continue
324+ if (prefsKeyString != evnt.KeyString)
325+ evnt.ChangeKeyString (prefsKeyString);
326+
327+ //if we are registering the summon key, do something special
328+ if (evnt.EventName == DoKeyEvents.Summon) {
329+ //try to register the key from the prefs with the OS
330+ success = RegisterSummonKey (evnt.KeyString, evnt.Callback);
331+ //if we fail to register the summon key, try again with the default binding
332+ if (!success && RegisterSummonKey (evnt.DefaultKeyString, evnt.Callback)) {
333+ //if we succeeded now, change the event's keystring
334+ evnt.ChangeKeyString (evnt.DefaultKeyString);
335+ success = true;
336+ }
337+ }
338+
339+ if (success) {
340+ //add the event to our mapped events dict
341+ KeyEvents.Add (evnt.EventName, evnt);
342+ //set the bound keystring in the prefs
343+ SetKeyString (evnt.EventName, evnt.KeyString);
344+ }
345+
346+ return success;
347+ }
348+
349+ public KeyEvent GetEvent (DoKeyEvents eventName) {
350+ if (KeyEvents.ContainsKey (eventName))
351+ return KeyEvents [eventName];
352+ return null;
353+ }
354+
355+ public KeyEvent GetEvent (string keyString) {
356+ if (KeyEvents.Values.Where (ev => ev.KeyString == keyString).Any ())
357+ return KeyEvents.Values.First (ev => ev.KeyString == keyString);
358+ return null;
359+ }
360+
361+ public bool SetKeyString (DoKeyEvents eventName, string keyString) {
362+ bool success = true;
363+ if (GetEvent (eventName) == null) {
364+ Log<AbstractKeyBindingService>.Error ("{0} is not mapped.", eventName);
365+ return false;
366+ }
367+
368+ //if it's the summon key, reregister it with the OS
369+ if (eventName == DoKeyEvents.Summon) {
370+ //remove the old keystring from the OS
371+ UnRegisterSummonKey (KeyEvents [eventName].KeyString);
372+ //register again with the new keystring
373+ success = RegisterSummonKey (keyString, KeyEvents [eventName].Callback);
374+ }
375+
376+ if (success) {
377+ //change the keystring in the dict of mapped events
378+ KeyEvents [eventName].ChangeKeyString (keyString);
379+
380+ //save the new value in the prefs
381+ prefs.Set (KeyEvents [eventName].EventName.ToString (), KeyEvents [eventName].KeyString);
382+
383+ Log<AbstractKeyBindingService>.Debug ("Event {0} now mapped to: {1}", eventName, keyString);
384+ }
385+
386+ return success;
387+ }
388+
389+ public IEnumerable<KeyEvent> BoundEvents {
390+ get {
391+ return KeyEvents.Values;
392+ }
393+ }
394+
395+ #endregion
396+ }
397+}
398\ No newline at end of file
399
400=== added file 'Do.Platform/src/Do.Platform/Do.Platform.Common/DoKeyEvents.cs'
401--- Do.Platform/src/Do.Platform/Do.Platform.Common/DoKeyEvents.cs 1970-01-01 00:00:00 +0000
402+++ Do.Platform/src/Do.Platform/Do.Platform.Common/DoKeyEvents.cs 2009-07-19 02:53:52 +0000
403@@ -0,0 +1,29 @@
404+using System;
405+using System.Collections.Generic;
406+using System.Linq;
407+using System.Text;
408+
409+namespace Do.Platform.Common
410+{
411+ public enum DoKeyEvents
412+ {
413+ Summon,
414+ EnterTextMode,
415+ Copy,
416+ Paste,
417+ AltEscape,
418+ AltActivate,
419+ AltDelete,
420+ NextPane,
421+ PreviousPane,
422+ Up,
423+ Down,
424+ First,
425+ Last,
426+ PageNext,
427+ PageLast,
428+ Left,
429+ Right,
430+ MultiSelect,
431+ }
432+}
433
434=== added file 'Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs'
435--- Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs 1970-01-01 00:00:00 +0000
436+++ Do.Platform/src/Do.Platform/Do.Platform.Default/KeyBindingService.cs 2009-07-20 05:32:59 +0000
437@@ -0,0 +1,29 @@
438+using System;
439+using System.Collections.Generic;
440+using System.Linq;
441+using System.Text;
442+
443+using Do.Platform.Common;
444+
445+namespace Do.Platform.Default
446+{
447+ class KeyBindingService : IKeyBindingService
448+ {
449+ public bool RegisterKeyEvent (KeyEvent evnt) {
450+ Log.Error ("Default keybinding service cannot register key events. {0}", evnt.KeyString);
451+ return false;
452+ }
453+ public KeyEvent GetEvent (DoKeyEvents eventName) {
454+ return null;
455+ }
456+ public KeyEvent GetEvent (string KeyString) {
457+ return null;
458+ }
459+ public bool SetKeyString (DoKeyEvents eventName, string keyString) {
460+ return false;
461+ }
462+ public IEnumerable<KeyEvent> BoundEvents { get { return Enumerable.Empty<KeyEvent> (); } }
463+ public void Initialize () {
464+ }
465+ }
466+}
467
468=== added file 'Do.Platform/src/Do.Platform/IKeyBindingService.cs'
469--- Do.Platform/src/Do.Platform/IKeyBindingService.cs 1970-01-01 00:00:00 +0000
470+++ Do.Platform/src/Do.Platform/IKeyBindingService.cs 2009-07-20 05:32:59 +0000
471@@ -0,0 +1,21 @@
472+using System;
473+using System.Collections.Generic;
474+
475+using Do.Platform.Common;
476+using Do.Platform.ServiceStack;
477+
478+using Gdk;
479+
480+namespace Do.Platform
481+{
482+ public delegate void EventCallback (EventKey evtky);
483+
484+ public interface IKeyBindingService : IInitializedService
485+ {
486+ bool RegisterKeyEvent (KeyEvent evnt);
487+ KeyEvent GetEvent (DoKeyEvents eventName);
488+ KeyEvent GetEvent (string keyString);
489+ bool SetKeyString (DoKeyEvents eventName, string keyString);
490+ IEnumerable<KeyEvent> BoundEvents { get; }
491+ }
492+}
493
494=== added file 'Do.Platform/src/Do.Platform/KeyEvent.cs'
495--- Do.Platform/src/Do.Platform/KeyEvent.cs 1970-01-01 00:00:00 +0000
496+++ Do.Platform/src/Do.Platform/KeyEvent.cs 2009-07-20 05:32:59 +0000
497@@ -0,0 +1,32 @@
498+using System;
499+using System.Collections.Generic;
500+using System.Linq;
501+using System.Text;
502+
503+using Gdk;
504+
505+namespace Do.Platform
506+{
507+ public class KeyEvent
508+ {
509+ //public delegate void EventCallback (EventKey evtky);
510+
511+ public Common.DoKeyEvents EventName { get; private set; }
512+ public string DisplayName { get; private set; }
513+ public EventCallback Callback { get; private set; }
514+ public string KeyString { get; private set; }
515+ public string DefaultKeyString { get; private set; }
516+
517+ public KeyEvent (Common.DoKeyEvents eventName, string displayName, string keyString, EventCallback eventFunc) {
518+ this.EventName = eventName;
519+ this.DisplayName = displayName;
520+ this.KeyString = keyString;
521+ this.DefaultKeyString = keyString;
522+ this.Callback = eventFunc;
523+ }
524+
525+ public void ChangeKeyString (string newKeyString) {
526+ this.KeyString = newKeyString;
527+ }
528+ }
529+}
530\ No newline at end of file
531
532=== modified file 'Do.Platform/src/Do.Platform/Services.cs'
533--- Do.Platform/src/Do.Platform/Services.cs 2009-06-21 03:37:34 +0000
534+++ Do.Platform/src/Do.Platform/Services.cs 2009-07-18 23:45:47 +0000
535@@ -43,7 +43,8 @@
536 static IEnvironmentService environment;
537 static INotificationsService notifications;
538 static IUniverseFactoryService universe_factory;
539- static INetworkService network;
540+ static INetworkService network;
541+ static IKeyBindingService keybinder;
542
543 /// <summary>
544 /// Initializes the class. Must be called after Mono.Addins is initialized; if this is
545@@ -101,7 +102,9 @@
546 if (service is AbstractSystemService)
547 system = null;
548 if (service is INetworkService)
549- network = null;
550+ network = null;
551+ if (service is IKeyBindingService)
552+ keybinder = null;
553 }
554
555 /// <summary>
556@@ -185,7 +188,15 @@
557 network = LocateService<INetworkService, Default.NetworkService> ();
558 return network;
559 }
560- }
561+ }
562+
563+ public static IKeyBindingService Keybinder {
564+ get {
565+ if (keybinder == null)
566+ keybinder = LocateService<IKeyBindingService, Default.KeyBindingService> ();
567+ return keybinder;
568+ }
569+ }
570
571 public static PreferencesFactory Preferences {
572 get {
573
574=== modified file 'Do/Do.csproj'
575--- Do/Do.csproj 2009-07-06 09:22:35 +0000
576+++ Do/Do.csproj 2009-07-19 02:56:23 +0000
577@@ -3,7 +3,7 @@
578 <PropertyGroup>
579 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
580 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
581- <ProductVersion>9.0.21022</ProductVersion>
582+ <ProductVersion>9.0.30729</ProductVersion>
583 <SchemaVersion>2.0</SchemaVersion>
584 <ProjectGuid>{182DAEB4-34D0-43C7-B0A1-034C72BA643C}</ProjectGuid>
585 <OutputType>Exe</OutputType>
586@@ -72,7 +72,6 @@
587 <DesignTime>True</DesignTime>
588 <DependentUpon>Resources.resx</DependentUpon>
589 </Compile>
590- <Compile Include="src\CoreKeybindings.cs" />
591 <Compile Include="src\CorePreferences.cs" />
592 <Compile Include="src\Do.Core\Controller.cs" />
593 <Compile Include="src\Do.Core\Do.Core.Addins\AddinClassifier.cs" />
594@@ -132,7 +131,6 @@
595 <Compile Include="src\Notifications.cs" />
596 <Compile Include="src\PathExtensions.cs" />
597 <Compile Include="src\Util.cs" />
598- <Compile Include="src\XKeybinder.cs" />
599 </ItemGroup>
600 <ItemGroup>
601 <EmbeddedResource Include="Do.addins">
602@@ -190,10 +188,6 @@
603 <Project>{7F9464B7-A890-4E54-AE06-F813E8D1E458}</Project>
604 <Name>Do.Universe</Name>
605 </ProjectReference>
606- <ProjectReference Include="..\ManagedWinapi\ManagedWinapi.csproj">
607- <Project>{FBD3EC1E-47E2-4D2D-81C9-D6506125A09A}</Project>
608- <Name>ManagedWinapi</Name>
609- </ProjectReference>
610 <ProjectReference Include="..\Mono.Addins.CecilReflector\Mono.Addins.CecilReflector.csproj">
611 <Project>{E7AAA09F-6715-45C5-903B-184452B52EBF}</Project>
612 <Name>Mono.Addins.CecilReflector</Name>
613
614=== removed file 'Do/src/CoreKeybindings.cs'
615--- Do/src/CoreKeybindings.cs 2009-06-23 05:57:47 +0000
616+++ Do/src/CoreKeybindings.cs 1970-01-01 00:00:00 +0000
617@@ -1,230 +0,0 @@
618-
619-/* Keybindings.cs
620- *
621- * GNOME Do is the legal property of its developers. Please refer to the
622- * COPYRIGHT file distributed with this
623- * source distribution.
624- *
625- * This program is free software: you can redistribute it and/or modify
626- * it under the terms of the GNU General Public License as published by
627- * the Free Software Foundation, either version 3 of the License, or
628- * (at your option) any later version.
629- *
630- * This program is distributed in the hope that it will be useful,
631- * but WITHOUT ANY WARRANTY; without even the implied warranty of
632- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
633- * GNU General Public License for more details.
634- *
635- * You should have received a copy of the GNU General Public License
636- * along with this program. If not, see <http://www.gnu.org/licenses/>.
637- */
638-
639-using System;
640-using System.Linq;
641-using System.Collections;
642-using System.Collections.Generic;
643-using Env = System.Environment;
644-
645-using Do.Platform;
646-
647-namespace Do
648-{
649-
650- class CoreKeybindings
651- {
652- Dictionary<string, string> KeycodeMap ; // keybinding -> shortcut name
653- Dictionary<string, Shortcut> ShortcutMap ; // shortcut name -> shortcut
654- Dictionary<string, string> DefaultShortcutMap ; // default keybinding -> shortcut name
655-
656- IPreferences Preferences { get; set; }
657-
658- public ArrayList Shortcuts ;
659- public Dictionary<string, List<KeyChangedCb>> PreferencesCbs;
660- public delegate void KeyChangedCb (object sender, PreferencesChangedEventArgs e);
661-
662- public CoreKeybindings ()
663- {
664-
665- Preferences = Services.Preferences.Get<CoreKeybindings> ();
666- Preferences.PreferencesChanged += PreferencesChanged;
667-
668- Shortcuts = new ArrayList ();
669- KeycodeMap = new Dictionary<string, string> (); // keybinding -> shortcut name
670- ShortcutMap = new Dictionary<string, Shortcut> (); // shortcut name -> shortcut
671- DefaultShortcutMap = new Dictionary<string, string> (); // default keybinding -> shortcut name
672- PreferencesCbs = new Dictionary<string, List<KeyChangedCb>> ();
673-
674- Initialize ();
675- }
676-
677- public void Initialize ()
678- {
679- // Read all values out of preferences and populate the KeybindingMap
680- ReadShortcuts ();
681- }
682-
683- public bool RegisterShortcut (Shortcut sc, string defaultBinding)
684- {
685- if (!RegisterShortcut (sc))
686- return false;
687- if (!BindDefault (sc, defaultBinding))
688- return false;
689- return true;
690- }
691-
692- public bool RegisterShortcut (Shortcut sc)
693- {
694- if (Shortcuts.Contains (sc) || ShortcutMap.ContainsKey (sc.ShortcutName))
695- return false;
696-
697- Shortcuts.Add (sc);
698- ShortcutMap [sc.ShortcutName] = sc;
699- PreferencesCbs [sc.ShortcutName] = new List<KeyChangedCb> ();
700- SaveShortcuts ();
701- return true;
702- }
703-
704- public Shortcut GetShortcutByKeycode (string keycode)
705- {
706- if (!KeycodeMap.ContainsKey (keycode))
707- return null;
708-
709- string scname = KeycodeMap [keycode];
710-
711- if (!ShortcutMap.ContainsKey (scname))
712- return null;
713-
714- return ShortcutMap [scname];
715-
716- }
717-
718- public string GetKeybinding (Shortcut sc)
719- {
720- return GetKeybinding (sc.ShortcutName);
721- }
722-
723- public string GetKeybinding (string sc)
724- {
725-
726- foreach (KeyValuePair<string, string> entry in KeycodeMap) {
727- if (entry.Value == sc)
728- return entry.Key;
729- }
730- return null;
731- }
732-
733- public string GetDefaultKeybinding (Shortcut sc)
734- {
735- return GetDefaultKeybinding (sc.ShortcutName);
736- }
737-
738- public string GetDefaultKeybinding (string sc)
739- {
740- foreach (KeyValuePair<string, string> entry in DefaultShortcutMap) {
741- if (entry.Value == sc)
742- return entry.Key;
743- }
744- return null;
745- }
746-
747-
748- public bool BindShortcut (Shortcut sc, string keycode)
749- {
750- // Add this function to our keybinding map
751- return BindShortcut (sc.ShortcutName, keycode);
752-
753- }
754-
755- public bool BindShortcut (string sc, string keycode)
756- {
757- string oldcode = GetKeybinding (sc);
758- if (oldcode != null)
759- KeycodeMap.Remove (oldcode); // remove the old keybinding from the map
760-
761- KeycodeMap [keycode] = sc;
762- Preferences.Set (sc, keycode);
763-
764- return true;
765- }
766-
767- // Add Default Keycode mapping - used for resetting to default or not overwriting read values
768- public bool BindDefault (Shortcut sc, string keycode)
769- {
770- return BindDefault (sc.ShortcutName, keycode);
771-
772- }
773-
774- public bool BindDefault (string sc, string keycode)
775- {
776-
777- string assigned_keycode = GetKeybinding (sc);
778- if (assigned_keycode == null) {
779- // Put this shortcut in the mapping
780- BindShortcut (sc, keycode);
781- }
782-
783- DefaultShortcutMap [keycode] = sc;
784- return true;
785-
786- }
787-
788- public bool UnregisterShortcut (Shortcut sc)
789- {
790- if (!Shortcuts.Contains (sc))
791- return false;
792-
793- Shortcuts.Remove (sc);
794- ShortcutMap.Remove (sc.ShortcutName);
795- SaveShortcuts ();
796- return true;
797- }
798-
799- public bool RegisterNotification (Shortcut sc, KeyChangedCb cb)
800- {
801- return RegisterNotification (sc.ShortcutName, cb);
802- }
803-
804- public bool RegisterNotification (string scname, KeyChangedCb cb)
805- {
806- PreferencesCbs [scname].Add (cb);
807- return true;
808- }
809-
810- void SaveShortcuts ()
811- {
812- string scstring = "";
813- foreach (Shortcut sc in Shortcuts) {
814- scstring += sc.ShortcutName.Trim () + ",";
815- }
816- Preferences.Set ("RegisteredShortcuts", scstring);
817- }
818-
819- void ReadShortcuts ()
820- {
821- string scstring = Preferences.Get ("RegisteredShortcuts", "").Trim ();
822- if (scstring == "")
823- return;
824-
825- foreach (string sc in scstring.Split (',')) {
826- if (sc.Trim () == "")
827- continue;
828-
829- string keycode = Preferences.Get (sc, "");
830- if (keycode != "")
831- BindShortcut (sc, keycode);
832- }
833- }
834-
835- void PreferencesChanged (object sender, PreferencesChangedEventArgs e)
836- {
837-
838- if (PreferencesCbs.ContainsKey (e.Key)) {
839- foreach (KeyChangedCb cb in PreferencesCbs [e.Key]) {
840- cb (this, e);
841- }
842- }
843- }
844-
845- }
846-
847-}
848
849=== modified file 'Do/src/Do.Core/Controller.cs'
850--- Do/src/Do.Core/Controller.cs 2009-06-23 05:57:47 +0000
851+++ Do/src/Do.Core/Controller.cs 2009-07-19 02:45:35 +0000
852@@ -29,7 +29,8 @@
853 using Do;
854 using Do.UI;
855 using Do.Universe;
856-using Do.Platform;
857+using Do.Platform;
858+using Do.Platform.Common;
859 using Do.Interface;
860
861 namespace Do.Core
862@@ -99,105 +100,42 @@
863 {
864 foreach (char c in e.Str)
865 SearchController.AddChar (c);
866- }
867-
868- public void Initialize ()
869- {
870- SetTheme (Do.Preferences.Theme);
871- Do.Preferences.ThemeChanged += OnThemeChanged;
872- Screen.Default.CompositedChanged += OnCompositingChanged;
873-
874- // Register Shortcuts
875- // TODO: Localize the text here.
876- // Previous shortcuts
877- Do.Keybindings.RegisterShortcut (
878- new Shortcut ("SummonKey",
879- Catalog.GetString ("Summon GNOME Do"),
880- OnSummonKeyPressEvent),
881- "<Super>space");
882- Do.Keybindings.RegisterShortcut (
883- new Shortcut ("TextModeKey",
884- Catalog.GetString ("Enter text mode"),
885- OnTextModePressEvent),
886- "period");
887- // New shortcuts
888- Do.Keybindings.RegisterShortcut (
889- new Shortcut ("CopyKey",
890- Catalog.GetString ("Copy Text"),
891- OnCopyEvent),
892- "<Control>c");
893- Do.Keybindings.RegisterShortcut (
894- new Shortcut ("PasteKey",
895- Catalog.GetString ("Paste Text"),
896- OnPasteEvent),
897- "<Control>v");
898- Do.Keybindings.RegisterShortcut (
899- new Shortcut ("AlternateEscapeKey",
900- Catalog.GetString ("Alternate Escape"),
901- OnEscapeKeyPressEvent));
902- Do.Keybindings.RegisterShortcut (
903- new Shortcut ("AlternateActivateKey",
904- Catalog.GetString ("Alternate Activate"),
905- OnActivateKeyPressEvent));
906- Do.Keybindings.RegisterShortcut (
907- new Shortcut ("AlternateDeleteKey",
908- Catalog.GetString ("Alternate Delete"),
909- OnDeleteKeyPressEvent));
910- Do.Keybindings.RegisterShortcut (
911- new Shortcut ("ShiftTabKey",
912- Catalog.GetString ("Previous Pane"),
913- OnShiftTabKeyPressEvent),
914- "ISO_Left_Tab");
915- Do.Keybindings.RegisterShortcut (
916- new Shortcut ("TabKey",
917- Catalog.GetString ("Next Pane"),
918- OnTabKeyPressEvent),
919- "Tab");
920- Do.Keybindings.RegisterShortcut (
921- new Shortcut ("UpKey",
922- Catalog.GetString ("Previous Result"),
923- OnUpKeyPressEvent),
924- "Up");
925- Do.Keybindings.RegisterShortcut (
926- new Shortcut ("DownKey",
927- Catalog.GetString ("Next Result"),
928- OnDownKeyPressEvent),
929- "Down");
930- Do.Keybindings.RegisterShortcut (
931- new Shortcut ("HomeKey",
932- Catalog.GetString ("First Result"),
933- OnHomeKeyPressEvent),
934- "Home");
935- Do.Keybindings.RegisterShortcut (
936- new Shortcut ("EndKey",
937- Catalog.GetString ("Last Result"),
938- OnEndKeyPressEvent),
939- "End");
940- Do.Keybindings.RegisterShortcut (
941- new Shortcut ("PageUpKey",
942- Catalog.GetString ("Previous 5 Results"),
943- OnPageUpKeyPressEvent),
944- "Page_Up");
945- Do.Keybindings.RegisterShortcut (
946- new Shortcut ("PageDownKey",
947- Catalog.GetString ("Next 5 Results"),
948- OnPageDownKeyPressEvent),
949- "Page_Down");
950- Do.Keybindings.RegisterShortcut (
951- new Shortcut ("LeftKey",
952- Catalog.GetString ("Step out of Item"),
953- OnLeftKeyPressEvent),
954- "Left");
955- Do.Keybindings.RegisterShortcut (
956- new Shortcut ("RightKey",
957- Catalog.GetString ("Browse Into Item"),
958- OnRightKeyPressEvent),
959- "Right");
960- Do.Keybindings.RegisterShortcut (
961- new Shortcut ("CommaKey",
962- Catalog.GetString ("Multiple selection"),
963- OnSelectionKeyPressEvent),
964- "comma");
965+ }
966+
967+ public void Initialize () {
968+ SetTheme (Do.Preferences.Theme);
969+ Do.Preferences.ThemeChanged += OnThemeChanged;
970+ Screen.Default.CompositedChanged += OnCompositingChanged;
971+
972+ // Register Shortcuts
973+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.EnterTextMode, Catalog.GetString ("Enter Text Mode"),
974+ "period", OnTextModePressEvent));
975+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.Copy, Catalog.GetString ("Copy to Clipboard"),
976+ "<Control>c", OnCopyEvent));
977+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.Paste, Catalog.GetString ("Paste Current Text"),
978+ "<Control>v", OnPasteEvent));
979+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.PreviousPane, Catalog.GetString ("Previous Pane"),
980+ "ISO_Left_Tab", OnPreviousPanePressEvent));
981+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.NextPane, Catalog.GetString ("Next Pane"),
982+ "Tab", OnNextPanePressEvent));
983+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.Up , Catalog.GetString ("Previous Item"),
984+ "Up", OnUpKeyPressEvent));
985+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.Down, Catalog.GetString ("Next Item"),
986+ "Down", OnDownKeyPressEvent));
987+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.First, Catalog.GetString ("First Item"),
988+ "Home", OnHomeKeyPressEvent));
989+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.Last, Catalog.GetString ("Last Item"),
990+ "End", OnEndKeyPressEvent));
991+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.PageLast, Catalog.GetString ("Previous 5 Results"),
992+ "Page_Up", OnPageUpKeyPressEvent));
993+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.PageNext, Catalog.GetString ("Next 5 Results"),
994+ "Page_Down", OnPageDownKeyPressEvent));
995+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.Left, Catalog.GetString ("Step Out of Item"),
996+ "Left", OnLeftKeyPressEvent));
997+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.Right, Catalog.GetString ("Browse Into Item"),
998+ "Right", OnRightKeyPressEvent));
999+ Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.MultiSelect, Catalog.GetString ("Select Multiple Items"),
1000+ "comma", OnSelectionKeyPressEvent));
1001 }
1002
1003 void OnSummoned ()
1004@@ -508,11 +446,11 @@
1005 key == Key.BackSpace) {
1006 OnDeleteKeyPressEvent (evnt);
1007 } else {
1008- // User set keybindings
1009- Shortcut sc = Do.Keybindings.GetShortcutByKeycode (KeyEventToString (evnt));
1010- if (sc != null) {
1011- sc.Callback (evnt);
1012- return;
1013+ // User set keybindings
1014+ KeyEvent eve = Services.Keybinder.GetEvent (KeyEventToString (evnt));
1015+ if (eve != null) {
1016+ eve.Callback (evnt);
1017+ return;
1018 }
1019 OnInputKeyPressEvent (evnt);
1020 }
1021@@ -648,7 +586,7 @@
1022 if (SearchController.ItemChildSearch ()) GrowResults ();
1023 }
1024
1025- void OnTabKeyPressEvent (EventKey evnt)
1026+ void OnNextPanePressEvent (EventKey evnt)
1027 {
1028 im_context.Reset ();
1029 ShrinkResults ();
1030@@ -661,7 +599,7 @@
1031 UpdatePane (CurrentPane);
1032 }
1033
1034- void OnShiftTabKeyPressEvent (EventKey evnt)
1035+ void OnPreviousPanePressEvent (EventKey evnt)
1036 {
1037 im_context.Reset ();
1038 ShrinkResults ();
1039@@ -759,7 +697,8 @@
1040 }
1041 if ((evnt.State & ModifierType.Mod1Mask) != 0) {
1042 modifier += "<Alt>";
1043- }
1044+ }
1045+
1046 return modifier + evnt.Key.ToString ();
1047 }
1048 #endregion
1049
1050=== modified file 'Do/src/Do.UI/KeybindingTreeView.cs'
1051--- Do/src/Do.UI/KeybindingTreeView.cs 2009-06-23 05:57:47 +0000
1052+++ Do/src/Do.UI/KeybindingTreeView.cs 2009-07-20 05:32:59 +0000
1053@@ -19,9 +19,14 @@
1054 */
1055
1056
1057-using System;
1058+using System;
1059+using System.Linq;
1060+
1061 using Gtk;
1062-using Mono.Unix;
1063+using Mono.Unix;
1064+
1065+using Do.Platform;
1066+using Do.Platform.Common;
1067
1068 namespace Do.UI
1069 {
1070@@ -31,20 +36,20 @@
1071 Action = 0,
1072 Binding,
1073 DefaultKeybinding,
1074- ShortcutName,
1075+ KeyEvent,
1076 NumColumns
1077 }
1078
1079 public KeybindingTreeView ()
1080 {
1081- Model = new ListStore (typeof (string), typeof (string), typeof (string), typeof (string));
1082+ Model = new ListStore (typeof (string), typeof (string), typeof (string), typeof (DoKeyEvents));
1083
1084 CellRendererText actionCell = new CellRendererText ();
1085 actionCell.Width = 150;
1086 InsertColumn (-1, Catalog.GetString ("Action"), actionCell, "text", (int)Column.Action);
1087
1088- CellRendererAccel bindingCell = new CellRendererAccel ();
1089- bindingCell.AccelMode = CellRendererAccelMode.Gtk;
1090+ CellRendererAccel bindingCell = new CellRendererAccel ();
1091+ bindingCell.AccelMode = CellRendererAccelMode.Other;
1092 bindingCell.Editable = true;
1093 bindingCell.AccelEdited += new AccelEditedHandler (OnAccelEdited);
1094 bindingCell.AccelCleared += new AccelClearedHandler (OnAccelCleared);
1095@@ -64,11 +69,10 @@
1096 private void AddBindings ()
1097 {
1098 ListStore store = Model as ListStore;
1099- store.Clear ();
1100-
1101- foreach (Shortcut sc in Do.Keybindings.Shortcuts) {
1102- store.AppendValues (sc.FriendlyName, Do.Keybindings.GetKeybinding (sc),
1103- Do.Keybindings.GetDefaultKeybinding (sc), sc.ShortcutName);
1104+ store.Clear ();
1105+
1106+ foreach (KeyEvent evnt in Services.Keybinder.BoundEvents.OrderBy (k => k.DisplayName)) {
1107+ store.AppendValues (evnt.DisplayName, evnt.KeyString, evnt.DefaultKeyString, evnt.EventName);
1108 }
1109 }
1110
1111@@ -142,15 +146,21 @@
1112
1113 private bool SaveBindingsForeachFunc (TreeModel model, TreePath path, TreeIter iter)
1114 {
1115- string binding, shortcutname;
1116- binding = model.GetValue (iter, (int) Column.Binding) as string;
1117- shortcutname = model.GetValue (iter, (int) Column.ShortcutName) as string;
1118-
1119- if (binding != null && binding != "DISABLED" && binding != Do.Keybindings.GetKeybinding (shortcutname))
1120- Do.Keybindings.BindShortcut (shortcutname, binding);
1121+ string newKeyString;
1122+ newKeyString = model.GetValue (iter, (int) Column.Binding) as string;
1123+
1124+ DoKeyEvents keyEvent = (DoKeyEvents) model.GetValue (iter, (int) Column.KeyEvent);
1125+
1126+ if (newKeyString != null) {
1127+ //try to save
1128+ if (!Services.Keybinder.SetKeyString (keyEvent, newKeyString)) {
1129+ //if we fail reset to the default value
1130+ KeyEvent evnt = Services.Keybinder.GetEvent (keyEvent);
1131+ model.SetValue (iter, (int) Column.Binding, evnt.DefaultKeyString);
1132+ Services.Keybinder.SetKeyString (keyEvent, evnt.DefaultKeyString);
1133+ }
1134+ }
1135 return false;
1136 }
1137-
1138 }
1139-
1140 }
1141
1142=== modified file 'Do/src/Do.cs'
1143--- Do/src/Do.cs 2009-06-23 20:13:50 +0000
1144+++ Do/src/Do.cs 2009-07-20 05:32:59 +0000
1145@@ -26,18 +26,17 @@
1146
1147 using Do.UI;
1148 using Do.Core;
1149-using Do.Platform;
1150+using Do.Platform;
1151+using Do.Platform.Common;
1152
1153 namespace Do {
1154
1155 static class Do {
1156
1157- static XKeybinder keybinder;
1158 static Controller controller;
1159 static UniverseManager universe_manager;
1160
1161 public static CorePreferences Preferences { get; private set; }
1162- public static CoreKeybindings Keybindings { get; private set; }
1163
1164 internal static void Main (string [] args)
1165 {
1166@@ -55,8 +54,6 @@
1167
1168 Preferences = new CorePreferences ();
1169
1170- Keybindings = new CoreKeybindings ();
1171-
1172 // Now we can set the preferred log level.
1173 if (Preferences.QuietStart)
1174 Log.DisplayLevel = LogLevel.Error;
1175@@ -75,7 +72,6 @@
1176 Controller.Initialize ();
1177 UniverseManager.Initialize ();
1178
1179- keybinder = new XKeybinder ();
1180 SetupKeybindings ();
1181
1182 if (!Preferences.QuietStart)
1183@@ -102,37 +98,18 @@
1184 return universe_manager;
1185 }
1186 }
1187-
1188- static void SummonKeyCb (object sender, PreferencesChangedEventArgs e)
1189- {
1190- try {
1191- if (e.OldValue != null)
1192- keybinder.Unbind (e.OldValue as string);
1193- keybinder.Bind (Keybindings.GetKeybinding ("SummonKey"), OnActivate);
1194- } catch (Exception ex) {
1195- Log.Error ("Could not bind summon key: {0}", ex.Message);
1196- Log.Debug (ex.StackTrace);
1197- }
1198-
1199- }
1200
1201 static void SetupKeybindings ()
1202 {
1203- try {
1204- keybinder.Bind (Keybindings.GetKeybinding ("SummonKey"), OnActivate);
1205+ try {
1206+ if (!Services.Keybinder.RegisterKeyEvent (new KeyEvent (DoKeyEvents.Summon, Catalog.GetString ("Summon Do"),
1207+ "<Shift>space", delegate { controller.Summon (); })))
1208+ throw new Exception ("Could not bind summon key from preferences value or default.");
1209 } catch (Exception e) {
1210 Log.Error ("Could not bind summon key: {0}", e.Message);
1211- Log.Debug (e.StackTrace);
1212+ Log.Debug (e.StackTrace);
1213+ Gtk.Application.Quit ();
1214 }
1215-
1216- // Watch preferences for changes to the keybinding so we
1217- // can change the binding when the user reassigns it.
1218- Keybindings.RegisterNotification ("SummonKey", SummonKeyCb);
1219- }
1220-
1221- static void OnActivate (object sender, EventArgs e)
1222- {
1223- controller.Summon ();
1224 }
1225 }
1226-}
1227+}
1228\ No newline at end of file
1229
1230=== removed file 'Do/src/XKeybinder.cs'
1231--- Do/src/XKeybinder.cs 2009-06-24 06:06:11 +0000
1232+++ Do/src/XKeybinder.cs 1970-01-01 00:00:00 +0000
1233@@ -1,116 +0,0 @@
1234-/*****************************************************************************/
1235-/* XKeybinder.cs - Keybinding code taken from Tomboy */
1236-/* Copyright (C) 2004-2007 Alex Graveley <alex@beatniksoftware.com> */
1237-/* */
1238-/* This library is free software; you can redistribute it and/or */
1239-/* modify it under the terms of the GNU Lesser General Public */
1240-/* License as published by the Free Software Foundation; either */
1241-/* version 2.1 of the License, or (at your option) any later version. */
1242-/* */
1243-/* This library is distributed in the hope that it will be useful, */
1244-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
1245-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
1246-/* Lesser General Public License for more details. */
1247-/* */
1248-/* You should have received a copy of the GNU Lesser General Public */
1249-/* License along with this library; if not, write to the Free Software */
1250-/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1251-/*****************************************************************************/
1252-
1253-using System;
1254-using System.Collections;
1255-using System.Collections.Generic;
1256-using System.Runtime.InteropServices;
1257-using System.Windows.Forms;
1258-
1259-using Do.Platform;
1260-using ManagedWinapi;
1261-using System.Text.RegularExpressions;
1262-using System.Globalization;
1263-
1264-namespace Do
1265-{
1266- public class XKeybinder
1267- {
1268- public delegate void BindkeyHandler (string key, IntPtr user_data);
1269-
1270- /// <summary>
1271- /// Key bindings, key string -> Binding
1272- /// </summary>
1273- private Dictionary<string, Binding> bindings;
1274- BindkeyHandler key_handler;
1275-
1276- private Regex rexp = new Regex ("<.*>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
1277-
1278- struct Binding {
1279- internal string keystring;
1280- internal EventHandler handler;
1281- internal Hotkey hkey;
1282- }
1283-
1284- public XKeybinder ()
1285- : base ()
1286- {
1287- bindings = new Dictionary<string, Binding> ();
1288- key_handler = new BindkeyHandler (KeybindingPressed);
1289- }
1290-
1291- void KeybindingPressed (string keystring, IntPtr user_data)
1292- {
1293- if (bindings.ContainsKey (keystring)) {
1294- bindings [keystring].handler (this, new EventArgs ());
1295- }
1296- }
1297-
1298- public void Bind (string keystring, EventHandler handler)
1299- {
1300- Hotkey new_key = new Hotkey ();
1301- new_key.HotkeyPressed += handler;
1302-
1303- // determine modifiers to use
1304- if (keystring.ToLower ().Contains ("super"))
1305- new_key.WindowsKey = true;
1306-
1307- if (keystring.ToLower ().Contains ("shift"))
1308- new_key.Shift = true;
1309-
1310- if (keystring.ToLower ().Contains ("alt"))
1311- new_key.Alt = true;
1312-
1313- if (keystring.ToLower ().Contains ("ctrl"))
1314- new_key.Ctrl = true;
1315-
1316- // figure out what the key is...this is so incredibly hacky but it should work for most cases
1317- // -- ootz0rz
1318- string thekey = rexp.Replace (keystring, "");
1319- thekey = CultureInfo.CurrentCulture.TextInfo.ToTitleCase (thekey);
1320- new_key.KeyCode = (Keys) Enum.Parse (typeof (Keys), thekey);
1321-
1322- // enable the bind
1323- new_key.Enabled = true;
1324-
1325- Binding bind = new Binding ();
1326- bind.keystring = keystring;
1327- bind.handler = handler;
1328- bind.hkey = new_key;
1329- bindings.Add (keystring, bind);
1330- }
1331-
1332- public void Unbind (string keystring)
1333- {
1334- if (bindings.ContainsKey (keystring)) {
1335- bindings [keystring].hkey.Enabled = false;
1336- bindings [keystring].hkey.HotkeyPressed -= bindings [keystring].handler;
1337- bindings [keystring].hkey.Dispose ();
1338- bindings.Remove (keystring);
1339- }
1340- }
1341-
1342- public virtual void UnbindAll ()
1343- {
1344- foreach (string key in bindings.Keys) {
1345- Unbind (key);
1346- }
1347- }
1348- }
1349-}
1350
1351=== removed directory 'ManagedWinapi'
1352=== removed file 'ManagedWinapi/AccessibleObjectListener.cs'
1353--- ManagedWinapi/AccessibleObjectListener.cs 2009-06-24 06:06:11 +0000
1354+++ ManagedWinapi/AccessibleObjectListener.cs 1970-01-01 00:00:00 +0000
1355@@ -1,522 +0,0 @@
1356-/*
1357- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
1358- * access native API by managed code. http://mwinapi.sourceforge.net/
1359- * Copyright (C) 2006, 2007 Michael Schierl
1360- *
1361- * This library is free software; you can redistribute it and/or
1362- * modify it under the terms of the GNU Lesser General Public
1363- * License as published by the Free Software Foundation; either
1364- * version 2.1 of the License, or (at your option) any later version.
1365- * This library is distributed in the hope that it will be useful,
1366- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1367- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1368- * Lesser General Public License for more details.
1369- *
1370- * You should have received a copy of the GNU Lesser General Public
1371- * License along with this library; see the file COPYING. if not, visit
1372- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
1373- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1374- */
1375-using System;
1376-using System.ComponentModel;
1377-using System.Runtime.InteropServices;
1378-using Accessibility;
1379-
1380-namespace ManagedWinapi.Accessibility
1381-{
1382- /// <summary>
1383- /// Listens to events from the Windows accessibility system. These events are useful
1384- /// if you want to write a screenreader or similar program.
1385- /// </summary>
1386- public class AccessibleEventListener : Component
1387- {
1388- /// <summary>
1389- /// Occurs when an accessible event is received.
1390- /// </summary>
1391- public event AccessibleEventHandler EventOccurred;
1392-
1393- private bool enabled;
1394- private IntPtr handle = IntPtr.Zero;
1395- private AccessibleEventType min = AccessibleEventType.EVENT_MIN;
1396- private AccessibleEventType max = AccessibleEventType.EVENT_MAX;
1397- private WinEventDelegate internalDelegate;
1398- private GCHandle gch;
1399- private UInt32 processId = 0;
1400- private UInt32 threadId = 0;
1401-
1402- /// <summary>
1403- /// Initializes a new instance of this class with the specified container.
1404- /// </summary>
1405- /// <param name="container">The container to add it to.</param>
1406- public AccessibleEventListener(IContainer container)
1407- : this()
1408- {
1409- container.Add(this);
1410- }
1411-
1412- /// <summary>
1413- /// Initializes a new instance of this class.
1414- /// </summary>
1415- public AccessibleEventListener()
1416- {
1417- internalDelegate = new WinEventDelegate(InternalCallback);
1418- gch = GCHandle.Alloc(internalDelegate);
1419- }
1420-
1421- /// <summary>
1422- /// Enables this listener so that it reports accessible events.
1423- /// </summary>
1424- public bool Enabled
1425- {
1426- get
1427- {
1428- return enabled;
1429- }
1430- set
1431- {
1432- enabled = value;
1433- updateListener();
1434- }
1435- }
1436-
1437- /// <summary>
1438- /// The minimal event type to listen to.
1439- /// </summary>
1440- public AccessibleEventType MinimalEventType
1441- {
1442- get { return min; }
1443- set { min = value; updateListener(); }
1444- }
1445-
1446- /// <summary>
1447- /// The maximal event type to listen to.
1448- /// </summary>
1449- public AccessibleEventType MaximalEventType
1450- {
1451- get { return max; }
1452- set { max = value; updateListener(); }
1453- }
1454-
1455- /// <summary>
1456- /// The Process ID to listen to.
1457- /// Default 0 listens to all processes.
1458- /// </summary>
1459- public UInt32 ProcessId
1460- {
1461- get { return processId; }
1462- set { processId = value; updateListener(); }
1463- }
1464-
1465- /// <summary>
1466- /// The Thread ID to listen to.
1467- /// Default 0 listens to all threads.
1468- /// </summary>
1469- public UInt32 ThreadId
1470- {
1471- get { return threadId; }
1472- set { threadId = value; updateListener(); }
1473- }
1474-
1475- private void updateListener()
1476- {
1477- if (handle != IntPtr.Zero)
1478- {
1479- UnhookWinEvent(handle);
1480- handle = IntPtr.Zero;
1481- }
1482- if (enabled)
1483- {
1484- handle = SetWinEventHook(min, max, IntPtr.Zero, internalDelegate, processId, threadId, 0);
1485- }
1486- }
1487-
1488- /// <summary>
1489- /// Releases all resources used by the System.ComponentModel.Component.
1490- /// </summary>
1491- /// <param name="disposing">Whether to dispose managed resources.</param>
1492- protected override void Dispose(bool disposing)
1493- {
1494- if (enabled)
1495- {
1496- enabled = false;
1497- updateListener();
1498- }
1499- gch.Free();
1500- base.Dispose(disposing);
1501- }
1502-
1503- private void InternalCallback(IntPtr hWinEventHook, AccessibleEventType eventType,
1504- IntPtr hwnd, uint idObject, uint idChild, uint dwEventThread, uint dwmsEventTime)
1505- {
1506- if (hWinEventHook != handle) return;
1507- AccessibleEventArgs aea = new AccessibleEventArgs(eventType, hwnd, idObject, idChild, dwEventThread, dwmsEventTime);
1508- if (EventOccurred != null)
1509- EventOccurred(this, aea);
1510- }
1511-
1512- internal static SystemAccessibleObject GetAccessibleObject(AccessibleEventArgs e)
1513- {
1514- IAccessible iacc;
1515- object child;
1516- uint result = AccessibleObjectFromEvent(e.HWnd, e.ObjectID, e.ChildID, out iacc, out child);
1517- if (result != 0) throw new Exception("AccessibleObjectFromPoint returned " + result);
1518- return new SystemAccessibleObject(iacc, (int)child);
1519- }
1520-
1521- #region PInvoke Declarations
1522-
1523- [DllImport("user32.dll")]
1524- private static extern IntPtr SetWinEventHook(AccessibleEventType eventMin, AccessibleEventType eventMax, IntPtr
1525- hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess,
1526- uint idThread, uint dwFlags);
1527-
1528- [DllImport("user32.dll")]
1529- static extern bool UnhookWinEvent(IntPtr hWinEventHook);
1530-
1531- private delegate void WinEventDelegate(IntPtr hWinEventHook, AccessibleEventType eventType,
1532- IntPtr hwnd, uint idObject, uint idChild, uint dwEventThread, uint dwmsEventTime);
1533-
1534- [DllImport("oleacc.dll")]
1535- private static extern uint AccessibleObjectFromEvent(IntPtr hwnd, uint dwObjectID, uint dwChildID, out IAccessible ppacc, [MarshalAs(UnmanagedType.Struct)] out object pvarChild);
1536-
1537- #endregion
1538- }
1539-
1540- /// <summary>
1541- /// Represents the method that will handle accessibility events.
1542- /// </summary>
1543- public delegate void AccessibleEventHandler(object sender, AccessibleEventArgs e);
1544-
1545- /// <summary>
1546- /// Provides data for accessible events.
1547- /// </summary>
1548- public class AccessibleEventArgs : EventArgs
1549- {
1550- private AccessibleEventType eventType;
1551- private IntPtr hWnd;
1552- private uint idObject;
1553- private uint idChild;
1554- private uint dwEventThread;
1555- private uint dwmsEventTime;
1556-
1557- /// <summary>
1558- /// Initializes a new instance of the AccessibleEventArgs class.
1559- /// </summary>
1560- public AccessibleEventArgs(AccessibleEventType eventType,
1561- IntPtr hwnd, uint idObject, uint idChild, uint dwEventThread, uint dwmsEventTime)
1562- {
1563- this.eventType = eventType;
1564- this.hWnd = hwnd;
1565- this.idObject = idObject;
1566- this.idChild = idChild;
1567- this.dwEventThread = dwEventThread;
1568- this.dwmsEventTime = dwmsEventTime;
1569- }
1570-
1571- /// <summary>
1572- /// Type of this accessible event
1573- /// </summary>
1574- public AccessibleEventType EventType
1575- {
1576- get { return eventType; }
1577- }
1578-
1579- /// <summary>
1580- /// Handle of the affected window, if any.
1581- /// </summary>
1582- public IntPtr HWnd
1583- {
1584- get { return hWnd; }
1585- }
1586-
1587- /// <summary>
1588- /// Object ID.
1589- /// </summary>
1590- public uint ObjectID
1591- {
1592- get { return idObject; }
1593- }
1594-
1595- /// <summary>
1596- /// Child ID.
1597- /// </summary>
1598- public uint ChildID
1599- {
1600- get { return idChild; }
1601- }
1602-
1603- /// <summary>
1604- /// The thread that generated this event.
1605- /// </summary>
1606- public uint Thread
1607- {
1608- get { return dwEventThread; }
1609- }
1610-
1611- /// <summary>
1612- /// Time in milliseconds when the event was generated.
1613- /// </summary>
1614- public uint Time
1615- {
1616- get { return dwmsEventTime; }
1617- }
1618-
1619- /// <summary>
1620- /// The accessible object related to this event.
1621- /// </summary>
1622- public SystemAccessibleObject AccessibleObject
1623- {
1624- get
1625- {
1626- return AccessibleEventListener.GetAccessibleObject(this);
1627- }
1628- }
1629- }
1630-
1631- /// <summary>
1632- /// This enumeration lists known accessible event types.
1633- /// </summary>
1634- public enum AccessibleEventType
1635- {
1636- /// <summary>
1637- /// Sent when a sound is played. Currently nothing is generating this, we
1638- /// are going to be cleaning up the SOUNDSENTRY feature in the control panel
1639- /// and will use this at that time. Applications implementing WinEvents
1640- /// are perfectly welcome to use it. Clients of IAccessible* will simply
1641- /// turn around and get back a non-visual object that describes the sound.
1642- /// </summary>
1643- EVENT_SYSTEM_SOUND = 0x0001,
1644-
1645- /// <summary>
1646- /// Sent when an alert needs to be given to the user. MessageBoxes generate
1647- /// alerts for example.
1648- /// </summary>
1649- EVENT_SYSTEM_ALERT = 0x0002,
1650-
1651- /// <summary>
1652- /// Sent when the foreground (active) window changes, even if it is changing
1653- /// to another window in the same thread as the previous one.
1654- /// </summary>
1655- EVENT_SYSTEM_FOREGROUND = 0x0003,
1656-
1657- /// <summary>
1658- /// Sent when entering into and leaving from menu mode (system, app bar, and
1659- /// track popups).
1660- /// </summary>
1661- EVENT_SYSTEM_MENUSTART = 0x0004,
1662-
1663- /// <summary>
1664- /// Sent when entering into and leaving from menu mode (system, app bar, and
1665- /// track popups).
1666- /// </summary>
1667- EVENT_SYSTEM_MENUEND = 0x0005,
1668-
1669- /// <summary>
1670- /// Sent when a menu popup comes up and just before it is taken down. Note
1671- /// that for a call to TrackPopupMenu(), a client will see EVENT_SYSTEM_MENUSTART
1672- /// followed almost immediately by EVENT_SYSTEM_MENUPOPUPSTART for the popup
1673- /// being shown.
1674- /// </summary>
1675- EVENT_SYSTEM_MENUPOPUPSTART = 0x0006,
1676-
1677- /// <summary>
1678- /// Sent when a menu popup comes up and just before it is taken down. Note
1679- /// that for a call to TrackPopupMenu(), a client will see EVENT_SYSTEM_MENUSTART
1680- /// followed almost immediately by EVENT_SYSTEM_MENUPOPUPSTART for the popup
1681- /// being shown.
1682- /// </summary>
1683- EVENT_SYSTEM_MENUPOPUPEND = 0x0007,
1684-
1685-
1686- /// <summary>
1687- /// Sent when a window takes the capture and releases the capture.
1688- /// </summary>
1689- EVENT_SYSTEM_CAPTURESTART = 0x0008,
1690-
1691- /// <summary>
1692- /// Sent when a window takes the capture and releases the capture.
1693- /// </summary>
1694- EVENT_SYSTEM_CAPTUREEND = 0x0009,
1695-
1696- /// <summary>
1697- /// Sent when a window enters and leaves move-size dragging mode.
1698- /// </summary>
1699- EVENT_SYSTEM_MOVESIZESTART = 0x000A,
1700-
1701- /// <summary>
1702- /// Sent when a window enters and leaves move-size dragging mode.
1703- /// </summary>
1704- EVENT_SYSTEM_MOVESIZEEND = 0x000B,
1705-
1706- /// <summary>
1707- /// Sent when a window enters and leaves context sensitive help mode.
1708- /// </summary>
1709- EVENT_SYSTEM_CONTEXTHELPSTART = 0x000C,
1710-
1711- /// <summary>
1712- /// Sent when a window enters and leaves context sensitive help mode.
1713- /// </summary>
1714- EVENT_SYSTEM_CONTEXTHELPEND = 0x000D,
1715-
1716- /// <summary>
1717- /// Sent when a window enters and leaves drag drop mode. Note that it is up
1718- /// to apps and OLE to generate this, since the system doesn't know. Like
1719- /// EVENT_SYSTEM_SOUND, it will be a while before this is prevalent.
1720- /// </summary>
1721- EVENT_SYSTEM_DRAGDROPSTART = 0x000E,
1722-
1723- /// <summary>
1724- /// Sent when a window enters and leaves drag drop mode. Note that it is up
1725- /// to apps and OLE to generate this, since the system doesn't know. Like
1726- /// EVENT_SYSTEM_SOUND, it will be a while before this is prevalent.
1727- /// </summary>
1728- EVENT_SYSTEM_DRAGDROPEND = 0x000F,
1729-
1730- /// <summary>
1731- /// Sent when a dialog comes up and just before it goes away.
1732- /// </summary>
1733- EVENT_SYSTEM_DIALOGSTART = 0x0010,
1734-
1735- /// <summary>
1736- /// Sent when a dialog comes up and just before it goes away.
1737- /// </summary>
1738- EVENT_SYSTEM_DIALOGEND = 0x0011,
1739-
1740- /// <summary>
1741- /// Sent when beginning and ending the tracking of a scrollbar in a window,
1742- /// and also for scrollbar controls.
1743- /// </summary>
1744- EVENT_SYSTEM_SCROLLINGSTART = 0x0012,
1745-
1746- /// <summary>
1747- /// Sent when beginning and ending the tracking of a scrollbar in a window,
1748- /// and also for scrollbar controls.
1749- /// </summary>
1750- EVENT_SYSTEM_SCROLLINGEND = 0x0013,
1751-
1752- /// <summary>
1753- /// Sent when beginning and ending alt-tab mode with the switch window.
1754- /// </summary>
1755- EVENT_SYSTEM_SWITCHSTART = 0x0014,
1756-
1757- /// <summary>
1758- /// Sent when beginning and ending alt-tab mode with the switch window.
1759- /// </summary>
1760- EVENT_SYSTEM_SWITCHEND = 0x0015,
1761-
1762- /// <summary>
1763- /// Sent when a window minimizes.
1764- /// </summary>
1765- EVENT_SYSTEM_MINIMIZESTART = 0x0016,
1766-
1767- /// <summary>
1768- /// Sent just before a window restores.
1769- /// </summary>
1770- EVENT_SYSTEM_MINIMIZEEND = 0x0017,
1771-
1772- /// <summary>
1773- /// hwnd + ID + idChild is created item
1774- /// </summary>
1775- EVENT_OBJECT_CREATE = 0x8000,
1776-
1777- /// <summary>
1778- /// hwnd + ID + idChild is destroyed item
1779- /// </summary>
1780- EVENT_OBJECT_DESTROY = 0x8001,
1781-
1782- /// <summary>
1783- /// hwnd + ID + idChild is shown item
1784- /// </summary>
1785- EVENT_OBJECT_SHOW = 0x8002,
1786-
1787- /// <summary>
1788- /// hwnd + ID + idChild is hidden item
1789- /// </summary>
1790- EVENT_OBJECT_HIDE = 0x8003,
1791-
1792- /// <summary>
1793- /// hwnd + ID + idChild is parent of zordering children
1794- /// </summary>
1795- EVENT_OBJECT_REORDER = 0x8004,
1796-
1797- /// <summary>
1798- /// hwnd + ID + idChild is focused item
1799- /// </summary>
1800- EVENT_OBJECT_FOCUS = 0x8005,
1801-
1802- /// <summary>
1803- /// hwnd + ID + idChild is selected item (if only one), or idChild is OBJID_WINDOW if complex
1804- /// </summary>
1805- EVENT_OBJECT_SELECTION = 0x8006,
1806-
1807- /// <summary>
1808- /// hwnd + ID + idChild is item added
1809- /// </summary>
1810- EVENT_OBJECT_SELECTIONADD = 0x8007,
1811-
1812- /// <summary>
1813- /// hwnd + ID + idChild is item removed
1814- /// </summary>
1815- EVENT_OBJECT_SELECTIONREMOVE = 0x8008,
1816-
1817- /// <summary>
1818- /// hwnd + ID + idChild is parent of changed selected items
1819- /// </summary>
1820- EVENT_OBJECT_SELECTIONWITHIN = 0x8009,
1821-
1822- /// <summary>
1823- /// hwnd + ID + idChild is item w/ state change
1824- /// </summary>
1825- EVENT_OBJECT_STATECHANGE = 0x800A,
1826-
1827- /// <summary>
1828- /// hwnd + ID + idChild is moved/sized item
1829- /// </summary>
1830- EVENT_OBJECT_LOCATIONCHANGE = 0x800B,
1831-
1832- /// <summary>
1833- /// hwnd + ID + idChild is item w/ name change
1834- /// </summary>
1835- EVENT_OBJECT_NAMECHANGE = 0x800C,
1836-
1837- /// <summary>
1838- /// hwnd + ID + idChild is item w/ desc change
1839- /// </summary>
1840- EVENT_OBJECT_DESCRIPTIONCHANGE = 0x800D,
1841-
1842- /// <summary>
1843- /// hwnd + ID + idChild is item w/ value change
1844- /// </summary>
1845- EVENT_OBJECT_VALUECHANGE = 0x800E,
1846-
1847- /// <summary>
1848- /// hwnd + ID + idChild is item w/ new parent
1849- /// </summary>
1850- EVENT_OBJECT_PARENTCHANGE = 0x800F,
1851-
1852- /// <summary>
1853- /// hwnd + ID + idChild is item w/ help change
1854- /// </summary>
1855- EVENT_OBJECT_HELPCHANGE = 0x8010,
1856-
1857- /// <summary>
1858- /// hwnd + ID + idChild is item w/ def action change
1859- /// </summary>
1860- EVENT_OBJECT_DEFACTIONCHANGE = 0x8011,
1861-
1862- /// <summary>
1863- /// hwnd + ID + idChild is item w/ keybd accel change
1864- /// </summary>
1865- EVENT_OBJECT_ACCELERATORCHANGE = 0x8012,
1866-
1867- /// <summary>
1868- /// The lowest possible event value
1869- /// </summary>
1870- EVENT_MIN = 0x00000001,
1871-
1872- /// <summary>
1873- /// The highest possible event value
1874- /// </summary>
1875- EVENT_MAX = 0x7FFFFFFF,
1876- }
1877-}
1878
1879=== removed file 'ManagedWinapi/ApiHelper.cs'
1880--- ManagedWinapi/ApiHelper.cs 2009-06-24 06:06:11 +0000
1881+++ ManagedWinapi/ApiHelper.cs 1970-01-01 00:00:00 +0000
1882@@ -1,62 +0,0 @@
1883-/*
1884- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
1885- * access native API by managed code. http://mwinapi.sourceforge.net/
1886- * Copyright (C) 2006 Michael Schierl
1887- *
1888- * This library is free software; you can redistribute it and/or
1889- * modify it under the terms of the GNU Lesser General Public
1890- * License as published by the Free Software Foundation; either
1891- * version 2.1 of the License, or (at your option) any later version.
1892- * This library is distributed in the hope that it will be useful,
1893- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1894- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1895- * Lesser General Public License for more details.
1896- *
1897- * You should have received a copy of the GNU Lesser General Public
1898- * License along with this library; see the file COPYING. if not, visit
1899- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
1900- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1901- */
1902-using System;
1903-using System.Collections.Generic;
1904-using System.Text;
1905-using System.ComponentModel;
1906-using System.Runtime.InteropServices;
1907-
1908-namespace ManagedWinapi
1909-{
1910- /// <summary>
1911- /// Helper class that contains static methods useful for API programming. This
1912- /// class is not exposed to the user.
1913- /// </summary>
1914- internal class ApiHelper
1915- {
1916- /// <summary>
1917- /// Throw a <see cref="Win32Exception"/> if the supplied (return) value is zero.
1918- /// This exception uses the last Win32 error code as error message.
1919- /// </summary>
1920- /// <param name="returnValue">The return value to test.</param>
1921- internal static int FailIfZero(int returnValue)
1922- {
1923- if (returnValue == 0)
1924- {
1925- throw new Win32Exception(Marshal.GetLastWin32Error());
1926- }
1927- return returnValue;
1928- }
1929-
1930- /// <summary>
1931- /// Throw a <see cref="Win32Exception"/> if the supplied (return) value is zero.
1932- /// This exception uses the last Win32 error code as error message.
1933- /// </summary>
1934- /// <param name="returnValue">The return value to test.</param>
1935- internal static IntPtr FailIfZero(IntPtr returnValue)
1936- {
1937- if (returnValue == IntPtr.Zero)
1938- {
1939- throw new Win32Exception(Marshal.GetLastWin32Error());
1940- }
1941- return returnValue;
1942- }
1943- }
1944-}
1945
1946=== removed file 'ManagedWinapi/COPYING'
1947--- ManagedWinapi/COPYING 2009-06-24 06:06:11 +0000
1948+++ ManagedWinapi/COPYING 1970-01-01 00:00:00 +0000
1949@@ -1,456 +0,0 @@
1950- GNU LESSER GENERAL PUBLIC LICENSE
1951- Version 2.1, February 1999
1952-
1953- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
1954- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1955- Everyone is permitted to copy and distribute verbatim copies
1956- of this license document, but changing it is not allowed.
1957-
1958-[This is the first released version of the Lesser GPL. It also counts
1959- as the successor of the GNU Library Public License, version 2, hence
1960- the version number 2.1.]
1961-
1962- Preamble
1963-
1964- The licenses for most software are designed to take away your
1965-freedom to share and change it. By contrast, the GNU General Public
1966-Licenses are intended to guarantee your freedom to share and change
1967-free software--to make sure the software is free for all its users.
1968-
1969- This license, the Lesser General Public License, applies to some
1970-specially designated software packages--typically libraries--of the
1971-Free Software Foundation and other authors who decide to use it. You
1972-can use it too, but we suggest you first think carefully about whether
1973-this license or the ordinary General Public License is the better
1974-strategy to use in any particular case, based on the explanations below.
1975-
1976- When we speak of free software, we are referring to freedom of use,
1977-not price. Our General Public Licenses are designed to make sure that
1978-you have the freedom to distribute copies of free software (and charge
1979-for this service if you wish); that you receive source code or can get
1980-it if you want it; that you can change the software and use pieces of
1981-it in new free programs; and that you are informed that you can do
1982-these things.
1983-
1984- To protect your rights, we need to make restrictions that forbid
1985-distributors to deny you these rights or to ask you to surrender these
1986-rights. These restrictions translate to certain responsibilities for
1987-you if you distribute copies of the library or if you modify it.
1988-
1989- For example, if you distribute copies of the library, whether gratis
1990-or for a fee, you must give the recipients all the rights that we gave
1991-you. You must make sure that they, too, receive or can get the source
1992-code. If you link other code with the library, you must provide
1993-complete object files to the recipients, so that they can relink them
1994-with the library after making changes to the library and recompiling
1995-it. And you must show them these terms so they know their rights.
1996-
1997- We protect your rights with a two-step method: (1) we copyright the
1998-library, and (2) we offer you this license, which gives you legal
1999-permission to copy, distribute and/or modify the library.
2000-
2001- To protect each distributor, we want to make it very clear that
2002-there is no warranty for the free library. Also, if the library is
2003-modified by someone else and passed on, the recipients should know
2004-that what they have is not the original version, so that the original
2005-author's reputation will not be affected by problems that might be
2006-introduced by others.
2007-
2008
2009- Finally, software patents pose a constant threat to the existence of
2010-any free program. We wish to make sure that a company cannot
2011-effectively restrict the users of a free program by obtaining a
2012-restrictive license from a patent holder. Therefore, we insist that
2013-any patent license obtained for a version of the library must be
2014-consistent with the full freedom of use specified in this license.
2015-
2016- Most GNU software, including some libraries, is covered by the
2017-ordinary GNU General Public License. This license, the GNU Lesser
2018-General Public License, applies to certain designated libraries, and
2019-is quite different from the ordinary General Public License. We use
2020-this license for certain libraries in order to permit linking those
2021-libraries into non-free programs.
2022-
2023- When a program is linked with a library, whether statically or using
2024-a shared library, the combination of the two is legally speaking a
2025-combined work, a derivative of the original library. The ordinary
2026-General Public License therefore permits such linking only if the
2027-entire combination fits its criteria of freedom. The Lesser General
2028-Public License permits more lax criteria for linking other code with
2029-the library.
2030-
2031- We call this license the "Lesser" General Public License because it
2032-does Less to protect the user's freedom than the ordinary General
2033-Public License. It also provides other free software developers Less
2034-of an advantage over competing non-free programs. These disadvantages
2035-are the reason we use the ordinary General Public License for many
2036-libraries. However, the Lesser license provides advantages in certain
2037-special circumstances.
2038-
2039- For example, on rare occasions, there may be a special need to
2040-encourage the widest possible use of a certain library, so that it becomes
2041-a de-facto standard. To achieve this, non-free programs must be
2042-allowed to use the library. A more frequent case is that a free
2043-library does the same job as widely used non-free libraries. In this
2044-case, there is little to gain by limiting the free library to free
2045-software only, so we use the Lesser General Public License.
2046-
2047- In other cases, permission to use a particular library in non-free
2048-programs enables a greater number of people to use a large body of
2049-free software. For example, permission to use the GNU C Library in
2050-non-free programs enables many more people to use the whole GNU
2051-operating system, as well as its variant, the GNU/Linux operating
2052-system.
2053-
2054- Although the Lesser General Public License is Less protective of the
2055-users' freedom, it does ensure that the user of a program that is
2056-linked with the Library has the freedom and the wherewithal to run
2057-that program using a modified version of the Library.
2058-
2059- The precise terms and conditions for copying, distribution and
2060-modification follow. Pay close attention to the difference between a
2061-"work based on the library" and a "work that uses the library". The
2062-former contains code derived from the library, whereas the latter must
2063-be combined with the library in order to run.
2064-
2065
2066- GNU LESSER GENERAL PUBLIC LICENSE
2067- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
2068-
2069- 0. This License Agreement applies to any software library or other
2070-program which contains a notice placed by the copyright holder or
2071-other authorized party saying it may be distributed under the terms of
2072-this Lesser General Public License (also called "this License").
2073-Each licensee is addressed as "you".
2074-
2075- A "library" means a collection of software functions and/or data
2076-prepared so as to be conveniently linked with application programs
2077-(which use some of those functions and data) to form executables.
2078-
2079- The "Library", below, refers to any such software library or work
2080-which has been distributed under these terms. A "work based on the
2081-Library" means either the Library or any derivative work under
2082-copyright law: that is to say, a work containing the Library or a
2083-portion of it, either verbatim or with modifications and/or translated
2084-straightforwardly into another language. (Hereinafter, translation is
2085-included without limitation in the term "modification".)
2086-
2087- "Source code" for a work means the preferred form of the work for
2088-making modifications to it. For a library, complete source code means
2089-all the source code for all modules it contains, plus any associated
2090-interface definition files, plus the scripts used to control compilation
2091-and installation of the library.
2092-
2093- Activities other than copying, distribution and modification are not
2094-covered by this License; they are outside its scope. The act of
2095-running a program using the Library is not restricted, and output from
2096-such a program is covered only if its contents constitute a work based
2097-on the Library (independent of the use of the Library in a tool for
2098-writing it). Whether that is true depends on what the Library does
2099-and what the program that uses the Library does.
2100-
2101- 1. You may copy and distribute verbatim copies of the Library's
2102-complete source code as you receive it, in any medium, provided that
2103-you conspicuously and appropriately publish on each copy an
2104-appropriate copyright notice and disclaimer of warranty; keep intact
2105-all the notices that refer to this License and to the absence of any
2106-warranty; and distribute a copy of this License along with the
2107-Library.
2108-
2109- You may charge a fee for the physical act of transferring a copy,
2110-and you may at your option offer warranty protection in exchange for a
2111-fee.
2112-
2113
2114- 2. You may modify your copy or copies of the Library or any portion
2115-of it, thus forming a work based on the Library, and copy and
2116-distribute such modifications or work under the terms of Section 1
2117-above, provided that you also meet all of these conditions:
2118-
2119- a) The modified work must itself be a software library.
2120-
2121- b) You must cause the files modified to carry prominent notices
2122- stating that you changed the files and the date of any change.
2123-
2124- c) You must cause the whole of the work to be licensed at no
2125- charge to all third parties under the terms of this License.
2126-
2127- d) If a facility in the modified Library refers to a function or a
2128- table of data to be supplied by an application program that uses
2129- the facility, other than as an argument passed when the facility
2130- is invoked, then you must make a good faith effort to ensure that,
2131- in the event an application does not supply such function or
2132- table, the facility still operates, and performs whatever part of
2133- its purpose remains meaningful.
2134-
2135- (For example, a function in a library to compute square roots has
2136- a purpose that is entirely well-defined independent of the
2137- application. Therefore, Subsection 2d requires that any
2138- application-supplied function or table used by this function must
2139- be optional: if the application does not supply it, the square
2140- root function must still compute square roots.)
2141-
2142-These requirements apply to the modified work as a whole. If
2143-identifiable sections of that work are not derived from the Library,
2144-and can be reasonably considered independent and separate works in
2145-themselves, then this License, and its terms, do not apply to those
2146-sections when you distribute them as separate works. But when you
2147-distribute the same sections as part of a whole which is a work based
2148-on the Library, the distribution of the whole must be on the terms of
2149-this License, whose permissions for other licensees extend to the
2150-entire whole, and thus to each and every part regardless of who wrote
2151-it.
2152-
2153-Thus, it is not the intent of this section to claim rights or contest
2154-your rights to work written entirely by you; rather, the intent is to
2155-exercise the right to control the distribution of derivative or
2156-collective works based on the Library.
2157-
2158-In addition, mere aggregation of another work not based on the Library
2159-with the Library (or with a work based on the Library) on a volume of
2160-a storage or distribution medium does not bring the other work under
2161-the scope of this License.
2162-
2163- 3. You may opt to apply the terms of the ordinary GNU General Public
2164-License instead of this License to a given copy of the Library. To do
2165-this, you must alter all the notices that refer to this License, so
2166-that they refer to the ordinary GNU General Public License, version 2,
2167-instead of to this License. (If a newer version than version 2 of the
2168-ordinary GNU General Public License has appeared, then you can specify
2169-that version instead if you wish.) Do not make any other change in
2170-these notices.
2171-
2172
2173- Once this change is made in a given copy, it is irreversible for
2174-that copy, so the ordinary GNU General Public License applies to all
2175-subsequent copies and derivative works made from that copy.
2176-
2177- This option is useful when you wish to copy part of the code of
2178-the Library into a program that is not a library.
2179-
2180- 4. You may copy and distribute the Library (or a portion or
2181-derivative of it, under Section 2) in object code or executable form
2182-under the terms of Sections 1 and 2 above provided that you accompany
2183-it with the complete corresponding machine-readable source code, which
2184-must be distributed under the terms of Sections 1 and 2 above on a
2185-medium customarily used for software interchange.
2186-
2187- If distribution of object code is made by offering access to copy
2188-from a designated place, then offering equivalent access to copy the
2189-source code from the same place satisfies the requirement to
2190-distribute the source code, even though third parties are not
2191-compelled to copy the source along with the object code.
2192-
2193- 5. A program that contains no derivative of any portion of the
2194-Library, but is designed to work with the Library by being compiled or
2195-linked with it, is called a "work that uses the Library". Such a
2196-work, in isolation, is not a derivative work of the Library, and
2197-therefore falls outside the scope of this License.
2198-
2199- However, linking a "work that uses the Library" with the Library
2200-creates an executable that is a derivative of the Library (because it
2201-contains portions of the Library), rather than a "work that uses the
2202-library". The executable is therefore covered by this License.
2203-Section 6 states terms for distribution of such executables.
2204-
2205- When a "work that uses the Library" uses material from a header file
2206-that is part of the Library, the object code for the work may be a
2207-derivative work of the Library even though the source code is not.
2208-Whether this is true is especially significant if the work can be
2209-linked without the Library, or if the work is itself a library. The
2210-threshold for this to be true is not precisely defined by law.
2211-
2212- If such an object file uses only numerical parameters, data
2213-structure layouts and accessors, and small macros and small inline
2214-functions (ten lines or less in length), then the use of the object
2215-file is unrestricted, regardless of whether it is legally a derivative
2216-work. (Executables containing this object code plus portions of the
2217-Library will still fall under Section 6.)
2218-
2219- Otherwise, if the work is a derivative of the Library, you may
2220-distribute the object code for the work under the terms of Section 6.
2221-Any executables containing that work also fall under Section 6,
2222-whether or not they are linked directly with the Library itself.
2223-
2224
2225- 6. As an exception to the Sections above, you may also combine or
2226-link a "work that uses the Library" with the Library to produce a
2227-work containing portions of the Library, and distribute that work
2228-under terms of your choice, provided that the terms permit
2229-modification of the work for the customer's own use and reverse
2230-engineering for debugging such modifications.
2231-
2232- You must give prominent notice with each copy of the work that the
2233-Library is used in it and that the Library and its use are covered by
2234-this License. You must supply a copy of this License. If the work
2235-during execution displays copyright notices, you must include the
2236-copyright notice for the Library among them, as well as a reference
2237-directing the user to the copy of this License. Also, you must do one
2238-of these things:
2239-
2240- a) Accompany the work with the complete corresponding
2241- machine-readable source code for the Library including whatever
2242- changes were used in the work (which must be distributed under
2243- Sections 1 and 2 above); and, if the work is an executable linked
2244- with the Library, with the complete machine-readable "work that
2245- uses the Library", as object code and/or source code, so that the
2246- user can modify the Library and then relink to produce a modified
2247- executable containing the modified Library. (It is understood
2248- that the user who changes the contents of definitions files in the
2249- Library will not necessarily be able to recompile the application
2250- to use the modified definitions.)
2251-
2252- b) Use a suitable shared library mechanism for linking with the
2253- Library. A suitable mechanism is one that (1) uses at run time a
2254- copy of the library already present on the user's computer system,
2255- rather than copying library functions into the executable, and (2)
2256- will operate properly with a modified version of the library, if
2257- the user installs one, as long as the modified version is
2258- interface-compatible with the version that the work was made with.
2259-
2260- c) Accompany the work with a written offer, valid for at
2261- least three years, to give the same user the materials
2262- specified in Subsection 6a, above, for a charge no more
2263- than the cost of performing this distribution.
2264-
2265- d) If distribution of the work is made by offering access to copy
2266- from a designated place, offer equivalent access to copy the above
2267- specified materials from the same place.
2268-
2269- e) Verify that the user has already received a copy of these
2270- materials or that you have already sent this user a copy.
2271-
2272- For an executable, the required form of the "work that uses the
2273-Library" must include any data and utility programs needed for
2274-reproducing the executable from it. However, as a special exception,
2275-the materials to be distributed need not include anything that is
2276-normally distributed (in either source or binary form) with the major
2277-components (compiler, kernel, and so on) of the operating system on
2278-which the executable runs, unless that component itself accompanies
2279-the executable.
2280-
2281- It may happen that this requirement contradicts the license
2282-restrictions of other proprietary libraries that do not normally
2283-accompany the operating system. Such a contradiction means you cannot
2284-use both them and the Library together in an executable that you
2285-distribute.
2286-
2287
2288- 7. You may place library facilities that are a work based on the
2289-Library side-by-side in a single library together with other library
2290-facilities not covered by this License, and distribute such a combined
2291-library, provided that the separate distribution of the work based on
2292-the Library and of the other library facilities is otherwise
2293-permitted, and provided that you do these two things:
2294-
2295- a) Accompany the combined library with a copy of the same work
2296- based on the Library, uncombined with any other library
2297- facilities. This must be distributed under the terms of the
2298- Sections above.
2299-
2300- b) Give prominent notice with the combined library of the fact
2301- that part of it is a work based on the Library, and explaining
2302- where to find the accompanying uncombined form of the same work.
2303-
2304- 8. You may not copy, modify, sublicense, link with, or distribute
2305-the Library except as expressly provided under this License. Any
2306-attempt otherwise to copy, modify, sublicense, link with, or
2307-distribute the Library is void, and will automatically terminate your
2308-rights under this License. However, parties who have received copies,
2309-or rights, from you under this License will not have their licenses
2310-terminated so long as such parties remain in full compliance.
2311-
2312- 9. You are not required to accept this License, since you have not
2313-signed it. However, nothing else grants you permission to modify or
2314-distribute the Library or its derivative works. These actions are
2315-prohibited by law if you do not accept this License. Therefore, by
2316-modifying or distributing the Library (or any work based on the
2317-Library), you indicate your acceptance of this License to do so, and
2318-all its terms and conditions for copying, distributing or modifying
2319-the Library or works based on it.
2320-
2321- 10. Each time you redistribute the Library (or any work based on the
2322-Library), the recipient automatically receives a license from the
2323-original licensor to copy, distribute, link with or modify the Library
2324-subject to these terms and conditions. You may not impose any further
2325-restrictions on the recipients' exercise of the rights granted herein.
2326-You are not responsible for enforcing compliance by third parties with
2327-this License.
2328-
2329
2330- 11. If, as a consequence of a court judgment or allegation of patent
2331-infringement or for any other reason (not limited to patent issues),
2332-conditions are imposed on you (whether by court order, agreement or
2333-otherwise) that contradict the conditions of this License, they do not
2334-excuse you from the conditions of this License. If you cannot
2335-distribute so as to satisfy simultaneously your obligations under this
2336-License and any other pertinent obligations, then as a consequence you
2337-may not distribute the Library at all. For example, if a patent
2338-license would not permit royalty-free redistribution of the Library by
2339-all those who receive copies directly or indirectly through you, then
2340-the only way you could satisfy both it and this License would be to
2341-refrain entirely from distribution of the Library.
2342-
2343-If any portion of this section is held invalid or unenforceable under any
2344-particular circumstance, the balance of the section is intended to apply,
2345-and the section as a whole is intended to apply in other circumstances.
2346-
2347-It is not the purpose of this section to induce you to infringe any
2348-patents or other property right claims or to contest validity of any
2349-such claims; this section has the sole purpose of protecting the
2350-integrity of the free software distribution system which is
2351-implemented by public license practices. Many people have made
2352-generous contributions to the wide range of software distributed
2353-through that system in reliance on consistent application of that
2354-system; it is up to the author/donor to decide if he or she is willing
2355-to distribute software through any other system and a licensee cannot
2356-impose that choice.
2357-
2358-This section is intended to make thoroughly clear what is believed to
2359-be a consequence of the rest of this License.
2360-
2361- 12. If the distribution and/or use of the Library is restricted in
2362-certain countries either by patents or by copyrighted interfaces, the
2363-original copyright holder who places the Library under this License may add
2364-an explicit geographical distribution limitation excluding those countries,
2365-so that distribution is permitted only in or among countries not thus
2366-excluded. In such case, this License incorporates the limitation as if
2367-written in the body of this License.
2368-
2369- 13. The Free Software Foundation may publish revised and/or new
2370-versions of the Lesser General Public License from time to time.
2371-Such new versions will be similar in spirit to the present version,
2372-but may differ in detail to address new problems or concerns.
2373-
2374-Each version is given a distinguishing version number. If the Library
2375-specifies a version number of this License which applies to it and
2376-"any later version", you have the option of following the terms and
2377-conditions either of that version or of any later version published by
2378-the Free Software Foundation. If the Library does not specify a
2379-license version number, you may choose any version ever published by
2380-the Free Software Foundation.
2381-
2382
2383- 14. If you wish to incorporate parts of the Library into other free
2384-programs whose distribution conditions are incompatible with these,
2385-write to the author to ask for permission. For software which is
2386-copyrighted by the Free Software Foundation, write to the Free
2387-Software Foundation; we sometimes make exceptions for this. Our
2388-decision will be guided by the two goals of preserving the free status
2389-of all derivatives of our free software and of promoting the sharing
2390-and reuse of software generally.
2391-
2392- NO WARRANTY
2393-
2394- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
2395-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
2396-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
2397-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
2398-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
2399-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2400-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
2401-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
2402-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
2403-
2404- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
2405-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
2406-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
2407-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
2408-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
2409-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
2410-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
2411-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
2412-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
2413-DAMAGES.
2414
2415=== removed file 'ManagedWinapi/ClipboardNotifier.cs'
2416--- ManagedWinapi/ClipboardNotifier.cs 2009-06-24 06:06:11 +0000
2417+++ ManagedWinapi/ClipboardNotifier.cs 1970-01-01 00:00:00 +0000
2418@@ -1,132 +0,0 @@
2419-/*
2420- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
2421- * access native API by managed code. http://mwinapi.sourceforge.net/
2422- * Copyright (C) 2006 Michael Schierl
2423- *
2424- * This library is free software; you can redistribute it and/or
2425- * modify it under the terms of the GNU Lesser General Public
2426- * License as published by the Free Software Foundation; either
2427- * version 2.1 of the License, or (at your option) any later version.
2428- * This library is distributed in the hope that it will be useful,
2429- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2430- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2431- * Lesser General Public License for more details.
2432- *
2433- * You should have received a copy of the GNU Lesser General Public
2434- * License along with this library; see the file COPYING. if not, visit
2435- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
2436- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2437- */
2438-using System;
2439-using System.ComponentModel;
2440-using System.Collections.Generic;
2441-using System.Diagnostics;
2442-using System.Text;
2443-using ManagedWinapi.Windows;
2444-using System.Runtime.InteropServices;
2445-using Microsoft.Win32;
2446-
2447-namespace ManagedWinapi
2448-{
2449- /// <summary>
2450- /// Specifies a component that monitors the system clipboard for changes.
2451- /// </summary>
2452- [DefaultEvent("ClipboardChanged")]
2453- public class ClipboardNotifier : Component
2454- {
2455-
2456- /// <summary>
2457- /// Occurs when the clipboard contents have changed.
2458- /// </summary>
2459- public event EventHandler ClipboardChanged;
2460-
2461- private readonly IntPtr hWnd;
2462- private IntPtr nextHWnd;
2463- private readonly EventDispatchingNativeWindow ednw;
2464-
2465- private static Boolean instantiated = false;
2466-
2467- /// <summary>
2468- /// Creates a new clipboard notifier.
2469- /// </summary>
2470- /// <param name="container">The container.</param>
2471- public ClipboardNotifier(IContainer container)
2472- : this()
2473- {
2474- container.Add(this);
2475- }
2476-
2477- /// <summary>
2478- /// Creates a new clipboard notifier.
2479- /// </summary>
2480- public ClipboardNotifier()
2481- {
2482- if (instantiated)
2483- {
2484- // use new windows if more than one instance is used.
2485- System.Diagnostics.Debug.WriteLine("WARNING: More than one ClipboardNotifier used!");
2486- ednw = new EventDispatchingNativeWindow();
2487- }
2488- else
2489- {
2490- ednw = EventDispatchingNativeWindow.Instance;
2491- instantiated = true;
2492- }
2493- ednw.EventHandler += clipboardEventHandler;
2494- hWnd = ednw.Handle;
2495- nextHWnd = SetClipboardViewer(hWnd);
2496- }
2497-
2498- /// <summary>
2499- /// Frees resources.
2500- /// </summary>
2501- protected override void Dispose(bool disposing)
2502- {
2503- ChangeClipboardChain(hWnd, nextHWnd);
2504- ednw.EventHandler -= clipboardEventHandler;
2505- base.Dispose(disposing);
2506- }
2507-
2508- void clipboardEventHandler(ref System.Windows.Forms.Message m, ref bool handled)
2509- {
2510- if (handled) return;
2511- if (m.Msg == WM_DRAWCLIPBOARD)
2512- {
2513- // notify me
2514- if (ClipboardChanged != null)
2515- ClipboardChanged(this, EventArgs.Empty);
2516- // pass on message
2517- SendMessage(nextHWnd, m.Msg, m.WParam, m.LParam);
2518- handled = true;
2519- }
2520- else if (m.Msg == WM_CHANGECBCHAIN)
2521- {
2522- if (m.WParam == nextHWnd)
2523- {
2524- nextHWnd = m.LParam;
2525- }
2526- else
2527- {
2528- SendMessage(nextHWnd, m.Msg, m.WParam, m.LParam);
2529- }
2530- }
2531- }
2532-
2533- #region PInvoke Declarations
2534-
2535- [DllImport("User32.dll", CharSet = CharSet.Auto)]
2536- private static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);
2537-
2538- [DllImport("user32.dll")]
2539- private static extern bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext);
2540-
2541- [DllImport("user32.dll", CharSet = CharSet.Auto)]
2542- private static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
2543-
2544- private static readonly int
2545- WM_DRAWCLIPBOARD = 0x0308,
2546- WM_CHANGECBCHAIN = 0x030D;
2547-
2548- #endregion
2549- }
2550-}
2551
2552=== removed file 'ManagedWinapi/CodepointRange.cs'
2553--- ManagedWinapi/CodepointRange.cs 2009-06-24 06:06:11 +0000
2554+++ ManagedWinapi/CodepointRange.cs 1970-01-01 00:00:00 +0000
2555@@ -1,204 +0,0 @@
2556-using System;
2557-using System.Collections.Generic;
2558-using System.Text;
2559-using System.Drawing;
2560-using System.Runtime.InteropServices;
2561-
2562-namespace ManagedWinapi
2563-{
2564- /// <summary>
2565- /// The unicode range of codepoints supported by a font.
2566- /// </summary>
2567- public class CodepointRange
2568- {
2569- char[] ranges;
2570- readonly int codepointCount;
2571-
2572- /// <summary>
2573- /// Creates a new CodepointRange object for a font.
2574- /// </summary>
2575- public CodepointRange(Font font)
2576- {
2577- List<char> rangeList = new List<char>();
2578- Graphics g = Graphics.FromImage(new Bitmap(1, 1));
2579- IntPtr hdc = g.GetHdc();
2580- IntPtr hFont = font.ToHfont();
2581- IntPtr oldFont = SelectObject(hdc, hFont);
2582- uint size = GetFontUnicodeRanges(hdc, IntPtr.Zero);
2583- IntPtr glyphSet = Marshal.AllocHGlobal((int)size);
2584- GetFontUnicodeRanges(hdc, glyphSet);
2585- codepointCount = Marshal.ReadInt32(glyphSet, 8);
2586- int tmp = 0;
2587- int count = Marshal.ReadInt32(glyphSet, 12);
2588- for (int i = 0; i < count; i++)
2589- {
2590- char firstIncluded = (char)Marshal.ReadInt16(glyphSet, 16 + i * 4);
2591- char firstExcluded = (char)(firstIncluded + Marshal.ReadInt16(glyphSet, 18 + i * 4));
2592- tmp += firstExcluded - firstIncluded;
2593- rangeList.Add(firstIncluded);
2594- rangeList.Add(firstExcluded);
2595- }
2596- SelectObject(hdc, oldFont);
2597- DeleteObject(hFont);
2598- Marshal.FreeHGlobal(glyphSet);
2599- g.ReleaseHdc(hdc);
2600- g.Dispose();
2601- if (tmp != codepointCount) throw new Exception(font.FontFamily.Name);
2602- ranges = rangeList.ToArray();
2603- if (ranges.Length < 2) throw new Exception();
2604- }
2605-
2606- /// <summary>
2607- /// Returns a dictionary containing codepoint ranges of all fonts.
2608- /// If multiple fonts of one family (bold, italic, etc.) share their
2609- /// codepoint range, only their base font is included in this list,
2610- /// otherwise all different variants are included.
2611- /// </summary>
2612- public static Dictionary<Font, CodepointRange> GetRangesForAllFonts()
2613- {
2614- Dictionary<Font, CodepointRange> result = new Dictionary<Font, CodepointRange>();
2615- foreach (FontFamily ff in FontFamily.Families)
2616- {
2617- Font[] fonts = new Font[16];
2618- CodepointRange[] range = new CodepointRange[fonts.Length];
2619- for (int i = 0; i < fonts.Length; i++)
2620- {
2621- if (ff.IsStyleAvailable((FontStyle)i))
2622- {
2623- fonts[i] = new Font(ff, 10, (FontStyle)i);
2624- range[i] = new CodepointRange(fonts[i]);
2625- }
2626- }
2627- int importantBits = 0;
2628- for (int bit = 1; bit < fonts.Length; bit <<= 1)
2629- {
2630- for (int i = 0; i < fonts.Length; i++)
2631- {
2632- if ((i & bit) != 0) continue;
2633- if (range[i] != null && range[i | bit] != null)
2634- {
2635- if (!range[i].Equals(range[i | bit]))
2636- {
2637- importantBits |= bit;
2638- break;
2639- }
2640- }
2641- else if (range[i] != null || range[i | bit] != null)
2642- {
2643- importantBits |= bit;
2644- break;
2645- }
2646- }
2647- }
2648- for (int i = 0; i < fonts.Length; i++)
2649- {
2650- if ((i & importantBits) != i || fonts[i] == null) continue;
2651- result.Add(fonts[i], range[i]);
2652- }
2653- }
2654- return result;
2655- }
2656-
2657- /// <summary>
2658- /// The number of codepoints supported by this font.
2659- /// </summary>
2660- public int SupportedCodepointCount { get { return codepointCount; } }
2661-
2662- /// <summary>
2663- /// The first (lowest) supported codepoint.
2664- /// </summary>
2665- public char FirstCodepoint { get { return ranges[0]; } }
2666-
2667- /// <summary>
2668- /// The last (highest) supported codepoint.
2669- /// </summary>
2670- public char LastCodepoint { get { return (char)(ranges[ranges.Length - 1] - 1); } }
2671-
2672- /// <summary>
2673- /// Tests whether a specific codepoint is supported by this font.
2674- /// </summary>
2675- public bool IsSupported(char codepoint)
2676- {
2677- bool result = false;
2678- foreach (char c in ranges)
2679- {
2680- if (c > codepoint) break;
2681- result = !result;
2682- }
2683- return result;
2684- }
2685-
2686- /// <summary>
2687- /// Finds the next codepoint that is either supported or not.
2688- /// </summary>
2689- public char FindNext(char from, bool supported)
2690- {
2691- if (IsSupported(from) == supported) return from;
2692- foreach (char c in ranges)
2693- {
2694- if (c > from) return c;
2695- }
2696- return (char)0xFFFF;
2697- }
2698-
2699- /// <summary>
2700- /// Returns a <see cref="String"/> representation of this codepoint range.
2701- /// </summary>
2702- public override string ToString()
2703- {
2704- StringBuilder sb = new StringBuilder("[");
2705- for (int i = 0; i < ranges.Length; i++)
2706- {
2707- if (i % 2 == 1)
2708- {
2709- if (ranges[i] == ranges[i - 1] + 1) continue;
2710- sb.Append("-");
2711- }
2712- else if (i != 0)
2713- {
2714- sb.Append(", ");
2715- }
2716- sb.Append(((int)ranges[i] - i % 2).ToString("X4"));
2717- }
2718- return sb.Append("]").ToString();
2719- }
2720-
2721- #region Equals and HashCode
2722-
2723- ///
2724- public override bool Equals(object obj)
2725- {
2726- CodepointRange cr = obj as CodepointRange;
2727- if (cr == null)
2728- return false;
2729- if (codepointCount != cr.codepointCount || ranges.Length != cr.ranges.Length)
2730- return false;
2731- for (int i = 0; i < ranges.Length; i++)
2732- {
2733- if (ranges[i] != cr.ranges[i])
2734- {
2735- return false;
2736- }
2737- }
2738- return true;
2739- }
2740-
2741- ///
2742- public override int GetHashCode()
2743- {
2744- return 3 * codepointCount + 7 * ranges.Length + 9 * FirstCodepoint + 11 * LastCodepoint;
2745- }
2746- #endregion
2747-
2748- #region PInvoke Declarations
2749- [DllImport("gdi32.dll")]
2750- private static extern uint GetFontUnicodeRanges(IntPtr hdc, IntPtr lpgs);
2751-
2752- [DllImport("gdi32.dll")]
2753- private static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
2754-
2755- [DllImport("gdi32.dll")]
2756- private static extern bool DeleteObject(IntPtr hObject);
2757- #endregion
2758- }
2759-}
2760
2761=== removed directory 'ManagedWinapi/Contents'
2762=== removed file 'ManagedWinapi/Contents/AccessibleWindowParser.cs'
2763--- ManagedWinapi/Contents/AccessibleWindowParser.cs 2009-06-24 06:06:11 +0000
2764+++ ManagedWinapi/Contents/AccessibleWindowParser.cs 1970-01-01 00:00:00 +0000
2765@@ -1,193 +0,0 @@
2766-/*
2767- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
2768- * access native API by managed code. http://mwinapi.sourceforge.net/
2769- * Copyright (C) 2006 Michael Schierl
2770- *
2771- * This library is free software; you can redistribute it and/or
2772- * modify it under the terms of the GNU Lesser General Public
2773- * License as published by the Free Software Foundation; either
2774- * version 2.1 of the License, or (at your option) any later version.
2775- * This library is distributed in the hope that it will be useful,
2776- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2777- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2778- * Lesser General Public License for more details.
2779- *
2780- * You should have received a copy of the GNU Lesser General Public
2781- * License along with this library; see the file COPYING. if not, visit
2782- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
2783- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2784- */
2785-using System;
2786-using System.Collections.Generic;
2787-using System.Text;
2788-using System.Runtime.InteropServices;
2789-using ManagedWinapi.Accessibility;
2790-
2791-namespace ManagedWinapi.Windows.Contents
2792-{
2793- /// <summary>
2794- /// The content of an object that supports the Accessibility API
2795- /// (used by screen readers and similar programs).
2796- /// </summary>
2797- public class AccessibleWindowContent : WindowContent
2798- {
2799-
2800- bool parsed = false;
2801- readonly string name;
2802- string menu, sysmenu, clientarea;
2803- readonly bool hasMenu, hasSysMenu, hasClientArea;
2804- SystemWindow sw;
2805-
2806- internal AccessibleWindowContent(string name, bool hasMenu, bool hasSysMenu, bool hasClientArea, SystemWindow sw)
2807- {
2808- this.name = name;
2809- this.hasMenu = hasMenu;
2810- this.hasSysMenu = hasSysMenu;
2811- this.hasClientArea = hasClientArea;
2812- this.sw = sw;
2813- }
2814-
2815- ///
2816- public string ComponentType
2817- {
2818- get { return "AccessibleWindow"; }
2819- }
2820-
2821- ///
2822- public string ShortDescription
2823- {
2824- get
2825- {
2826- return name + " <AccessibleWindow:" +
2827- (hasSysMenu ? " SystemMenu" : "") +
2828- (hasMenu ? " Menu" : "") +
2829- (hasClientArea ? " ClientArea" : "") + ">";
2830- }
2831- }
2832-
2833- ///
2834- public string LongDescription
2835- {
2836- get
2837- {
2838- ParseIfNeeded();
2839- string result = ShortDescription + "\n";
2840- if (sysmenu != null)
2841- result += "System menu:\n" + sysmenu + "\n";
2842- if (menu != null)
2843- result += "Menu:\n" + menu + "\n";
2844- if (clientarea != null)
2845- result += "Client area:\n" + clientarea + "\n";
2846- return result;
2847- }
2848- }
2849-
2850- private void ParseIfNeeded()
2851- {
2852- if (parsed) return;
2853- if (hasSysMenu) sysmenu = ParseMenu(sw, AccessibleObjectID.OBJID_SYSMENU);
2854- if (hasMenu) menu = ParseMenu(sw, AccessibleObjectID.OBJID_MENU);
2855- if (hasClientArea) clientarea = ParseClientArea(sw);
2856- parsed = true;
2857- }
2858-
2859- private string ParseMenu(SystemWindow sw, AccessibleObjectID accessibleObjectID)
2860- {
2861- SystemAccessibleObject sao = SystemAccessibleObject.FromWindow(sw, accessibleObjectID);
2862- StringBuilder menuitems = new StringBuilder();
2863- ParseSubMenu(menuitems, sao, 1);
2864- return menuitems.ToString();
2865- }
2866-
2867- private void ParseSubMenu(StringBuilder menuitems, SystemAccessibleObject sao, int depth)
2868- {
2869- foreach (SystemAccessibleObject c in sao.Children)
2870- {
2871- if (c.RoleIndex == 11 || c.RoleIndex == 12)
2872- {
2873- menuitems.Append(ListContent.Repeat('\t', depth) + c.Name + "\n");
2874- ParseSubMenu(menuitems, c, depth + 1);
2875- }
2876- }
2877- }
2878-
2879- private string ParseClientArea(SystemWindow sw)
2880- {
2881- SystemAccessibleObject sao = SystemAccessibleObject.FromWindow(sw, AccessibleObjectID.OBJID_CLIENT);
2882- StringBuilder sb = new StringBuilder();
2883- ParseClientAreaElement(sb, sao, 1);
2884- return sb.ToString();
2885- }
2886-
2887- private void ParseClientAreaElement(StringBuilder sb, SystemAccessibleObject sao, int depth)
2888- {
2889- sb.Append("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
2890- sb.Append(ListContent.Repeat('*', depth) + " " + sao.ToString() + "\n");
2891- try
2892- {
2893- sb.Append("D: " + sao.Description + "\n");
2894- }
2895- catch (COMException) { }
2896- try
2897- {
2898- sb.Append("V: " + sao.Value + "\n");
2899- }
2900- catch (COMException) { }
2901- foreach (SystemAccessibleObject c in sao.Children)
2902- {
2903- if (c.Window == sao.Window)
2904- ParseClientAreaElement(sb, c, depth + 1);
2905- }
2906- }
2907-
2908- ///
2909- public Dictionary<string, string> PropertyList
2910- {
2911- get
2912- {
2913- Dictionary<string, string> result = new Dictionary<string, string>();
2914- return result;
2915- }
2916- }
2917-
2918- }
2919-
2920- class AccessibleWindowParser : WindowContentParser
2921- {
2922- internal override bool CanParseContent(SystemWindow sw)
2923- {
2924- return TestMenu(sw, AccessibleObjectID.OBJID_MENU) ||
2925- TestMenu(sw, AccessibleObjectID.OBJID_SYSMENU) ||
2926- TestClientArea(sw);
2927- }
2928-
2929- internal override WindowContent ParseContent(SystemWindow sw)
2930- {
2931- SystemAccessibleObject sao = SystemAccessibleObject.FromWindow(sw, AccessibleObjectID.OBJID_WINDOW);
2932- bool sysmenu = TestMenu(sw, AccessibleObjectID.OBJID_SYSMENU);
2933- bool menu = TestMenu(sw, AccessibleObjectID.OBJID_MENU);
2934- bool clientarea = TestClientArea(sw);
2935- return new AccessibleWindowContent(sao.Name, menu, sysmenu, clientarea, sw);
2936- }
2937-
2938- private bool TestClientArea(SystemWindow sw)
2939- {
2940- try
2941- {
2942- SystemAccessibleObject sao = SystemAccessibleObject.FromWindow(sw, AccessibleObjectID.OBJID_CLIENT);
2943- foreach (SystemAccessibleObject c in sao.Children)
2944- {
2945- if (c.Window == sw) return true;
2946- }
2947- }
2948- catch (COMException) { }
2949- return false;
2950- }
2951-
2952- private bool TestMenu(SystemWindow sw, AccessibleObjectID accessibleObjectID)
2953- {
2954- SystemAccessibleObject sao = SystemAccessibleObject.FromWindow(sw, accessibleObjectID);
2955- return sao.Children.Length > 0;
2956- }
2957- }
2958-}
2959
2960=== removed file 'ManagedWinapi/Contents/ContentParserRegistry.cs'
2961--- ManagedWinapi/Contents/ContentParserRegistry.cs 2009-06-24 06:06:11 +0000
2962+++ ManagedWinapi/Contents/ContentParserRegistry.cs 1970-01-01 00:00:00 +0000
2963@@ -1,61 +0,0 @@
2964-/*
2965- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
2966- * access native API by managed code. http://mwinapi.sourceforge.net/
2967- * Copyright (C) 2006 Michael Schierl
2968- *
2969- * This library is free software; you can redistribute it and/or
2970- * modify it under the terms of the GNU Lesser General Public
2971- * License as published by the Free Software Foundation; either
2972- * version 2.1 of the License, or (at your option) any later version.
2973- * This library is distributed in the hope that it will be useful,
2974- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2975- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2976- * Lesser General Public License for more details.
2977- *
2978- * You should have received a copy of the GNU Lesser General Public
2979- * License along with this library; see the file COPYING. if not, visit
2980- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
2981- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2982- */
2983-using System;
2984-using System.Collections.Generic;
2985-
2986-namespace ManagedWinapi.Windows.Contents
2987-{
2988- internal class ContentParserRegistry
2989- {
2990- static ContentParserRegistry instance = null;
2991-
2992- public static ContentParserRegistry Instance
2993- {
2994- get
2995- {
2996- if (instance == null)
2997- instance = new ContentParserRegistry();
2998- return instance;
2999- }
3000- }
3001-
3002- List<WindowContentParser> parsers = new List<WindowContentParser>();
3003-
3004- private ContentParserRegistry()
3005- {
3006- parsers.Add(new ComboBoxParser());
3007- parsers.Add(new ListBoxParser());
3008- parsers.Add(new TextFieldParser(true));
3009- parsers.Add(new ListViewParser());
3010- parsers.Add(new TreeViewParser());
3011- parsers.Add(new AccessibleWindowParser());
3012- parsers.Add(new TextFieldParser(false));
3013- }
3014-
3015- public WindowContentParser GetParser(SystemWindow sw)
3016- {
3017- foreach(WindowContentParser p in parsers) {
3018- if (p.CanParseContent(sw))
3019- return p;
3020- }
3021- return null;
3022- }
3023- }
3024-}
3025
3026=== removed file 'ManagedWinapi/Contents/ListParser.cs'
3027--- ManagedWinapi/Contents/ListParser.cs 2009-06-24 06:06:11 +0000
3028+++ ManagedWinapi/Contents/ListParser.cs 1970-01-01 00:00:00 +0000
3029@@ -1,361 +0,0 @@
3030-/*
3031- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
3032- * access native API by managed code. http://mwinapi.sourceforge.net/
3033- * Copyright (C) 2006 Michael Schierl
3034- *
3035- * This library is free software; you can redistribute it and/or
3036- * modify it under the terms of the GNU Lesser General Public
3037- * License as published by the Free Software Foundation; either
3038- * version 2.1 of the License, or (at your option) any later version.
3039- * This library is distributed in the hope that it will be useful,
3040- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3041- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3042- * Lesser General Public License for more details.
3043- *
3044- * You should have received a copy of the GNU Lesser General Public
3045- * License along with this library; see the file COPYING. if not, visit
3046- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
3047- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3048- */
3049-using System;
3050-using System.Collections.Generic;
3051-using System.Text;
3052-using System.Runtime.InteropServices;
3053-using ManagedWinapi.Accessibility;
3054-
3055-namespace ManagedWinapi.Windows.Contents
3056-{
3057- /// <summary>
3058- /// The content of a list box or combo box.
3059- /// </summary>
3060- public class ListContent : WindowContent
3061- {
3062- string type, current;
3063- string[] values;
3064- int selected;
3065-
3066- internal ListContent(string type, int selected, string current, string[] values)
3067- {
3068- this.type = type;
3069- this.selected = selected;
3070- this.current = current;
3071- this.values = values;
3072- }
3073-
3074- ///
3075- public string ComponentType
3076- {
3077- get { return type; }
3078- }
3079-
3080- ///
3081- public string ShortDescription
3082- {
3083- get { return (current == null ? "" : current + " ") + "<" + type + ">"; }
3084- }
3085-
3086- ///
3087- public string LongDescription
3088- {
3089- get
3090- {
3091- StringBuilder sb = new StringBuilder();
3092- sb.Append("<" + type + ">");
3093- if (current != null)
3094- sb.Append(" (selected value: \"" + current + "\")");
3095- sb.Append("\nAll values:\n");
3096- int idx = 0;
3097- foreach (string v in values)
3098- {
3099- if (selected == idx) sb.Append("*");
3100- sb.Append("\t" + v + "\n");
3101- idx++;
3102- }
3103- return sb.ToString();
3104- }
3105- }
3106-
3107- ///
3108- public Dictionary<string, string> PropertyList
3109- {
3110- get
3111- {
3112- Dictionary<string, string> result = new Dictionary<string, string>();
3113- result.Add("SelectedValue", current);
3114- result.Add("SelectedIndex", "" + selected);
3115- result.Add("Count", "" + values.Length);
3116- for (int i = 0; i < values.Length; i++)
3117- {
3118- result.Add("Value" + i, values[i]);
3119- }
3120- return result;
3121- }
3122- }
3123-
3124- /// <summary>
3125- /// The value in this list or combo box that is selected.
3126- /// In a combo box, this value may not be in the list.
3127- /// </summary>
3128- public String SelectedValue
3129- {
3130- get { return current; }
3131- }
3132-
3133- /// <summary>
3134- /// The index of the selected item, or -1 if no item
3135- /// is selected.
3136- /// </summary>
3137- public int SelectedIndex
3138- {
3139- get
3140- {
3141- return selected;
3142- }
3143- }
3144-
3145- /// <summary>
3146- /// The number of items in this list.
3147- /// </summary>
3148- public int Count
3149- {
3150- get
3151- {
3152- return values.Length;
3153- }
3154- }
3155-
3156- /// <summary>
3157- /// Accesses individual list items.
3158- /// </summary>
3159- /// <param name="index">Index of list item.</param>
3160- /// <returns>The list item.</returns>
3161- public string this[int index]
3162- {
3163- get
3164- {
3165- return values[index];
3166- }
3167- }
3168-
3169- internal static string Repeat(char ch, int count)
3170- {
3171- char[] tmp = new char[count];
3172- for (int i = 0; i < tmp.Length; i++)
3173- {
3174- tmp[i] = ch;
3175- }
3176- return new string(tmp);
3177- }
3178- }
3179-
3180- internal class ListBoxParser : WindowContentParser
3181- {
3182- internal override bool CanParseContent(SystemWindow sw)
3183- {
3184- return SystemListBox.FromSystemWindow(sw) != null;
3185- }
3186-
3187- internal override WindowContent ParseContent(SystemWindow sw)
3188- {
3189- SystemListBox slb = SystemListBox.FromSystemWindow(sw);
3190- int c = slb.Count;
3191- string[] values = new string[c];
3192- for (int i = 0; i < c; i++)
3193- {
3194- values[i] = slb[i];
3195- }
3196- return new ListContent("ListBox", slb.SelectedIndex, slb.SelectedItem, values);
3197- }
3198- }
3199-
3200- internal class ComboBoxParser : WindowContentParser
3201- {
3202- internal override bool CanParseContent(SystemWindow sw)
3203- {
3204- return SystemComboBox.FromSystemWindow(sw) != null;
3205- }
3206-
3207- internal override WindowContent ParseContent(SystemWindow sw)
3208- {
3209- SystemComboBox slb = SystemComboBox.FromSystemWindow(sw);
3210- int c = slb.Count;
3211- string[] values = new string[c];
3212- for (int i = 0; i < c; i++)
3213- {
3214- values[i] = slb[i];
3215- }
3216- return new ListContent("ComboBox", -1, sw.Title, values);
3217- }
3218- }
3219-
3220- internal class ListViewParser : WindowContentParser
3221- {
3222-
3223- internal override bool CanParseContent(SystemWindow sw)
3224- {
3225- uint LVM_GETITEMCOUNT = (0x1000 + 4);
3226- int cnt = sw.SendGetMessage(LVM_GETITEMCOUNT);
3227- return cnt != 0;
3228- }
3229-
3230- internal override WindowContent ParseContent(SystemWindow sw)
3231- {
3232- uint LVM_GETITEMCOUNT = (0x1000 + 4);
3233- int cnt = sw.SendGetMessage(LVM_GETITEMCOUNT);
3234- if (cnt == 0) throw new Exception();
3235- SystemAccessibleObject o = SystemAccessibleObject.FromWindow(sw, AccessibleObjectID.OBJID_CLIENT);
3236- if (o.RoleIndex == 33)
3237- {
3238- // are there column headers?
3239- int cs = o.Children.Length;
3240- string[] hdr = null;
3241- if (cs > 0)
3242- {
3243- SystemAccessibleObject headers = o.Children[cs - 1];
3244- if (headers.RoleIndex == 9 && headers.Window != sw)
3245- {
3246- SystemAccessibleObject hdrL = SystemAccessibleObject.FromWindow(headers.Window, AccessibleObjectID.OBJID_CLIENT);
3247- hdr = new string[hdrL.Children.Length];
3248- for (int i = 0; i < hdr.Length; i++)
3249- {
3250- if (hdrL.Children[i].RoleIndex != 25)
3251- {
3252- hdr = null;
3253- break;
3254- }
3255- hdr[i] = hdrL.Children[i].Name;
3256- }
3257- if (hdr != null)
3258- {
3259- cs--;
3260- }
3261- }
3262- }
3263- List<string> values = new List<string>();
3264- for (int i = 0; i < cs; i++)
3265- {
3266- if (o.Children[i].RoleIndex == 34)
3267- {
3268- string name = o.Children[i].Name;
3269- if (hdr != null)
3270- {
3271- try
3272- {
3273- string cols = o.Children[i].Description;
3274- if (cols == null && values.Count == 0) { hdr = null; }
3275- else
3276- {
3277- string tmpCols = "; " + cols;
3278- List<string> usedHdr = new List<string>();
3279- foreach (string header in hdr)
3280- {
3281- string h = "; " + header + ": ";
3282- if (tmpCols.Contains(h))
3283- {
3284- usedHdr.Add(header);
3285- tmpCols = tmpCols.Substring(tmpCols.IndexOf(h) + h.Length);
3286- }
3287- }
3288- foreach (string header in hdr)
3289- {
3290- name += "\t";
3291- if (usedHdr.Count > 0 && usedHdr[0] == header)
3292- {
3293- if (!cols.StartsWith(header + ": "))
3294- throw new Exception();
3295- cols = cols.Substring(header.Length + 1);
3296- string elem;
3297- if (usedHdr.Count > 1)
3298- {
3299- int pos = cols.IndexOf("; " + usedHdr[1] + ": ");
3300- elem = cols.Substring(0, pos);
3301- cols = cols.Substring(pos + 2);
3302- }
3303- else
3304- {
3305- elem = cols;
3306- cols = "";
3307- }
3308- name += elem;
3309- usedHdr.RemoveAt(0);
3310- }
3311- }
3312- }
3313- }
3314- catch (COMException ex)
3315- {
3316- if (ex.ErrorCode == -2147352573 && values.Count == 0)
3317- {
3318- hdr = null;
3319- }
3320- else
3321- {
3322- throw ex;
3323- }
3324- }
3325- }
3326- values.Add(name);
3327- }
3328- }
3329- if (hdr != null)
3330- {
3331- string lines = "", headers = "";
3332- foreach (string h in hdr)
3333- {
3334- if (lines.Length > 0) lines += "\t";
3335- if (headers.Length > 0) headers += "\t";
3336- headers += h;
3337- lines += ListContent.Repeat('~', h.Length);
3338- }
3339- values.Insert(0, lines);
3340- values.Insert(0, headers);
3341- return new ListContent("DetailsListView", -1, null, values.ToArray());
3342- }
3343- else
3344- {
3345- return new ListContent("ListView", -1, null, values.ToArray());
3346- }
3347- }
3348- else
3349- {
3350- return new ListContent("EmptyListView", -1, null, new string[0]);
3351- }
3352- }
3353- }
3354-
3355- class TreeViewParser : WindowContentParser
3356- {
3357- uint TVM_GETCOUNT = 0x1100 + 5;
3358-
3359- internal override bool CanParseContent(SystemWindow sw)
3360- {
3361- int cnt = sw.SendGetMessage(TVM_GETCOUNT, 0);
3362- return cnt != 0;
3363- }
3364-
3365- internal override WindowContent ParseContent(SystemWindow sw)
3366- {
3367- SystemAccessibleObject sao = SystemAccessibleObject.FromWindow(sw, AccessibleObjectID.OBJID_CLIENT);
3368- if (sao.RoleIndex == 35)
3369- {
3370- List<string> treeNodes = new List<string>();
3371- int selected = -1;
3372- foreach(SystemAccessibleObject n in sao.Children) {
3373- if (n.RoleIndex == 36)
3374- {
3375- if ((n.State & 0x2) != 0)
3376- {
3377- selected = treeNodes.Count;
3378- }
3379- treeNodes.Add(ListContent.Repeat('\t', int.Parse(n.Value)) + n.Name);
3380- }
3381- }
3382- if (treeNodes.Count > 0)
3383- {
3384- return new ListContent("TreeView", selected, null, treeNodes.ToArray());
3385- }
3386- }
3387- return new ListContent("EmptyTreeView", -1, null, new string[0]);
3388- }
3389- }
3390-}
3391
3392=== removed file 'ManagedWinapi/Contents/TextFieldParser.cs'
3393--- ManagedWinapi/Contents/TextFieldParser.cs 2009-06-24 06:06:11 +0000
3394+++ ManagedWinapi/Contents/TextFieldParser.cs 1970-01-01 00:00:00 +0000
3395@@ -1,116 +0,0 @@
3396-/*
3397- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
3398- * access native API by managed code. http://mwinapi.sourceforge.net/
3399- * Copyright (C) 2006 Michael Schierl
3400- *
3401- * This library is free software; you can redistribute it and/or
3402- * modify it under the terms of the GNU Lesser General Public
3403- * License as published by the Free Software Foundation; either
3404- * version 2.1 of the License, or (at your option) any later version.
3405- * This library is distributed in the hope that it will be useful,
3406- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3407- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3408- * Lesser General Public License for more details.
3409- *
3410- * You should have received a copy of the GNU Lesser General Public
3411- * License along with this library; see the file COPYING. if not, visit
3412- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
3413- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3414- */
3415-using System;
3416-using System.Collections.Generic;
3417-
3418-namespace ManagedWinapi.Windows.Contents
3419-{
3420-
3421- /// <summary>
3422- /// The content of a text box.
3423- /// </summary>
3424- public class TextContent : WindowContent
3425- {
3426- readonly string text;
3427- readonly bool password;
3428- readonly bool strict;
3429-
3430- internal TextContent(string text, bool password, bool strict)
3431- {
3432- this.text = text;
3433- this.password = password;
3434- this.strict = strict;
3435- }
3436-
3437- ///
3438- public string ComponentType
3439- {
3440- get { return strict ? "TextBox" : "Text"; }
3441- }
3442-
3443- ///
3444- public string ShortDescription
3445- {
3446- get
3447- {
3448- string s = strict ? " <TextBox>" : "";
3449- if (text.IndexOf("\n") != -1)
3450- return "<MultiLine>" + s;
3451- else if (password)
3452- return text + " <Password>" + s;
3453- else
3454- return text + s;
3455- }
3456- }
3457-
3458- ///
3459- public string LongDescription
3460- {
3461- get
3462- {
3463- if (password)
3464- return text + " <Password>";
3465- else
3466- return text;
3467- }
3468- }
3469-
3470- ///
3471- public Dictionary<string, string> PropertyList
3472- {
3473- get
3474- {
3475- Dictionary<string, string> result = new Dictionary<string, string>();
3476- result.Add("Password", password ? "True" : "False");
3477- result.Add("MultiLine", text.IndexOf('\n') != -1 ? "True" : "False");
3478- result.Add("Text", text);
3479- return result;
3480- }
3481- }
3482- }
3483-
3484- class TextFieldParser : WindowContentParser
3485- {
3486- readonly bool strict;
3487-
3488- public TextFieldParser(bool strict)
3489- {
3490- this.strict = strict;
3491- }
3492-
3493- internal override bool CanParseContent(SystemWindow sw)
3494- {
3495- if (strict)
3496- {
3497- uint EM_GETLINECOUNT = 0xBA;
3498- return sw.SendGetMessage(EM_GETLINECOUNT) != 0;
3499- }
3500- else
3501- {
3502- return sw.Title != "";
3503- }
3504- }
3505-
3506- internal override WindowContent ParseContent(SystemWindow sw)
3507- {
3508- return new TextContent(sw.Title, sw.PasswordCharacter != 0, strict);
3509- }
3510- }
3511-}
3512
3513=== removed file 'ManagedWinapi/Contents/WindowContent.cs'
3514--- ManagedWinapi/Contents/WindowContent.cs 2009-06-24 06:06:11 +0000
3515+++ ManagedWinapi/Contents/WindowContent.cs 1970-01-01 00:00:00 +0000
3516@@ -1,50 +0,0 @@
3517-/*
3518- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
3519- * access native API by managed code. http://mwinapi.sourceforge.net/
3520- * Copyright (C) 2006 Michael Schierl
3521- *
3522- * This library is free software; you can redistribute it and/or
3523- * modify it under the terms of the GNU Lesser General Public
3524- * License as published by the Free Software Foundation; either
3525- * version 2.1 of the License, or (at your option) any later version.
3526- * This library is distributed in the hope that it will be useful,
3527- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3528- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3529- * Lesser General Public License for more details.
3530- *
3531- * You should have received a copy of the GNU Lesser General Public
3532- * License along with this library; see the file COPYING. if not, visit
3533- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
3534- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3535- */
3536-using System;
3537-using System.Collections.Generic;
3538-
3539-namespace ManagedWinapi.Windows.Contents
3540-{
3541- /// <summary>
3542- /// An abstract representation of the content of a window or control.
3543- /// </summary>
3544- public interface WindowContent
3545- {
3546- /// <summary>
3547- /// A short description of the type of this window.
3548- /// </summary>
3549- string ComponentType { get;}
3550-
3551- /// <summary>
3552- /// A short description of this content.
3553- /// </summary>
3554- string ShortDescription { get;}
3555-
3556- /// <summary>
3557- /// The full description of this content.
3558- /// </summary>
3559- string LongDescription { get;}
3560-
3561- /// <summary>
3562- /// A list of properties of this content.
3563- /// </summary>
3564- Dictionary<String, String> PropertyList { get;}
3565- }
3566-}
3567
3568=== removed file 'ManagedWinapi/Contents/WindowContentParser.cs'
3569--- ManagedWinapi/Contents/WindowContentParser.cs 2009-06-24 06:06:11 +0000
3570+++ ManagedWinapi/Contents/WindowContentParser.cs 1970-01-01 00:00:00 +0000
3571@@ -1,36 +0,0 @@
3572-/*
3573- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
3574- * access native API by managed code. http://mwinapi.sourceforge.net/
3575- * Copyright (C) 2006 Michael Schierl
3576- *
3577- * This library is free software; you can redistribute it and/or
3578- * modify it under the terms of the GNU Lesser General Public
3579- * License as published by the Free Software Foundation; either
3580- * version 2.1 of the License, or (at your option) any later version.
3581- * This library is distributed in the hope that it will be useful,
3582- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3583- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3584- * Lesser General Public License for more details.
3585- *
3586- * You should have received a copy of the GNU Lesser General Public
3587- * License along with this library; see the file COPYING. if not, visit
3588- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
3589- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3590- */
3591-using System;
3592-
3593-namespace ManagedWinapi.Windows.Contents
3594-{
3595- internal abstract class WindowContentParser
3596- {
3597- internal abstract bool CanParseContent(SystemWindow sw);
3598- internal abstract WindowContent ParseContent(SystemWindow sw);
3599-
3600- internal static WindowContent Parse(SystemWindow sw)
3601- {
3602- WindowContentParser parser = ContentParserRegistry.Instance.GetParser(sw);
3603- if (parser == null) return null;
3604- return parser.ParseContent(sw);
3605- }
3606- }
3607-}
3608
3609=== removed file 'ManagedWinapi/Crosshair.Designer.cs'
3610--- ManagedWinapi/Crosshair.Designer.cs 2009-06-24 06:06:11 +0000
3611+++ ManagedWinapi/Crosshair.Designer.cs 1970-01-01 00:00:00 +0000
3612@@ -1,65 +0,0 @@
3613-namespace ManagedWinapi
3614-{
3615- partial class Crosshair
3616- {
3617- /// <summary>
3618- /// Required designer variable.
3619- /// </summary>
3620- private System.ComponentModel.IContainer components = null;
3621-
3622- /// <summary>
3623- /// Clean up any resources being used.
3624- /// </summary>
3625- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
3626- protected override void Dispose(bool disposing)
3627- {
3628- if (disposing && (components != null))
3629- {
3630- components.Dispose();
3631- }
3632- base.Dispose(disposing);
3633- }
3634-
3635- #region Component Designer generated code
3636-
3637- /// <summary>
3638- /// Required method for Designer support - do not modify
3639- /// the contents of this method with the code editor.
3640- /// </summary>
3641- private void InitializeComponent()
3642- {
3643- this.dragger = new System.Windows.Forms.PictureBox();
3644- ((System.ComponentModel.ISupportInitialize)(this.dragger)).BeginInit();
3645- this.SuspendLayout();
3646- //
3647- // dragger
3648- //
3649- this.dragger.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
3650- this.dragger.Cursor = System.Windows.Forms.Cursors.Cross;
3651- this.dragger.Dock = System.Windows.Forms.DockStyle.Fill;
3652- this.dragger.Location = new System.Drawing.Point(0, 0);
3653- this.dragger.Name = "dragger";
3654- this.dragger.Size = new System.Drawing.Size(36, 36);
3655- this.dragger.TabIndex = 0;
3656- this.dragger.TabStop = false;
3657- this.dragger.MouseDown += new System.Windows.Forms.MouseEventHandler(this.dragger_MouseDown);
3658- this.dragger.MouseMove += new System.Windows.Forms.MouseEventHandler(this.dragger_MouseMove);
3659- this.dragger.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dragger_MouseUp);
3660- //
3661- // Crosshair
3662- //
3663- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
3664- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
3665- this.Controls.Add(this.dragger);
3666- this.Name = "Crosshair";
3667- this.Size = new System.Drawing.Size(36, 36);
3668- ((System.ComponentModel.ISupportInitialize)(this.dragger)).EndInit();
3669- this.ResumeLayout(false);
3670-
3671- }
3672-
3673- #endregion
3674-
3675- private System.Windows.Forms.PictureBox dragger;
3676- }
3677-}
3678
3679=== removed file 'ManagedWinapi/Crosshair.cs'
3680--- ManagedWinapi/Crosshair.cs 2009-06-24 06:06:11 +0000
3681+++ ManagedWinapi/Crosshair.cs 1970-01-01 00:00:00 +0000
3682@@ -1,83 +0,0 @@
3683-using System;
3684-using System.Collections.Generic;
3685-using System.ComponentModel;
3686-using System.Drawing;
3687-using System.Data;
3688-using System.Text;
3689-using System.Windows.Forms;
3690-using System.Runtime.InteropServices;
3691-
3692-namespace ManagedWinapi
3693-{
3694- /// <summary>
3695- /// This component displays a crosshair icon that can be dragged to any point
3696- /// on screen. This is useful to select other programs by dragging the crosshair
3697- /// to a program window.
3698- /// </summary>
3699- [DefaultEvent("CrosshairDragged")]
3700- public partial class Crosshair : UserControl
3701- {
3702- Image myImage;
3703- Cursor myCursor;
3704-
3705- /// <summary>
3706- /// Occurs when the user finished dragging the crosshair. Use
3707- /// <see cref="Cursor.Position"/> to detect the cursor position.
3708- /// </summary>
3709- public event EventHandler CrosshairDragged;
3710-
3711- /// <summary>
3712- /// Occurs while the user drags the crosshair. Use
3713- /// <see cref="Cursor.Position"/> to detect the cursor position.
3714- /// </summary>
3715- public event EventHandler CrosshairDragging;
3716-
3717- /// <summary>
3718- /// Creates a new crosshair control.
3719- /// </summary>
3720- public Crosshair()
3721- {
3722- InitializeComponent();
3723- myImage = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ManagedWinapi.crosshair.ico"));
3724- myCursor = new Cursor(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ManagedWinapi.crosshair.ico"));
3725- dragger.Image = myImage;
3726- }
3727-
3728- private void dragger_MouseDown(object sender, MouseEventArgs e)
3729- {
3730- dragger.Image = null;
3731- dragger.Cursor = myCursor;
3732- }
3733-
3734- private void dragger_MouseUp(object sender, MouseEventArgs e)
3735- {
3736- dragger.Image = myImage;
3737- dragger.Cursor = Cursors.Cross;
3738- if (CrosshairDragged != null)
3739- {
3740- CrosshairDragged(this, new EventArgs());
3741- }
3742- }
3743-
3744- private void dragger_MouseMove(object sender, MouseEventArgs e)
3745- {
3746- if (dragger.Cursor == myCursor)
3747- {
3748- if (CrosshairDragging != null)
3749- {
3750- CrosshairDragging(this, new EventArgs());
3751- }
3752- }
3753- }
3754-
3755- /// <summary>
3756- /// When a window is hidden, the .NET framework releases mouse capture.
3757- /// If you hide your window while the crosshair is dragged, invoke
3758- /// this method afterwards to restore mouse capture.
3759- /// </summary>
3760- public void RestoreMouseCapture()
3761- {
3762- dragger.Capture = true;
3763- }
3764- }
3765-}
3766
3767=== removed file 'ManagedWinapi/Crosshair.resx'
3768--- ManagedWinapi/Crosshair.resx 2009-06-24 06:06:11 +0000
3769+++ ManagedWinapi/Crosshair.resx 1970-01-01 00:00:00 +0000
3770@@ -1,120 +0,0 @@
3771-<?xml version="1.0" encoding="utf-8"?>
3772-<root>
3773- <!--
3774- Microsoft ResX Schema
3775-
3776- Version 2.0
3777-
3778- The primary goals of this format is to allow a simple XML format
3779- that is mostly human readable. The generation and parsing of the
3780- various data types are done through the TypeConverter classes
3781- associated with the data types.
3782-
3783- Example:
3784-
3785- ... ado.net/XML headers & schema ...
3786- <resheader name="resmimetype">text/microsoft-resx</resheader>
3787- <resheader name="version">2.0</resheader>
3788- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
3789- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
3790- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
3791- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
3792- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
3793- <value>[base64 mime encoded serialized .NET Framework object]</value>
3794- </data>
3795- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
3796- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
3797- <comment>This is a comment</comment>
3798- </data>
3799-
3800- There are any number of "resheader" rows that contain simple
3801- name/value pairs.
3802-
3803- Each data row contains a name, and value. The row also contains a
3804- type or mimetype. Type corresponds to a .NET class that support
3805- text/value conversion through the TypeConverter architecture.
3806- Classes that don't support this are serialized and stored with the
3807- mimetype set.
3808-
3809- The mimetype is used for serialized objects, and tells the
3810- ResXResourceReader how to depersist the object. This is currently not
3811- extensible. For a given mimetype the value must be set accordingly:
3812-
3813- Note - application/x-microsoft.net.object.binary.base64 is the format
3814- that the ResXResourceWriter will generate, however the reader can
3815- read any of the formats listed below.
3816-
3817- mimetype: application/x-microsoft.net.object.binary.base64
3818- value : The object must be serialized with
3819- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
3820- : and then encoded with base64 encoding.
3821-
3822- mimetype: application/x-microsoft.net.object.soap.base64
3823- value : The object must be serialized with
3824- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
3825- : and then encoded with base64 encoding.
3826-
3827- mimetype: application/x-microsoft.net.object.bytearray.base64
3828- value : The object must be serialized into a byte array
3829- : using a System.ComponentModel.TypeConverter
3830- : and then encoded with base64 encoding.
3831- -->
3832- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
3833- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
3834- <xsd:element name="root" msdata:IsDataSet="true">
3835- <xsd:complexType>
3836- <xsd:choice maxOccurs="unbounded">
3837- <xsd:element name="metadata">
3838- <xsd:complexType>
3839- <xsd:sequence>
3840- <xsd:element name="value" type="xsd:string" minOccurs="0" />
3841- </xsd:sequence>
3842- <xsd:attribute name="name" use="required" type="xsd:string" />
3843- <xsd:attribute name="type" type="xsd:string" />
3844- <xsd:attribute name="mimetype" type="xsd:string" />
3845- <xsd:attribute ref="xml:space" />
3846- </xsd:complexType>
3847- </xsd:element>
3848- <xsd:element name="assembly">
3849- <xsd:complexType>
3850- <xsd:attribute name="alias" type="xsd:string" />
3851- <xsd:attribute name="name" type="xsd:string" />
3852- </xsd:complexType>
3853- </xsd:element>
3854- <xsd:element name="data">
3855- <xsd:complexType>
3856- <xsd:sequence>
3857- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
3858- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
3859- </xsd:sequence>
3860- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
3861- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
3862- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
3863- <xsd:attribute ref="xml:space" />
3864- </xsd:complexType>
3865- </xsd:element>
3866- <xsd:element name="resheader">
3867- <xsd:complexType>
3868- <xsd:sequence>
3869- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
3870- </xsd:sequence>
3871- <xsd:attribute name="name" type="xsd:string" use="required" />
3872- </xsd:complexType>
3873- </xsd:element>
3874- </xsd:choice>
3875- </xsd:complexType>
3876- </xsd:element>
3877- </xsd:schema>
3878- <resheader name="resmimetype">
3879- <value>text/microsoft-resx</value>
3880- </resheader>
3881- <resheader name="version">
3882- <value>2.0</value>
3883- </resheader>
3884- <resheader name="reader">
3885- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
3886- </resheader>
3887- <resheader name="writer">
3888- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
3889- </resheader>
3890-</root>
3891\ No newline at end of file
3892
3893=== removed file 'ManagedWinapi/EventDispatchingNativeWindow.cs'
3894--- ManagedWinapi/EventDispatchingNativeWindow.cs 2009-06-24 06:06:11 +0000
3895+++ ManagedWinapi/EventDispatchingNativeWindow.cs 1970-01-01 00:00:00 +0000
3896@@ -1,93 +0,0 @@
3897-/*
3898- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
3899- * access native API by managed code. http://mwinapi.sourceforge.net/
3900- * Copyright (C) 2006 Michael Schierl
3901- *
3902- * This library is free software; you can redistribute it and/or
3903- * modify it under the terms of the GNU Lesser General Public
3904- * License as published by the Free Software Foundation; either
3905- * version 2.1 of the License, or (at your option) any later version.
3906- * This library is distributed in the hope that it will be useful,
3907- * but WITHOUT ANY WARRANTY; without even the implied warranty of
3908- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3909- * Lesser General Public License for more details.
3910- *
3911- * You should have received a copy of the GNU Lesser General Public
3912- * License along with this library; see the file COPYING. if not, visit
3913- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
3914- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3915- */
3916-using System;
3917-using System.Collections.Generic;
3918-using System.Text;
3919-using System.Windows.Forms;
3920-
3921-namespace ManagedWinapi.Windows
3922-{
3923-
3924- /// <summary>
3925- /// Called by an EventDispatchingNativeWindow when a window message is received
3926- /// </summary>
3927- /// <param name="m">The message to handle.</param>
3928- /// <param name="handled">Whether the event has already been handled. If this value is true, the handler
3929- /// should return immediately. It may set the value to true to indicate that no others
3930- /// should handle it. If the event is not handled by any handler, it is passed to the
3931- /// default WindowProc.</param>
3932- public delegate void WndProcEventHandler(ref Message m, ref bool handled);
3933-
3934- /// <summary>
3935- /// A Win32 native window that delegates window messages to handlers. So several
3936- /// components can use the same native window to save "USER resources". This class
3937- /// is useful when writing your own components.
3938- /// </summary>
3939- public class EventDispatchingNativeWindow : NativeWindow
3940- {
3941-
3942- private static Object myLock = new Object();
3943- private static EventDispatchingNativeWindow _instance;
3944-
3945- /// <summary>
3946- /// A global instance which can be used by components that do not need
3947- /// their own window.
3948- /// </summary>
3949- public static EventDispatchingNativeWindow Instance
3950- {
3951- get
3952- {
3953- lock (myLock)
3954- {
3955- if (_instance == null)
3956- _instance = new EventDispatchingNativeWindow();
3957- return _instance;
3958- }
3959- }
3960- }
3961-
3962- /// <summary>
3963- /// Attach your event handlers here.
3964- /// </summary>
3965- public event WndProcEventHandler EventHandler;
3966-
3967- /// <summary>
3968- /// Create your own event dispatching window.
3969- /// </summary>
3970- public EventDispatchingNativeWindow()
3971- {
3972- CreateHandle(new CreateParams());
3973- }
3974-
3975- /// <summary>
3976- /// Parse messages passed to this window and send them to the event handlers.
3977- /// </summary>
3978- /// <param name="m">A System.Windows.Forms.Message that is associated with the
3979- /// current Windows message.</param>
3980- protected override void WndProc(ref Message m)
3981- {
3982- bool handled = false;
3983- if (EventHandler != null)
3984- EventHandler(ref m, ref handled);
3985- if (!handled)
3986- base.WndProc(ref m);
3987- }
3988- }
3989-}
3990
3991=== removed file 'ManagedWinapi/ExtendedFileInfo.cs'
3992--- ManagedWinapi/ExtendedFileInfo.cs 2009-06-24 06:06:11 +0000
3993+++ ManagedWinapi/ExtendedFileInfo.cs 1970-01-01 00:00:00 +0000
3994@@ -1,177 +0,0 @@
3995-/*
3996- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
3997- * access native API by managed code. http://mwinapi.sourceforge.net/
3998- * Copyright (C) 2006, 2007 Michael Schierl
3999- *
4000- * This library is free software; you can redistribute it and/or
4001- * modify it under the terms of the GNU Lesser General Public
4002- * License as published by the Free Software Foundation; either
4003- * version 2.1 of the License, or (at your option) any later version.
4004- * This library is distributed in the hope that it will be useful,
4005- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4006- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4007- * Lesser General Public License for more details.
4008- *
4009- * You should have received a copy of the GNU Lesser General Public
4010- * License along with this library; see the file COPYING. if not, visit
4011- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
4012- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4013- */
4014-using System;
4015-using System.Collections.Generic;
4016-using System.Text;
4017-using System.Drawing;
4018-using System.Runtime.InteropServices;
4019-using System.IO;
4020-using System.ComponentModel;
4021-
4022-namespace ManagedWinapi
4023-{
4024- /// <summary>
4025- /// Provides methods for getting additional information about
4026- /// files, like icons or compressed file size.
4027- /// </summary>
4028- public sealed class ExtendedFileInfo
4029- {
4030- /// <summary>
4031- /// Get the icon used for folders.
4032- /// </summary>
4033- /// <param name="small">Whether to get the small icon instead of the large one</param>
4034- public static Icon GetFolderIcon(bool small)
4035- {
4036- return GetIconForFilename(Environment.GetFolderPath(Environment.SpecialFolder.System), small);
4037- }
4038-
4039- /// <summary>
4040- /// Get the icon used for files that do not have their own icon
4041- /// </summary>
4042- /// <param name="small">Whether to get the small icon instead of the large one</param>
4043- public static Icon GetFileIcon(bool small)
4044- {
4045- return GetExtensionIcon("", small);
4046- }
4047-
4048- /// <summary>
4049- /// Get the icon used by files of a given extension.
4050- /// </summary>
4051- /// <param name="extension">The extension without leading dot</param>
4052- /// <param name="small">Whether to get the small icon instead of the large one</param>
4053- public static Icon GetExtensionIcon(string extension, bool small)
4054- {
4055- string tmp = Path.GetTempFileName();
4056- File.Delete(tmp);
4057- string fn = tmp + "." + extension;
4058- try
4059- {
4060- File.Create(fn).Close();
4061- return GetIconForFilename(fn, small);
4062- }
4063- finally
4064- {
4065- File.Delete(fn);
4066- }
4067- }
4068-
4069- /// <summary>
4070- /// Get the icon used for a given, existing file.
4071- /// </summary>
4072- /// <param name="fileName">Name of the file</param>
4073- /// <param name="small">Whether to get the small icon instead of the large one</param>
4074- public static Icon GetIconForFilename(string fileName, bool small)
4075- {
4076- SHFILEINFO shinfo = new SHFILEINFO();
4077-
4078- if (small)
4079- {
4080- IntPtr hImgSmall = SHGetFileInfo(fileName, 0, ref shinfo,
4081- (uint)Marshal.SizeOf(shinfo),
4082- SHGFI_ICON |
4083- SHGFI_SMALLICON);
4084- }
4085- else
4086- {
4087- IntPtr hImgLarge = SHGetFileInfo(fileName, 0,
4088- ref shinfo, (uint)Marshal.SizeOf(shinfo),
4089- SHGFI_ICON | SHGFI_LARGEICON);
4090- }
4091-
4092- if (shinfo.hIcon == IntPtr.Zero) return null;
4093-
4094- System.Drawing.Icon myIcon =
4095- System.Drawing.Icon.FromHandle(shinfo.hIcon);
4096- return myIcon;
4097- }
4098-
4099- /// <summary>
4100- /// Get the size a file requires on disk. This takes NTFS
4101- /// compression into account.
4102- /// </summary>
4103- public static ulong GetPhysicalFileSize(string filename)
4104- {
4105- uint high;
4106- uint low;
4107- low = GetCompressedFileSize(filename, out high);
4108- int error = Marshal.GetLastWin32Error();
4109- if (error == 32)
4110- {
4111- return (ulong)new FileInfo(filename).Length;
4112- }
4113- if (high == 0 && low == 0xFFFFFFFF && error != 0)
4114- throw new Win32Exception(error);
4115- else
4116- return ((ulong)high << 32) + low;
4117- }
4118-
4119- /// <summary>
4120- /// Get the cluster size for the filesystem that contains the given file.
4121- /// </summary>
4122- public static uint GetClusterSize(string filename)
4123- {
4124- uint sectors, bytes, dummy;
4125- string drive = Path.GetPathRoot(filename);
4126- if (!GetDiskFreeSpace(drive, out sectors, out bytes,
4127- out dummy, out dummy))
4128- {
4129- throw new Win32Exception(Marshal.GetLastWin32Error());
4130- }
4131- return sectors * bytes;
4132- }
4133-
4134- #region PInvoke Declarations
4135-
4136- private const uint SHGFI_ICON = 0x100;
4137- private const uint SHGFI_LARGEICON = 0x0; // 'Large icon
4138- private const uint SHGFI_SMALLICON = 0x1; // 'Small icon
4139-
4140- [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
4141- static extern bool GetDiskFreeSpace(string lpRootPathName,
4142- out uint lpSectorsPerCluster,
4143- out uint lpBytesPerSector,
4144- out uint lpNumberOfFreeClusters,
4145- out uint lpTotalNumberOfClusters);
4146-
4147- [DllImport("kernel32.dll")]
4148- private static extern uint GetCompressedFileSize(string lpFileName,
4149- out uint lpFileSizeHigh);
4150-
4151- [DllImport("shell32.dll")]
4152- private static extern IntPtr SHGetFileInfo(string pszPath,
4153- uint dwFileAttributes,
4154- ref SHFILEINFO psfi,
4155- uint cbSizeFileInfo,
4156- uint uFlags);
4157-
4158- [StructLayout(LayoutKind.Sequential)]
4159- private struct SHFILEINFO
4160- {
4161- public IntPtr hIcon;
4162- public IntPtr iIcon;
4163- public uint dwAttributes;
4164- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
4165- public string szDisplayName;
4166- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
4167- public string szTypeName;
4168- };
4169- #endregion
4170- }
4171-}
4172\ No newline at end of file
4173
4174=== removed file 'ManagedWinapi/Hook.cs'
4175--- ManagedWinapi/Hook.cs 2009-06-24 06:06:11 +0000
4176+++ ManagedWinapi/Hook.cs 1970-01-01 00:00:00 +0000
4177@@ -1,309 +0,0 @@
4178-/*
4179- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
4180- * access native API by managed code. http://mwinapi.sourceforge.net/
4181- * Copyright (C) 2006, 2007 Michael Schierl
4182- *
4183- * This library is free software; you can redistribute it and/or
4184- * modify it under the terms of the GNU Lesser General Public
4185- * License as published by the Free Software Foundation; either
4186- * version 2.1 of the License, or (at your option) any later version.
4187- * This library is distributed in the hope that it will be useful,
4188- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4189- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4190- * Lesser General Public License for more details.
4191- *
4192- * You should have received a copy of the GNU Lesser General Public
4193- * License along with this library; see the file COPYING. if not, visit
4194- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
4195- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4196- */
4197-using System;
4198-using System.Collections.Generic;
4199-using System.Text;
4200-using System.ComponentModel;
4201-using System.Runtime.InteropServices;
4202-using System.Windows.Forms;
4203-using System.Diagnostics;
4204-using System.Reflection;
4205-using System.Threading;
4206-
4207-namespace ManagedWinapi.Hooks
4208-{
4209- /// <summary>
4210- /// A hook is a point in the system message-handling mechanism where an application
4211- /// can install a subroutine to monitor the message traffic in the system and process
4212- /// certain types of messages before they reach the target window procedure.
4213- /// </summary>
4214- public class Hook : Component
4215- {
4216- private HookType type;
4217- internal bool hooked = false;
4218- private IntPtr hHook;
4219- private bool wrapCallback, global;
4220- private IntPtr wrappedDelegate;
4221- private IntPtr hWrapperInstance;
4222- private readonly HookProc managedDelegate;
4223-
4224- /// <summary>
4225- /// Occurs when the hook's callback is called.
4226- /// </summary>
4227- public event HookCallback Callback;
4228-
4229- /// <summary>
4230- /// Represents a method that handles a callback from a hook.
4231- /// </summary>
4232- public delegate int HookCallback(int code, IntPtr wParam, IntPtr lParam, ref bool callNext);
4233-
4234- /// <summary>
4235- /// Creates a new hook and hooks it.
4236- /// </summary>
4237- public Hook(HookType type, HookCallback callback, bool wrapCallback, bool global)
4238- : this(type, wrapCallback, global)
4239- {
4240- this.Callback += callback;
4241- StartHook();
4242- }
4243-
4244- /// <summary>
4245- /// Creates a new hook.
4246- /// </summary>
4247- public Hook(HookType type, bool wrapCallback, bool global)
4248- : this()
4249- {
4250- this.type = type;
4251- this.wrapCallback = wrapCallback;
4252- this.global = global;
4253- }
4254-
4255- /// <summary>
4256- /// Creates a new hook.
4257- /// </summary>
4258- public Hook(IContainer container)
4259- : this()
4260- {
4261- container.Add(this);
4262- }
4263-
4264- /// <summary>
4265- /// Creates a new hook.
4266- /// </summary>
4267- public Hook()
4268- {
4269- managedDelegate = new HookProc(InternalCallback);
4270- }
4271-
4272- /// <summary>
4273- /// The type of the hook.
4274- /// </summary>
4275- public HookType Type
4276- {
4277- get { return type; }
4278- set { type = value; }
4279- }
4280-
4281- /// <summary>
4282- /// Whether this hook has been started.
4283- /// </summary>
4284- public bool Hooked
4285- {
4286- get { return hooked; }
4287- }
4288-
4289- /// <summary>
4290- /// Hooks the hook.
4291- /// </summary>
4292- public virtual void StartHook()
4293- {
4294- if (hooked) return;
4295- IntPtr delegt = Marshal.GetFunctionPointerForDelegate(managedDelegate);
4296- if (wrapCallback)
4297- {
4298- wrappedDelegate = AllocHookWrapper(delegt);
4299- hWrapperInstance = LoadLibrary("ManagedWinapiNativeHelper.dll");
4300- hHook = SetWindowsHookEx(type, wrappedDelegate, hWrapperInstance, 0);
4301- }
4302- else if (global)
4303- {
4304- hHook = SetWindowsHookEx(type, delegt, Marshal.GetHINSTANCE(typeof(Hook).Assembly.GetModules()[0]), 0);
4305- }
4306- else
4307- {
4308- hHook = SetWindowsHookEx(type, delegt, IntPtr.Zero, getThreadID());
4309- }
4310- if (hHook == IntPtr.Zero) throw new Win32Exception(Marshal.GetLastWin32Error());
4311- hooked = true;
4312- }
4313-
4314- private uint getThreadID()
4315- {
4316-#pragma warning disable 0618
4317- return (uint)AppDomain.GetCurrentThreadId();
4318-#pragma warning restore 0618
4319- }
4320-
4321- /// <summary>
4322- /// Unhooks the hook.
4323- /// </summary>
4324- public virtual void Unhook()
4325- {
4326- if (!hooked) return;
4327- if (!UnhookWindowsHookEx(hHook)) throw new Win32Exception(Marshal.GetLastWin32Error());
4328- if (wrapCallback)
4329- {
4330- if (!FreeHookWrapper(wrappedDelegate)) throw new Win32Exception();
4331- if (!FreeLibrary(hWrapperInstance)) throw new Win32Exception();
4332- }
4333- hooked = false;
4334- }
4335-
4336- /// <summary>
4337- /// Unhooks the hook if necessary.
4338- /// </summary>
4339- protected override void Dispose(bool disposing)
4340- {
4341- if (hooked)
4342- {
4343- Unhook();
4344- }
4345- base.Dispose(disposing);
4346- }
4347-
4348- /// <summary>
4349- /// Override this method if you want to prevent a call
4350- /// to the CallNextHookEx method or if you want to return
4351- /// a different return value. For most hooks this is not needed.
4352- /// </summary>
4353- protected virtual int InternalCallback(int code, IntPtr wParam, IntPtr lParam)
4354- {
4355- if (code >= 0 && Callback != null)
4356- {
4357- bool callNext = true;
4358- int retval = Callback(code, wParam, lParam, ref callNext);
4359- if (!callNext) return retval;
4360- }
4361- return CallNextHookEx(hHook, code, wParam, lParam);
4362- }
4363-
4364- #region PInvoke Declarations
4365-
4366- [DllImport("user32.dll", SetLastError = true)]
4367- private static extern IntPtr SetWindowsHookEx(HookType hook, IntPtr callback,
4368- IntPtr hMod, uint dwThreadId);
4369-
4370- [DllImport("user32.dll", SetLastError = true)]
4371- internal static extern bool UnhookWindowsHookEx(IntPtr hhk);
4372-
4373- [DllImport("user32.dll")]
4374- internal static extern int CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam,
4375- IntPtr lParam);
4376-
4377- [DllImport("ManagedWinapiNativeHelper.dll")]
4378- private static extern IntPtr AllocHookWrapper(IntPtr callback);
4379-
4380- [DllImport("ManagedWinapiNativeHelper.dll")]
4381- private static extern bool FreeHookWrapper(IntPtr wrapper);
4382-
4383- [DllImport("kernel32.dll")]
4384- private static extern IntPtr LoadLibrary(string lpFileName);
4385-
4386- [DllImport("kernel32.dll", SetLastError = true)]
4387- private static extern bool FreeLibrary(IntPtr hModule);
4388-
4389- private delegate int HookProc(int code, IntPtr wParam, IntPtr lParam);
4390-
4391- internal static readonly int HC_ACTION = 0,
4392- HC_GETNEXT = 1,
4393- HC_SKIP = 2,
4394- HC_NOREMOVE = 3,
4395- HC_SYSMODALON = 4,
4396- HC_SYSMODALOFF = 5;
4397- #endregion
4398- }
4399-
4400- /// <summary>
4401- /// A hook that intercepts local window messages.
4402- /// </summary>
4403- public class LocalMessageHook : Hook
4404- {
4405- /// <summary>
4406- /// Called when a message has been intercepted.
4407- /// </summary>
4408- public event MessageCallback MessageOccurred;
4409-
4410- /// <summary>
4411- /// Represents a method that handles a message from a message hook.
4412- /// </summary>
4413- /// <param name="msg"></param>
4414- public delegate void MessageCallback(Message msg);
4415-
4416- /// <summary>
4417- /// Creates a local message hook and hooks it.
4418- /// </summary>
4419- /// <param name="callback"></param>
4420- public LocalMessageHook(MessageCallback callback)
4421- : this()
4422- {
4423- this.MessageOccurred = callback;
4424- StartHook();
4425- }
4426-
4427- /// <summary>
4428- /// Creates a local message hook.
4429- /// </summary>
4430- public LocalMessageHook()
4431- : base(HookType.WH_GETMESSAGE, false, false)
4432- {
4433- base.Callback += MessageHookCallback;
4434- }
4435-
4436- private int MessageHookCallback(int code, IntPtr lParam, IntPtr wParam, ref bool callNext)
4437- {
4438- if (code == HC_ACTION)
4439- {
4440- Message msg = (Message)Marshal.PtrToStructure(wParam, typeof(Message));
4441- if (MessageOccurred != null)
4442- {
4443- MessageOccurred(msg);
4444- }
4445- }
4446- return 0;
4447- }
4448- }
4449-
4450- /// <summary>
4451- /// Hook Types. See the documentation of SetWindowsHookEx for reference.
4452- /// </summary>
4453- public enum HookType : int
4454- {
4455- ///
4456- WH_JOURNALRECORD = 0,
4457- ///
4458- WH_JOURNALPLAYBACK = 1,
4459- ///
4460- WH_KEYBOARD = 2,
4461- ///
4462- WH_GETMESSAGE = 3,
4463- ///
4464- WH_CALLWNDPROC = 4,
4465- ///
4466- WH_CBT = 5,
4467- ///
4468- WH_SYSMSGFILTER = 6,
4469- ///
4470- WH_MOUSE = 7,
4471- ///
4472- WH_HARDWARE = 8,
4473- ///
4474- WH_DEBUG = 9,
4475- ///
4476- WH_SHELL = 10,
4477- ///
4478- WH_FOREGROUNDIDLE = 11,
4479- ///
4480- WH_CALLWNDPROCRET = 12,
4481- ///
4482- WH_KEYBOARD_LL = 13,
4483- ///
4484- WH_MOUSE_LL = 14
4485- }
4486-}
4487
4488=== removed file 'ManagedWinapi/Hotkey.cs'
4489--- ManagedWinapi/Hotkey.cs 2009-06-24 06:06:11 +0000
4490+++ ManagedWinapi/Hotkey.cs 1970-01-01 00:00:00 +0000
4491@@ -1,206 +0,0 @@
4492-/*
4493- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
4494- * access native API by managed code. http://mwinapi.sourceforge.net/
4495- * Copyright (C) 2006 Michael Schierl
4496- *
4497- * This library is free software; you can redistribute it and/or
4498- * modify it under the terms of the GNU Lesser General Public
4499- * License as published by the Free Software Foundation; either
4500- * version 2.1 of the License, or (at your option) any later version.
4501- * This library is distributed in the hope that it will be useful,
4502- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4503- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4504- * Lesser General Public License for more details.
4505- *
4506- * You should have received a copy of the GNU Lesser General Public
4507- * License along with this library; see the file COPYING. if not, visit
4508- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
4509- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4510- */
4511-using System;
4512-using System.Collections.Generic;
4513-using System.Text;
4514-using System.ComponentModel;
4515-using System.Windows.Forms;
4516-using System.Runtime.InteropServices;
4517-using ManagedWinapi.Windows;
4518-
4519-namespace ManagedWinapi
4520-{
4521-
4522- /// <summary>
4523- /// Specifies a component that creates a global keyboard hotkey.
4524- /// </summary>
4525- [DefaultEvent("HotkeyPressed")]
4526- public class Hotkey : Component
4527- {
4528-
4529- /// <summary>
4530- /// Occurs when the hotkey is pressed.
4531- /// </summary>
4532- public event EventHandler HotkeyPressed;
4533-
4534- private static Object myStaticLock = new Object();
4535- private static int hotkeyCounter = 0xA000;
4536-
4537- private int hotkeyIndex;
4538- private bool isDisposed = false, isEnabled = false, isRegistered = false;
4539- private Keys _keyCode;
4540- private bool _ctrl, _alt, _shift, _windows;
4541- private readonly IntPtr hWnd;
4542-
4543- /// <summary>
4544- /// Initializes a new instance of this class with the specified container.
4545- /// </summary>
4546- /// <param name="container">The container to add it to.</param>
4547- public Hotkey(IContainer container) : this()
4548- {
4549- container.Add(this);
4550- }
4551-
4552- /// <summary>
4553- /// Initializes a new instance of this class.
4554- /// </summary>
4555- public Hotkey()
4556- {
4557- EventDispatchingNativeWindow.Instance.EventHandler += nw_EventHandler;
4558- lock(myStaticLock)
4559- {
4560- hotkeyIndex = ++hotkeyCounter;
4561- }
4562- hWnd = EventDispatchingNativeWindow.Instance.Handle;
4563- }
4564-
4565- /// <summary>
4566- /// Enables the hotkey. When the hotkey is enabled, pressing it causes a
4567- /// <c>HotkeyPressed</c> event instead of being handled by the active
4568- /// application.
4569- /// </summary>
4570- public bool Enabled
4571- {
4572- get
4573- {
4574- return isEnabled;
4575- }
4576- set
4577- {
4578- isEnabled = value;
4579- updateHotkey(false);
4580- }
4581- }
4582-
4583- /// <summary>
4584- /// The key code of the hotkey.
4585- /// </summary>
4586- public Keys KeyCode
4587- {
4588- get
4589- {
4590- return _keyCode;
4591- }
4592-
4593- set
4594- {
4595- _keyCode = value;
4596- updateHotkey(true);
4597- }
4598- }
4599-
4600- /// <summary>
4601- /// Whether the shortcut includes the Control modifier.
4602- /// </summary>
4603- public bool Ctrl {
4604- get { return _ctrl; }
4605- set {_ctrl = value; updateHotkey(true);}
4606- }
4607-
4608- /// <summary>
4609- /// Whether this shortcut includes the Alt modifier.
4610- /// </summary>
4611- public bool Alt {
4612- get { return _alt; }
4613- set {_alt = value; updateHotkey(true);}
4614- }
4615-
4616- /// <summary>
4617- /// Whether this shortcut includes the shift modifier.
4618- /// </summary>
4619- public bool Shift {
4620- get { return _shift; }
4621- set {_shift = value; updateHotkey(true);}
4622- }
4623-
4624- /// <summary>
4625- /// Whether this shortcut includes the Windows key modifier. The windows key
4626- /// is an addition by Microsoft to the keyboard layout. It is located between
4627- /// Control and Alt and depicts a Windows flag.
4628- /// </summary>
4629- public bool WindowsKey {
4630- get { return _windows; }
4631- set {_windows = value; updateHotkey(true);}
4632- }
4633-
4634- void nw_EventHandler(ref Message m, ref bool handled)
4635- {
4636- if (handled) return;
4637- if (m.Msg == WM_HOTKEY && m.WParam.ToInt32() == hotkeyIndex)
4638- {
4639- if (HotkeyPressed != null)
4640- HotkeyPressed(this, EventArgs.Empty);
4641- handled = true;
4642- }
4643- }
4644-
4645- /// <summary>
4646- /// Releases all resources used by the System.ComponentModel.Component.
4647- /// </summary>
4648- /// <param name="disposing">Whether to dispose managed resources.</param>
4649- protected override void Dispose(bool disposing)
4650- {
4651- isDisposed = true;
4652- updateHotkey(false);
4653- EventDispatchingNativeWindow.Instance.EventHandler -= nw_EventHandler;
4654- base.Dispose(disposing);
4655- }
4656-
4657- private void updateHotkey(bool reregister)
4658- {
4659- bool shouldBeRegistered = isEnabled && !isDisposed && !DesignMode;
4660- if (isRegistered && (!shouldBeRegistered || reregister))
4661- {
4662- // unregister hotkey
4663- UnregisterHotKey(hWnd, hotkeyIndex);
4664- isRegistered = false;
4665- }
4666- if (!isRegistered && shouldBeRegistered)
4667- {
4668- // register hotkey
4669- bool success = RegisterHotKey(hWnd, hotkeyIndex,
4670- (_shift ? MOD_SHIFT : 0) + (_ctrl ? MOD_CONTROL : 0) +
4671- (_alt ? MOD_ALT : 0) + (_windows ? MOD_WIN : 0), (int)_keyCode);
4672- if (!success) throw new HotkeyAlreadyInUseException();
4673- isRegistered = true;
4674- }
4675- }
4676-
4677- #region PInvoke Declarations
4678-
4679- [DllImport("user32.dll", SetLastError=true)]
4680- private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc);
4681- [DllImport("user32.dll", SetLastError=true)]
4682- private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
4683-
4684- private static readonly int MOD_ALT = 0x0001,
4685- MOD_CONTROL = 0x0002, MOD_SHIFT = 0x0004, MOD_WIN = 0x0008;
4686-
4687- private static readonly int WM_HOTKEY = 0x0312;
4688-
4689- #endregion
4690- }
4691-
4692- /// <summary>
4693- /// The exception is thrown when a hotkey should be registered that
4694- /// has already been registered by another application.
4695- /// </summary>
4696- public class HotkeyAlreadyInUseException : Exception { }
4697-}
4698
4699=== removed file 'ManagedWinapi/InputBlocker.cs'
4700--- ManagedWinapi/InputBlocker.cs 2009-06-24 06:06:11 +0000
4701+++ ManagedWinapi/InputBlocker.cs 1970-01-01 00:00:00 +0000
4702@@ -1,38 +0,0 @@
4703-using System;
4704-using System.Runtime.InteropServices;
4705-
4706-namespace ManagedWinapi
4707-{
4708- /// <summary>
4709- /// Blocks keyboard and mouse input until this object is disposed.
4710- /// Unlike <see cref="ManagedWinapi.Hooks.InputLocker"/>, you cannot detect when the systems
4711- /// removes the block (which happens when the user presses CTRL+ALT+DEL),
4712- /// but it works on Windows Vista as well.
4713- /// </summary>
4714- public class InputBlocker : IDisposable
4715- {
4716- bool needUnblock;
4717-
4718- /// <summary>
4719- /// Blocks keyboard and mouse input until this object is disposed.
4720- /// </summary>
4721- public InputBlocker()
4722- {
4723- needUnblock = BlockInput(true);
4724- }
4725-
4726- /// <summary>
4727- /// Unblocks keyboard and mouse input.
4728- /// </summary>
4729- public void Dispose()
4730- {
4731- if (needUnblock) BlockInput(false);
4732- needUnblock = false;
4733- }
4734-
4735- #region PInvoke Declarations
4736- [DllImport("user32.dll")]
4737- static extern bool BlockInput(bool fBlockIt);
4738- #endregion
4739- }
4740-}
4741
4742=== removed file 'ManagedWinapi/JournalHook.cs'
4743--- ManagedWinapi/JournalHook.cs 2009-06-24 06:06:11 +0000
4744+++ ManagedWinapi/JournalHook.cs 1970-01-01 00:00:00 +0000
4745@@ -1,423 +0,0 @@
4746-/*
4747- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
4748- * access native API by managed code. http://mwinapi.sourceforge.net/
4749- * Copyright (C) 2006, 2007 Michael Schierl
4750- *
4751- * This library is free software; you can redistribute it and/or
4752- * modify it under the terms of the GNU Lesser General Public
4753- * License as published by the Free Software Foundation; either
4754- * version 2.1 of the License, or (at your option) any later version.
4755- * This library is distributed in the hope that it will be useful,
4756- * but WITHOUT ANY WARRANTY; without even the implied warranty of
4757- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4758- * Lesser General Public License for more details.
4759- *
4760- * You should have received a copy of the GNU Lesser General Public
4761- * License along with this library; see the file COPYING. if not, visit
4762- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
4763- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4764- */
4765-using System;
4766-using System.Collections.Generic;
4767-using System.Text;
4768-using System.ComponentModel;
4769-using System.Runtime.InteropServices;
4770-
4771-namespace ManagedWinapi.Hooks
4772-{
4773- /// <summary>
4774- /// Abstract base class for hooks that can be used to create or playback
4775- /// a log of keyboard and mouse events.
4776- /// </summary>
4777- public abstract class JournalHook : Hook
4778- {
4779- /// <summary>
4780- /// Occurs when the journal activity has been cancelled by
4781- /// CTRL+ALT+DEL or CTRL+ESC.
4782- /// </summary>
4783- public event EventHandler JournalCancelled;
4784- private readonly LocalMessageHook lmh;
4785-
4786- /// <summary>
4787- /// Creates a new journal hook.
4788- /// </summary>
4789- public JournalHook(HookType type)
4790- : base(type, true, false)
4791- {
4792- lmh = new LocalMessageHook();
4793- lmh.MessageOccurred += new LocalMessageHook.MessageCallback(lmh_Callback);
4794- }
4795-
4796- private void lmh_Callback(System.Windows.Forms.Message msg)
4797- {
4798- if (msg.Msg == WM_CANCELJOURNAL)
4799- {
4800- hooked = false;
4801- lmh.Unhook();
4802- if (JournalCancelled != null)
4803- {
4804- JournalCancelled(this, new EventArgs());
4805- }
4806- }
4807- }
4808-
4809- /// <summary>
4810- /// Hooks the hook.
4811- /// </summary>
4812- public override void StartHook()
4813- {
4814- if (Hooked) return;
4815- lmh.StartHook();
4816- base.StartHook();
4817- }
4818-
4819- /// <summary>
4820- /// Unhooks the hook.
4821- /// </summary>
4822- public override void Unhook()
4823- {
4824- if (!Hooked) return;
4825- base.Unhook();
4826- lmh.Unhook();
4827- }
4828-
4829- #region PInvoke Declarations
4830-
4831- private static readonly int WM_CANCELJOURNAL = 0x4B;
4832-
4833- [StructLayout(LayoutKind.Sequential)]
4834- internal struct EVENTMSG
4835- {
4836- public uint message;
4837- public uint paramL;
4838- public uint paramH;
4839- public int time;
4840- public IntPtr hWnd;
4841- }
4842- #endregion
4843- }
4844-
4845- /// <summary>
4846- /// An event that has been recorded by a journal hook.
4847- /// </summary>
4848- public class JournalMessage
4849- {
4850- internal static JournalMessage Create(JournalHook.EVENTMSG msg)
4851- {
4852- return new JournalMessage(msg);
4853- }
4854-
4855- private JournalHook.EVENTMSG msg;
4856- private JournalMessage(JournalHook.EVENTMSG msg)
4857- {
4858- this.msg = msg;
4859- }
4860-
4861- /// <summary>
4862- /// Creates a new journal message.
4863- /// </summary>
4864- public JournalMessage(IntPtr hWnd, uint message, uint paramL, uint paramH, uint time)
4865- {
4866- msg = new JournalHook.EVENTMSG();
4867- msg.hWnd = hWnd;
4868- msg.message = message;
4869- msg.paramL = paramL;
4870- msg.paramH = paramH;
4871- msg.time = 0;
4872- }
4873-
4874- /// <summary>
4875- /// The window this message has been sent to.
4876- /// </summary>
4877- public IntPtr HWnd { get { return msg.hWnd; } }
4878-
4879- /// <summary>
4880- /// The message.
4881- /// </summary>
4882- public uint Message { get { return msg.message; } }
4883-
4884- /// <summary>
4885- /// The first parameter of the message.
4886- /// </summary>
4887- public uint ParamL { get { return msg.paramL; } }
4888-
4889- /// <summary>
4890- /// The second parameter of the message.
4891- /// </summary>
4892- public uint ParamH { get { return msg.paramH; } }
4893-
4894- /// <summary>
4895- /// The timestamp of the message.
4896- /// </summary>
4897- public int Time
4898- {
4899- get { return msg.time; }
4900- set { msg.time = value; }
4901- }
4902-
4903- /// <summary>
4904- /// Returns a System.String that represents the current System.Object.
4905- /// </summary>
4906- public override string ToString()
4907- {
4908- return "JournalMessage[hWnd=" + msg.hWnd + ",message=" + msg.message + ",L=" + msg.paramL +
4909- ",H=" + msg.paramH + ",time=" + msg.time + "]";
4910- }
4911- }
4912-
4913- /// <summary>
4914- /// Event data for a journal record event.
4915- /// </summary>
4916- public class JournalRecordEventArgs : EventArgs
4917- {
4918- private JournalMessage msg;
4919-
4920- internal JournalRecordEventArgs(JournalMessage msg)
4921- {
4922- this.msg = msg;
4923- }
4924-
4925- /// <summary>
4926- /// The recorded message.
4927- /// </summary>
4928- public JournalMessage RecordedMessage
4929- {
4930- get { return msg; }
4931- }
4932- }
4933-
4934- /// <summary>
4935- /// A hook that can be used to create a log of keyboard and mouse events.
4936- /// </summary>
4937- public class JournalRecordHook : JournalHook
4938- {
4939- /// <summary>
4940- /// Occurs when a system modal dialog appears. This may be used
4941- /// to stop recording.
4942- /// </summary>
4943- public event EventHandler SystemModalDialogAppeared;
4944-
4945- /// <summary>
4946- /// Occurs when a system modal dialog disappears. This may be used
4947- /// to continue recording.
4948- /// </summary>
4949- public event EventHandler SystemModalDialogDisappeared;
4950-
4951- /// <summary>
4952- /// Occurs when an event can be recorded.
4953- /// </summary>
4954- public event EventHandler<JournalRecordEventArgs> RecordEvent;
4955-
4956- /// <summary>
4957- /// Creates a new journal record hook.
4958- /// </summary>
4959- public JournalRecordHook()
4960- : base(HookType.WH_JOURNALRECORD)
4961- {
4962- base.Callback += JournalRecordHook_Callback;
4963- }
4964-
4965- private int JournalRecordHook_Callback(int code, IntPtr wParam, IntPtr lParam, ref bool callNext)
4966- {
4967- if (code == HC_ACTION)
4968- {
4969- EVENTMSG em = (EVENTMSG)Marshal.PtrToStructure(lParam, typeof(EVENTMSG));
4970- JournalMessage jm = JournalMessage.Create(em);
4971- if (RecordEvent != null)
4972- {
4973- RecordEvent(this, new JournalRecordEventArgs(jm));
4974- }
4975- }
4976- else if (code == HC_SYSMODALON)
4977- {
4978- if (SystemModalDialogAppeared != null)
4979- {
4980- SystemModalDialogAppeared(this, new EventArgs());
4981- }
4982- }
4983- else if (code == HC_SYSMODALOFF)
4984- {
4985- if (SystemModalDialogDisappeared != null)
4986- {
4987- SystemModalDialogDisappeared(this, new EventArgs());
4988- }
4989- }
4990- return 0;
4991- }
4992- }
4993-
4994- /// <summary>
4995- /// A hook that can be used to playback a log of keyboard and mouse events.
4996- /// </summary>
4997- public class JournalPlaybackHook : JournalHook
4998- {
4999- /// <summary>
5000- /// Occurs when a system modal dialog appears. This may be used to
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: