using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
using Shared;

namespace ChtiCanon
{
    public partial class frmConnect : Form
    {
        ConnectionManager connexion;

        public frmConnect()
        {
            InitializeComponent();
        }

        private void btnConnecter_Click(object sender, EventArgs e)
        {
            try{
                if (tbxIp.Text != "" && tbxPort.Text != "")
                {
                    connexion = new ConnectionManager((IPAddress.Parse(tbxIp.Text)), Convert.ToInt32(tbxPort.Text));
                    frmLobby lobby = new frmLobby(connexion);
                    lobby.Show();
                    this.Visible = false;
                }
                else
                {
                    MessageBox.Show("WARNING : Required field missing", "Chti'Canon",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch
            {
                MessageBox.Show("ERROR : Connection failed", "Chti'Canon",
                MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }

        private void btnLocal_Click(object sender, EventArgs e)
        {
            new Program.GameThread(null, null, 1, null);
        }
    }
}
