private void Overlay_Loaded(object sender, RoutedEventArgs e) { // Start topmost updater _winHook = new WindowHook(); _winHook.BrawlhallaOpened += (_, __) => MessageBox.Show("bh opened"); _winHook.WindowFocused += (_, __) => this.Topmost = true; _winHook.LostWindowFocus += (_, __) => this.Topmost = false; // Add ping items var config = ConfigManager.GetPingConfig(); foreach (var server in config.ServersEnabled) { var item = new PingItem(server.Name, Utilities.GetIPToPingFromName(server.Name), server.XPos, server.YPos); (this.Content as Canvas).Children.Add(item); item.MoveTo(item.XPos, item.YPos); } // Create low level mouse hook LowLevelMouseHook.Hook(); // Handle moving of ping items LowLevelMouseHook.MouseDown += Overlay_MouseDown; LowLevelMouseHook.MouseMoved += Overlay_MouseMoved; LowLevelMouseHook.MouseUp += Overlay_MouseUp; }
public void Track() { if (tracking) { throw new InvalidOperationException("Already tracking. Can't call track on a started tracker"); } mouseHook.HookActivated += MouseHook_HookActivated; mouseHook.Hook(); tracking = true; }