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

namespace WTD_Editor
{
    public partial class AddWaypoint : Form
    {
        // attributes
        public int x;
        public int y;

        public AddWaypoint()
        {
            InitializeComponent();
            x = 0;
            y = 0;
            textBox1.Text = x.ToString();
            textBox2.Text = y.ToString();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            try
            {
                int num = int.Parse(textBox1.Text);
                if (num >= 0 && num <= Map.MAP_WIDTH_MAX)
                {
                    x = num;
                }
                else if (num > Map.MAP_WIDTH_MAX)
                {
                    x = Map.MAP_WIDTH_MAX;
                }
                textBox1.Text = x.ToString();
            }
            catch (Exception)
            {
                textBox1.Text = x.ToString();
            }
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            try
            {
                int num = int.Parse(textBox2.Text);
                if (num >= 0 && num <= Map.MAP_HEIGHT_MAX)
                {
                    y = num;
                }
                else if (num > Map.MAP_HEIGHT_MAX)
                {
                    y = Map.MAP_WIDTH_MAX;
                }
                textBox2.Text = y.ToString();
            }
            catch (Exception)
            {
                textBox2.Text = y.ToString();
            }
        }
    }
}