Пример #1
0
        void cnv_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ItemUC6 it = (ItemUC6)sender;

            if (CheckMove(it.I - 1, it.J))
            {
                MoveItem(it, it.I - 1, it.J);
            }
            else if (CheckMove(it.I, it.J + 1))
            {
                MoveItem(it, it.I, it.J + 1);
            }
            else if (CheckMove(it.I + 1, it.J))
            {
                MoveItem(it, it.I + 1, it.J);
            }
            else if (CheckMove(it.I, it.J - 1))
            {
                MoveItem(it, it.I, it.J - 1);
            }
            if (CheckWin())
            {
                Board[3, 3] = 16;
                ItemUC6 cnv = new ItemUC6(16);
                Canvas.SetTop(cnv, 330);
                Canvas.SetLeft(cnv, 330);
                cnBoard.Children.Add(cnv);
                UCWin uCWin = new UCWin();
                uc.Children.Add(uCWin);
                Uri uri = new Uri("../../Sound/chucmung.mp3", UriKind.Relative);
                mediaPlayer.Open(uri);
                mediaPlayer.Play();
                bantay.Visibility = Visibility.Visible;
            }
        }
Пример #2
0
        private void Feast_MouseUp(object sender, MouseButtonEventArgs e)
        {
            int   temp = 0;
            Image l    = e.Source as Image;

            if (l != null)
            {
                if (l.Name == "img1")
                {
                    temp = 1;
                    MouseUpImage(_BasePoint1, img1);
                    LocationImage(_BasePoint1);
                    _BasePoint1 = pointtemp;
                    img1.ReleaseMouseCapture();
                }
                else if (l.Name == "img2")
                {
                    temp = 2;
                    MouseUpImage(_BasePoint2, img2);
                    LocationImage(_BasePoint2);
                    _BasePoint2 = pointtemp;
                    img2.ReleaseMouseCapture();
                }
                else if (l.Name == "img3")
                {
                    temp = 3;
                    MouseUpImage(_BasePoint3, img3);
                    LocationImage(_BasePoint3);
                    _BasePoint3 = pointtemp;
                    img3.ReleaseMouseCapture();
                }
                else if (l.Name == "img4")
                {
                    temp = 4;
                    MouseUpImage(_BasePoint4, img4);
                    LocationImage(_BasePoint4);
                    _BasePoint4 = pointtemp;
                    img4.ReleaseMouseCapture();
                }
                else if (l.Name == "img5")
                {
                    temp = 5;
                    MouseUpImage(_BasePoint5, img5);
                    LocationImage(_BasePoint5);
                    _BasePoint5 = pointtemp;
                    img5.ReleaseMouseCapture();
                }
                else if (l.Name == "img6")
                {
                    temp = 6;
                    MouseUpImage(_BasePoint6, img6);
                    LocationImage(_BasePoint6);
                    _BasePoint6 = pointtemp;
                    img6.ReleaseMouseCapture();
                }
                else if (l.Name == "img7")
                {
                    temp = 7;
                    MouseUpImage(_BasePoint7, img7);
                    LocationImage(_BasePoint7);
                    _BasePoint7 = pointtemp;
                    img7.ReleaseMouseCapture();
                }
                else if (l.Name == "img8")
                {
                    temp = 8;
                    MouseUpImage(_BasePoint8, img8);
                    LocationImage(_BasePoint8);
                    _BasePoint8 = pointtemp;
                    img8.ReleaseMouseCapture();
                }
                else if (l.Name == "img9")
                {
                    temp = 9;
                    MouseUpImage(_BasePoint9, img9);
                    LocationImage(_BasePoint9);
                    _BasePoint9 = pointtemp;
                    img9.ReleaseMouseCapture();
                }
                else if (l.Name == "img10")
                {
                    temp = 10;
                    MouseUpImage(_BasePoint10, img10);
                    LocationImage(_BasePoint10);
                    _BasePoint10 = pointtemp;
                    img10.ReleaseMouseCapture();
                }
                else if (l.Name == "img11")
                {
                    temp = 11;
                    MouseUpImage(_BasePoint11, img11);
                    LocationImage(_BasePoint11);
                    _BasePoint11 = pointtemp;
                    img11.ReleaseMouseCapture();
                }
                else if (l.Name == "img12")
                {
                    temp = 12;
                    MouseUpImage(_BasePoint12, img12);
                    LocationImage(_BasePoint12);
                    _BasePoint12 = pointtemp;
                    img12.ReleaseMouseCapture();
                }
                else if (l.Name == "img13")
                {
                    temp = 13;
                    MouseUpImage(_BasePoint13, img13);
                    LocationImage(_BasePoint13);
                    _BasePoint13 = pointtemp;
                    img13.ReleaseMouseCapture();
                }
                else if (l.Name == "img14")
                {
                    temp = 14;
                    MouseUpImage(_BasePoint14, img14);
                    LocationImage(_BasePoint14);
                    _BasePoint14 = pointtemp;
                    img14.ReleaseMouseCapture();
                }
                else if (l.Name == "img15")
                {
                    temp = 15;
                    MouseUpImage(_BasePoint15, img15);
                    LocationImage(_BasePoint15);
                    _BasePoint15 = pointtemp;
                    img15.ReleaseMouseCapture();
                }
                else if (l.Name == "img16")
                {
                    temp = 16;
                    MouseUpImage(_BasePoint16, img16);
                    LocationImage(_BasePoint16);
                    _BasePoint16 = pointtemp;
                    img16.ReleaseMouseCapture();
                }

                PropertyChange(temp);
                if (checkWin())
                {
                    shadow1.Opacity  = 0;
                    shadow2.Opacity  = 0;
                    shadow3.Opacity  = 0;
                    shadow4.Opacity  = 0;
                    shadow5.Opacity  = 0;
                    shadow6.Opacity  = 0;
                    shadow7.Opacity  = 0;
                    shadow8.Opacity  = 0;
                    shadow9.Opacity  = 0;
                    shadow10.Opacity = 0;
                    shadow11.Opacity = 0;
                    shadow12.Opacity = 0;
                    shadow13.Opacity = 0;
                    shadow14.Opacity = 0;
                    shadow15.Opacity = 0;
                    shadow16.Opacity = 0;
                    Uri uri = new Uri("../../Sound/chucmung.mp3", UriKind.Relative); // "/PuzzleGame;component/Sound/Ilikeme.wav", UriKind.Relative, browsing to the sound folder and then the WAV file location
                    playMedia.Open(uri);                                             // inserting the URI to the media player
                    playMedia.Play();
                    UCWin uCWin = new UCWin();
                    uc.Children.Add(uCWin);
                    next.Visibility   = Visibility.Visible;
                    bantay.Visibility = Visibility.Visible;
                }
            }
        }
