你有没有定时DrawCurve
需要多长时间?也许它足够快,可以实时进行。不要忘记,GDI会将绘图原语剪切到绘图区域。您只需在您移动鼠标时设置剪切矩形。
为了加速重绘,创建主窗口图像(您粘贴的那个)作为离屏位图,并在屏幕上显示屏幕上的屏幕版本。这样你可以减少DrawCurve
的影响。
最后,为了获得好看的结果,重载OnPaintBackground
(记不清名字,但是它是这样的),所以它什么都不做(甚至不用调用基类)并在OnPaint
方法中执行所有的绘制使用一个BufferedGraphics
对象。
更新
你的油漆的功能可能是这样的:
OnPaint (...)
{
the_graphics_object.DrawImage (the background image);
the_graphics_object.Clip = new Region (new Rectangle (coords relative to mouse position));
the_graphics_object.TranslateTransform (drawing offset based on mouse position);
RenderScene (the_graphics_object, scale_factor); // draws grid and curve, etc
the_graphics_object.DrawRectangle (zoom view rectangle); // draw a frame around the zoomed view
}
这将产生相对于鼠标位置的浮动“窗口”。
嗯,我认为它绘制te曲线相当快(我粗略猜测大约10毫秒)。你能解释更多关于使用鼠标悬停剪辑的事件吗? –
@ Sean87:查看更新的答案。当鼠标移动并且缩放功能启用时,重新绘制窗口。 – Skizz