小弟正在做一个项目,老总要求在界面上实现一个动画的线条效果,大致意思如下:     --------------------------- 
    |                          |
    |                          |
    |                          |
    |                          |按上面这个路径,用一个红色带拖尾的线条,从左向右或从右向左运动,就像Flash里面那种边框流动效果!!要是拖尾难做,不带拖尾也行,只要线条能流动就行!!小弟完全没有头绪,想上网搜又不知该怎么搜,抓狂中小弟刚找到这份工作,现在找工作这么难,万望各位老大帮忙啊,解决了另有分送上,谢谢谢谢啦!

解决方案 »

  1.   

    在wpf中就很好实现了,直接用时间线就可以了,如果不用wpf,就只能用gdi+了,不知道是不是固定的位置,如果固定好办,记录下所有的线段位置,画图就好了,把线段想成背景,每次先重画背景
      

  2.   

    给你个简单的例子建立一个Winform工程,再设计器中托一个Panel和一个Timerusing System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication3
    {
        public partial class Form1 : Form
        {
            private int i_localprama; //控制位置参数
            private Pen p_Ground;  //底色
            private Pen p_Current; //当前色        public Form1()
            {
                InitializeComponent();
                this.i_localprama = 0;
                this.p_Ground = new Pen(Brushes.Black, 2);
                this.p_Current = new Pen(Brushes.Red, 4);
            }        private void Form1_Load(object sender, EventArgs e)
            {
                this.timer1.Start();
            }        private void panel1_Paint(object sender, PaintEventArgs e)
            {
                e.Graphics.DrawLine(this.p_Ground, 0, 20, i_localprama, 20);
                e.Graphics.DrawLine(this.p_Current, i_localprama, 20, i_localprama + 4, 20);
            }        private void timer1_Tick(object sender, EventArgs e)
            {
                this.i_localprama++;
                this.panel1.Refresh();
            }
        }
    }
      

  3.   

    用c#来实现漂亮的效果估计不太好做。嘿嘿。
    建议lz用flash做,然后在c#中用控件加载flash。点击看看这个c#与flash交互编程的,呵呵
      

  4.   

    这样?  左边向上滚,右边向下滚?
    —      —
    —      —
    —      —
    —      —
    —      —
    —      —
    —      —
    —      —
    —      —
    —      —using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace WindowsApplication58
    {
        public partial class Form1 : Form
        {
            Timer T = new Timer();
            int[,] Lines = new int[2, 10];
            Bitmap OrgBmp = null;        public Form1()
            {
                InitializeComponent();
                this.Controls.Clear();            OrgBmp = new Bitmap(300, 300);
                Graphics G = Graphics.FromImage(OrgBmp);
                G.FillRectangle(new SolidBrush(this.BackColor), new Rectangle(0, 0, 300, 300));
                G.Dispose();            for (int i = 0; i < 10; i++)
                    Lines[0, i] = Lines[1, i] = i * 10;            T.Interval = 100;
                T.Tick += new EventHandler(T_Tick);
                T.Enabled = true;
            }        void T_Tick(object sender, EventArgs e)
            {
                Bitmap CacheBmp = new Bitmap(OrgBmp);
                Graphics G = Graphics.FromImage(CacheBmp);
                for (int i = 0; i < 10; i++)
                {
                    Lines[0, i] = Lines[0, i] - 1 < 0 ? 90 : Lines[0, i] - 1;
                    Lines[1, i] = (Lines[1, i] + 1) % 90;
                    G.DrawLine(new Pen(new SolidBrush(Color.Red)), new Point(0, Lines[0, i]), new Point(30, Lines[0, i]));
                    G.DrawLine(new Pen(new SolidBrush(Color.Green)), new Point(100, Lines[1, i]), new Point(130, Lines[1, i]));
                }
                G.Dispose();
                G = this.CreateGraphics();
                G.DrawImage(CacheBmp, new Point(0, 0));
                G.Dispose();
            }
        }
    }
      

  5.   


    那是因为每次都new了一个bitmap,如果你不想等自动垃圾回收,就强制垃圾回收一下内存就不会涨了        void T_Tick(object sender, EventArgs e)
            {
                Bitmap CacheBmp = new Bitmap(OrgBmp);
                ...
                GC.Collect(); 
            }