예제 #1
0
        private void ShowRotateOption()
        {
            if ((this.m_bPlaceTime) || (this.m_plrCurrentTurn == Player.Empty))
            {
                this.CreateGraphics().DrawImage(this.m_imgCurrImage,
                                                0, 0, this.Width, this.Height);
                return;
            }
            Point        pCursor   = this.PointToClient(Cursor.Position);
            DynamicImage diCurrent = this.ContainingBoard(pCursor.X, pCursor.Y);

            if (diCurrent != this.m_diLast)
            {
                this.m_diLast = diCurrent;
                if (diCurrent != null)
                {
                    Pen p = new Pen(this.m_plrCurrentTurn == Player.Red ?
                                    Color.Red : Color.Gold,
                                    4.0f);
                    Graphics g = this.CreateGraphics();
                    g.DrawImage(this.m_imgCurrImage,
                                0, 0, this.Width, this.Height);
                    g.DrawRectangle(p,
                                    new Rectangle(diCurrent.Location.X,
                                                  diCurrent.Location.Y,
                                                  diCurrent.Size.Width,
                                                  diCurrent.Size.Height));
                }
            }
        }
예제 #2
0
        private void ShowOption()
        {
            if ((!this.m_bPlaceTime) || (this.m_plrCurrentTurn == Player.Empty))
            {
                this.m_pLastOption = new Point(-1, -1);
                this.CreateGraphics().DrawImage(this.m_imgCurrImage,
                                                0,
                                                0,
                                                this.Width,
                                                this.Height);
                return;
            }

            Point pCursor = this.PointToClient(Cursor.Position);

            DynamicImage diCurrent = this.ContainingBoard(pCursor.X, pCursor.Y);

            if (diCurrent == null)
            {
                this.m_pLastOption = new Point(-1, -1);
                this.CreateGraphics().DrawImage(this.m_imgCurrImage,
                                                0,
                                                0,
                                                this.Width,
                                                this.Height);
                return;
            }

            Point pSphereLoc = Board.GetClosestSphere(pCursor.X - diCurrent.Location.X,
                                                      pCursor.Y - diCurrent.Location.Y);

            Point pToDraw =
                Board.GetSphereLocation(pSphereLoc);

            if (diCurrent.Board[pSphereLoc.X, pSphereLoc.Y] != Player.Empty)
            {
                return;
            }

            if (pToDraw != this.m_pLastOption)
            {
                this.m_pLastOption = pToDraw;
                pToDraw.X         += diCurrent.Location.X;
                pToDraw.Y         += diCurrent.Location.Y;
                int nNewSize = (int)(Consts.SPHERE_SIZE * Consts.RELATION);
                this.CreateGraphics().DrawImage(this.m_imgCurrImage,
                                                0,
                                                0,
                                                this.Width,
                                                this.Height);
                this.CreateGraphics().DrawImage(frmMain.SetAlpha(Consts.SPHERE_IMAGES[(int)this.m_plrCurrentTurn],
                                                                 200),
                                                pToDraw.X + (Consts.SPHERE_SIZE - nNewSize) / 2,
                                                pToDraw.Y + (Consts.SPHERE_SIZE - nNewSize) / 2,
                                                nNewSize,
                                                nNewSize);
            }
        }
예제 #3
0
        private void PlaceSphere()
        {
            if ((!this.m_bPlaceTime) || (this.m_plrCurrentTurn == Player.Empty))
            {
                return;
            }

            Point pCursor = this.PointToClient(Cursor.Position);

            DynamicImage diCurrent = this.ContainingBoard(pCursor.X, pCursor.Y);

            if (diCurrent == null)
            {
                this.m_pLastOption = new Point(-1, -1);
                this.CreateGraphics().DrawImage(this.m_imgCurrImage,
                                                0,
                                                0,
                                                this.Width,
                                                this.Height);
                return;
            }

            Point pSphereLoc = Board.GetClosestSphere(pCursor.X - diCurrent.Location.X,
                                                      pCursor.Y - diCurrent.Location.Y);

            Point pToDraw =
                Board.GetSphereLocation(pSphereLoc);

            if (diCurrent.Board[pSphereLoc.X, pSphereLoc.Y] != Player.Empty)
            {
                return;
            }

            int nNewSize = (int)(Consts.SPHERE_SIZE * Consts.RELATION);

            Graphics.FromImage(diCurrent.Image).DrawImage(Consts.SPHERE_IMAGES[(int)this.m_plrCurrentTurn],
                                                          pSphereLoc.X * (Consts.SPHERE_SIZE + Consts.SPACE) +
                                                          Consts.SPACE,
                                                          pSphereLoc.Y * (Consts.SPHERE_SIZE + Consts.SPACE) +
                                                          Consts.SPACE,
                                                          Consts.SPHERE_SIZE,
                                                          Consts.SPHERE_SIZE);
            pToDraw.X += diCurrent.Location.X;
            pToDraw.Y += diCurrent.Location.Y;
            Graphics.FromImage(this.m_imgCurrImage).DrawImage(Consts.SPHERE_IMAGES[(int)this.m_plrCurrentTurn],
                                                              pToDraw.X + (Consts.SPHERE_SIZE - nNewSize) / 2,
                                                              pToDraw.Y + (Consts.SPHERE_SIZE - nNewSize) / 2,
                                                              nNewSize,
                                                              nNewSize);
            this.CreateGraphics().DrawImage(this.m_imgCurrImage, 0, 0, this.Width, this.Height);
            diCurrent.Board[pSphereLoc.X, pSphereLoc.Y] = this.m_plrCurrentTurn;
            this.m_bPlaceTime = false;
            this.m_diLast     = null;
            this.ShowRotateOption();
        }
예제 #4
0
        private void SpinImage(object oToSpin)
        {
            DynamicImage diToSpin = (DynamicImage)oToSpin;

            diToSpin.Board.Rotate(this.m_bClockWise);
            this.m_bMayCheckWinner = true;
            Image    imgTemp = (Image)Consts.BACKGROUND_IMAGE.Clone();
            Graphics g       = Graphics.FromImage(imgTemp);

            foreach (DynamicImage di in this.m_arrdiBoards)
            {
                if (di != diToSpin)
                {
                    g.DrawImage(di.Image,
                                di.Location.X, di.Location.Y,
                                di.Size.Width, di.Size.Height);
                }
            }

            const double INC = 2.5;
            Image        imgTemp2;

            for (double i = 0; i <= 90; i += INC)
            {
                int nOffsetX, nOffsetY;
                nOffsetX = (int)((diToSpin.Destination.X - diToSpin.Location.X) *
                                 ((90 * i - i * i) / 2025));
                nOffsetY = (int)((diToSpin.Destination.Y - diToSpin.Location.Y) *
                                 ((90 * i - i * i) / 2025));
                imgTemp2 = (Image)imgTemp.Clone();
                g        = Graphics.FromImage(imgTemp2);
                g.TranslateTransform(diToSpin.Location.X + diToSpin.Size.Width / 2 + nOffsetX,
                                     diToSpin.Location.Y + diToSpin.Size.Height / 2 + nOffsetY);
                g.RotateTransform((this.m_bClockWise ? 1 : (-1)) * (float)i);
                g.TranslateTransform(-diToSpin.Size.Width / 2,
                                     -diToSpin.Size.Height / 2);
                g.DrawImage(diToSpin.Image, 0, 0, diToSpin.Size.Width, diToSpin.Size.Height);
                this.CreateGraphics().DrawImage(imgTemp2, 0, 0, this.Width, this.Height);
                this.m_imgCurrImage = (Image)imgTemp2.Clone();
            }

            diToSpin.Image.RotateFlip(this.m_bClockWise ? RotateFlipType.Rotate90FlipNone :
                                      RotateFlipType.Rotate270FlipNone);
        }
예제 #5
0
        private void RotateBoard(bool bClockWise)
        {
            this.m_bClockWise = bClockWise;
            Point        pCursor   = this.PointToClient(Cursor.Position);
            DynamicImage diCurrent = this.ContainingBoard(pCursor.X, pCursor.Y);

            if (diCurrent != null)
            {
                if ((this.m_thSpinningThread == null) ||
                    (this.m_thSpinningThread.ThreadState != ThreadState.Running))
                {
                    this.m_thSpinningThread =
                        new Thread(new ParameterizedThreadStart(this.SpinImage));
                    this.m_bMayCheckWinner = false;
                    this.m_thSpinningThread.Start(diCurrent);
                    while (!this.m_bMayCheckWinner)
                    {
                        ;
                    }
                    this.OnFinishRotation();
                }
            }
        }