Click here to Skip to main content
Licence 
First Posted 28 Mar 2007
Views 18,534
Bookmarked 13 times

Easter egg surprise with Animated Matrix

By | 28 Mar 2007 | Article
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.

Background

Have you seen the Matrix. Very good sci-fi movies.

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.

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

About the Author

Long Tang

Software Developer (Senior)

United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionNo file? PinmemberGh0stman9:00 28 Mar '07  
AnswerRe: No file? PinmemberLong Tang12:32 28 Mar '07  
GeneralNot threadsafe! PinmemberOlliFromTor4:42 28 Mar '07  
AnswerRe: Not threadsafe! PinmemberLong Tang5:43 28 Mar '07  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 28 Mar 2007
Article Copyright 2007 by Long Tang
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid