Exemple #1
0
        private void AreaStatistics_Click(object sender, EventArgs e)
        {
            StatisticAnalyze statisticAnalyze = new StatisticAnalyze(axMapControl1.Map);
            IFeatureClass    featureClass     = statisticAnalyze.CreateShapefile("D:\\", "deodatabase", "Clip_Polygon");

            if (featureClass == null)
            {
                MessageBox.Show("失败");
                return;
            }
            bool bRes = statisticAnalyze.AddFeatureClassToMap(featureClass, "Clip_Polygon");

            if (!bRes)
            {
                MessageBox.Show("加入");
                return;
            }

            statisticAnalyze.AddPolygonToLayer(m_polygon);

            statisticAnalyze.cilpOperator(axMapControl1.Map, "XZDW", "Clip_Polygon", "D:\\");
            statisticAnalyze.cilpOperator(axMapControl1.Map, "DLTB", "Clip_Polygon", "D:\\");
            statisticAnalyze.cilpOperator(axMapControl1.Map, "LXDW", "Clip_Polygon", "D:\\");

            statisticAnalyze.DLTBquitXZandLX("DLTB_Clip", "XZDW_Clip", "LXDW_Clip");

            DataBoard databoard = new DataBoard("面积统计", statisticAnalyze.GetSt());

            databoard.Show();
        }
        public void Run()
        {
            var dataBoard = new DataBoard();
            var data      = GetData();

            dataBoard.DisplayData(data);
        }
Exemple #3
0
        new private void DisplayData()
        {
            var dataBoard = new DataBoard();
            var data      = GetData();

            dataBoard.DisplayData(data);
        }
Exemple #4
0
        static private long defend_2(int curr_Row, int curr_Column)
        {
            long Sum       = 0;
            long PointTemp = 0;
            int  QuanTa    = 0;
            int  QuanDich  = 0;

            for (int count = 1; count < 6 && curr_Column + count < Cons.chess_board_width; count++)
            {
                if (DataBoard.Get_Board_value(curr_Column + count, curr_Row) == 2)
                {
                    QuanTa++;
                    break;
                }
                else
                if (DataBoard.Get_Board_value(curr_Column + count, curr_Row) == 1)
                {
                    QuanDich++;
                }
                else
                {
                    break;
                }
            }


            for (int count = 1; count < 6 && curr_Column - count >= 0; count++)
            {
                if (DataBoard.Get_Board_value(curr_Column - count, curr_Row) == 2)
                {
                    QuanTa++;
                    break;
                }
                else
                if (DataBoard.Get_Board_value(curr_Column - count, curr_Row) == 1)
                {
                    QuanDich++;
                }
                else
                {
                    break;
                }
            }


            if (QuanTa == 2)
            {
                return(0);
            }

            Sum += Score_DEF[QuanDich];
            if (QuanDich > 0)
            {
                Sum -= Score_ATK[QuanTa];
            }
            PointTemp += Sum;


            return(PointTemp);
        }
Exemple #5
0
        private void NewButton_Click(object sender, EventArgs e)
        {
            Focus_Panel();
            sound.Play(sound.click);
            timer.Stop();
            CheckBoard = new BoardManager(PlayPanel, Mode);
            CheckBoard.ClearChessBoard();
            CheckBoard.DrawChessBoard();
            // Reset timer and announce current player
            InitTimer();
            timer.Stop();
            //Set Score
            Score.Text = Cons.Player1_score.ToString() + ":" + Cons.Player2_score.ToString();
            //Set new First Player and set avatar
            DataBoard.Random_Player();

            if (DataBoard.Get_Cur_Player() == 1)
            {
                CurPlayerMark.BackgroundImage   = Cons.Player1_icon_IMG;
                CurPlayerAvatar.BackgroundImage = Player1Avatar.BackgroundImage;
            }
            else
            {
                CurPlayerMark.BackgroundImage   = Cons.Player2_icon_IMG;
                CurPlayerAvatar.BackgroundImage = Player2Avatar.BackgroundImage;
            }
            //Annouce
            AnnounceCurPlayer();
            timer.Start();
            Focus_Panel();
            if (Mode == false && DataBoard.Get_Cur_Player() == 2 && DataBoard.isEmpty())//PvC and Bot go first
            {
                CheckBoard.ButtonMove(CheckBoard.btn[Cons.chess_board_width / 2, Cons.chess_board_height / 2], false);
            }
        }
Exemple #6
0
 void timer_Tick(object sender, EventArgs e)
 {
     if (DataBoard.Get_Cur_Player() == 1 && Time1 > 0)
     {
         Time1--;
         Player1Timer.Text = FormatTime(Time1);
         if (Time1 == 0)
         {
             DataBoard.GameOver(2);             //player2 win when player 1 time out
         }
     }
     if (DataBoard.Get_Cur_Player() == 2 && Time2 > 0)
     {
         Time2--;
         Player2Timer.Text = FormatTime(Time2);
         if (Time2 == 0)
         {
             DataBoard.GameOver(1);              //player1 win when player 2 time out
         }
     }
     if (DataBoard.isEmpty() && Mode == false && DataBoard.Get_Cur_Player() == 2)
     {
         CheckBoard.ButtonMove(CheckBoard.btn[Cons.chess_board_width / 2, Cons.chess_board_height / 2], false);
     }
 }
Exemple #7
0
 static private bool PrunningHorizontal(int curr_row, int curr_coll)
 {
     // Right way check
     if (curr_coll < Cons.chess_board_width - 5)
     {
         for (int i = 1; i <= 4; i++)
         {
             if (DataBoard.Get_Board_value(curr_coll + i, curr_row) != 0)
             {
                 return(false);
             }
         }
     }
     // Left way check
     if (curr_coll >= 4)
     {
         for (int i = 1; i <= 4; i++)
         {
             if (DataBoard.Get_Board_value(curr_coll - i, curr_row) != 0)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemple #8
0
        public bool ButtonMove(Button bt, bool isSetUp)
        {
            Point Move = new Point(bt.Location.X / Cons.chess_width, bt.Location.Y / Cons.chess_height);

            if (bt.BackgroundImage == null)          //Check that Button have been used (No Image)
            {                                        //Set Image to Button
                if (DataBoard.Get_Cur_Player() == 1) //Player 1
                {
                    if (!isSetUp)
                    {
                        sound.Play(sound.p1);
                    }
                    bt.BackgroundImage = Cons.Player1_icon_IMG;
                }
                else    //Player 2
                {
                    if (!isSetUp)
                    {
                        sound.Play(sound.p2);
                    }
                    bt.BackgroundImage = Cons.Player2_icon_IMG;
                }
                //Set Value in DataBoard
                DataBoard.Move(Move, isSetUp);
                return(true);
            }
            return(false);
        } //Make a Move by a Button
Exemple #9
0
 static private bool PrunningVertical(int curr_row, int curr_coll)
 {
     // Down way check
     if (curr_row <= Cons.chess_board_height - 5)
     {
         for (int i = 1; i <= 4; i++)
         {
             if (DataBoard.Get_Board_value(curr_coll, curr_row + i) != 0)
             {
                 return(false);
             }
         }
     }
     // Up way check
     if (curr_row >= 4)
     {
         for (int i = 1; i <= 4; i++)
         {
             if (DataBoard.Get_Board_value(curr_coll, curr_row - i) != 0)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemple #10
0
 static private bool PrunningSubDiagonal(int curr_row, int curr_coll)
 {
     // Up to down way check
     if (curr_row <= Cons.chess_board_height - 5 && curr_coll <= Cons.chess_board_width - 5)
     {
         for (int i = 1; i <= 4; i++)
         {
             if (DataBoard.Get_Board_value(curr_coll + i, curr_row + i) != 0)
             {
                 return(false);
             }
         }
     }
     // Down to up way check
     if (curr_coll >= 4 && curr_row >= 4)
     {
         for (int i = 1; i <= 4; i++)
         {
             if (DataBoard.Get_Board_value(curr_coll - i, curr_row - i) != 0)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemple #11
0
        void btn_Click(object sender, EventArgs e)
        {
            if (!DataBoard.Get_GameOver())
            {
                Button movebtn = sender as Button;

                if (f.pForm.Mode == true) // PvP

                {
                    ButtonMove(movebtn, false);     //Player Move //and // change Player
                }
                if (f.pForm.Mode == false)
                {
                    bool click_res = false;
                    //Player Move
                    if (DataBoard.Get_Cur_Player() == 1)
                    {
                        click_res = ButtonMove(movebtn, false); //Player Move //and // change Player
                    }
                    //Bot move
                    if (click_res)
                    {
                        Point BotMove = AI.BotFindMove();
                        ButtonMove(btn[BotMove.X, BotMove.Y], false);
                        f.pForm.Focus_Panel();
                    }
                }
            }
        }
Exemple #12
0
        public void SetUp(bool status, int time1, int time2, int cur_player, List <Point> List)
        {
            DataBoard.Set_isGameOver(status);
            Time1             = time1;
            Time2             = time2;
            Player1Timer.Text = FormatTime(Time1);
            Player2Timer.Text = FormatTime(Time2);

            if (Time1 == 0 || Time2 == 0)
            {
                timer.Enabled     = false;
                Player1Timer.Text = "No Limit";
                Player2Timer.Text = "No Limit";
            }

            DataBoard.Set_Cur_Player(cur_player);
            if (List.Count % 2 == 1)
            {
                DataBoard.changePlayer();
            }


            if (!status)
            {
                f.pForm.timer.Start();
            }
            for (int i = 0; i < List.Count; i++)
            {
                f.pForm.CheckBoard.ButtonMove(f.pForm.CheckBoard.btn[List[i].X, List[i].Y], false);
            }
            //Focus in last move
            Focus_Panel();
        }
Exemple #13
0
        public void AnnounceCurPlayer()
        {
            AnnounceForm aForm = new AnnounceForm();

            aForm.ShowDialog();
            if (Mode == false && DataBoard.Get_Cur_Player() == 2 && DataBoard.isEmpty())//PvC and Bot go first
            {
                CheckBoard.ButtonMove(CheckBoard.btn[Cons.chess_board_width / 2, Cons.chess_board_height / 2], false);
            }
        }
Exemple #14
0
        public BoardManager(Panel panel_chessboard, bool GameMode)
        {
            ChessBoard = panel_chessboard;

            //Set DataBoard Start value
            DataBoard.New_Board();

            //Set Player Bot or Human
            TypePlayer1 = true;     //Player1 alway human
            TypePlayer2 = GameMode; //Player2 set to human or bot (true/false)
        }
Exemple #15
0
        private void miGeometry_Click(object sender, EventArgs e)
        {
            DataOperator dataoperator = new DataOperator(axMapControl1.Map);
            //ILayer layer;
            //layer = dataoperator.GetLayerByName("DLTB");
            //IFeatureLayer featureLayer = layer as IFeatureLayer;
            //IFeatureCursor featureCursor = featureLayer.Search(null, false);
            //IFeature feature = featureCursor.NextFeature();
            IGeometry geometry = new PolygonClass();

            geometry = m_polygon;

            IPointCollection pointCollection = (Polygon)geometry;
            DataTable        dataTable       = new DataTable();
            DataColumn       dataColumn      = new DataColumn();//创建列

            dataColumn            = new DataColumn();
            dataColumn.ColumnName = "number";//设置第一列,表示用户指定的列名
            dataColumn.DataType   = System.Type.GetType("System.String");
            dataTable.Columns.Add(dataColumn);

            dataColumn            = new DataColumn();
            dataColumn.ColumnName = "X";//设置第二列为在目标图层类作为分类标准的属性
            dataColumn.DataType   = System.Type.GetType("System.String");
            dataTable.Columns.Add(dataColumn);

            dataColumn            = new DataColumn();
            dataColumn.ColumnName = "Y";//设置第三列为在目标图层类作为分类标准的属性
            dataColumn.DataType   = System.Type.GetType("System.String");
            dataTable.Columns.Add(dataColumn);


            IGraphicsContainer pGraphicsContainer = axMapControl1.Map as IGraphicsContainer;
            DataRow            dataRow;

            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                dataRow    = dataTable.NewRow();
                dataRow[0] = i;
                dataRow[1] = pointCollection.Point[i].X;
                dataRow[2] = pointCollection.Point[i].Y;//将统计结果添加到第三列
                dataTable.Rows.Add(dataRow);
                IMarkerElement pMarkerElement = new MarkerElementClass();
                IElement       pElement       = pMarkerElement as IElement;
                pElement.Geometry = pointCollection.Point[i];
                pGraphicsContainer.AddElement((IElement)pMarkerElement, 0);
            }
            axMapControl1.ActiveView.Refresh();

            DataBoard dataBoard = new DataBoard("Position", dataTable);

            dataBoard.Show();
        }
Exemple #16
0
        public void Focus_Panel()
        {
            if (!DataBoard.isEmpty())

            {//focus last move
                CheckBoard.btn[DataBoard.Get_LastMove().X, DataBoard.Get_LastMove().Y].Focus();
            }

            else
            { //focus middle
                CheckBoard.btn[Cons.chess_board_width / 2, Cons.chess_board_height / 2].Focus();
            }
        }
Exemple #17
0
        static private Point SearchRoads()
        {
            Point move = new Point();

            long Score       = 0;
            long extra_Score = 0;

            for (int i = 0; i < Cons.chess_board_height; i++)
            {
                for (int j = 0; j < Cons.chess_board_width; j++)
                {
                    long p_Attack = 0;
                    long p_Defend = 0;
                    if (DataBoard.Get_Board_value(i, j) == 0 && !Prunning(j, i))
                    {
                        p_Attack += attack_1(j, i);
                        p_Attack += attack_2(j, i);
                        p_Attack += attack_3(j, i);
                        p_Attack += attack_4(j, i);

                        p_Defend += defend_1(j, i);
                        p_Defend += defend_2(j, i);
                        p_Defend += defend_3(j, i);
                        p_Defend += defend_4(j, i);


                        if (p_Defend < p_Attack)
                        {
                            if (Score < p_Attack || (Score == p_Attack && extra_Score < p_Defend))
                            {
                                Score       = p_Attack;
                                extra_Score = p_Defend;
                                move        = new Point(i, j);
                            }
                        }
                        else
                        {
                            if (Score < p_Defend || (Score == p_Defend && extra_Score < p_Attack))
                            {
                                Score       = p_Defend;
                                extra_Score = p_Attack;
                                move        = new Point(i, j);
                            }
                        }
                    }
                }
            }
            return(move);
        }
Exemple #18
0
 public AnnounceForm()
 {
     InitializeComponent();
     Location = new Point(f.pForm.Location.X + 250, f.pForm.Location.Y + 175);
     if (DataBoard.Get_Cur_Player() == 1)
     {
         Avatar.Image     = Cons.Player1_avt_IMG;
         NameBox.Text     = Cons.Player1_Name;
         PlayerMark.Image = Cons.Player1_icon_IMG;
     }
     else
     {
         Avatar.Image     = Cons.Player2_avt_IMG;
         NameBox.Text     = Cons.Player2_Name;
         PlayerMark.Image = Cons.Player2_icon_IMG;
     }
 }
Exemple #19
0
        }// Keyboard Control change Location

        public void Redo()
        {
            if (!DataBoard.isEmpty())
            {   //Return to Pre-Win state
                if (DataBoard.Get_GameOver())
                {
                    BackForm backForm = new BackForm();
                    backForm.ShowDialog();
                }
                else
                {
                    //Remove Mark
                    btn[DataBoard.Get_LastMove().X, DataBoard.Get_LastMove().Y].BackgroundImage = null;
                    //Remove DataBoard Value
                    DataBoard.Remove_LastMove();
                }
            }
        }
Exemple #20
0
 private void gunaButton1_Click(object sender, EventArgs e)
 {
     DataBoard.Set_isGameOver(false);
     f.pForm.timer.Start();
     //Remove Mark
     f.pForm.CheckBoard.btn[DataBoard.Get_LastMove().X, DataBoard.Get_LastMove().Y].BackgroundImage = null;
     //Remove DataBoard Value
     DataBoard.Remove_LastMove();
     f.pForm.CheckBoard.Refesh();
     if (DataBoard.Get_Cur_Player() == 1)
     {
         Cons.Player1_score--;
     }
     else
     {
         Cons.Player2_score--;
     }
     f.pForm.Score.Text = Cons.Player1_score.ToString() + ":" + Cons.Player2_score.ToString();
     this.Close();
 }
Exemple #21
0
 public void Refesh()
 {
     for (int i = 0; i < Cons.chess_board_height; i++)
     {
         for (int j = 0; j < Cons.chess_board_width; j++)
         {
             if (DataBoard.Get_Board_value(i, j) == 1)
             {
                 btn[i, j].BackgroundImage = Cons.Player1_icon_IMG;
             }
             else if (DataBoard.Get_Board_value(i, j) == 2)
             {
                 btn[i, j].BackgroundImage = Cons.Player2_icon_IMG;
             }
             else
             {
                 btn[i, j].BackgroundImage = null;
             }
         }
     }
 }
Exemple #22
0
        public int Time1, Time2; // Time each player have
        #endregion

        #region Initialize
        public PlayForm(bool GameMode)
        {
            //Initialize Form Component
            InitializeComponent();
            //Set player avatars
            Player1Avatar.BackgroundImage = Cons.Player1_avt_IMG;
            Player2Avatar.BackgroundImage = Cons.Player2_avt_IMG;


            //set Player Mark
            Player1Mark.Image = Cons.Player1_icon_IMG;
            Player2Mark.Image = Cons.Player2_icon_IMG;

            //Set Player Name
            Player2NameLabel.Text = Cons.Player2_Name;
            Player1NameLabel.Text = Cons.Player1_Name;

            //Create a panel of button
            CheckBoard = new BoardManager(PlayPanel, GameMode);
            CheckBoard.ClearChessBoard();
            CheckBoard.DrawChessBoard();
            Focus_Panel();
            //Set Score
            Score.Text = Cons.Player1_score.ToString() + ":" + Cons.Player2_score.ToString();
            //set CurPlayer Avatar and mark
            if (DataBoard.Get_Cur_Player() == 1)
            {
                CurPlayerMark.BackgroundImage   = Cons.Player1_icon_IMG;
                CurPlayerAvatar.BackgroundImage = Player1Avatar.BackgroundImage;
            }
            else
            {
                CurPlayerMark.BackgroundImage   = Cons.Player2_icon_IMG;
                CurPlayerAvatar.BackgroundImage = Player2Avatar.BackgroundImage;
            }
            //Set Game Mode
            Mode = GameMode;
            //Initialize Timer
            InitTimer();
        }
Exemple #23
0
        } //Format int to String (mm:ss)

        private void SaveButton_Click(object sender, EventArgs e)
        {
            sound.Play(sound.click);
            //Set string for board data
            string num_Move = DataBoard.ListMove.Count.ToString();

            //Set string for game status
            string game_status;

            if (DataBoard.Get_GameOver())
            {
                game_status = "1";
            }
            else
            {
                game_status = "0";
            }
            string[] lines = new string[12 + (2 * DataBoard.ListMove.Count)];

            lines[0]  = Mode ? "1" : "0";
            lines[1]  = Cons.Player1_Name;
            lines[2]  = Cons.Player2_Name;
            lines[3]  = Cons.Player1_score.ToString();
            lines[4]  = Cons.Player2_score.ToString();
            lines[5]  = num_Move;
            lines[6]  = game_status;
            lines[7]  = Time1.ToString();
            lines[8]  = Time2.ToString();
            lines[9]  = DataBoard.Get_Cur_Player().ToString();
            lines[10] = Cons.Player1_avt_num.ToString();
            lines[11] = Cons.Player2_avt_num.ToString();
            for (int i = 0; i < DataBoard.ListMove.Count; i++)
            {
                lines[12 + i * 2]     = DataBoard.ListMove[i].X.ToString();
                lines[12 + i * 2 + 1] = DataBoard.ListMove[i].Y.ToString();
            }

            /*
             *  0 gamemode (1:PVP , 0:PvC)
             *  1 player1_name
             *  2 player2_name
             *  3 player1_score
             *  4 player2_score
             *  5 number of Move
             *  6 game status (is Game end?)
             *  7 player1_time (int)
             *  8 player2_tine (int)
             *  9 curent player (int)
             *  10 player1_avatar_num  (index : 0->9)
             *  11 player2_avatar_num  (index : 0->9)
             *
             *  12 Move[1] X
             *  13 Move[1] Y
             *
             *  15 Move[2] X
             *  16 Move[2] Y
             *  ...
             */
            System.IO.File.WriteAllLines(Application.StartupPath + "Save.txt", lines);

            PauseButton_Click(sender, e);
        }
Exemple #24
0
        static private long attack_1(int curr_Row, int curr_Column)
        {
            long Sum       = 0;
            long PointTemp = 0;
            int  QuanTa    = 0;
            int  QuanDich  = 0;

            for (int count = 1; count < 6 && curr_Row + count < Cons.chess_board_height; count++)
            {
                if (DataBoard.Get_Board_value(curr_Column, curr_Row + count) == 2)
                {
                    QuanTa++;
                }
                else
                if (DataBoard.Get_Board_value(curr_Column, curr_Row + count) == 1)
                {
                    QuanDich++;
                    PointTemp -= Score_ATK[1];
                    break;
                }
                else
                {
                    break;
                }
            }

            for (int count = 1; count < 6 && curr_Row - count >= 0; count++)
            {
                if (DataBoard.Get_Board_value(curr_Column, curr_Row - count) == 2)
                {
                    QuanTa++;
                }
                else
                if (DataBoard.Get_Board_value(curr_Column, curr_Row - count) == 1)
                {
                    QuanDich++;
                    PointTemp -= Score_ATK[1];
                    break;
                }
                else
                {
                    break;
                }
            }


            if (QuanDich == 2)
            {
                return(0);
            }
            if (QuanTa > 5)
            {
                return(0);
            }

            Sum       += Score_ATK[QuanTa];
            Sum       -= Score_ATK[QuanDich];
            PointTemp += Sum;

            return(PointTemp);
        }