Example #1
0
        public void Load(string sFileName)
        {
            if (!File.Exists(sFileName))
            {
                return;
            }

            CellList.Clear();
            // считать из файла
            string[] arLine = File.ReadAllLines(sFileName, Encoding.UTF8);
            // ---
            int iLineNum = 0;

            if (arLine[iLineNum++] != FileSignature)
            {
                return;
            }

            Width  = Int32.Parse(arLine[iLineNum++]);
            Height = Int32.Parse(arLine[iLineNum++]);
            for (int ii = iLineNum; ii < arLine.Length; ii++)
            {
                ChessCell chessCell = new ChessCell(arLine[ii]);
                CellList.Add(chessCell);
            }
        }
Example #2
0
        /// <summary>
        /// Метод, вызывающий реакцию на щелчок мышью
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public void Click(int x, int y)
        {
            ChessCell pCell = GetCell(x, y);

            if (pCell == null)
            {
                return;
            }

            pCell.Click();
            bool bWin = h_CheckWin();
        }
Example #3
0
        /// <summary>
        /// Заполнение поля (создание клеток) заданного размера
        /// </summary>
        /// <param name="iW"></param>
        /// <param name="iH"></param>
        private void h_Fill(int iW, int iH)
        {
            EColor color = EColor.Black;

            for (int iX = 0; iX < iW; iX++)
            {
                for (int iY = 0; iY < iH; iY++)
                {
                    if (color == EColor.Black)
                    {
                        color = EColor.White;
                    }
                    else
                    {
                        color = EColor.Black;
                    }

                    ChessCell pC = new ChessCell(iX, iY, color);
                    CellList.Add(pC);
                }
            }
        }