使用GDI画坐标曲线

代码
 
      
// 画速度曲线
Graphics g = e.Graphics;
g.DrawLine(Pens.White,
40 , picChart.ClientRectangle.Height - 10 , picChart.Width - 40 , picChart.ClientRectangle.Height - 10 );
g.DrawLine(Pens.White,
40 , picChart.ClientRectangle.Height - 50 , picChart.Width - 40 , picChart.ClientRectangle.Height - 50 );
g.DrawLine(Pens.White,
40 , picChart.ClientRectangle.Height - 90 , picChart.Width - 40 , picChart.ClientRectangle.Height - 90 );
g.DrawLine(Pens.White,
40 , picChart.ClientRectangle.Height - 130 , picChart.Width - 40 , picChart.ClientRectangle.Height - 130 );

Pen p
= new Pen(Color.White, 1 );
// p.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
// p.DashCap = System.Drawing.Drawing2D.DashCap.Flat;
AdjustableArrowCap aac = new AdjustableArrowCap( 5 , 5 , false ); // 箭头的大小可以自己随便定义
p.CustomEndCap = aac;
g.DrawLine(p,
40 , picChart.ClientRectangle.Height, 40 , 4 );
g.DrawLine(p, picChart.Width
- 40 , picChart.ClientRectangle.Height, picChart.Width - 40 , 4 );
p.Dispose();

Font f
= new Font( " Arial " , 9 );
// 画线上箭头文字
int stepY = (picChart.Height - 150 ) / 13 ;
int curH = 0 ;
StringFormat sf
= new StringFormat();
sf.Alignment
= StringAlignment.Far;
int du = 0 ;
for ( int i = 0 ; i < 13 ; i ++ )
{
bool jo = i % 2 == 0 ;
int w = jo ? 10 : 5 ;
g.DrawLine(Pens.White,
40 - w, picChart.ClientRectangle.Height - 130 - curH, 40 , picChart.ClientRectangle.Height - 130 - curH);
g.DrawLine(Pens.White, picChart.Width
- 40 , picChart.ClientRectangle.Height - 130 - curH, picChart.Width - ( 40 - w), picChart.ClientRectangle.Height - 130 - curH);

if (jo)
{
// 如果是偶数
g.DrawString(du.ToString(), f, new SolidBrush(Color.White), 30 , picChart.ClientRectangle.Height - 137 - curH, sf);
g.DrawString(du.ToString(), f,
new SolidBrush(Color.White), picChart.Width - 30 , picChart.ClientRectangle.Height - 137 - curH);

du
+= 40 ;
}

curH
+= stepY;
}


g.DrawString(
" 道桥隧 " , f, new SolidBrush(Color.White), 0 , picChart.ClientRectangle.Height - 30 );
g.DrawString(
" 曲 线 " , f, new SolidBrush(Color.White), 0 , picChart.ClientRectangle.Height - 70 );
g.DrawString(
" 纵断面 " , f, new SolidBrush(Color.White), 0 , picChart.ClientRectangle.Height - 110 );
f.Dispose();

 

在winform程序中,只要了解了那几个类,使用GDI画图是相当方便的
posted on 2010-09-28 11:45 whinsh 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/whinsh/archive/2010/09/28/1837438.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值