标题:方法之间如何互相调用
取消只看楼主
one_june
Rank: 4
等 级:业余侠客
帖 子:139
专家分:212
注 册:2010-3-14
结帖率:86.96%
已结贴  问题点数:30 回复次数:0 
方法之间如何互相调用
大家好:
我现在在做一个五子棋,在棋盘的方法中定义了一个画板,现在想在往棋盘上画棋子,但是在棋子的方法中不能使用棋盘那个画板,麻烦各位帮帮忙,谢谢...
        private int linespace = 30;
        private int n = 19;
        private new int Margin = 15;     


        /// <summary>
        /// 棋盘
        /// </summary>
        public void DrawChessBorld()
        {
            Graphics gs = this.CreateGraphics();
            Pen mypen = new Pen(Color.Green, 1);
            SolidBrush brush = new SolidBrush(Color.BurlyWood);
            gs.FillRectangle(brush, Margin, Margin + linespace, linespace * n, linespace * (n - 1));
            //横线
            for (int i = 0; i < n; i++)
            {
                Point Start = new Point(Margin, i * linespace + Margin + linespace);
                Point End = new Point(linespace * n + Margin, i * linespace + Margin + linespace);
                gs.DrawLine(mypen, Start, End);
            }
            //竖线
            for (int i = 0; i <= n; i++)
            {
                Point Start = new Point(Margin + linespace * i, Margin + linespace);
                Point End = new Point(Margin + linespace * i, linespace * n + Margin);
                gs.DrawLine(mypen, Start, End);
            }
            gs.Dispose();
        }

        /// <summary>
        /// 棋子
        /// </summary>
        public void DrawPiece()
        {
             如何在这里调用棋盘里面那个画板gs ...  
        }


     
 麻烦各位大虾...






搜索更多相关主题的帖子: 五子棋 棋子 
2010-08-18 11:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-316060-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.131157 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved