private void RegisterHotkeys() { var locale = System.Threading.Thread.CurrentThread.CurrentCulture.KeyboardLayoutId; logger.WriteLine($"defining hotkeys for input locale {locale}"); var s = new SettingsProvider() .GetCollection("KeyboardSheet")?.Get <XElement>("commands"); HotkeyManager.Initialize(); RegisterHotKey(s, nameof(AddFootnoteCmd), async() => await AddFootnoteCmd(null)); RegisterHotKey(s, nameof(AddFormulaCmd), async() => await AddFormulaCmd(null)); RegisterHotKey(s, nameof(ApplyStyle1Cmd), async() => await ApplyStyle1Cmd(null)); RegisterHotKey(s, nameof(ApplyStyle2Cmd), async() => await ApplyStyle2Cmd(null)); RegisterHotKey(s, nameof(ApplyStyle3Cmd), async() => await ApplyStyle3Cmd(null)); RegisterHotKey(s, nameof(ApplyStyle4Cmd), async() => await ApplyStyle4Cmd(null)); RegisterHotKey(s, nameof(ApplyStyle5Cmd), async() => await ApplyStyle5Cmd(null)); RegisterHotKey(s, nameof(ApplyStyle6Cmd), async() => await ApplyStyle6Cmd(null)); RegisterHotKey(s, nameof(ApplyStyle7Cmd), async() => await ApplyStyle7Cmd(null)); RegisterHotKey(s, nameof(ApplyStyle8Cmd), async() => await ApplyStyle8Cmd(null)); RegisterHotKey(s, nameof(ApplyStyle9Cmd), async() => await ApplyStyle9Cmd(null)); RegisterHotKey(s, nameof(ClearLogCmd), async() => await ClearLogCmd(null)); RegisterHotKey(s, nameof(DecreaseFontSizeCmd), async() => await DecreaseFontSizeCmd(null)); RegisterHotKey(s, nameof(DiagnosticsCmd), async() => await DiagnosticsCmd(null)); RegisterHotKey(s, nameof(FillDownCmd), async() => await FillDownCmd(null)); RegisterHotKey(s, nameof(HighlightCmd), async() => await HighlightCmd(null)); RegisterHotKey(s, nameof(InsertCodeBlockCmd), async() => await InsertCodeBlockCmd(null)); RegisterHotKey(s, nameof(InsertDateCmd), async() => await InsertDateCmd(null)); RegisterHotKey(s, nameof(InsertDoubleHorizontalLineCmd), async() => await InsertDoubleHorizontalLineCmd(null)); RegisterHotKey(s, nameof(InsertHorizontalLineCmd), async() => await InsertHorizontalLineCmd(null)); RegisterHotKey(s, nameof(InsertTimerCmd), async() => await InsertTimerCmd(null)); RegisterHotKey(s, nameof(DisableSpellCheckCmd), async() => await DisableSpellCheckCmd(null)); RegisterHotKey(s, nameof(PasteRtfCmd), async() => await PasteRtfCmd(null)); RegisterHotKey(s, nameof(PasteTextCmd), async() => await PasteTextCmd(null)); RegisterHotKey(s, nameof(RecalculateFormulaCmd), async() => await RecalculateFormulaCmd(null)); RegisterHotKey(s, nameof(RemoveFootnoteCmd), async() => await RemoveFootnoteCmd(null)); RegisterHotKey(s, nameof(ReplayCmd), async() => await ReplayCmd(null)); RegisterHotKey(s, nameof(RemindCmd), async() => await RemindCmd(null)); RegisterHotKey(s, nameof(SearchCmd), async() => await SearchCmd(null)); RegisterHotKey(s, nameof(SearchAndReplaceCmd), async() => await SearchAndReplaceCmd(null)); RegisterHotKey(s, nameof(ShowXmlCmd), async() => await ShowXmlCmd(null)); RegisterHotKey(s, nameof(StartTimerCmd), async() => await StartTimerCmd(null)); RegisterHotKey(s, nameof(TaggedCmd), async() => await TaggedCmd(null)); RegisterHotKey(s, nameof(TaggingCmd), async() => await TaggingCmd(null)); RegisterHotKey(s, nameof(ToLowercaseCmd), async() => await ToLowercaseCmd(null)); RegisterHotKey(s, nameof(ToUppercaseCmd), async() => await ToUppercaseCmd(null)); // an awful hack to avoid a conflict with Italian keyboard (FIGS and likely UK) that // use AltGr as Ctrl+Alt. This means users pressing AltGr+OemPlus to get a square // bracket would instead end up increasing the font size of the page when they didn't // mean to! So here we only register these hot keys for the US keyboard input layout. if (locale == 1033) { RegisterHotKey(s, nameof(IncreaseFontSizeCmd), async() => await IncreaseFontSizeCmd(null)); } }
private void RegisterHotkeys() { logger.WriteLine("defining hotkeys"); HotkeyManager.Initialize(); HotkeyManager.RegisterHotKey(async() => await AddFootnoteCmd(null), Keys.F, Hotmods.ControlAlt); HotkeyManager.RegisterHotKey(async() => await AddFormulaCmd(null), Keys.F5); HotkeyManager.RegisterHotKey(async() => await DecreaseFontSizeCmd(null), Keys.OemMinus, Hotmods.ControlAlt); HotkeyManager.RegisterHotKey(async() => await HighlightCmd(null), Keys.H, Hotmods.ControlShift); HotkeyManager.RegisterHotKey(async() => await IncreaseFontSizeCmd(null), Keys.Oemplus, Hotmods.ControlAlt); HotkeyManager.RegisterHotKey(async() => await InsertCodeBlockCmd(null), Keys.F6); HotkeyManager.RegisterHotKey(async() => await InsertDateCmd(null), Keys.D, Hotmods.ControlShift); HotkeyManager.RegisterHotKey(async() => await InsertDoubleHorizontalLineCmd(null), Keys.F12, Hotmods.AltShift); HotkeyManager.RegisterHotKey(async() => await InsertHorizontalLineCmd(null), Keys.F11, Hotmods.AltShift); HotkeyManager.RegisterHotKey(async() => await NoSpellCheckCmd(null), Keys.F4); HotkeyManager.RegisterHotKey(async() => await PasteRtfCmd(null), Keys.V, Hotmods.ControlAlt); HotkeyManager.RegisterHotKey(async() => await RecalculateFormulaCmd(null), Keys.F5, Hotmods.Shift); HotkeyManager.RegisterHotKey(async() => await RemoveFootnoteCmd(null), Keys.F, Hotmods.ControlShift); HotkeyManager.RegisterHotKey(async() => await SearchCmd(null), Keys.F, Hotmods.Alt); HotkeyManager.RegisterHotKey(async() => await SearchAndReplaceCmd(null), Keys.H, Hotmods.Control); HotkeyManager.RegisterHotKey(async() => await TaggedCmd(null), Keys.T, Hotmods.ControlAlt); HotkeyManager.RegisterHotKey(async() => await TaggingCmd(null), Keys.T, Hotmods.Alt); HotkeyManager.RegisterHotKey(async() => await ToLowercaseCmd(null), Keys.U, Hotmods.ControlShift); HotkeyManager.RegisterHotKey(async() => await ToUppercaseCmd(null), Keys.U, Hotmods.ControlAltShift); // tools HotkeyManager.RegisterHotKey(async() => await ShowXmlCmd(null), Keys.X, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(async() => await factory.Run <DiagnosticsCommand>(), Keys.F8); HotkeyManager.RegisterHotKey(async() => await factory.Run <ClearLogCommand>(), Keys.F8, Hotmods.Control); // custom styles, CtrlAltShift+1..9 HotkeyManager.RegisterHotKey(async() => await factory.Run <ApplyStyleCommand>(0), Keys.D1, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(async() => await factory.Run <ApplyStyleCommand>(1), Keys.D2, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(async() => await factory.Run <ApplyStyleCommand>(2), Keys.D3, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(async() => await factory.Run <ApplyStyleCommand>(3), Keys.D4, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(async() => await factory.Run <ApplyStyleCommand>(4), Keys.D5, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(async() => await factory.Run <ApplyStyleCommand>(5), Keys.D6, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(async() => await factory.Run <ApplyStyleCommand>(6), Keys.D7, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(async() => await factory.Run <ApplyStyleCommand>(7), Keys.D8, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(async() => await factory.Run <ApplyStyleCommand>(9), Keys.D9, Hotmods.ControlAltShift); }
private void RegisterHotkeys() { HotkeyManager.Initialize(); HotkeyManager.RegisterHotKey(() => AddFootnoteCmd(null), Keys.F, Hotmods.ControlAlt); HotkeyManager.RegisterHotKey(() => RemoveFootnoteCmd(null), Keys.F, Hotmods.ControlShift); HotkeyManager.RegisterHotKey(() => AddFormulaCmd(null), Keys.F5); HotkeyManager.RegisterHotKey(() => RecalculateFormulaCmd(null), Keys.F5, Hotmods.Shift); HotkeyManager.RegisterHotKey(() => InsertCodeBlockCmd(null), Keys.F6); HotkeyManager.RegisterHotKey(() => InsertHorizontalLineCmd(null), Keys.OemMinus, Hotmods.AltShift); HotkeyManager.RegisterHotKey(() => InsertDoubleHorizontalLineCmd(null), Keys.Oemplus, Hotmods.AltShift); HotkeyManager.RegisterHotKey(() => NoSpellCheckCmd(null), Keys.F4); HotkeyManager.RegisterHotKey(() => PasteRtfCmd(null), Keys.V, Hotmods.ControlAlt); HotkeyManager.RegisterHotKey(() => SearchCmd(null), Keys.F, Hotmods.Alt); HotkeyManager.RegisterHotKey(() => SearchAndReplaceCmd(null), Keys.H, Hotmods.Control); HotkeyManager.RegisterHotKey(() => ToLowercaseCmd(null), Keys.U, Hotmods.ControlShift); HotkeyManager.RegisterHotKey(() => ToUppercaseCmd(null), Keys.U, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(() => IncreaseFontSizeCmd(null), Keys.Oemplus, Hotmods.ControlAlt); HotkeyManager.RegisterHotKey(() => DecreaseFontSizeCmd(null), Keys.OemMinus, Hotmods.ControlAlt); HotkeyManager.RegisterHotKey(() => ShowXmlCmd(null), Keys.X, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(() => factory.Run <DiagnosticsCommand>(), Keys.F8); HotkeyManager.RegisterHotKey(() => factory.Run <ClearLogCommand>(), Keys.F8, Hotmods.Control); // custom styles, CtrlAltShift+1..9 HotkeyManager.RegisterHotKey(() => factory.Run <ApplyStyleCommand>(0), Keys.D1, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(() => factory.Run <ApplyStyleCommand>(1), Keys.D2, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(() => factory.Run <ApplyStyleCommand>(2), Keys.D3, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(() => factory.Run <ApplyStyleCommand>(3), Keys.D4, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(() => factory.Run <ApplyStyleCommand>(4), Keys.D5, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(() => factory.Run <ApplyStyleCommand>(5), Keys.D6, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(() => factory.Run <ApplyStyleCommand>(6), Keys.D7, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(() => factory.Run <ApplyStyleCommand>(7), Keys.D8, Hotmods.ControlAltShift); HotkeyManager.RegisterHotKey(() => factory.Run <ApplyStyleCommand>(9), Keys.D9, Hotmods.ControlAltShift); }