﻿/* -----------------input_f.cs-----------------
 * 
 * MySQL Explorer
 * 
 * Copyright (C) 2015 Ivan Juan Kara
 * 
 * MySQL Explorer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * MySQL Explorer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


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

namespace mysql1 {
	public partial class input_f : Form {
		public input_f() {
			InitializeComponent();
		}

		public input_f(string title, Form caller) {
			this.title = title;
			mainform = caller as Form1;
			InitializeComponent();
		}

		Form1 mainform = null;
		string title;

		private void input_f_Load(object sender, EventArgs e) {
			this.Text = title;
			textBox1.GotFocus += txtGot;
			textBox1.LostFocus += txtLost;
			textBox1.Text = "Your text here...";
			textBox1.ForeColor = Color.Gray;
		}

		private void txtLost(object sender, EventArgs e) {
			if (textBox1.Text == "") {
				textBox1.Text = "Your text here...";
				textBox1.ForeColor = Color.Gray;
			}
		}

		private void txtGot(object sender, EventArgs e) {
			if (textBox1.Text == "Your text here...") {
				textBox1.Text = "";
				textBox1.ForeColor = Color.Black;
			}
		}

		private void button1_Click(object sender, EventArgs e) {
			if (textBox1.Text != "Your text here..." && textBox1.Text != "") {
				mainform.new_name_of_db = textBox1.Text;
				this.DialogResult = DialogResult.OK;
				this.Close();
			} else
				MessageBox.Show("Please check the field again!", "NULL VALUE", MessageBoxButtons.OK, MessageBoxIcon.Warning);
		}

		private void button2_Click(object sender, EventArgs e) {
			this.DialogResult = DialogResult.Cancel;
			this.Close();
		}
	}
}
