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

namespace CSGBuilder {
    public partial class ScaleForm : Form {
        public ScaleForm() {
            InitializeComponent();
        }

        private void ScaleForm_FormClosing(object sender, FormClosingEventArgs e) {
            if (this.DialogResult == DialogResult.OK) {
                if (tbLX.Text == "" || tbLY.Text == "" || tbLZ.Text == "") {
                    MessageBox.Show("Empty fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    e.Cancel = true; return;
                }
                double x;
                if (!Double.TryParse(tbLX.Text, out x) || !Double.TryParse(tbLY.Text, out x) || !Double.TryParse(tbLZ.Text, out x)) {
                    MessageBox.Show("Incorrect number format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    e.Cancel = true; return;
                }
                if (Double.Parse(tbLX.Text) < 0 || Double.Parse(tbLY.Text) < 0 || Double.Parse(tbLZ.Text) < 0) {
                    MessageBox.Show("Scale cannot be negative!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    e.Cancel = true; return;
                }
            }
        }
    }
}