private DateTime?GetFirstClickTime() { using (var context = new ClickContext()) { var firstClick = context.Clicks.FirstOrDefault()?.ClickedAt; return(firstClick); } }
public bool handleClick(ClickContext clickContext) { if (clickHandled) { return(false); } clickHandled = clickHandlers[clickContext](); return(clickHandled); }
public override Task OnClick(ClickContext context) { if (context.GamePlugin is ISinglePlayerGameMode singlePlayerStarter) { return(singlePlayerStarter.StartSinglePlayer()); } else { MessageBox.Show($"Game {context.GamePlugin} does not have a single player mode", "404", MessageBoxButton.OK, MessageBoxImage.Warning); return(Task.CompletedTask); } }
private void CaptureClicks() { NSEvent.AddGlobalMonitorForEventsMatchingMask(NSEventMask.LeftMouseDown, (NSEvent theEvent) => { var windowNumber = theEvent.WindowNumber; var now = DateTime.UtcNow; Console.WriteLine(theEvent); using (var _context = new ClickContext()) { _context.Add(new Click { WindowOwnerName = GetWindow(windowNumber) ?? "unknown" }); _context.SaveChanges(); } }); }
public MenuScreen(GamePlugin gamePlugin, MenuPlugin menuPlugin) { _menuPlugin = menuPlugin ?? throw new ArgumentNullException(nameof(menuPlugin)); Title = gamePlugin.Details.Name; InitializeComponent(); foreach (var item in menuPlugin.MenuItems) { var button = new Button { Content = item.Text, HorizontalAlignment = HorizontalAlignment.Stretch }; button.Click += async(sender, args) => { this.IsEnabled = false; try { await Task.Delay(200); var context = new ClickContext(gamePlugin); await item.OnClick(context); } catch (Exception ex) { //TODO: Shutodwn error } finally { this.IsEnabled = true; } }; ButtonList.Items.Add(button); } //var converter = new BrushConverter(); //var brush = (Brush)converter.ConvertFromString(plugin.Theme.Background); //this.Background = brush; }