需要连续绘制并向用户显示变化的角度。 [英] Need to draw and show to the user a varying angle continuously.

查看:61
本文介绍了需要连续绘制并向用户显示变化的角度。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#winform中用户控制中绘制一个连续变化的角度?



我尝试了什么:



需要在C#winform中绘制一个连续变化的角度。

我将有一个参考角度,但就我而言我需要绘制角度差异连续并显示给用户。

how to draw an continuously varying angle in user control in C# winform?

What I have tried:

need to draw a continuously varying angle in C# winform.
I will have a Reference angle will be ,but with respect to that i need to draw the angle difference continuously and show to user.

推荐答案

使用WPF,RotateTransform和StoryBoard。



带有RotateTransform的故事板 [ ^ ]
Use WPF, RotateTransform and a StoryBoard.

Storyboard with RotateTransform[^]


第一步是确保您的控件可以正确绘制当前角度。完成后,您将必须指示它定期绘制自己。



您可以使用此调用让控件再次绘制:



Control.Invalidate方法(System.Windows.Forms)| Microsoft Docs [ ^ ]



您可以通过计时器调用它 - 甚至可以从paint方法本身调用它立刻强行重拍。尝试一下,找到性能影响和平滑动画之间的最佳平衡。



如果你无法获得所需的性能,你可能需要考虑像WPF甚至DirectX这样的东西 - 除非你有非常严格的要求或复杂的渲染你是用WinForm可能还行。
The first step is to ensure your control can draw the current angle correctly. Once this is done, you will have to instruct it to draw itself regularly.

You can use this call to get the control to paint once again:

Control.Invalidate Method (System.Windows.Forms) | Microsoft Docs[^]

You call it from a timer - or even call it from within the paint method itself to force a repaint immediately. Experiment a bit to find the best balance between performance impact and a smooth animation.

If you can't get the desired performance, you might need to consider something like WPF or even DirectX - but unless you have very strict requirements or complex rendering you are probably OK with WinForm.


这篇关于需要连续绘制并向用户显示变化的角度。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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