如何调试 GDI+在 c# 中?

发布于 2024-08-13 22:41:30 字数 66 浏览 7 评论 0原文

我有一个用户控件,但它没有正确绘制,如何调试绘图? 如果设置断点,控件会被阻塞,无法立即看到绘图结果? 有什么想法吗?

i have a user control, and it's not drawn correctly, how to debug the drawing?
If i set break point, the control will get blocked, i can't see the drawing result instantly?
any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甜柠檬 2024-08-20 22:41:30

最好使用多显示器设置来调试绘图活动,但如果您只有一台显示器,还有一些其他方法可以提供帮助。

  1. 重新定位 IDE (Visual Studio),使其不重叠。不幸的是,如果您需要主动关注控件,这可能没有帮助。
  2. 将第二个副本绘制到位图中,并将位图写入磁盘或在对话框或其他窗口中重新显示它。这是一些额外的工作,但在概念上与进行日志记录相同。
  3. 更改绘图代码,以便仅在按下某些键(左移/右移、ctrl、alt 或这些键的某种组合)时才绘制某些元素或元素的某些部分。这很容易添加,并且可以让您过滤掉调试器难以单步执行的代码部分。

下面的函数可以为您提供状态(需要 p/invoke)和来自 pinvoke.net 的签名。

GetKeyState Function() @ MSDN
pinvoke.net:GetKeyState (user32)

It's best to debug drawing activities with a multi-monitor setup, but there are a handful of other things that can help if you've only got one monitor.

  1. Repositioning your IDE (Visual Studio) so that it doesn't overlap. Unfortunately, this may not help if you need active focus on the control.
  2. Draw a 2nd copy into a bitmap, and write the bitmap to disk or redisplay it in a dialog or some other window. This is a bit of extra work, but conceptually the same as doing logging.
  3. Alter your drawing code so that certain elements or certain parts of elements are only drawn if you have certain keys pressed down (left-shift/right-shift, ctrl, alt, or some combination of those keys). This is easy to add and can allow you to filter out parts of your code that would be tricky to step into with the debugger.

Here's the function that can provide the state for you (requires p/invoke) and the signature from pinvoke.net.

GetKeyState Function() @ MSDN
pinvoke.net: GetKeyState (user32)

话少心凉 2024-08-20 22:41:30

有一个免费的开源扩展支持 VS 2008-VS 2022:

KGy SOFT Image DebuggerVisualizers x64

它将允许您查看图形表示单步执行代码时的任何时候的对象(包括 Graphics 对象)。

https: //kgysoft.net/images/DebuggerVisualizerUsage.png

在此处输入图像描述

There's a free and open source extension supporting VS 2008-VS 2022:

KGy SOFT Image DebuggerVisualizers x64

It will allow you to view the graphical representation of objects, including Graphics objects, at any point while stepping through your code.

https://kgysoft.net/images/DebuggerVisualizerUsage.png

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文