WPF绘制五子棋盘

本文介绍如何利用WPF技术实现一个五子棋的游戏界面,详细讲解了绘制棋盘、设置交互以及实现基本游戏逻辑的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

        public void DrawChessBoard()
        {
            canva.Height = 450;
            canva.Width = 450;
            canva.Margin = new Thickness(0, 0, 0, 0);
            for (int i = 0; i <= 15; i++)
            {
                DrawingLine(new Point(0, i * 30), new Point(450, i * 30));
                DrawingLine(new Point(i * 30, 0), new Point(i * 30, 450));
            }
            canva.IsEnabled = true;
            return;
        }
        private void DrawingLine(Point Sp, Point Ep)
        {
            LineGeometry linegemetry = new LineGeometry();
            linegemetry.StartPoint = Sp;
            linegemetry.EndPoint = Ep;

            Path mypath = new Path();
            mypath.Stroke = Brushes.Black;
            mypath.StrokeThickness = 1;
            mypath.Data = linegemetry;
            canva.Children.Add(mypath);
            return;
        }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值