Пример #1
0
        /// <summary>
        /// 开始
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStart_Click(object sender, EventArgs e)
        {
            InitControl();

            fileName = DateTime.Now.ToString("yyyyMMddhhmmssfff") + ".txt";

            g = new Gobang(15);

            mainPanel.MouseClick -= Panel_MouseClick;
            mainPanel.MouseClick += Panel_MouseClick;

            mainPanel.Refresh();

            DrawGobang(mainPanel, pBegin);
        }
Пример #2
0
        /// <summary>
        /// 绘制当前存在的棋子
        /// </summary>
        private void DrawCurrentPiece(Control c, Gobang gob)
        {
            var cb = gob.GetCheckerboard();

            if (cb != null)
            {
                //var ps = cb.Select(p => p.Where(q => q.Color != PieceColor.None).First()).ToArray();
                //foreach (var p in ps)
                //{

                //}
                for (var i = 0; i < cb.Length; ++i)
                {
                    for (var j = 0; j < cb[i].Length; ++j)
                    {
                        if (cb[i][j].Color != PieceColor.None)
                        {
                            var b = cb[i][j].Color == PieceColor.Black ? Brushes.Black : Brushes.White;
                            DrawPiece(c, cb[i][j].X * pSize + pBegin, cb[i][j].Y * pSize + pBegin, b);
                        }
                    }
                }
            }
        }