Commit avent modif

This commit is contained in:
Adrien VAN DAMME 2018-12-14 14:08:07 +01:00
parent ed3fc9d6d2
commit 960e870171
40 changed files with 2994 additions and 107 deletions

BIN
giphy.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

BIN
go01.rar Normal file

Binary file not shown.

View File

@ -1,6 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="go01.Settings1" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<userSettings>
<go01.Settings1>
<setting name="dbg" serializeAs="String">
<value>True</value>
</setting>
<setting name="vitesseAnimDBG" serializeAs="String">
<value>50</value>
</setting>
</go01.Settings1>
</userSettings>
</configuration>

262
go01/CreerPartieReseau_serv.Designer.cs generated Normal file
View File

@ -0,0 +1,262 @@
using System;
using System.Net;
using System.Net.Sockets;
namespace go01
{
partial class CreerPartieReseau_serv
{
public string GetLocalIPAddress()
{
var host = Dns.GetHostEntry(Dns.GetHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
return ip.ToString();
}
}
throw new Exception("No network adapters with an IPv4 address in the system!");
}
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.tbUid = new System.Windows.Forms.TextBox();
this.lblUid = new System.Windows.Forms.Label();
this.lblIp = new System.Windows.Forms.Label();
this.tbIp = new System.Windows.Forms.TextBox();
this.lblNomPartie = new System.Windows.Forms.Label();
this.tbPartName = new System.Windows.Forms.TextBox();
this.tbNomJoeur = new System.Windows.Forms.TextBox();
this.lblNomJoeur = new System.Windows.Forms.Label();
this.btnCreatePart = new System.Windows.Forms.Button();
this.tbTaille = new System.Windows.Forms.TextBox();
this.lblTaille = new System.Windows.Forms.Label();
this.tbPionaAligner = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.cbNic = new System.Windows.Forms.ComboBox();
this.lblPort = new System.Windows.Forms.Label();
this.tbPort = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// tbUid
//
this.tbUid.Enabled = false;
this.tbUid.Location = new System.Drawing.Point(45, 12);
this.tbUid.Name = "tbUid";
this.tbUid.ReadOnly = true;
this.tbUid.Size = new System.Drawing.Size(198, 20);
this.tbUid.TabIndex = 1;
this.tbUid.Text = "f89cf97049ed4e33925d712ec38890b6";
//
// lblUid
//
this.lblUid.AutoSize = true;
this.lblUid.Location = new System.Drawing.Point(13, 15);
this.lblUid.Name = "lblUid";
this.lblUid.Size = new System.Drawing.Size(26, 13);
this.lblUid.TabIndex = 10;
this.lblUid.Text = "UID";
//
// lblIp
//
this.lblIp.AutoSize = true;
this.lblIp.Location = new System.Drawing.Point(350, 15);
this.lblIp.Name = "lblIp";
this.lblIp.Size = new System.Drawing.Size(17, 13);
this.lblIp.TabIndex = 16;
this.lblIp.Text = "IP";
//
// tbIp
//
this.tbIp.Enabled = false;
this.tbIp.Location = new System.Drawing.Point(278, 38);
this.tbIp.Name = "tbIp";
this.tbIp.ReadOnly = true;
this.tbIp.Size = new System.Drawing.Size(152, 20);
this.tbIp.TabIndex = 3;
//
// lblNomPartie
//
this.lblNomPartie.AutoSize = true;
this.lblNomPartie.Location = new System.Drawing.Point(12, 100);
this.lblNomPartie.Name = "lblNomPartie";
this.lblNomPartie.Size = new System.Drawing.Size(59, 13);
this.lblNomPartie.TabIndex = 12;
this.lblNomPartie.Text = "Nom Partie";
//
// tbPartName
//
this.tbPartName.Location = new System.Drawing.Point(89, 97);
this.tbPartName.Name = "tbPartName";
this.tbPartName.Size = new System.Drawing.Size(154, 20);
this.tbPartName.TabIndex = 5;
//
// tbNomJoeur
//
this.tbNomJoeur.Location = new System.Drawing.Point(326, 97);
this.tbNomJoeur.Name = "tbNomJoeur";
this.tbNomJoeur.Size = new System.Drawing.Size(154, 20);
this.tbNomJoeur.TabIndex = 6;
//
// lblNomJoeur
//
this.lblNomJoeur.AutoSize = true;
this.lblNomJoeur.Location = new System.Drawing.Point(249, 100);
this.lblNomJoeur.Name = "lblNomJoeur";
this.lblNomJoeur.Size = new System.Drawing.Size(55, 13);
this.lblNomJoeur.TabIndex = 15;
this.lblNomJoeur.Text = "Nom joeur";
//
// btnCreatePart
//
this.btnCreatePart.Location = new System.Drawing.Point(15, 160);
this.btnCreatePart.Name = "btnCreatePart";
this.btnCreatePart.Size = new System.Drawing.Size(465, 23);
this.btnCreatePart.TabIndex = 9;
this.btnCreatePart.Text = "Creer partie";
this.btnCreatePart.UseVisualStyleBackColor = true;
this.btnCreatePart.Click += new System.EventHandler(this.btnCreatePart_Click);
//
// tbTaille
//
this.tbTaille.Location = new System.Drawing.Point(90, 123);
this.tbTaille.Name = "tbTaille";
this.tbTaille.Size = new System.Drawing.Size(154, 20);
this.tbTaille.TabIndex = 7;
//
// lblTaille
//
this.lblTaille.AutoSize = true;
this.lblTaille.Location = new System.Drawing.Point(13, 126);
this.lblTaille.Name = "lblTaille";
this.lblTaille.Size = new System.Drawing.Size(32, 13);
this.lblTaille.TabIndex = 13;
this.lblTaille.Text = "Taille";
//
// tbPionaAligner
//
this.tbPionaAligner.Location = new System.Drawing.Point(326, 123);
this.tbPionaAligner.Name = "tbPionaAligner";
this.tbPionaAligner.Size = new System.Drawing.Size(154, 20);
this.tbPionaAligner.TabIndex = 8;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(250, 126);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(71, 13);
this.label2.TabIndex = 14;
this.label2.Text = "Pion à aligner";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 42);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(25, 13);
this.label1.TabIndex = 11;
this.label1.Text = "NIC";
//
// cbNic
//
this.cbNic.FormattingEnabled = true;
this.cbNic.Location = new System.Drawing.Point(45, 39);
this.cbNic.Name = "cbNic";
this.cbNic.Size = new System.Drawing.Size(198, 21);
this.cbNic.TabIndex = 2;
this.cbNic.SelectedIndexChanged += new System.EventHandler(this.cbNic_SelectedIndexChanged);
//
// lblPort
//
this.lblPort.AutoSize = true;
this.lblPort.Location = new System.Drawing.Point(443, 15);
this.lblPort.Name = "lblPort";
this.lblPort.Size = new System.Drawing.Size(26, 13);
this.lblPort.TabIndex = 0;
this.lblPort.Text = "Port";
//
// tbPort
//
this.tbPort.Location = new System.Drawing.Point(436, 38);
this.tbPort.Name = "tbPort";
this.tbPort.Size = new System.Drawing.Size(42, 20);
this.tbPort.TabIndex = 4;
this.tbPort.Text = "9999";
//
// CreerPartieReseau_serv
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(490, 193);
this.Controls.Add(this.tbPort);
this.Controls.Add(this.lblPort);
this.Controls.Add(this.cbNic);
this.Controls.Add(this.label1);
this.Controls.Add(this.tbPionaAligner);
this.Controls.Add(this.label2);
this.Controls.Add(this.tbTaille);
this.Controls.Add(this.lblTaille);
this.Controls.Add(this.btnCreatePart);
this.Controls.Add(this.tbNomJoeur);
this.Controls.Add(this.lblNomJoeur);
this.Controls.Add(this.tbPartName);
this.Controls.Add(this.lblNomPartie);
this.Controls.Add(this.lblIp);
this.Controls.Add(this.tbIp);
this.Controls.Add(this.lblUid);
this.Controls.Add(this.tbUid);
this.Name = "CreerPartieReseau_serv";
this.Text = "CreerPartieReseau_serv";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox tbUid;
private System.Windows.Forms.Label lblUid;
private System.Windows.Forms.Label lblIp;
private System.Windows.Forms.TextBox tbIp;
private System.Windows.Forms.Label lblNomPartie;
private System.Windows.Forms.TextBox tbPartName;
private System.Windows.Forms.TextBox tbNomJoeur;
private System.Windows.Forms.Label lblNomJoeur;
private System.Windows.Forms.Button btnCreatePart;
private System.Windows.Forms.TextBox tbTaille;
private System.Windows.Forms.Label lblTaille;
private System.Windows.Forms.TextBox tbPionaAligner;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox cbNic;
private System.Windows.Forms.Label lblPort;
private System.Windows.Forms.TextBox tbPort;
}
}

