首页
社区
课程
招聘
怎么样用c#绘制一条直线并让直线从上往下移动
发表于: 2010-11-1 19:10 5451

怎么样用c#绘制一条直线并让直线从上往下移动

2010-11-1 19:10
5451
从上往下或者从右往左移动都可以``需要怎么实现?

[课程]FART 脱壳王!加量不加价!FART作者讲授!

收藏
免费 0
支持
分享
最新回复 (6)
雪    币: 255
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
我也不知道····顶一下吧······
2010-11-2 11:41
0
雪    币: 310
活跃值: (159)
能力值: ( LV12,RANK:200 )
在线值:
发帖
回帖
粉丝
3
GDI+是很容易实现的吧!
2010-11-3 15:14
0
雪    币: 0
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
使用GDI+画线,并用一个Timer控件在不同的位置画但要把之前画的擦掉哦。
2010-11-4 16:40
0
雪    币: 2087
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
用VC还容易实现
2010-11-4 17:02
0
雪    币: 109
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace line
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private int nLength = 400; //线长度
      private int nStep = 2;
        Point ptStart;
        Point ptEnd;
        Pen pen = new Pen(Color.Black);

        private void Form1_Load(object sender, EventArgs e)
        {

            ptStart = new Point(10, 20);
            ptEnd = new Point(10 + nLength, 20);

            Timer tmr = new Timer();
            tmr.Interval = 50;
            tmr.Tick += new EventHandler(tmr_Tick);
            tmr.Start();

        }

        void tmr_Tick(object sender, EventArgs e)
        {
            ptStart.Y += nStep;
            ptEnd.Y += nStep;
            this.Invalidate();
            //throw new NotImplementedException();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            
            e.Graphics.DrawLine(pen, ptStart, ptEnd);
            base.OnPaint(e);
        }
    }
}

虽然比较丑陋,但是达到你的要求了哈,kx啊啊啊啊
2010-11-5 01:57
0
雪    币: 91
活跃值: (13)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
感谢```今天自己也弄了下``线的移动实现了 ,就是不知道怎么清除
2010-11-5 20:46
0
游客
登录 | 注册 方可回帖
返回
//