Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions RetailCoder.VBE/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Runtime.InteropServices.ComTypes;
using System.Threading.Tasks;
using System.Windows.Forms;
using Rubberduck.Common.Hotkeys;

namespace Rubberduck
{
Expand Down Expand Up @@ -132,9 +133,9 @@ private bool ShouldEvaluateCanExecute(Declaration selectedDeclaration, ParserSta
private void _configService_SettingsChanged(object sender, EventArgs e)
{
_config = _configService.LoadConfiguration();
_hooks.HookHotkeys();
// also updates the ShortcutKey text
_appMenus.Localize();
_hooks.HookHotkeys();
UpdateLoggingLevel();
}

Expand All @@ -147,9 +148,9 @@ public void Startup()
{
CleanReloadConfig();
_appMenus.Initialize();
_hooks.HookHotkeys(); // need to hook hotkeys before we localize menus, to correctly display ShortcutTexts
_appMenus.Localize();
Task.Delay(1000).ContinueWith(t => UiDispatcher.Invoke(() => _parser.State.OnParseRequested(this))).ConfigureAwait(false);
_hooks.HookHotkeys();
UpdateLoggingLevel();
}

Expand Down
23 changes: 23 additions & 0 deletions RetailCoder.VBE/Common/Hotkeys/Hotkey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Windows.Input;
using Rubberduck.Common.WinAPI;
using NLog;
using Rubberduck.UI.Command;

namespace Rubberduck.Common.Hotkeys
{
Expand Down Expand Up @@ -58,6 +59,7 @@ public void Attach()
}

HookKey(key, shift);
SetCommandShortcutText();
}

public void Detach()
Expand All @@ -71,6 +73,7 @@ public void Detach()
Kernel32.GlobalDeleteAtom(HotkeyInfo.HookId);

IsAttached = false;
ClearCommandShortcutText();
}

private void HookKey(Keys key, uint shift)
Expand All @@ -90,9 +93,29 @@ private void HookKey(Keys key, uint shift)

HotkeyInfo = new HotkeyInfo(hookId, Combo);
IsAttached = true;

_logger.Debug("Hotkey '{0}' hooked successfully to command '{1}'", Key, Command.GetType()); //no translation needed for Debug.Writeline
}

private void SetCommandShortcutText()
{
var command = Command as CommandBase;
if (command != null)
{
command.ShortcutText = HotkeyInfo.ToString();
}
}

private void ClearCommandShortcutText()
{
var command = Command as CommandBase;
if (command != null)
{
command.ShortcutText = string.Empty;
}
}


private static readonly IDictionary<char,uint> Modifiers = new Dictionary<char, uint>
{
{ '+', (uint)KeyModifier.SHIFT },
Expand Down
6 changes: 3 additions & 3 deletions RetailCoder.VBE/Common/Hotkeys/HotkeyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ public override string ToString()
var builder = new StringBuilder();
if (_keys.HasFlag(Keys.Alt))
{
builder.Append("Alt");
builder.Append(Rubberduck.UI.RubberduckUI.GeneralSettings_HotkeyAlt);
builder.Append('+');
}
if (_keys.HasFlag(Keys.Control))
{
builder.Append("Ctrl");
builder.Append(Rubberduck.UI.RubberduckUI.GeneralSettings_HotkeyCtrl);
builder.Append('+');
}
if (_keys.HasFlag(Keys.Shift))
{
builder.Append("Shift");
builder.Append(Rubberduck.UI.RubberduckUI.GeneralSettings_HotkeyShift);
builder.Append('+');
}
builder.Append(_keys & ~Modifiers);
Expand Down
4 changes: 2 additions & 2 deletions RetailCoder.VBE/Inspections/InspectionsUI.de.resx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -59,7 +59,7 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
Expand Down
Loading