79 lines
2.4 KiB
C#
79 lines
2.4 KiB
C#
|
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();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|