@@ -53,8 +53,10 @@ private void Hotkey_PreviewMouseDown(object sender, MouseButtonEventArgs e)
5353 _ctrl = hkControl ;
5454 _currentControlHotkey = _ctrl . Hotkey ;
5555
56- var mi = new MenuItem ( ) ;
57- mi . Header = "Reset to default" ;
56+ var mi = new MenuItem
57+ {
58+ Header = "Reset to default"
59+ } ;
5860 var cm = new ContextMenu ( ) ;
5961 cm . Items . Add ( mi ) ;
6062 hkControl . HotkeyTextBox . ContextMenu = cm ;
@@ -63,16 +65,16 @@ private void Hotkey_PreviewMouseDown(object sender, MouseButtonEventArgs e)
6365 {
6466 foreach ( var hk in Program . HotkeysList )
6567 {
66- if ( hk . Hotkey . ToString ( ) == HotkeyControl . DefaultHotkeys [ hkControl . Name . Substring ( 2 ) ] )
68+ var hkStr = hk . Hotkey . ToString ( ) ;
69+ if ( hkStr == HotkeyControl . DefaultHotkeys [ hkControl . Name . Substring ( 2 ) ] && hkStr != hkControl . Hotkey . ToString ( ) )
6770 {
68- ShowLabel ( "Default taken!" ) ;
71+ ShowLabel ( Program . Translations . GetLanguage ( "DefaultTaken" ) ) ;
6972 return ;
7073 }
7174 }
7275
7376 HideLabel ( ) ;
74- hkControl . Hotkey = new Hotkey ( HotkeyControl . DefaultHotkeys [ hkControl . Name . Substring ( 2 ) ] ) ;
75- Program . HotkeysList . FirstOrDefault ( x => x . Command == hkControl . Name . Substring ( 2 ) ) . Hotkey = hkControl . Hotkey ;
77+ SaveHotkey ( true ) ;
7678 } ;
7779
7880 }
@@ -88,7 +90,7 @@ private void OnTimerTick(object sender, EventArgs e)
8890 /// <summary>
8991 /// Saves the input hotkey to the Hotkeys file, and caches it.
9092 /// </summary>
91- private void SaveHotkey ( )
93+ private void SaveHotkey ( bool toDefault = false )
9294 {
9395 // Create the hotkeys file if it doesn't exist for some reason
9496 if ( ! File . Exists ( Constants . HotkeysFile ) )
@@ -99,6 +101,13 @@ private void SaveHotkey()
99101 // Get the control name by separating it from its x:Name suffix
100102 var ctrlName = _ctrl . Name . Substring ( 2 ) ;
101103
104+ // We skip checks if we're setting a default hotkey
105+ if ( toDefault )
106+ {
107+ _ctrl . Hotkey = new Hotkey ( HotkeyControl . DefaultHotkeys [ _ctrl . Name . Substring ( 2 ) ] ) ;
108+ goto SaveDirectly ;
109+ }
110+
102111 foreach ( var hkInfo in Program . HotkeysList )
103112 {
104113 // Check if the user has cleared the hotkey field
@@ -131,6 +140,8 @@ private void SaveHotkey()
131140 }
132141 }
133142
143+ SaveDirectly :
144+
134145 // Modify the XML document to update hotkey
135146 var document = new XmlDocument ( ) ;
136147 document . Load ( Constants . HotkeysFile ) ;
0 commit comments