using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
/*
* Copyright Jeff Gaines 2007 - 2011 (jeff@jgaines.co.uk)
* Free licence for private use
* Please contact the author if you wish to use the code commercially
*/
namespace JGCreateDataClasses
{
/// <summary>
/// Allows creation of an XML database for current project
/// </summary>
public partial class FormCreateXMLSchema : Form
{
// Tooltip for buttons
private ToolTip m_ToolTip = new ToolTip();
public FormCreateXMLSchema()
{
InitializeComponent();
// ToolTips
m_ToolTip.SetToolTip(btnCreateSchema, "Create XML Schema File");
m_ToolTip.SetToolTip(btnClose, "Close Dialog");
}
private void FormCreateXMLSchema_Load(object sender, EventArgs e)
{
jFileFolderPicker1.Focus();
}
private void btnClose_Click(object sender, EventArgs e)
{
Close();
}
private void btnCreateSchema_Click(object sender, EventArgs e)
{
if (!IsDataComplete(true))
return;
this.DialogResult = DialogResult.OK;
Close();
}
private string GetFileName()
{
string fileName = txtXMLFileName.Text;
if (!fileName.EndsWith(".xml", true, System.Globalization.CultureInfo.CurrentCulture))
fileName += ".xml";
return fileName;
}
private bool IsDataComplete(bool showMessage)
{
bool blnOK = true;
string strMissing = "";
if (string.IsNullOrEmpty(jFileFolderPicker1.SelectedPath))
{
strMissing += "XML Folder, ";
blnOK = false;
}
if (string.IsNullOrEmpty(txtXMLFileName.Text))
{
strMissing += "XML File Name, ";
blnOK = false;
}
if (string.IsNullOrEmpty(txtXMLNamespace.Text))
{
strMissing += "Namespace, ";
blnOK = false;
}
if (string.IsNullOrEmpty(txtXMLDataSetName.Text))
{
strMissing += "Dataset Name, ";
blnOK = false;
}
if (string.IsNullOrEmpty(txtXMLTableName.Text))
{
strMissing += "Table Name, ";
blnOK = false;
}
if (showMessage && !blnOK)
ShowMessage("These Fields Must Be Completed: " + strMissing, true);
return blnOK;
}
private void ShowMessage(string strMes, bool blnBeep)
{
tslblMessage.Text = strMes;
if (blnBeep)
JCommon.MessageBeep(-1);
}
private void txtXMLFolderName_TextChanged(object sender, EventArgs e)
{
btnCreateSchema.Enabled = IsDataComplete(false);
}
public string XMLFolderName
{
get { return this.jFileFolderPicker1.SelectedPath; }
}
public string XMLFileName
{
get { return GetFileName(); }
}
public string XMLNameSpace
{
get { return this.txtXMLNamespace.Text; }
}
public string XMLDataSetName
{
get { return this.txtXMLDataSetName.Text; }
}
public string XMLTableName
{
get { return this.txtXMLTableName.Text; }
}
}
}