• 大小: 126KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-14
  • 语言: C#
  • 标签: C#  winform  算法  socket  

资源简介

基于winfrom的联网双人对战五子棋,双人对战,用到socket通讯技术

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Net;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.groupBox1.MouseClick += new MouseEventHandler(this.groupbox_Click);   
        }

        bool isput;//是否落子
        TcpClient tcpClient;

        PictureBox[] chesspb = new PictureBox[15 15];//定义棋子数组

        //棋子
        public class qizi
        {
            public int color;
        }
        qizi[] qizis = new qizi[15 15];//棋子数组

        int blackWinInt = 0;//黑子胜场
        int whiteWinInt = 0;//白子胜场

        private void Form1_Load(object sender EventArgs e)
        {
            string hostName = Dns.GetHostName();   //获取本机名
            IPHostEntry localhost = Dns.GetHostByName(hostName);    //方法已过期,可以获取IPv4的地址
            //IPHostEntry localhost = Dns.GetHostEntry(hostName);   //获取IPv6地址
            IPAddress localaddr = localhost.AddressList[0];
            IP.Text = localaddr.ToString();
            //画棋子
            int x y;
            for (x = 0; x < 15; x++)
            {
                for (y = 0; y < 15; y++)
                {
                    chesspb[x y] = new PictureBox();
                    chesspb[x y].Location = new Point(45 + 30 * x 45 + 30 * y);//这是棋子图的左上角坐标
                    chesspb[x y].Size = new Size(10 10);///棋子图尺寸
                    chesspb[x y].BackColor = Color.Wheat;
                    chesspb[x y].SizeMode = PictureBoxSizeMode.CenterImage;
                    GraphicsPath gp = new GraphicsPath();

                    gp.AddEllipse(chesspb[x y].ClientRectangle);

                    Region region = new Region(gp);
                    chesspb[x y].Region = region;
                    chesspb[x y].Visible = false;//先隐藏棋子
                    groupBox1.Controls.Add(chesspb[x y]);
                }
            }

            for (int i = 0; i < 15; i++)
            {
                for (int j = 0; j < 15; j++)
                {
                    qizi qz = new qizi();
                    qz.color = 0;
                    qizis[i j] = qz;
                    
                }
            }
        }

        

        

        //画棋盘
        private void groupBox1_Paint(object sender PaintEventArgs e)
        {
            //画格子
            int i;
            Graphics gr = e.Graphics;
            Pen myPen = new Pen(Color.Black 1);
            Pen margin = new Pen(Color.Black 2);
            //这里是在给棋盘加一个框框哦~
            gr.DrawLine(margin 30 30 30 490);
            gr.DrawLine(margin 30 30 490 30);
            gr.DrawLine(margin 30 490 490 490);
            gr.DrawLine(margin 490 30 490 490);
            for

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        130  2018-12-28 14:04  WindowsFormsApplication1 - client\WindowsFormsApplication1\app.config

     文件        127  2018-12-22 15:19  WindowsFormsApplication1 - client\WindowsFormsApplication1\bai.png

     文件      15872  2019-02-20 13:09  WindowsFormsApplication1 - client\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe

     文件        130  2018-12-28 14:04  WindowsFormsApplication1 - client\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config

     文件      32256  2019-02-20 13:09  WindowsFormsApplication1 - client\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb

     文件      11608  2019-02-20 13:10  WindowsFormsApplication1 - client\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe

     文件        130  2018-12-28 14:04  WindowsFormsApplication1 - client\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.config

     文件        490  2010-03-17 22:39  WindowsFormsApplication1 - client\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest

     文件       9047  2019-02-20 13:09  WindowsFormsApplication1 - client\WindowsFormsApplication1\Form1.cs

     文件       6461  2018-12-28 13:03  WindowsFormsApplication1 - client\WindowsFormsApplication1\Form1.Designer.cs

     文件       6011  2018-12-28 13:03  WindowsFormsApplication1 - client\WindowsFormsApplication1\Form1.resx

     文件      18211  2018-12-22 15:17  WindowsFormsApplication1 - client\WindowsFormsApplication1\hei.png

     文件       6170  2018-12-28 13:42  WindowsFormsApplication1 - client\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6565  2019-02-20 13:10  WindowsFormsApplication1 - client\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2018-12-28 13:43  WindowsFormsApplication1 - client\WindowsFormsApplication1\obj\x86\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2018-12-28 13:43  WindowsFormsApplication1 - client\WindowsFormsApplication1\obj\x86\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2018-12-28 13:43  WindowsFormsApplication1 - client\WindowsFormsApplication1\obj\x86\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件       4608  2018-12-28 14:06  WindowsFormsApplication1 - client\WindowsFormsApplication1\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件       1749  2019-02-20 13:10  WindowsFormsApplication1 - client\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt

     文件        975  2019-02-20 13:09  WindowsFormsApplication1 - client\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache

     文件      15872  2019-02-20 13:09  WindowsFormsApplication1 - client\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.exe

     文件        180  2019-02-20 13:09  WindowsFormsApplication1 - client\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Form1.resources

     文件      32256  2019-02-20 13:09  WindowsFormsApplication1 - client\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.pdb

     文件        180  2019-02-20 13:09  WindowsFormsApplication1 - client\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Properties.Resources.resources

     文件        485  2018-12-28 13:43  WindowsFormsApplication1 - client\WindowsFormsApplication1\Program.cs

     文件       1400  2018-12-22 15:05  WindowsFormsApplication1 - client\WindowsFormsApplication1\Properties\AssemblyInfo.cs

     文件       2888  2018-12-28 14:04  WindowsFormsApplication1 - client\WindowsFormsApplication1\Properties\Resources.Designer.cs

     文件       5612  2018-12-22 15:05  WindowsFormsApplication1 - client\WindowsFormsApplication1\Properties\Resources.resx

     文件       1124  2018-12-28 14:04  WindowsFormsApplication1 - client\WindowsFormsApplication1\Properties\Settings.Designer.cs

     文件        249  2018-12-22 15:05  WindowsFormsApplication1 - client\WindowsFormsApplication1\Properties\Settings.settings

............此处省略58个文件信息

评论

共有 条评论