상세 컨텐츠

본문 제목

[Windows Forms 창 흔들기 효과]

C#

by 탑~! 2010. 12. 31. 14:33

본문


void ShakeMe()
        {
            Point myLoc = this.Location;
            Point myDefaultLoc = this.Location;

            for (int i = 0; i < 20; i++)
            {
                for (int x = 0; x <= 4; x++)
                {
                    switch (x)
                    {
                        case 0:
                            myLoc.X = myDefaultLoc.X + 10;
                            break;
                        case 1:
                            myLoc.X = myDefaultLoc.X - 10;
                            break;
                        case 2:
                            myLoc.Y = myDefaultLoc.Y + 10;
                            break;
                        case 3:
                            myLoc.Y = myDefaultLoc.Y - 10;
                            break;
                        case 4:
                            myLoc = myDefaultLoc;
                            break;
                    }

                    Thread.Sleep(10);

                    s_ctxThread.Send(new SendOrPostCallback((object target) =>
                    {
                        this.Location = myLoc;
                    }), null);

                }
            }
        }

관련글 더보기