图标平滑移动显示在面板 [英] Smooth movement of icon displayed on a Panel

查看:228
本文介绍了图标平滑移动显示在面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编码的应用程序,我展示一个System.Windows.Forms.Panel一个System.Drawing.Icon对象使用code,它不用像这样:

I'm coding an app where I display a System.Drawing.Icon object on a System.Windows.Forms.Panel using a code that goes something like so:

Graphics g = _panel.CreateGraphics();
g.DrawIcon(this.NodeIcon, _rectangle);

我有code键移动图标周围使用拖放正下降。 我的问题是,当用户移动图标周围,它决不是平滑的。 该图标看起来扭曲,直到用户停止移动的图标。

I have code to move the icon around using drag-n-drop. My problem is that when the user move the icon around, it is anything but smooth. The icon looks distorted until the user stops moving the icon.

我试图发现周围的净这方面的资料,但我不能让它光滑。 我有这种特殊的编码(使用图形)的小previous经验,所以我是菜鸟了这一点。

I have tried to find information on this around the net but I can't get it to be smooth. I have little previous experience of this particular kind of coding (using graphics) so I am a rookie to this.

如果任何一种灵魂可以帮助我一些提示这将是更AP preciated。

If any kind soul could help me with some hints it would be much appreciated.

在此先感谢!

推荐答案

我相信你正在试图做的是重绘的MouseMove事件处理程序的控制。看起来像你的问题是闪烁重绘面板时。首先你可以尝试做的是设置为TRUE 您的面板DoubleBuffered 财产。这样做,你就设置在面板使用辅助缓冲区,以减少或prevent闪烁重绘其表面。此属性是受保护的,所以你需要创建一个新的面板后裔:

I believe what you're trying to do is to redraw your control on the MouseMove event handler. And looks like your problem is the flicker when redrawing the panel. First what you can try to do is set true to DoubleBuffered property of your panel. Doing this you would set the panel to redraw its surface using a secondary buffer to reduce or prevent flicker. This property is protected so you would need to create a new panel descendant:

public class TestPanel : Panel
{
  public TestPanel()
  {
     DoubleBuffered = true;
  }
}

作为替代,你可以设置DoubleBuffered属性的面板通过反射

as an alternative you can set the DoubleBuffered property for your panel through reflection

希望这会有所帮助,至于

hope this helps, regards

这篇关于图标平滑移动显示在面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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