コード例 #1
0
        //web item을 떨어뜨리거나 할 때, 상자 이미지가 바뀔 것이다. 그것을 다루는 것.
        //bool opening이 true라면 열린 상자 이미지로, false라면 일반 상자 이미지로
        public static void changeImg(flyingBox flyingbox, ILwin.MainWindow thisWin, bool opening)
        {
            //열린 상자 이미지로 바꾸어라
            if(opening)
            {
                if(flyingbox.dir == LEFT)
                    thisWin.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                    {
                        flyingbox.boximg.Fill = flyingbox.boxBr[2];
                    }));

                else if(flyingbox.dir == RIGHT)
                    thisWin.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                    {
                        flyingbox.boximg.Fill = flyingbox.boxBr[3];
                    }));
            }

            //일반 상자 이미지로 바꾸어라
            else
            {
                if (flyingbox.dir == LEFT)
                    thisWin.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                    {
                        flyingbox.boximg.Fill = flyingbox.boxBr[0];
                    }));

                else if (flyingbox.dir == RIGHT)
                    thisWin.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                    {
                        flyingbox.boximg.Fill = flyingbox.boxBr[1];
                    }));
            }
        }
コード例 #2
0
        //박스가 날아다니기 시작할 것이다.
        public static void startmoving(flyingBox flyingbox, ILwin.MainWindow thisWin)
        {
            int boxLoc_x = 0;


            while (true)
            {
                //현재 margin left 값을 가져온다
            thisWin.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                    {
                        boxLoc_x = (int)flyingbox.boximg.Margin.Left;
                    }));

                Thread.Sleep(50);

                if (flyingbox.dir == LEFT)
                {
                    //왼쪽 벽에 다다르면
                    if (boxLoc_x <= 0)
                    {
                        //방향은 오른쪽으로 바뀌고, 그림도 바뀌어야지.
                        flyingbox.dir = RIGHT;
                        thisWin.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                        {
                            flyingbox.boximg.Fill = flyingbox.boxBr[1];
                        }));
                    }

                    //그렇지 않다면 계속 왼쪽으로 이동
                    else
                    {

                        thisWin.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                        {
                            flyingbox.boximg.Margin = new Thickness(flyingbox.boximg.Margin.Left - 2, flyingbox.boximg.Margin.Top,
                                flyingbox.boximg.Margin.Right, flyingbox.boximg.Margin.Bottom);
                        }));
                    }
                }



                else if (flyingbox.dir == RIGHT)
                {
                    //왼쪽 벽에 다다르면
                    if (boxLoc_x >= 640)
                    {
                        flyingbox.dir = LEFT;
                        thisWin.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                        {
                            flyingbox.boximg.Fill = flyingbox.boxBr[0];
                        }));
                    }

                    //그렇지 않다면 계속 왼쪽으로 이동
                    else
                    {

                        thisWin.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                        {
                            flyingbox.boximg.Margin = new Thickness(flyingbox.boximg.Margin.Left + 2, flyingbox.boximg.Margin.Top,
                                flyingbox.boximg.Margin.Right, flyingbox.boximg.Margin.Bottom);

                        }));
                    }
                }


            }


        }
コード例 #3
0
        //webImage를 생성한다. 하나의 query에 대해 주어진 개수만큼 이미지를 가져올 것이다.
        public static void generateWebImageThread(Datas datas, flyingBox flyingbox, string query, int start, int num, ILwin.ShowScreen showscreen)
        {

            List<string> urls = new List<string>();

            //string 리스트에 url을 필요한 개수만큼 받아온다.
            HTMLhandler.getImages(urls, num, query);

            //*************위 urlgetThread가 모두 끝날 때까지 기다린다. 그리고 나서 webitems를 추가하라.

            //박스 이미지를 변경. 열린 박스로 만든다
            flyingBox.changeImg(flyingbox, showscreen.getMWinReference(), true);

            for(int i = 0; i < num; i++)
            {
                //현재 플라잉 박스의 위치
                int flyingbox_x = 0;
                int flyingbox_y = 0;

                //마지막 web item인지를 확인
                bool isFinal = false;
                if (i == (num - 1)) isFinal = true;


                showscreen.getMWinReference().Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                {
                    flyingbox_x = (int)flyingbox.boximg.Margin.Left;
                    flyingbox_y = (int)flyingbox.boximg.Margin.Top;
                }));

                //가져온 string 리스트의 url을 하나하나 넣어 webItem를 생성한다.
                WebItem.addDatas(showscreen, datas.webItems.ElementAt(start + i), urls[i], flyingbox_x, flyingbox_y);
                WebItem.fallingItem(showscreen, datas.webItems.ElementAt(start + i), isFinal);
            }
        }