我在pictureBox上加载了一个image,从txt文件中读取了坐标数据后,在image上画了几条直线,这部分我都完成了,现在我想要做的是,当我再按一个键的时候,之前画的直线可以缓慢的改变颜色,就好像对它进行加工一样,加工过的地方变成红色,没加工过的地方还是黑色,颜色的变化一定要缓慢的,一开始我打算用定时器来做,但想想如果要实现缓慢效果,每500毫秒画一小段直线,那么一条长的直线,定时器要调用多少次啊,所以感觉行不通,不知道各位高手有没有什么好的办法可以帮帮我!

解决方案 »

  1.   

    可以用变相的方式考虑定时功能,用循环来做一小段一小段画线,每画完一段System.Threading.Thread.Sleep(500)
      

  2.   

    我找了一个测试代码,它基本符合我的想法,但是遇到一个问题,就是进程开始后,除非退出,不然进程一直在用,请问怎么取消进程,可以让程序重新开始执行:程序如下
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Threading;namespace WindowsApplication2
    {
        public partial class Form1 : Form
        {
            Thread mThread;
            int iCount = 0;        public Form1()
            {
                InitializeComponent();
                mThread = new Thread(new ThreadStart(this.ThreadProcess));
            }        private void ThreadProcess()
            {            while (true)
                {
                    Thread.Sleep(10);
                    this.textBox1.Text = iCount.ToString();
                    iCount++;
                }
            }               private void buttonStart_Click_1(object sender, EventArgs e)
            {
                iCount = 0;
                mThread.Start();
            }        private void buttonStop_Click_1(object sender, EventArgs e)
            {
                mThread.Suspend();
            }        private void buttonResume_Click(object sender, EventArgs e)
            {
                mThread.Resume();
            }        private void buttonExit_Click(object sender, EventArgs e)
            {
                mThread.Abort();
                this.Close();
                this.Dispose();
                Application.Exit();
            }
        }
    }
      

  3.   

    http://blog.csdn.net/Knight94/archive/2006/08/24/1111267.aspx
      

  4.   

            private void ThreadProcess() 
            {             while (iConut<10000) //(true) 
                { 
                    Thread.Sleep(10); 
                    this.textBox1.Text = iCount.ToString(); 
                    iCount++; 
                } 
            }
       
           不就做完退出了?