示例#1
0
        //Function      : autoDrawLine
        //Description   : Draw multiple lines at different position.
        //
        //Parameters    : NONE
        //
        //Returns       :NONE
        //
        //
        private void autoDrawLine()
        {
            Random pRandom = new Random();

            Point pStart = new Point(pRandom.Next(20, (this.Width) / 4 + 1), pRandom.Next(20, (this.Height)/4 + 1));

            int unitX = 7;
            int unitY = 7;
            int times = 0;
            for (times = 0; times < 50; times++ )
            {
                 DrawLine line = new DrawLine(this.CreateGraphics());

                line.BackgroundColor = this.BackColor;
                Thread t = new Thread(new ThreadStart(line.DrawLines));
                lines.Add(line);
                tRepo.Add(t);
                pStart.X += unitX;
                pStart.Y += unitX;

                line.XCentre = pStart.X;
                line.YCentre = pStart.Y;
                line.nScreenLength = this.Height;
                line.nScreenWidth = this.Width;

                if (pStart.X >= this.Width)
                {
                    unitX = -unitX;

                }
                else if (pStart.X <= 0)
                {
                    unitX = -unitX;
                }

                if (pStart.Y >= this.Height)
                {
                    unitY = -unitY;

                }
                else if (pStart.Y <= 0)
                {
                    unitY = -unitY;
                }

                Thread.Sleep(10);
                t.Start();

            }
        }
示例#2
0
        //Function      :DrawLine_MouseMove
        //Description   :Draw lines when mouse moving
        //
        //Parameters    :MouseEventArgs e: mouse move event
        //
        //Returns       :None
        //
        //
        private void DrawLine_MouseMove(MouseEventArgs e)
        {
            DrawLine line = new DrawLine(this.CreateGraphics());

            line.BackgroundColor = this.BackColor;
            Thread t = new Thread(new ThreadStart(line.DrawLines));
            lines.Add(line);
            tRepo.Add(t);
            line.XCentre = e.X;
            line.YCentre = e.Y;
            line.nScreenLength = this.Height;
            line.nScreenWidth = this.Width;

            t.Start();
        }