标题:方法之间如何互相调用
只看楼主
one_june
Rank: 4
等 级:业余侠客
帖 子:139
专家分:212
注 册:2010-3-14
结帖率:86.96%
已结贴  问题点数:30 回复次数:2 
方法之间如何互相调用
大家好:
我现在在做一个五子棋,在棋盘的方法中定义了一个画板,现在想在往棋盘上画棋子,但是在棋子的方法中不能使用棋盘那个画板,麻烦各位帮帮忙,谢谢...
        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
烟雨袅袅
Rank: 6Rank: 6
来 自:星空雨际
等 级:侠之大者
威 望:1
帖 子:430
专家分:494
注 册:2007-11-26
得分:30 
        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);
            }
 
               DrawPiece(gs)
            gs.Dispose();
        }

        /// <summary>
        /// 棋子
        /// </summary>
        public void DrawPiece( Graphics gs   )
        {
             如何在这里调用棋盘里面那个画板gs ...  
        }
 
2010-08-18 12:34
lisypro
Rank: 4
等 级:业余侠客
威 望:3
帖 子:695
专家分:216
注 册:2005-9-25
得分:0 
想学编程,又没有人带的同学注意了。
介绍一个学习VB/VC/C#的群11619730
收费的群,所以有资深老师解答问题,有问必答。

长期承接管理系统
代做各种vb/ / vc小程序
QQ:82341763
手机:13623290828
群号 11619730
2010-08-18 21:18



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




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

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