Click here to Skip to main content
16,013,548 members
Articles / Multimedia / GDI+
Article

Easter egg surprise with Animated Matrix

Rate me:
Please Sign up or sign in to vote.
1.14/5 (10 votes)
28 Mar 2007 28.6K   425   14   4
Easter egg surprise with Animated Matrix

Download LTAniMatrix_ThreadSafe.zip - 1,901.5 KB

Screenshot - LTAniMatrix.jpg

Screenshot - GoogleAtWork.jpg

Introduction

The header said it all: An Easter egg surprise idea.<o:p>

Background

Have you seen the Matrix. Very good sci-fi movies.<o:p>

Using the code


public partial class CLTAniMatrix : Panel
{
..
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (mbFreeze)
                return;

            Graphics g = e.Graphics;           

            if (mbStartOver == true)
            {
                mbStartOver = false;

                clockingBgkWorker.CancelAsync();                
                
                
                if (mbClearBgk)
                    ClearPanel(g);
                else
                    g.DrawImage(mBkImg, this.ClientRectangle);

                mStartOverSignal.Set();

                if (mbShowDebug)
                {
                    DrawDebugInfo(g);
                }

                return;
            }

            if (mbClearBgk)
                ClearPanel(g);
            else
                g.DrawImage(mBkImg, this.ClientRectangle);

            DropMatrixChars(g);
            DropMatrixClearChars(g);

            DrawBouncingLogo(g);

            if (mbShowDebug)
            {
                DrawDebugInfo(g);
            }
        }
 
        private void clockingBgkWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (clockingBgkWorker.CancellationPending)
                return;

            DoPlaySound();
            
            bool waitresult = false;

            while (clockingBgkWorker.CancellationPending == false)
            {                
                clockingBgkWorker.ReportProgress(99);

                Thread.Sleep(10);

                waitresult = mStartOverSignal.WaitOne(mPaintInterval, true);
                if (waitresult == true)
                    break;                    
            }
        }

        private void clockingBgkWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            this.Invalidate(false);
        }       

        private void clockingBgkWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            mSoundPlayer.Stop();

            InitMatrixChars();
            mMaxCharsToClear.Clear();

            if (mbFreeze)
            {
                mbStartOver = true;
                return;
            }
                       
            mbStartOver = false;
            WorkerRun();
        } 
... 

} 

A component extending Panel. Just drop it on the form and there you go. Set matrix visibility to false when no longer want it.<o:p>

Points of Interest

Easter is coming, give your team a good laugh with an animated matrix appear from nowhere.

History

+ RePaint Trigger is ThreadSafe now.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionNo file? Pin
Gh0stman28-Mar-07 9:00
Gh0stman28-Mar-07 9:00 
There is no file to DL.
Missing !? Dead | X|
AnswerRe: No file? Pin
Long Tang28-Mar-07 12:32
Long Tang28-Mar-07 12:32 
GeneralNot threadsafe! Pin
OlliFromTor28-Mar-07 4:42
OlliFromTor28-Mar-07 4:42 
AnswerRe: Not threadsafe! Pin
Long Tang28-Mar-07 5:43
Long Tang28-Mar-07 5:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.