Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Commit

Permalink
Added keyboard shortcuts (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Apr 20, 2022
1 parent b0bfb42 commit cedae06
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Gerayis/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/
using Gerayis.Classes;
using Gerayis.Enums;
using Gerayis.Pages;
using Gma.System.MouseKeyHook;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
Expand All @@ -39,6 +42,7 @@ public partial class MainWindow : Window
{
private Button CheckedButton { get; set; }
private AppPages? PageToShow { get; init; }
private IKeyboardMouseEvents KeyboardMouseEvents;

readonly ColorAnimation colorAnimation = new()
{
Expand All @@ -56,6 +60,24 @@ public MainWindow(AppPages? pageToShow = null)

private void InitUI()
{
KeyboardMouseEvents = Hook.GlobalEvents(); // Hook the keyboard and mouse events
Hook.GlobalEvents().OnCombination(new Dictionary<Combination, Action>
{
{
Combination.FromString("Control+C"), () =>
{
if (PageContent.Content is BarCodePage)
{
Global.BarCodePage.CopyBtn_Click(null, null);
}
else if (PageContent.Content is QRCodePage)
{
Global.QRCodePage.CopyBtn_Click(null, null);
}
}
}
});

HelloTxt.Text = Global.GetHiSentence; // Set the "Hello" message

CheckButton(((PageToShow is null) ? Global.Settings.StartupPage : PageToShow) switch
Expand Down

0 comments on commit cedae06

Please sign in to comment.