55using System . Windows . Input ;
66using Rubberduck . Common . WinAPI ;
77using NLog ;
8+ using Rubberduck . UI . Command ;
89
910namespace Rubberduck . Common . Hotkeys
1011{
@@ -58,6 +59,7 @@ public void Attach()
5859 }
5960
6061 HookKey ( key , shift ) ;
62+ SetCommandShortcutText ( ) ;
6163 }
6264
6365 public void Detach ( )
@@ -71,6 +73,7 @@ public void Detach()
7173 Kernel32 . GlobalDeleteAtom ( HotkeyInfo . HookId ) ;
7274
7375 IsAttached = false ;
76+ ClearCommandShortcutText ( ) ;
7477 }
7578
7679 private void HookKey ( Keys key , uint shift )
@@ -90,9 +93,29 @@ private void HookKey(Keys key, uint shift)
9093
9194 HotkeyInfo = new HotkeyInfo ( hookId , Combo ) ;
9295 IsAttached = true ;
96+
9397 _logger . Debug ( "Hotkey '{0}' hooked successfully to command '{1}'" , Key , Command . GetType ( ) ) ; //no translation needed for Debug.Writeline
9498 }
9599
100+ private void SetCommandShortcutText ( )
101+ {
102+ var command = Command as CommandBase ;
103+ if ( command != null )
104+ {
105+ command . ShortcutText = HotkeyInfo . ToString ( ) ;
106+ }
107+ }
108+
109+ private void ClearCommandShortcutText ( )
110+ {
111+ var command = Command as CommandBase ;
112+ if ( command != null )
113+ {
114+ command . ShortcutText = string . Empty ;
115+ }
116+ }
117+
118+
96119 private static readonly IDictionary < char , uint > Modifiers = new Dictionary < char , uint >
97120 {
98121 { '+' , ( uint ) KeyModifier . SHIFT } ,
0 commit comments