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

namespace Administration
{
    public partial class LoginForm : Form
    {
        public LoginForm()
        {
            InitializeComponent();
        }

        private void loginButton_Click(object sender, EventArgs e)
        {
            try {
               int port = int.Parse(portEdit.Text);

               if (ClientCommunicator.Instance.IsActive)
               {
                   ClientCommunicator.Instance.Disconnect();
               }

               ClientCommunicator.Instance.Connect(serverEdit.Text, port);
               ClientCommunicator.Instance.SendMessage(new LoginRequest { player_login = loginEdit.Text, player_password = passwordEdit.Text});
            }
            catch 
            {
                MessageBox.Show("Port není celé nezáporné číslo");
                return;
            }
        }
    }
}
