您的位置:程序门 -> .net技术 -> c#



c#中怎么样实现橡皮筋式画线的功能?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


c#中怎么样实现橡皮筋式画线的功能?[已结贴,结贴人:frequent]
发表于:2007-03-15 16:16:19 楼主
c#中怎么样实现橡皮筋式画线的功能?有没有这方面的资料或网页.
发表于:2007-03-15 16:17:441楼 得分:0
似乎没看到过     只看过c++写的
发表于:2007-03-15 16:17:592楼 得分:0
你可以参考下msdn的双缓冲绘图部分.
发表于:2007-03-15 16:41:133楼 得分:0
gdi+画图这一部分
发表于:2007-03-15 16:49:464楼 得分:0
msdn
gdi+画图这一部分

有的我用过
发表于:2007-03-15 17:28:495楼 得分:0
搞个自定义控件····
发表于:2007-03-15 17:30:486楼 得分:20
给你个画图的例子参考下:
using   system;
using   system.collections.generic;
using   system.componentmodel;
using   system.data;
using   system.drawing;
using   system.text;
using   system.windows.forms;

namespace   doublebufferdraw
{
public   partial   class   drawline   :   form
{
class   lineobj
{
private   point   m_start;
private   point   m_end;
public   lineobj(point   start,   point   end)
{
this.m_start   =   start;
this.m_end   =   end;
}
public   void   draw(graphics   g,   pen   pen)
{
g.drawline(pen,   m_start,   m_end);
}
}

private   point   m_startpoint   =   point.empty;
list <lineobj>   linelist   =   new   list <lineobj> ();
public   drawline()
{
initializecomponent();
}
private   void   drawline(graphics   graphics,   point   startpoint,   point   endpoint)
{
bufferedgraphicscontext   context   =   bufferedgraphicsmanager.current;
bufferedgraphics   bg   =   context.allocate(graphics,   this.clientrectangle);
bg.graphics.clear(this.backcolor);
foreach   (lineobj   line   in   this.linelist)
{
line.draw(bg.graphics,   systempens.controltext);
}
bg.graphics.drawline(systempens.controltext,   startpoint,   endpoint);
bg.render();
bg.dispose();
bg   =   null;
}
protected   override   void   onpaint(painteventargs   e)
{
base.onpaint(e);
foreach   (lineobj   line   in   this.linelist)
{
line.draw(e.graphics,   systempens.controltext);
}
}
protected   override   void   onmousedown(mouseeventargs   e)
{
base.onmousedown(e);
this.m_startpoint   =   new   point(e.x,   e.y);
}
protected   override   void   onmousemove(mouseeventargs   e)
{
base.onmousemove(e);
if   (e.button   ==   mousebuttons.left)
{
this.drawline(this.creategraphics(),   this.m_startpoint,   new   point(e.x,   e.y));
}
}
protected   override   void   onmouseup(mouseeventargs   e)
{
base.onmouseup(e);
lineobj   line   =   new   lineobj(this.m_startpoint,   e.location);
this.linelist.add(line);
}
}
}
发表于:2007-03-15 18:25:497楼 得分:0
多谢hbxtlhx(平民百姓),今天下班了,明天再来看.
发表于:2007-06-07 15:31:288楼 得分:0
学习中.....


快速检索

最新资讯
热门点击