コード例 #1
0
        private void btn_exit_Click(object sender, RoutedEventArgs e)
        {
            MenuWindow menu = new MenuWindow();

            menu.Show();
            this.Close();
            tmr.Stop();
        }
コード例 #2
0
        private void btn_exit_Click(object sender, RoutedEventArgs e)   //나가기 버튼. 메뉴 Window를 부르고 현재창을 닫는다.
        {
            MenuWindow menu = new MenuWindow();

            menu.Show();
            this.Close();
            tmr.Stop();
        }
コード例 #3
0
        private void start_Click(object sender, RoutedEventArgs e)
        //게임 시작 버튼. 게임 시작시 다음 메뉴선택 창을 띄우고 현재 창을 지운다.
        {
            MenuWindow menu = new MenuWindow();

            menu.Show();
            this.Close();
        }
コード例 #4
0
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            if (first == null)
            {
                first         = btn;
                btn.Opacity   = 0.5;
                btn.IsEnabled = false;
                return;
            }
            else if (second == null)
            {
                second        = btn;
                btn.Opacity   = 0.5;
                btn.IsEnabled = false;
            }
            else
            {
                return;
            }

            if ((int)first.Tag == (int)second.Tag)
            {
                Button btn1 = first;
                Button btn2 = second;
                btn1.Opacity = 0.0;
                btn2.Opacity = 0.0;

                first  = null;
                second = null;

                Matched = (Int32.Parse(Matched) - 2).ToString();

                if (Int32.Parse(Matched) <= 0)
                {
                    tmr.Stop();
                    MessageBoxResult res = MessageBox.Show(
                        "성공! 다시 하시겠습니까?", "Success", MessageBoxButton.YesNo);
                    if (res == MessageBoxResult.Yes)
                    {
                        resetRnd();
                        boardReset();
                        btnSet();
                        Matched = "36";

                        first  = null;
                        second = null;
                        Count  = 20.ToString();
                        tmr.Start();
                    }
                    else
                    {
                        MenuWindow menu = new MenuWindow();
                        menu.Show();
                        this.Close();
                    }
                }
            }

            else
            {
                Button btn1 = first;
                Button btn2 = second;
                btn1.Opacity   = 1.0;
                btn1.IsEnabled = true;
                btn2.Opacity   = 1.0;
                btn2.IsEnabled = true;

                first  = null;
                second = null;
            }
        }
コード例 #5
0
        private void btn_Click(object sender, RoutedEventArgs e)    //버튼 클릭 이벤트
        {
            Button btn = sender as Button;

            if (first == null)         // 눌려진 첫번째 버튼이 아직 눌러지지 않았으면 눌린 버튼을첫번째 버튼으로 설정
            {                          // 눌려진 버튼은 흐리게 바꾸고 선택할 수 없게 한다.
                first         = btn;
                btn.Opacity   = 0.5;
                btn.IsEnabled = false;
                return;
            }
            else if (second == null)   // 첫번째 버튼이 눌렸고 두번째 버튼이 아직 눌려지지 않았을때 두번째 버튼을 누르면 두번째 버튼으로 설정
            {
                second        = btn;
                btn.Opacity   = 0.5;
                btn.IsEnabled = false;
            }
            else
            {
                return;
            }

            // 매치가 되었을 때
            if ((int)first.Tag == (int)second.Tag)  // 선택된 두 버튼의 Tag Property가 같다면
            {
                Button btn1 = first;                // 두 버튼을 안보이게 하고
                Button btn2 = second;
                btn1.Opacity = 0.0;
                btn2.Opacity = 0.0;

                first  = null;                      // first second를 null로 설정해준다
                second = null;

                Matched = (Int32.Parse(Matched) - 2).ToString(); // 남은 카드를 2개 감소시킨다.

                if (Int32.Parse(Matched) <= 0)                   //남은 카드가 0이 되면 게임 Success.
                {
                    tmr.Stop();                                  //타이머를 멈추고 다시 할건지 메시지 박스로 물어본다.
                    MessageBoxResult res = MessageBox.Show(
                        "성공! 다시 하시겠습니까?", "Success", MessageBoxButton.YesNo);
                    if (res == MessageBoxResult.Yes)    //한다고 하면 위와 동일하게 다시 게임을 시작 아니라고 하면 창을 닫고 메뉴 화면을 띄운다
                    {
                        resetRnd();
                        boardReset();
                        btnSet();
                        Matched = "16";

                        first  = null;
                        second = null;
                        count  = 10.ToString();
                        tmr.Start();
                    }
                    else
                    {
                        MenuWindow menu = new MenuWindow();
                        menu.Show();
                        this.Close();
                    }
                }
            }
            // 매치가 안되었을 때
            else        // 선택이 되지 않게 해두었던 버튼들을 활성화. first, second 버튼을 null로 설정한다.
            {
                Button btn1 = first;
                Button btn2 = second;
                btn1.Opacity   = 1.0;
                btn1.IsEnabled = true;
                btn2.Opacity   = 1.0;
                btn2.IsEnabled = true;

                first  = null;
                second = null;
            }
        }