using Krypton.Toolkit;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SamaPager_Client
{
    public partial class Form1 : Krypton.Toolkit.KryptonForm
    {
        IPAddress DestinationIP = IPAddress.Loopback;
        Client pageClient { get; set; }

        public Form1()
        {
            InitializeComponent();
        }

        public void StartClient()
        {
            pageClient = new Client(DestinationIP, 2000);
            statusTxt.Text = "STATUS: " + pageClient.StartClient();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            StartClient();
        }

        private void changeDestinationAddressToolStripMenuItem_Click(object sender, EventArgs e)
        {
            KryptonMessageBox.Show("WIP");
        }

        private void restartUDPClientToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusTxt.Text = "STATUS: Restarting UdpClient";
            StartClient();
        }

        private void sendBtn_Click(object sender, EventArgs e)
        {
            if(messageTxt.Text == string.Empty)
            {
                KryptonMessageBox.Show("Inserire un messaggio");
            }
            else
            {
                pageClient.SendMessage(messageTxt.Text);
                messageTxt.Text = String.Empty;
            }

        }
    }
}
