我如何创建的WinForms自动UI事件跟踪? [英] How do I create an automatic UI event trace in winforms?

查看:160
本文介绍了我如何创建的WinForms自动UI事件跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个现有的WinForms应用程序拖放到一个事件跟踪模式,以希望为小摩擦越好。

I need to take an existing winforms application and drop into an event tracing mode, with hopefully as little friction as possible.

我希望看到每个用户需要一个简单的堆栈跟踪,看东西的动作:

I would like to see every action the user takes as a simple stack trace-looking thing:

MainForm.LaunchThing_Click
ThingWindow.NameInput_Focus
ThingWindow.NameInput_TextChanged
ThingWindow.AddressInput_Focus
ThingWindow.OKButton_Click

等等。

  • 如果这是一个WPF应用程序,我会做类似的过滤器类型WClientInputMessage的ETW所有事件。
  • 在我不能简单地转储一个堆栈跟踪,因为没有捕获用户的前行动。
  • 我可以从的这个讨论],但是这是一个现存的应用程序的的事件太多。另外,我很懒。总得有更好的方式。
  • 在我不能附加一个调试器,我想获得这个信息,自动连接到错误报告从测试的用户在该领域,因为 [原来...] 的没有人能准确地记不清楚了的事情,他们点击的顺序了。
  • If this was a WPF application, I would do something like filter all events of type WClientInputMessage in ETW.
  • I can't simply dump a stack trace, because that doesn't capture the user's prior actions.
  • I could add logging to every single event [with the recommended practices from this discussion], but this is an extant application with far too many events. Plus, I'm lazy. Gotta be a better way.
  • I can't attach a debugger, I want to get this information automatically attached to bug reports from testing users in the field because [it turns out...] nobody can accurately remember exactly what the sequence of things they clicked on was.

所以,我想知道如果任何人有什么好的招数,用子类或反射也许,锁存到UI事件。

So I'm wondering if anyone has any good tricks, using subclassing or reflection perhaps, to latch on to the UI events.

性能是不是一个真正的问题。如果我能得到一个勾成每一个事件,这是够好;我可以过滤下来到相关的设定很容易。

Performance is not really a concern. And if I can get a hook into every event, that's good enough; I can filter them down to the relevant set fairly easily.

推荐答案

怎么样的观察者模式?创建一堆重载登录方法(每个事件的方法签名)来完成这些记录的事件记录器类。实例化它在应用程序启动并将其订阅到每个UI事件。

How about an observer pattern? Create an EventLogger class with a bunch of overloaded Log methods (one for each event method signature) that do the logging. Instantiate it on application start and subscribe it to each of the UI events.

这应该甚至有可能与反思自动完成订阅 - 虽然我认为它是更多的精力来设置它比手工做任何合理大小的应用程序。此外,你仍然要确保你的事件记录器类有每一个可能的事件处理程序方法签名的登录方法。

It should even be possible to do the subscribing automatically with reflection - though I would think it is more effort to set that up than to do it manually for any reasonably sized application. Also you would still have to ensure that your EventLogger class has a Log method for every possible event handler method signature.

这篇关于我如何创建的WinForms自动UI事件跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