View File

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace go01
{
public partial class CreerPartieReseau_serv : Form
{
socketPlateau serveur;
public CreerPartieReseau_serv()
{
InitializeComponent();
this.tbUid.Text = Guid.NewGuid().ToString();
this.tbUid.Select(0, 0);
socketPlateau.net_adapters(cbNic);
//serveur = new socketPlateau()
}
private void btnCreatePart_Click(object sender, EventArgs e)
{
btnCreatePart.Enabled = false;
tbPartName.Enabled = false;
tbNomJoeur.Enabled = false;
var startTimeSpan = TimeSpan.Zero;
var periodTimeSpan = TimeSpan.FromSeconds(5);
socketPlateau.ConfigGo_S config = new socketPlateau.ConfigGo_S(tbUid.Text, tbPartName.Text, "", tbNomJoeur.Text, int.Parse(tbTaille.Text), int.Parse(tbPionaAligner.Text), IPAddress.Parse(tbIp.Text), int.Parse(tbPort.Text));
serveur = new socketPlateau(socketPlateau.TypeSocket_E.Serveur, config, null);
serveur.AttenteJoueur();
serveur.onJoinServ += new socketPlateau.OnJoinServ(JoueurRejoinServeur);
}
private void JoueurRejoinServeur(object o, socketPlateauServArgs e)
{
Console.WriteLine($"{e.ConfigGo.NomJoeurClient} vs {e.ConfigGo.NomJoeurServeur}");
}
private void broadcast()
{
var Client = new UdpClient();
var RequestData = Encoding.ASCII.GetBytes($"{tbUid.Text};{tbPartName.Text};{tbNomJoeur.Text};{tbTaille.Text};{tbPionaAligner.Text}");
Client.EnableBroadcast = true;
Client.Send(RequestData, RequestData.Length, new IPEndPoint(IPAddress.Broadcast, 8888));
Client.Close();
}
private void cbNic_SelectedIndexChanged(object sender, EventArgs e)
{
var local = NetworkInterface.GetAllNetworkInterfaces().Where(i => i.Name == cbNic.SelectedItem.ToString()).FirstOrDefault();
foreach (UnicastIPAddressInformation ip in local.GetIPProperties().UnicastAddresses)
{
if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
tbIp.Text = ip.Address.ToString();
}
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

BIN
go01/FAccueil.pdf Normal file

Binary file not shown.

39
go01/Form1.Designer.cs generated
View File

@ -1,39 +0,0 @@
namespace go01
{
partial class Form1
{
/// <summary>
/// Variable nécessaire au concepteur.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Nettoyage des ressources utilisées.
/// </summary>
/// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Code généré par le Concepteur Windows Form
/// <summary>
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette méthode avec l'éditeur de code.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace go01
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

435
go01/Goban.cs Normal file
View File

@ -0,0 +1,435 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace go01
{
public class Goban
{
public PictureBox Conteneur;
int nombreDePionAAligne;
int ptBlanc = 0, ptNoir = 0;
public Plateau Fenetre;
bool win = false;
public int dim;
Label LabelPlayerTurn;
public string PlayerTurn { get { return this.LabelPlayerTurn.Text; } }
string playerWName, playerBName;
List<PictureBox> pboxList = new List<PictureBox>();
Joueur_E tour;
Joueur_E Tour
{
get
{
return tour;
}
set
{
tour = value;
try
{
this.LabelPlayerTurn.Text = (tour == Joueur_E.Blanc) ? playerWName : playerBName;
this.LabelPlayerTurn.ForeColor = (tour == Joueur_E.Blanc) ? Color.Gray : Color.Black;
this.LabelPlayerTurn.Location = new Point(Conteneur.Location.X + Conteneur.Width + ((Fenetre.ClientSize.Width - Conteneur.Location.X - Conteneur.Width - LabelPlayerTurn.Width) / 2), Conteneur.Location.Y);
}
catch
{
Console.WriteLine("ERROR GOBAN LabelPlayerTurn ");
}
}
}
Occupant_E[,] tableauOccupation;
[Flags]
enum Deplacement_E
{
SG = 0b00000001,
S = 0b00000010,
SD = 0b00000100,
G = 0b00001000,
D = 0b00010000,
IG = 0b00100000,
I = 0b01000000,
ID = 0b10000000
}
[Serializable]
public struct sauvegarde_S
{
public string nomBlanc, nomNoir;
public int ptBlanc, ptNoir;
public int dimGoban, nbAlignementToWin;
public bool win;
public Goban.Occupant_E[,] tableauOccupation;
public Goban.Joueur_E tour;
public sauvegarde_S(string nomBlanc, string nomNoir, int pointBlanc, int pointNoir, int nbAlignementToWin, int dimGoban, Goban.Occupant_E[,] tableauOccupation, Goban.Joueur_E tour, bool win)
{
this.nomBlanc = nomBlanc; this.nomNoir=nomNoir;
this.ptBlanc = pointBlanc; this.ptNoir = pointNoir;
this.dimGoban = dimGoban; this.nbAlignementToWin = nbAlignementToWin;
this.win = win;
this.tableauOccupation = tableauOccupation;
this.tour = tour;
}
}
struct carrefour_S
{
public Point point;
public Deplacement_E SensDeDeplacment;
public carrefour_S(Point p, Deplacement_E sens)
{
point = p;
SensDeDeplacment = sens;
}
}
public enum Occupant_E { Vide, Blanc, Noir, LAST}
public enum Joueur_E { Blanc, Noir, LAST}
public Goban(Plateau fenetre, PictureBox conteneur, sauvegarde_S s)
{
tableauOccupation = s.tableauOccupation;
playerBName = s.nomNoir;
playerWName = s.nomBlanc;
nombreDePionAAligne = s.nbAlignementToWin;
dim = s.dimGoban;
this.Conteneur = conteneur;
this.Fenetre = fenetre;
fenetre.lblBlanc = playerWName + ":0";
fenetre.lblNoir = playerBName + ":0";
GenerationPlateau(false);
//redrawAllpb();
}
public Goban(Plateau fenetre, PictureBox conteneur, int dim, int nbPionAlignn, string playerW, string playerB)
{
int x = 0;
nombreDePionAAligne = nbPionAlignn;
this.Conteneur = conteneur;
this.dim = dim;
this.Fenetre = fenetre;
playerWName = playerW;
playerBName = playerB;
fenetre.lblBlanc = playerB + ":0";
fenetre.lblNoir = playerW + ":0";
Tour = Joueur_E.Noir;
//gen des tab
tableauOccupation = new Occupant_E[dim, dim];
GenerationPlateau();
}
public void PaintPb(object sender, PaintEventArgs e)
{
PictureBox pb = (PictureBox)sender;
String[] xy = ((PictureBox)sender).Name.Split(';');
Console.WriteLine($"Click sur {xy[0]};{xy[1]} par {Tour}");
int x = int.Parse(xy[0]), y = int.Parse(xy[1]);
if (tableauOccupation[x, y] != Occupant_E.Vide && !win)
{
//tableauOccupation[x, y] = (Tour == Joueur_E.Blanc) ? Occupant_E.Blanc : Occupant_E.Noir;
Graphics gr = e.Graphics;
SolidBrush b = (tableauOccupation[x, y] == Occupant_E.Blanc) ? new SolidBrush(Color.White) : new SolidBrush(Color.Black); ;
if (b != null)
gr.FillEllipse(b, 1, 0, pb.ClientSize.Width - 2, pb.ClientSize.Height - 1);
else
gr.DrawImage(pb.Image, 0, 0, pb.Width, pb.Height);
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
PictureBox pb = (PictureBox)sender;
String[] xy = ((PictureBox)sender).Name.Split(';');
Console.WriteLine($"Click sur {xy[0]};{xy[1]} par {Tour}");
int x = int.Parse(xy[0]), y = int.Parse(xy[1]);
if (tableauOccupation[x, y] == Occupant_E.Vide && !win)
{
tableauOccupation[x, y] = (Tour == Joueur_E.Blanc) ? Occupant_E.Blanc : Occupant_E.Noir;
using (Graphics gr = Graphics.FromHwnd((pb.Handle)))
{
SolidBrush b = (Tour == Joueur_E.Blanc)?new SolidBrush(Color.White):new SolidBrush(Color.Black);;
if (b != null)
gr.FillEllipse(b, 1, 0, pb.ClientSize.Width - 2, pb.ClientSize.Height - 1);
else
gr.DrawImage(pb.Image, 0, 0, pb.Width, pb.Height);
}
bool fin = win = RechercheTeritoir(x, y);
if (fin)
{
x=((Tour == Joueur_E.Blanc)) ? ptNoir++:ptBlanc++;
Win(true);
MessageBox.Show("YOUR WIN" + ((Tour == Joueur_E.Blanc) ? playerWName : playerBName));
}
Console.WriteLine(fin);
if(!win)
Tour = (Tour + 1 == Joueur_E.LAST) ? Joueur_E.Blanc : Tour + 1;
}
}
private int[] GetXY(int i)
{
return new int[2] { i % dim, i / dim };
}
private int[] GetXYStr(string s)
{
String[] xy = s.Split(';');
return new int[2] { int.Parse(xy[0]), int.Parse(xy[1]) };
}
private int GetX(int i)
{
return i % dim;
}
private int GetY(int i)
{
return i / dim;
}
bool RechercheTeritoir(int x, int y)
{
Point origine = new Point(x, y);
int pionAligneDsRecherche = 1;
int[,] tmpParcour = new int[dim, dim];
tmpParcour[origine.X, origine.Y] = 1;
List<carrefour_S>pointsSuivant = RecherchePointsSuivant(origine,(Deplacement_E)0xff);//Recherche les point autour du pion
if (pointsSuivant.Count == 0)
return false;
foreach (carrefour_S point in pointsSuivant)
{
pionAligneDsRecherche = 2;
tmpParcour[point.point.X, point.point.Y] = 1;
List<carrefour_S> parcour = RecherchePointsSuivant(point.point, point.SensDeDeplacment);
while(parcour.Count > 0)
{
pionAligneDsRecherche++;
tmpParcour[parcour[0].point.X, parcour[0].point.Y] = 1;
parcour = RecherchePointsSuivant(parcour[0].point, parcour[0].SensDeDeplacment);
printTab(tmpParcour);
}
Console.WriteLine(pionAligneDsRecherche);
if (pionAligneDsRecherche >= nombreDePionAAligne*(Math.Ceiling((double)pionAligneDsRecherche/(double)nombreDePionAAligne)))
return true;
}
return false;
}
bool RechercheTeritoir(Point p)
{
return RechercheTeritoir(p.X, p.Y);
}
List<carrefour_S> RecherchePointsSuivant(Point p, Deplacement_E deplacement)
{
List<carrefour_S> PointsTrouver = new List<carrefour_S>();
Occupant_E occupant = (Tour == Joueur_E.Blanc)?Occupant_E.Blanc:Occupant_E.Noir;
if (p.Y-1>=0 && tableauOccupation[p.X,p.Y-1] == occupant && (deplacement & Deplacement_E.S) == Deplacement_E.S)
{
PointsTrouver.Add(new carrefour_S(new Point(p.X,p.Y-1),Deplacement_E.S));
}
if (p.Y - 1 >= 0 && p.X+1 < dim && tableauOccupation[p.X+1,p.Y-1] == occupant && (deplacement & Deplacement_E.SD) == Deplacement_E.SD)
{
PointsTrouver.Add(new carrefour_S(new Point(p.X+1,p.Y-1),Deplacement_E.SD));
}
if (p.X + 1 < dim && tableauOccupation[p.X+1,p.Y] == occupant && (deplacement & Deplacement_E.D) == Deplacement_E.D)
{
PointsTrouver.Add(new carrefour_S(new Point(p.X+1,p.Y),Deplacement_E.D));
}
if (p.X + 1 < dim && p.Y+1<dim && tableauOccupation[p.X+1,p.Y+1] == occupant && (deplacement & Deplacement_E.ID) == Deplacement_E.ID)
{
PointsTrouver.Add(new carrefour_S(new Point(p.X+1,p.Y+1),Deplacement_E.ID));
}
if (p.Y + 1 < dim && tableauOccupation[p.X,p.Y+1] == occupant && (deplacement & Deplacement_E.I) == Deplacement_E.I)
{
PointsTrouver.Add(new carrefour_S(new Point(p.X,p.Y+1),Deplacement_E.I));
}
if (p.X-1>=0 && p.Y + 1 < dim && tableauOccupation[p.X-1,p.Y+1] == occupant && (deplacement & Deplacement_E.IG) == Deplacement_E.IG)
{
PointsTrouver.Add(new carrefour_S(new Point(p.X-1,p.Y+1),Deplacement_E.IG));
}
if (p.X - 1 >= 0 && tableauOccupation[p.X-1,p.Y] == occupant && (deplacement & Deplacement_E.G) == Deplacement_E.G)
{
PointsTrouver.Add(new carrefour_S(new Point(p.X-1,p.Y),Deplacement_E.G));
}
if (p.Y - 1 >= 0 && p.X - 1 >= 0 && tableauOccupation[p.X-1,p.Y-1] == occupant && (deplacement & Deplacement_E.SG) == Deplacement_E.SG)
{
PointsTrouver.Add(new carrefour_S(new Point(p.X-1,p.Y-1),Deplacement_E.SG));
}
return PointsTrouver;
}
Boolean ptEgal(Point ptBlanc, Point ptNoir)
{
return ptBlanc.X == ptNoir.X && ptBlanc.Y == ptNoir.Y;
}
void printTab(int[,] Tab)
{
for(int y = 0;y<dim;y++)
{
for (int x = 0; x < dim; x++)
{
Console.ForegroundColor = (Tab[x, y] !=0 ) ? ConsoleColor.Green : ConsoleColor.White;
Console.Write(Tab[x, y]);
}
Console.WriteLine();
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
}
int xyToi(int x, int y)
{
return x + dim* y;
}
public void redrawAllpb()
{
for(int i=0;i<dim*dim;i++)
{
if (tableauOccupation[GetX(i), GetY(i)] != Occupant_E.Vide)
{
//Tour = (Tour+1 == Joueur_E.LAST) ? Joueur_E.Blanc : Tour+1;
using (Graphics gr = Graphics.FromHwnd((pboxList [i].Handle)))
{
SolidBrush b = null;
switch (tableauOccupation[GetX(i), GetY(i)])
{
case Occupant_E.Blanc:
b = new SolidBrush(Color.White);
break;
case Occupant_E.Noir:
b = new SolidBrush(Color.Black);
break;
case Occupant_E.Vide:
b = null;
break;
}
if (b != null)
gr.FillEllipse(b, 1, 0, pboxList[i].ClientSize.Width - 2, pboxList[i].ClientSize.Height - 1);
else
gr.DrawImage(pboxList[i].Image, 0, 0, pboxList[i].Width, pboxList[i].Height);
}
}
}
}
public void resetGoban()
{
for (int x = 0; x < dim; x++)
for (int y = 0; y < dim; y++)
tableauOccupation[x, y] = Occupant_E.Vide;
redrawAllpb();
win = false;
Fenetre.pictureBox2WinVisible(false);
}
public void ContinuerAjouer()
{
win = false;
Fenetre.pictureBox2WinVisible(false);
Fenetre.btnContinuerEnable = false;
Tour = (Tour + 1 == Joueur_E.LAST) ? Joueur_E.Blanc : Tour + 1;
}
public sauvegarde_S sauvegarder()
{
sauvegarde_S s = new sauvegarde_S(playerWName, playerBName, ptBlanc,ptNoir, nombreDePionAAligne, dim, tableauOccupation, tour, win);
return s;
}
public static sauvegarde_S sauvegarder(Goban g)
{
sauvegarde_S s = new sauvegarde_S(g.playerWName, g.playerBName, g.ptBlanc, g.ptNoir, g.nombreDePionAAligne, g.dim, g.tableauOccupation, g.tour, g.win);
return s;
}
public void GenerationPlateau(bool initTableauOccupation)
{
//label qui indique à qui le tour
LabelPlayerTurn = new System.Windows.Forms.Label();
this.LabelPlayerTurn.AutoSize = true;
this.LabelPlayerTurn.Font = new System.Drawing.Font("Matura MT Script Capitals", 40F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.LabelPlayerTurn.ForeColor = System.Drawing.SystemColors.ControlText;
this.LabelPlayerTurn.Location = new System.Drawing.Point(529, 13);
this.LabelPlayerTurn.Name = "LabelPlayerTurn";
this.LabelPlayerTurn.TabIndex = 1;
this.LabelPlayerTurn.Text = "playerW";
Fenetre.Controls.Add(this.LabelPlayerTurn);
for (int i = 0; i < dim * dim; i++) //Genération du goban
{
pboxList.Add(new PictureBox());
//pboxList[i].Paint += new PaintEventHandler(this.PaintPb);
pboxList[i].Location = new Point((i % dim) * (Conteneur.Width / dim), (i / dim) * (Conteneur.Height / dim));
pboxList[i].Width = Conteneur.Width / dim;
pboxList[i].Height = Conteneur.Height / dim;
pboxList[i].SizeMode = PictureBoxSizeMode.StretchImage;
if (GetX(i) == 0)
if (GetY(i) == 0)
pboxList[i].Image = global::go01.Properties.Resources.tl;
else if (GetY(i) == dim - 1)
pboxList[i].Image = global::go01.Properties.Resources.bl;
else
pboxList[i].Image = global::go01.Properties.Resources.l;
else if (GetY(i) == 0)
if (GetX(i) == dim - 1)
pboxList[i].Image = global::go01.Properties.Resources.tr;
else
pboxList[i].Image = global::go01.Properties.Resources.t;
else if (GetY(i) == dim - 1)
if (GetX(i) == dim - 1)
pboxList[i].Image = global::go01.Properties.Resources.br;
else
pboxList[i].Image = global::go01.Properties.Resources.b;
else if (GetX(i) == dim - 1)
pboxList[i].Image = global::go01.Properties.Resources.r;
else
pboxList[i].Image = global::go01.Properties.Resources.m;
if (initTableauOccupation)
{
tableauOccupation[i % dim, i / dim] = Occupant_E.Vide;
}
pboxList[i].Name = (i % dim).ToString() + ";" + (i / dim).ToString();
pboxList[i].Click += new System.EventHandler(this.pictureBox1_Click);
pboxList[i].Paint += new PaintEventHandler(this.PaintPb);
Conteneur.Controls.Add(pboxList[i]);
pboxList[i].Invalidate();
}
Conteneur.Invalidate();
//redrawAllpb();
}
public void GenerationPlateau()
{
GenerationPlateau(true);
}
public void Win(bool status)
{
Fenetre.pictureBox2WinVisible(status);
Fenetre.lblBlanc = playerBName + ":"+(ptBlanc).ToString();
Fenetre.lblNoir = playerWName + ":"+ptNoir.ToString();
Fenetre.btnContinuerEnable = status;
}
}
}

166
go01/Plateau.Designer.cs generated Normal file
View File

@ -0,0 +1,166 @@
namespace go01
{
partial class Plateau
{
/// <summary>
/// Variable nécessaire au concepteur.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Nettoyage des ressources utilisées.
/// </summary>
/// <param name="disposing">true si les ressources managées doivent être supprimées ; sinon, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Code généré par le Concepteur Windows Form
/// <summary>
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette méthode avec l'éditeur de code.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
this.lblPtBlanc = new System.Windows.Forms.Label();
this.LblPtNoir = new System.Windows.Forms.Label();
this.btnContinuer = new System.Windows.Forms.Button();
this.ofd = new System.Windows.Forms.OpenFileDialog();
this.sfd = new System.Windows.Forms.SaveFileDialog();
this.btnEnreg = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// contextMenuStrip1
//
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
//
// pictureBox2
//
this.pictureBox2.Image = global::go01.Properties.Resources.giphy;
this.pictureBox2.Location = new System.Drawing.Point(495, 152);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(300, 168);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox2.TabIndex = 1;
this.pictureBox2.TabStop = false;
this.pictureBox2.Visible = false;
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(13, 13);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(448, 448);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
//
// button1
//
this.button1.Location = new System.Drawing.Point(702, 390);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 2;
this.button1.Text = "Reset";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// lblPtBlanc
//
this.lblPtBlanc.AutoSize = true;
this.lblPtBlanc.Location = new System.Drawing.Point(492, 136);
this.lblPtBlanc.Name = "lblPtBlanc";
this.lblPtBlanc.Size = new System.Drawing.Size(48, 13);
this.lblPtBlanc.TabIndex = 3;
this.lblPtBlanc.Text = "Joeur1:0";
//
// LblPtNoir
//
this.LblPtNoir.AutoSize = true;
this.LblPtNoir.Location = new System.Drawing.Point(669, 136);
this.LblPtNoir.Name = "LblPtNoir";
this.LblPtNoir.Size = new System.Drawing.Size(48, 13);
this.LblPtNoir.TabIndex = 4;
this.LblPtNoir.Text = "Joeur2:0";
//
// btnContinuer
//
this.btnContinuer.Enabled = false;
this.btnContinuer.Location = new System.Drawing.Point(510, 390);
this.btnContinuer.Name = "btnContinuer";
this.btnContinuer.Size = new System.Drawing.Size(105, 23);
this.btnContinuer.TabIndex = 5;
this.btnContinuer.Text = "Continuer à jouer";
this.btnContinuer.UseVisualStyleBackColor = true;
this.btnContinuer.Click += new System.EventHandler(this.btnContinuer_Click);
//
// ofd
//
this.ofd.FileName = "openFileDialog1";
//
// btnEnreg
//
this.btnEnreg.Location = new System.Drawing.Point(510, 352);
this.btnEnreg.Name = "btnEnreg";
this.btnEnreg.Size = new System.Drawing.Size(75, 23);
this.btnEnreg.TabIndex = 6;
this.btnEnreg.Text = "Enregistrer";
this.btnEnreg.UseVisualStyleBackColor = true;
this.btnEnreg.Click += new System.EventHandler(this.btnEnreg_Click);
//
// Plateau
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(837, 474);
this.Controls.Add(this.btnEnreg);
this.Controls.Add(this.btnContinuer);
this.Controls.Add(this.LblPtNoir);
this.Controls.Add(this.lblPtBlanc);
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.pictureBox1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Plateau";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "Morpion";
this.Load += new System.EventHandler(this.Plateau_Load);
this.Shown += new System.EventHandler(this.Plateau_Shown);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Plateau_Paint);
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label lblPtBlanc;
private System.Windows.Forms.Label LblPtNoir;
private System.Windows.Forms.Button btnContinuer;
private System.Windows.Forms.OpenFileDialog ofd;
private System.Windows.Forms.SaveFileDialog sfd;
private System.Windows.Forms.Button btnEnreg;
}
}

179
go01/Plateau.cs Normal file
View File

@ -0,0 +1,179 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace go01
{
public partial class Plateau : Form
{
TextWriter _writer = null;
StreamWriter _writerConsole = null;
enum CouleurVoulue { Red, Green, Blue, Black, LAST }
CouleurVoulue[,] tableauCouleur = new CouleurVoulue[19,19];
List<PictureBox> pboxList = new List<PictureBox>();
Goban g;
public Plateau(Goban.sauvegarde_S s)
{
InitializeComponent();
this.Text = $"Morpion {s.dimGoban}x{s.dimGoban}";
g = new Goban(this, pictureBox1, s);
}
public Plateau(int dim, int nbPionAlign, string playerW, string playerB)
{
InitializeComponent();
this.Text = $"Morpion {dim}x{dim}";
g = new Goban(this, pictureBox1,dim,nbPionAlign, playerW, playerB);
}
private void pictureBox1_Click(object sender, EventArgs e)
{
String[] xy = ((PictureBox)sender).Name.Split(';');
if (++tableauCouleur[int.Parse(xy[0]), int.Parse(xy[1])] == CouleurVoulue.LAST)
tableauCouleur[int.Parse(xy[0]), int.Parse(xy[1])] = CouleurVoulue.Red;
((PictureBox)sender).BackColor = Color.FromName((tableauCouleur[int.Parse(xy[0]),int.Parse(xy[1])]).ToString());
Console.WriteLine(((PictureBox)sender).Name);
}
private void chkBxDbg_CheckedChanged(object sender, EventArgs e)
{
// Settings1.Default.dbg = chkBxDbg.Checked;
Settings1.Default.Save();
}
private void txtBoxTmpAnim_TextChanged(object sender, EventArgs e)
{
int tmp;
//Settings1.Default.vitesseAnimDBG = int.TryParse(txtBoxTmpAnim.Text, out tmp) ?tmp: Settings1.Default.vitesseAnimDBG;
Settings1.Default.Save();
}
private void Plateau_Load(object sender, EventArgs e)
{
//base.OnLoad(e);
this.DoubleBuffered = true;
}
private void txtConsole_TextChanged(object sender, EventArgs e)
{
// set the current caret position to the end
//txtConsole.SelectionStart = txtConsole.Text.Length;
// scroll it automatically
//txtConsole.ScrollToCaret();
}
private void txtAffConsole_CheckedChanged(object sender, EventArgs e)
{
/*f(txtAffConsole.Checked)
{
_writer = new TextBoxStreamWriter(txtConsole);
Console.SetOut(_writer);
Console.WriteLine("Now redirecting output to the text box");
}
else
{
_writerConsole = new StreamWriter(Console.OpenStandardOutput());
_writerConsole.AutoFlush = true;
Console.SetOut(_writerConsole);
}*/
}
private void button1_Click(object sender, EventArgs e)
{
g.resetGoban();
}
public void pictureBox2WinVisible(bool t)
{
pictureBox2.Visible = t;
}
private void button1_Click_1(object sender, EventArgs e)
{
g.resetGoban();
}
public string lblNoir
{
set { this.lblPtBlanc.Text = value; }
}
public string lblBlanc
{
set { this.LblPtNoir.Text = value; }
}
public bool btnContinuerEnable
{
set
{
this.btnContinuer.Enabled = value;
}
}
private void btnContinuer_Click(object sender, EventArgs e)
{
g.ContinuerAjouer();
}
private void btnEnreg_Click(object sender, EventArgs e)
{
Stream myStream = null;
SaveFileDialog openFileDialog1 = new SaveFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "bin files (*.bin)|*.bin|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
WriteToBinaryFile<Goban.sauvegarde_S>(openFileDialog1.FileName, g.sauvegarder());
}
}
public static void WriteToBinaryFile<T>(string filePath, T objectToWrite, bool append = false)
{
using (Stream stream = File.Open(filePath, append ? FileMode.Append : FileMode.Create))
{
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryFormatter.Serialize(stream, objectToWrite);
}
}
/// <summary>
/// Reads an object instance from a binary file.
/// </summary>
/// <typeparam name="T">The type of object to read from the binary file.</typeparam>
/// <param name="filePath">The file path to read the object instance from.</param>
/// <returns>Returns a new instance of the object read from the binary file.</returns>
public static T ReadFromBinaryFile<T>(string filePath)
{
using (Stream stream = File.Open(filePath, FileMode.Open))
{
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
return (T)binaryFormatter.Deserialize(stream);
}
}
private void Plateau_Shown(object sender, EventArgs e)
{
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
}
private void Plateau_Paint(object sender, PaintEventArgs e)
{
}
}
}

132
go01/Plateau.resx Normal file
View File

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="ofd.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>172, 17</value>
</metadata>
<metadata name="sfd.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>242, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>60</value>
</metadata>
</root>

View File

@ -1,4 +1,6 @@
using System;
#define DEBUG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@ -16,7 +18,7 @@ namespace go01
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Application.Run(new mainWin());
}
}
}

View File

@ -1,49 +1,44 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Ce code a été généré par un outil.
// Version du runtime :4.0.30319.42000
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
// le code est régénéré.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace go01.Properties
{
namespace go01.Properties {
using System;
/// <summary>
/// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
// à l'aide d'un outil, tel que ResGen ou Visual Studio.
// Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
// avec l'option /str ou régénérez votre projet VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
internal Resources() {
}
/// <summary>
/// Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("go01.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
@ -52,20 +47,127 @@ namespace go01.Properties
}
/// <summary>
/// Remplace la propriété CurrentUICulture du thread actuel pour toutes
/// les recherches de ressources à l'aide de cette classe de ressource fortement typée.
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set
{
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap b {
get {
object obj = ResourceManager.GetObject("b", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap bl {
get {
object obj = ResourceManager.GetObject("bl", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap br {
get {
object obj = ResourceManager.GetObject("br", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap giphy {
get {
object obj = ResourceManager.GetObject("giphy", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap hoshi {
get {
object obj = ResourceManager.GetObject("hoshi", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap l {
get {
object obj = ResourceManager.GetObject("l", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap m {
get {
object obj = ResourceManager.GetObject("m", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap r {
get {
object obj = ResourceManager.GetObject("r", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap t {
get {
object obj = ResourceManager.GetObject("t", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap tl {
get {
object obj = ResourceManager.GetObject("tl", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap tr {
get {
object obj = ResourceManager.GetObject("tr", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
@ -109,9 +112,43 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="m" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\m.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="tl" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\tl.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="tr" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\tr.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="bl" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\bl.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="b" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\b.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="t" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\t.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="l" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\l.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="hoshi" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\hoshi.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="r" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\r.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="br" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\br.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="giphy" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\giphy.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,209 @@
namespace go01
{
partial class RejoindrePartieReseau_client
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dgvPart = new System.Windows.Forms.DataGridView();
this.tbIpServ = new System.Windows.Forms.TextBox();
this.lblIpServ = new System.Windows.Forms.Label();
this.tbPlayername = new System.Windows.Forms.TextBox();
this.lblPlayerName = new System.Windows.Forms.Label();
this.tbPort = new System.Windows.Forms.TextBox();
this.lblPort = new System.Windows.Forms.Label();
this.btnJoin = new System.Windows.Forms.Button();
this.uid = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.partName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.playerName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ip = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.port = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.timeStamp = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dgvPart)).BeginInit();
this.SuspendLayout();
//
// dgvPart
//
this.dgvPart.AllowUserToAddRows = false;
this.dgvPart.AllowUserToDeleteRows = false;
this.dgvPart.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvPart.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.uid,
this.partName,
this.playerName,
this.ip,
this.port,
this.timeStamp});
this.dgvPart.Location = new System.Drawing.Point(12, 12);
this.dgvPart.Name = "dgvPart";
this.dgvPart.ReadOnly = true;
this.dgvPart.RowHeadersVisible = false;
this.dgvPart.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvPart.Size = new System.Drawing.Size(505, 426);
this.dgvPart.TabIndex = 1;
this.dgvPart.Click += new System.EventHandler(this.dgvPart_Click);
//
// tbIpServ
//
this.tbIpServ.Location = new System.Drawing.Point(611, 12);
this.tbIpServ.Name = "tbIpServ";
this.tbIpServ.Size = new System.Drawing.Size(154, 20);
this.tbIpServ.TabIndex = 16;
//
// lblIpServ
//
this.lblIpServ.AutoSize = true;
this.lblIpServ.Location = new System.Drawing.Point(534, 15);
this.lblIpServ.Name = "lblIpServ";
this.lblIpServ.Size = new System.Drawing.Size(60, 13);
this.lblIpServ.TabIndex = 17;
this.lblIpServ.Text = "Ip serveur :";
//
// tbPlayername
//
this.tbPlayername.Location = new System.Drawing.Point(611, 64);
this.tbPlayername.Name = "tbPlayername";
this.tbPlayername.Size = new System.Drawing.Size(154, 20);
this.tbPlayername.TabIndex = 18;
//
// lblPlayerName
//
this.lblPlayerName.AutoSize = true;
this.lblPlayerName.Location = new System.Drawing.Point(534, 67);
this.lblPlayerName.Name = "lblPlayerName";
this.lblPlayerName.Size = new System.Drawing.Size(55, 13);
this.lblPlayerName.TabIndex = 19;
this.lblPlayerName.Text = "Nom joeur";
//
// tbPort
//
this.tbPort.Location = new System.Drawing.Point(611, 38);
this.tbPort.Name = "tbPort";
this.tbPort.Size = new System.Drawing.Size(154, 20);
this.tbPort.TabIndex = 20;
//
// lblPort
//
this.lblPort.AutoSize = true;
this.lblPort.Location = new System.Drawing.Point(534, 41);
this.lblPort.Name = "lblPort";
this.lblPort.Size = new System.Drawing.Size(26, 13);
this.lblPort.TabIndex = 21;
this.lblPort.Text = "Port";
//
// btnJoin
//
this.btnJoin.Location = new System.Drawing.Point(537, 93);
this.btnJoin.Name = "btnJoin";
this.btnJoin.Size = new System.Drawing.Size(228, 23);
this.btnJoin.TabIndex = 22;
this.btnJoin.Text = "Join";
this.btnJoin.UseVisualStyleBackColor = true;
this.btnJoin.Click += new System.EventHandler(this.btnJoin_Click);
//
// uid
//
this.uid.DataPropertyName = "uid";
this.uid.HeaderText = "uid";
this.uid.Name = "uid";
this.uid.ReadOnly = true;
//
// partName
//
this.partName.DataPropertyName = "partName";
this.partName.HeaderText = "Nom partie";
this.partName.Name = "partName";
this.partName.ReadOnly = true;
//
// playerName
//
this.playerName.DataPropertyName = "playerName";
this.playerName.HeaderText = "Nom joeur adverse";
this.playerName.Name = "playerName";
this.playerName.ReadOnly = true;
//
// ip
//
this.ip.DataPropertyName = "ip";
this.ip.HeaderText = "ip";
this.ip.Name = "ip";
this.ip.ReadOnly = true;
//
// port
//
this.port.DataPropertyName = "port";
this.port.HeaderText = "port";
this.port.Name = "port";
this.port.ReadOnly = true;
//
// timeStamp
//
this.timeStamp.DataPropertyName = "timeStamp";
this.timeStamp.HeaderText = "timeStamp";
this.timeStamp.Name = "timeStamp";
this.timeStamp.ReadOnly = true;
this.timeStamp.Visible = false;
//
// RejoindrePartieReseau_client
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(777, 450);
this.Controls.Add(this.btnJoin);
this.Controls.Add(this.tbPort);
this.Controls.Add(this.lblPort);
this.Controls.Add(this.tbPlayername);
this.Controls.Add(this.lblPlayerName);
this.Controls.Add(this.tbIpServ);
this.Controls.Add(this.lblIpServ);
this.Controls.Add(this.dgvPart);
this.Name = "RejoindrePartieReseau_client";
this.Text = "RejoindrePartieReseau_client";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.RejoindrePartieReseau_client_FormClosing);
this.Load += new System.EventHandler(this.RejoindrePartieReseau_client_Load);
((System.ComponentModel.ISupportInitialize)(this.dgvPart)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.DataGridView dgvPart;
private System.Windows.Forms.TextBox tbIpServ;
private System.Windows.Forms.Label lblIpServ;
private System.Windows.Forms.TextBox tbPlayername;
private System.Windows.Forms.Label lblPlayerName;
private System.Windows.Forms.TextBox tbPort;
private System.Windows.Forms.Label lblPort;
private System.Windows.Forms.Button btnJoin;
private System.Windows.Forms.DataGridViewTextBoxColumn uid;
private System.Windows.Forms.DataGridViewTextBoxColumn partName;
private System.Windows.Forms.DataGridViewTextBoxColumn playerName;
private System.Windows.Forms.DataGridViewTextBoxColumn ip;
private System.Windows.Forms.DataGridViewTextBoxColumn port;
private System.Windows.Forms.DataGridViewTextBoxColumn timeStamp;
}
}

View File

@ -0,0 +1,166 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace go01
{
public partial class RejoindrePartieReseau_client : Form
{
Thread ecouteThread;
System.Threading.Timer timerTTLdtListPart;
private DataTable dtListPart;
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
/*public struct partie_S
{
public string uid, partName, joueurAdverseName, ip;
public int taille, pionAaligner;
public partie_S(string uid, string partName, string joueurAdverseName, string ip, int taille, int pionAaligner)
{
this.uid = uid;
this.partName = partName;
this.joueurAdverseName = joueurAdverseName;
this.taille = taille;
this.pionAaligner = pionAaligner;
this.ip = ip;
}
public partie_S(string[] s, string ip)
{
this.uid = s[0];
this.partName = s[1];
this.joueurAdverseName = s[2];
this.taille = int.Parse(s[3]);
this.pionAaligner = int.Parse(s[4]);
this.ip = ip;
}
public override string ToString()
{
return uid;
}
public static implicit operator string(partie_S part)
{
return part.ToString();
}
}*/
public RejoindrePartieReseau_client()
{
InitializeComponent();
dtListPart = new DataTable();
dtListPart.Columns.Add("uid", typeof(string));
dtListPart.Columns.Add("partName", typeof(socketPlateau.ConfigGo_S));
dtListPart.Columns.Add("playerName", typeof(string));
dtListPart.Columns.Add("ip", typeof(string));
dtListPart.Columns.Add("port", typeof(int));//timeStamp
dtListPart.Columns.Add("timeStamp", typeof(DateTime));
ecouteThread = new Thread(() =>
{
Thread.CurrentThread.IsBackground = true;
Listen();
});
ecouteThread.Start();
var startTimeSpan = TimeSpan.Zero;
var periodTimeSpan = TimeSpan.FromSeconds(1);
timerTTLdtListPart = new System.Threading.Timer((ee) =>
{
TTLdtListPart();
}, null, startTimeSpan, periodTimeSpan);
}
private void Listen()
{
var Server = new UdpClient(8888);
while (1==1)
{
var ClientEp = new IPEndPoint(IPAddress.Any, 0);
byte[] ClientRequestData = Server.Receive(ref ClientEp);
using (MemoryStream ms = new MemoryStream(ClientRequestData))
{
socketPlateau.ConfigGo_S cfgGo = (socketPlateau.ConfigGo_S)binaryFormatter.Deserialize(ms);
Invoke(new Action(() => { ajoutPartie(cfgGo, ClientEp.Address.ToString()); }));
}
string ClientRequest = Encoding.ASCII.GetString(ClientRequestData);
Console.WriteLine("Recived {0} from {1}, sending response", ClientRequest, ClientEp.Address.ToString());
}
}
public void ajoutPartie(socketPlateau.ConfigGo_S cfgGo, string ip)
{
if(dtListPart.Select($"uid = '{cfgGo.Uid}'").Length==0)
dtListPart.Rows.Add(cfgGo.Uid, cfgGo, cfgGo.NomJoeurServeur, cfgGo.IpServeur, cfgGo.port, DateTime.Now);
//lock (DgvPart) ;
dtListPart.Select($"uid = '{cfgGo.Uid}'")[0]["timeStamp"] = DateTime.Now;
DgvPart.DataSource = dtListPart;
}
public void TTLdtListPart()
{
foreach(DataGridViewRow row in dgvPart.Rows)
{
if(((DateTime)row.Cells["timeStamp"].Value).AddSeconds(10) <= DateTime.Now)
{
Invoke(new Action(() => {
dgvPart.Rows.Remove(row);
dgvPart.Refresh();
}));
}
}
}
private void RejoindrePartieReseau_client_Load(object sender, EventArgs e)
{
}
private void RejoindrePartieReseau_client_FormClosing(object sender, FormClosingEventArgs e)
{
ecouteThread.Abort();
}
public DataGridView DgvPart
{
get { return this.dgvPart; }
set { }
}
private void dgvPart_Click(object sender, EventArgs e)
{
if (dgvPart.SelectedRows.Count <= 0)
return;
socketPlateau.ConfigGo_S cfg = (socketPlateau.ConfigGo_S)dgvPart.SelectedRows[0].Cells["partName"].Value;
tbIpServ.Text = cfg.IpServeur.ToString();
tbPort.Text = cfg.port.ToString();
}
private void btnJoin_Click(object sender, EventArgs e)
{
if (dgvPart.SelectedRows.Count <= 0)
return;
socketPlateau.ConfigGo_S cfg = (socketPlateau.ConfigGo_S)dgvPart.SelectedRows[0].Cells["partName"].Value;
cfg.NomJoeurClient = tbPlayername.Text;
socketPlateau sc = new socketPlateau(socketPlateau.TypeSocket_E.Client, cfg, null);
sc.senCmd(new socketPlateau.CommandeSocket_S(socketPlateau.commande_E.Join, cfg));
}
}
}

View File

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="uid.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="partName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="playerName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ip.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="port.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="timeStamp.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="uid.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="partName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="playerName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ip.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="port.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="timeStamp.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

50
go01/Settings1.Designer.cs generated Normal file
View File

@ -0,0 +1,50 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Ce code a été généré par un outil.
// Version du runtime :4.0.30319.42000
//
// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
// le code est régénéré.
// </auto-generated>
//------------------------------------------------------------------------------
namespace go01 {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")]
internal sealed partial class Settings1 : global::System.Configuration.ApplicationSettingsBase {
private static Settings1 defaultInstance = ((Settings1)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings1())));
public static Settings1 Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool dbg {
get {
return ((bool)(this["dbg"]));
}
set {
this["dbg"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("50")]
public int vitesseAnimDBG {
get {
return ((int)(this["vitesseAnimDBG"]));
}
set {
this["vitesseAnimDBG"] = value;
}
}
}
}

12
go01/Settings1.settings Normal file
View File

@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="go01" GeneratedClassName="Settings1">
<Profiles />
<Settings>
<Setting Name="dbg" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="vitesseAnimDBG" Type="System.Int32" Scope="User">
<Value Profile="(Default)">50</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -0,0 +1,29 @@
using System;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace go01
{
public class TextBoxStreamWriter : TextWriter
{
RichTextBox _output = null;
public TextBoxStreamWriter(RichTextBox output)
{
_output = output;
}
public override void Write(char value)
{
base.Write(value);
_output.AppendText(value.ToString().Replace('\n', ' '));
}
public override Encoding Encoding
{
get { return System.Text.Encoding.UTF8; }
}
}
}

View File

@ -34,6 +34,7 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Design" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -43,16 +44,55 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="VisualPlus">
<HintPath>..\..\GestionDeDommerceInformatique\packages\VisualPlus.0.4.1.4-beta\lib\VisualPlus\NET4\VisualPlus.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<Compile Include="CreerPartieReseau_serv.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
<Compile Include="CreerPartieReseau_serv.Designer.cs">
<DependentUpon>CreerPartieReseau_serv.cs</DependentUpon>
</Compile>
<Compile Include="Plateau.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Plateau.Designer.cs">
<DependentUpon>Plateau.cs</DependentUpon>
</Compile>
<Compile Include="Goban.cs" />
<Compile Include="mainWin.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="mainWin.Designer.cs">
<DependentUpon>mainWin.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RejoindrePartieReseau_client.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RejoindrePartieReseau_client.Designer.cs">
<DependentUpon>RejoindrePartieReseau_client.cs</DependentUpon>
</Compile>
<Compile Include="Settings1.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings1.settings</DependentUpon>
</Compile>
<Compile Include="socketPlateau.cs" />
<Compile Include="socketPlateauServArgs.cs" />
<Compile Include="TextBoxStreamWriter.cs" />
<EmbeddedResource Include="CreerPartieReseau_serv.resx">
<DependentUpon>CreerPartieReseau_serv.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Plateau.resx">
<DependentUpon>Plateau.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="mainWin.resx">
<DependentUpon>mainWin.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -61,7 +101,11 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="RejoindrePartieReseau_client.resx">
<DependentUpon>RejoindrePartieReseau_client.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -71,9 +115,46 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="Settings1.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings1.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="resources\b.png" />
</ItemGroup>
<ItemGroup>
<None Include="resources\bl.png" />
</ItemGroup>
<ItemGroup>
<None Include="resources\br.png" />
</ItemGroup>
<ItemGroup>
<None Include="resources\hoshi.png" />
</ItemGroup>
<ItemGroup>
<None Include="resources\l.png" />
</ItemGroup>
<ItemGroup>
<None Include="resources\m.png" />
</ItemGroup>
<ItemGroup>
<None Include="resources\r.png" />
</ItemGroup>
<ItemGroup>
<None Include="resources\t.png" />
</ItemGroup>
<ItemGroup>
<None Include="resources\tl.png" />
</ItemGroup>
<ItemGroup>
<None Include="resources\tr.png" />
</ItemGroup>
<ItemGroup>
<None Include="resources\giphy.gif" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

188
go01/mainWin.Designer.cs generated Normal file
View File

@ -0,0 +1,188 @@
namespace go01
{
partial class mainWin
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblJoeur1 = new System.Windows.Forms.Label();
this.tbJoeur1 = new System.Windows.Forms.TextBox();
this.tbJoueur2 = new System.Windows.Forms.TextBox();
this.lblJoeur2 = new System.Windows.Forms.Label();
this.btnConfim = new System.Windows.Forms.Button();
this.lblTaille = new System.Windows.Forms.Label();
this.txtBoxTaille = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.txtBoxPionAlign = new System.Windows.Forms.TextBox();
this.btnLoad = new System.Windows.Forms.Button();
this.btnChercherPartie = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblJoeur1
//
this.lblJoeur1.AutoSize = true;
this.lblJoeur1.Location = new System.Drawing.Point(13, 13);
this.lblJoeur1.Name = "lblJoeur1";
this.lblJoeur1.Size = new System.Drawing.Size(48, 13);
this.lblJoeur1.TabIndex = 8;
this.lblJoeur1.Text = "Joeur 1 :";
//
// tbJoeur1
//
this.tbJoeur1.Location = new System.Drawing.Point(67, 10);
this.tbJoeur1.Name = "tbJoeur1";
this.tbJoeur1.Size = new System.Drawing.Size(100, 20);
this.tbJoeur1.TabIndex = 0;
//
// tbJoueur2
//
this.tbJoueur2.Location = new System.Drawing.Point(67, 36);
this.tbJoueur2.Name = "tbJoueur2";
this.tbJoueur2.Size = new System.Drawing.Size(100, 20);
this.tbJoueur2.TabIndex = 1;
//
// lblJoeur2
//
this.lblJoeur2.AutoSize = true;
this.lblJoeur2.Location = new System.Drawing.Point(13, 39);
this.lblJoeur2.Name = "lblJoeur2";
this.lblJoeur2.Size = new System.Drawing.Size(48, 13);
this.lblJoeur2.TabIndex = 7;
this.lblJoeur2.Text = "Joeur 2 :";
//
// btnConfim
//
this.btnConfim.Location = new System.Drawing.Point(15, 115);
this.btnConfim.Name = "btnConfim";
this.btnConfim.Size = new System.Drawing.Size(151, 23);
this.btnConfim.TabIndex = 4;
this.btnConfim.Text = "Confirmer";
this.btnConfim.UseVisualStyleBackColor = true;
this.btnConfim.Click += new System.EventHandler(this.btnConfim_Click);
//
// lblTaille
//
this.lblTaille.AutoSize = true;
this.lblTaille.Location = new System.Drawing.Point(12, 69);
this.lblTaille.Name = "lblTaille";
this.lblTaille.Size = new System.Drawing.Size(80, 13);
this.lblTaille.TabIndex = 6;
this.lblTaille.Text = "Taille du goban";
//
// txtBoxTaille
//
this.txtBoxTaille.Location = new System.Drawing.Point(98, 66);
this.txtBoxTaille.Name = "txtBoxTaille";
this.txtBoxTaille.Size = new System.Drawing.Size(69, 20);
this.txtBoxTaille.TabIndex = 2;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(16, 92);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(76, 13);
this.label1.TabIndex = 5;
this.label1.Text = "Nb Pion aligne";
//
// txtBoxPionAlign
//
this.txtBoxPionAlign.Location = new System.Drawing.Point(98, 89);
this.txtBoxPionAlign.Name = "txtBoxPionAlign";
this.txtBoxPionAlign.Size = new System.Drawing.Size(69, 20);
this.txtBoxPionAlign.TabIndex = 3;
//
// btnLoad
//
this.btnLoad.Location = new System.Drawing.Point(16, 144);
this.btnLoad.Name = "btnLoad";
this.btnLoad.Size = new System.Drawing.Size(150, 23);
this.btnLoad.TabIndex = 9;
this.btnLoad.Text = "Charger";
this.btnLoad.UseVisualStyleBackColor = true;
this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click);
//
// btnChercherPartie
//
this.btnChercherPartie.Location = new System.Drawing.Point(16, 173);
this.btnChercherPartie.Name = "btnChercherPartie";
this.btnChercherPartie.Size = new System.Drawing.Size(150, 23);
this.btnChercherPartie.TabIndex = 10;
this.btnChercherPartie.Text = "Chercher une partie";
this.btnChercherPartie.UseVisualStyleBackColor = true;
this.btnChercherPartie.Click += new System.EventHandler(this.btnChercherPartie_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(16, 202);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(150, 23);
this.button2.TabIndex = 11;
this.button2.Text = "Creer une partie en réseau";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// mainWin
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(181, 237);
this.Controls.Add(this.button2);
this.Controls.Add(this.btnChercherPartie);
this.Controls.Add(this.btnLoad);
this.Controls.Add(this.txtBoxPionAlign);
this.Controls.Add(this.label1);
this.Controls.Add(this.txtBoxTaille);
this.Controls.Add(this.lblTaille);
this.Controls.Add(this.btnConfim);
this.Controls.Add(this.tbJoueur2);
this.Controls.Add(this.lblJoeur2);
this.Controls.Add(this.tbJoeur1);
this.Controls.Add(this.lblJoeur1);
this.Name = "mainWin";
this.Text = "mainWin";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblJoeur1;
private System.Windows.Forms.TextBox tbJoeur1;
private System.Windows.Forms.TextBox tbJoueur2;
private System.Windows.Forms.Label lblJoeur2;
private System.Windows.Forms.Button btnConfim;
private System.Windows.Forms.Label lblTaille;
private System.Windows.Forms.TextBox txtBoxTaille;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtBoxPionAlign;
private System.Windows.Forms.Button btnLoad;
private System.Windows.Forms.Button btnChercherPartie;
private System.Windows.Forms.Button button2;
}
}

78
go01/mainWin.cs Normal file
View File

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace go01
{
public partial class mainWin : Form
{
public mainWin()
{
InitializeComponent();
//cbTaille.SelectedIndex = 0;
}
private void btnConfim_Click(object sender, EventArgs e)
{
int taille = 5;
int pionAlign = 5;
taille = (int.TryParse(txtBoxTaille.Text, out taille)) ? taille : 5;
pionAlign = (int.TryParse(txtBoxPionAlign.Text, out pionAlign)) ? pionAlign : 3;
Plateau win = new Plateau(taille, pionAlign, tbJoueur2.Text, tbJoeur1.Text);
this.Hide();
win.ShowDialog();
this.Close();
}
private void btnLoad_Click(object sender, EventArgs e)
{
Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
// openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "bn files (*.bn)|*.bn";
openFileDialog1.FilterIndex = 1;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
Goban.sauvegarde_S s = ReadFromBinaryFile<Goban.sauvegarde_S>(openFileDialog1.FileName);
Plateau win = new Plateau(s);
this.Hide();
win.ShowDialog();
this.Close();
}
}
public static T ReadFromBinaryFile<T>(string filePath)
{
using (Stream stream = File.Open(filePath, FileMode.Open))
{
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
return (T)binaryFormatter.Deserialize(stream);
}
}
private void button2_Click(object sender, EventArgs e)
{
CreerPartieReseau_serv win = new CreerPartieReseau_serv();
this.Hide();
win.ShowDialog();
this.Close();
}
private void btnChercherPartie_Click(object sender, EventArgs e)
{
RejoindrePartieReseau_client win = new RejoindrePartieReseau_client();
this.Hide();
win.ShowDialog();
this.Close();
}
}
}

120
go01/mainWin.resx Normal file
View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

BIN
go01/resources/b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

BIN
go01/resources/bl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
go01/resources/br.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

BIN
go01/resources/giphy.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

BIN
go01/resources/hoshi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

BIN
go01/resources/l.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

BIN
go01/resources/m.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

BIN
go01/resources/r.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

BIN
go01/resources/t.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

BIN
go01/resources/tl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

BIN
go01/resources/tr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

313
go01/socketPlateau.cs Normal file
View File

@ -0,0 +1,313 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Threading;
using System.Net.NetworkInformation;
namespace go01
{
public class socketPlateau
{
#region enum
public enum TypeSocket_E { NONE, Serveur, Client, LAST }
public enum commande_E { Join, Leave, Place, Win, WhoTurn, LAST } // ConfigGo_S ; null ; Point ; Goban.PlayerTuen(string) ; Goban.Joueur_E(Tour)
#endregion
#region struct
[Serializable]
public struct CommandeSocket_S
{
public commande_E commande;
public object data;
public CommandeSocket_S(commande_E cmd, object dt)
{
commande = cmd;
data = dt;
}
}
[Serializable]
public struct ConfigGo_S
{
private string uid;
public string Uid { get { return uid; } }
private string partName;
public string PartName { get { return partName; } }
public string NomJoeurClient;
private string nomJoeurServeur;
public string NomJoeurServeur { get { return nomJoeurServeur; } }
private int taille;
public int Taille { get { return taille; } }
private int pionaAligner;
public int PionAligner { get { return pionaAligner; } }
private IPAddress ipServeur;
public IPAddress IpServeur { get => ipServeur; }
public readonly int port;
public ConfigGo_S(string Uid, string PartName, string NomJoeurClient, string NomJoeurServeur, int Taille, int PionaAligner, IPAddress ipServeur, int port)
{
this.uid = Uid;
this.partName = PartName;
this.NomJoeurClient = NomJoeurClient;
this.nomJoeurServeur = NomJoeurServeur;
this.taille = Taille;
this.pionaAligner = PionaAligner;
this.ipServeur = ipServeur;
this.port = port;
}
public override string ToString()
{
return partName;
}
public static implicit operator string(ConfigGo_S part)
{
return part.ToString();
}
}
#endregion
#region variable
private Socket socServ, socCli;
private Socket SocCli
{
get
{
if(socFlag == TypeSocket_E.Serveur && socCli != null || socFlag == TypeSocket_E.Client)
{
return socCli;
}
else
{
return null;
}
}
set
{
socCli = value;
}
}
private TypeSocket_E socFlag = 0;
IPAddress adresseIpCourante;
int port;
private static Boolean connexionEtablie = false;
System.Threading.Timer timerBroadcast;
Goban plateauDeJeu;
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
ConfigGo_S cfgGo;
#endregion
#region event
public delegate void OnJoinServ(object myObject, socketPlateauServArgs myArgs);
public event OnJoinServ onJoinServ;
#endregion
public socketPlateau(TypeSocket_E socF, ConfigGo_S cfgGo, Goban g)
{
plateauDeJeu = g;
adresseIpCourante = cfgGo.IpServeur;
socFlag = socF;
this.port = cfgGo.port;
this.cfgGo = cfgGo;
if(socFlag == TypeSocket_E.Client)
{
socFlag = TypeSocket_E.Client;
try
{
socCli = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
//socCli.Blocking = false;
//IPAddress IPDist = Verifier(cfgGo.IpServeur.ToString());
socCli.BeginConnect(new IPEndPoint(cfgGo.IpServeur, port), new AsyncCallback(SurConnection), socCli);
}
catch (Exception ee)
{
//controle(true);
MessageBox.Show("Connexion impossible : " + ee.Message);
}
}
else if(socFlag == TypeSocket_E.Serveur)
{
//AttenteJoueur();
}
}
#region serveur
public void AttenteJoueur()
{
if (socFlag != TypeSocket_E.Serveur)
return;
var startTimeSpan = TimeSpan.Zero;
var periodTimeSpan = TimeSpan.FromSeconds(5);
timerBroadcast = new System.Threading.Timer((ee) =>
{
broadcast();
}, null, startTimeSpan, periodTimeSpan);
socFlag = TypeSocket_E.Serveur;
socServ = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socServ.Bind(new IPEndPoint(adresseIpCourante, port));
socServ.Listen(1);
socServ.BeginAccept(new AsyncCallback(SurDemandeDeCo), socServ);
}
private void SurDemandeDeCo(IAsyncResult iAR)
{
if (socFlag == TypeSocket_E.Serveur && !socketPlateau.connexionEtablie)
{
Socket sTmp = (Socket)iAR.AsyncState;
socCli = sTmp.EndAccept(iAR);
#if DEBUG
Console.WriteLine($"Connexion effectuée par {((IPEndPoint)socCli.RemoteEndPoint).Address}");
#endif
connexionEtablie = true;
timerBroadcast.Dispose();
InitialiserReception(socCli);
}
else if(socFlag == TypeSocket_E.Serveur && socketPlateau.connexionEtablie)
{
Socket sTmp = (Socket)iAR.AsyncState;
socCli = sTmp.EndAccept(iAR);
socCli.Send(Encoding.Unicode.GetBytes("Serveur en cours de partie !"));
socCli.Close();
}
}
private void broadcast()
{
if (socFlag != TypeSocket_E.Serveur)
return;
var Client = new UdpClient();
using (MemoryStream ms = new MemoryStream())
{
binaryFormatter.Serialize(ms, cfgGo);
Client.EnableBroadcast = true;
byte[] RequestData = ms.ToArray();
Client.Send(RequestData, RequestData.Length, new IPEndPoint(IPAddress.Broadcast, 8888));
}
// byte[] RequestData = { }; /*= Encoding.ASCII.GetBytes($"{cfgGo.Uid};{cfgGo.PartName};{cfgGo.NomJoeurAdverse};{cfgGo.Taille};{cfgGo.PionaAligner}");*/;
Client.Close();
}
#endregion
#region client
public void rejoindrePartie(IPAddress IPServeur, int port)
{
socFlag = TypeSocket_E.Client;
try
{
socCli = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPAddress IPDist = IPServeur;
socCli.BeginConnect(new IPEndPoint(IPDist, port), new AsyncCallback(SurConnection), socCli);
}
catch (Exception ee)
{
MessageBox.Show("Connexion impossible : " + ee.Message);
}
}
private void SurConnection(IAsyncResult iAR)
{
Socket sTmp = (Socket)iAR.AsyncState;
if (sTmp.Connected) { connexionEtablie = true; InitialiserReception(sTmp); senCmd(new CommandeSocket_S(commande_E.Join, cfgGo)); }
else { MessageBox.Show("Serveur innacessible"); }
}
#endregion
#region commun
private void InitialiserReception(Socket sArg)
{
try
{
var netStream = new NetworkStream(sArg, true);
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
CommandeSocket_S cmd = (CommandeSocket_S)binaryFormatter.Deserialize(netStream);
switch (cmd.commande)
{
case commande_E.Join:
onJoinServ(this, new socketPlateauServArgs((ConfigGo_S)cmd.data));
break;
case commande_E.Leave:
break;
case commande_E.Place:
break;
case commande_E.WhoTurn:
break;
case commande_E.Win:
break;
}
InitialiserReception(sArg);
}
catch (Exception e)
{
Console.WriteLine("Réception imossible : " + e.Message);
}
}
public void senCmd(CommandeSocket_S cmd)
{
var netStream = new NetworkStream(socCli, true);
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryFormatter.Serialize(netStream, cmd);
}
#endregion
#region outil
public static void net_adapters(ComboBox cb)
{
List<String> values = new List<String>();
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
cb.Items.Add(nic.Name);
}
}
public static IPAddress Verifier(string sAdresse)
{
IPAddress rep = null;
if (sAdresse.Trim().Length > 0)
{
IPAddress[] ipVerifs = Dns.GetHostEntry(sAdresse).AddressList;
for (int i = 0; i < ipVerifs.Length; i++)
{
//rep += ipVerifs[0].ToString();
if (ipVerifs[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
if (ipVerifs[i] != new IPAddress(0X0100007F))
{
Ping pVerif = new Ping();
PingReply pRepon = pVerif.Send(ipVerifs[i]);
if (pRepon.Status == IPStatus.Success)
{
rep = ipVerifs[i];
Console.WriteLine(ipVerifs[i] + "Ping réussi");
break;
}
else
{
Console.WriteLine(ipVerifs[i] + "Ping KO");
}
}
}
}
}
else
{
Console.WriteLine("Renseigner une adresse");
}
return rep;
}
#endregion
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace go01
{
public class socketPlateauServArgs : EventArgs
{
public socketPlateau.ConfigGo_S ConfigGo;
public socketPlateauServArgs(socketPlateau.ConfigGo_S cfg)
{
this.ConfigGo = cfg;
}
}
}

BIN
goban.xcf Normal file

Binary file not shown.