Пример #3
0
        private void Feast_MouseUp(object sender, MouseButtonEventArgs e)
        {
            int   temp = 0;
            Image l    = e.Source as Image;

            if (l != null)
            {
                if (l.Name == "img1")
                {
                    temp = 1;
                    MouseUpImage(_BasePoint1, img1);
                    LocationImage(_BasePoint1);
                    _BasePoint1 = pointtemp;
                    img1.ReleaseMouseCapture();
                }
                else if (l.Name == "img2")
                {
                    temp = 2;
                    MouseUpImage(_BasePoint2, img2);
                    LocationImage(_BasePoint2);
                    _BasePoint2 = pointtemp;
                    img2.ReleaseMouseCapture();
                }
                else if (l.Name == "img3")
                {
                    temp = 3;
                    MouseUpImage(_BasePoint3, img3);
                    LocationImage(_BasePoint3);
                    _BasePoint3 = pointtemp;
                    img3.ReleaseMouseCapture();
                }
                else if (l.Name == "img4")
                {
                    temp = 4;
                    MouseUpImage(_BasePoint4, img4);
                    LocationImage(_BasePoint4);
                    _BasePoint4 = pointtemp;
                    img4.ReleaseMouseCapture();
                }
                else if (l.Name == "img5")
                {
                    temp = 5;
                    MouseUpImage(_BasePoint5, img5);
                    LocationImage(_BasePoint5);
                    _BasePoint5 = pointtemp;
                    img5.ReleaseMouseCapture();
                }
                else if (l.Name == "img6")
                {
                    temp = 6;
                    MouseUpImage(_BasePoint6, img6);
                    LocationImage(_BasePoint6);
                    _BasePoint6 = pointtemp;
                    img6.ReleaseMouseCapture();
                }
                else if (l.Name == "img7")
                {
                    temp = 7;
                    MouseUpImage(_BasePoint7, img7);
                    LocationImage(_BasePoint7);
                    _BasePoint7 = pointtemp;
                    img7.ReleaseMouseCapture();
                }
                else if (l.Name == "img8")
                {
                    temp = 8;
                    MouseUpImage(_BasePoint8, img8);
                    LocationImage(_BasePoint8);
                    _BasePoint8 = pointtemp;
                    img8.ReleaseMouseCapture();
                }
                else if (l.Name == "img9")
                {
                    temp = 9;
                    MouseUpImage(_BasePoint9, img9);
                    LocationImage(_BasePoint9);
                    _BasePoint9 = pointtemp;
                    img9.ReleaseMouseCapture();
                }

                PropertyChange(temp);
                if (checkWin())
                {
                    shadow1.Opacity = 0;
                    shadow2.Opacity = 0;
                    shadow3.Opacity = 0;
                    shadow4.Opacity = 0;
                    shadow5.Opacity = 0;
                    shadow6.Opacity = 0;
                    shadow7.Opacity = 0;
                    shadow8.Opacity = 0;
                    shadow9.Opacity = 0;

                    Uri uri = new Uri("../../Sound/chucmung.mp3", UriKind.Relative);
                    playMedia.Open(uri);
                    playMedia.Play();
                    UCWin uCWin = new UCWin();
                    uc.Children.Add(uCWin);
                    next.Visibility   = Visibility.Visible;
                    bantay.Visibility = Visibility.Visible;
                }
            }
        }