/// <summary>
/// Button click
/// </summary>
void Btn_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
string name = btn.Name;
if (name == "Accept")
{
bool isCorrect = true;
string language = atbxInputValues[0].Text;
string fileName = atbxInputValues[1].Text + ".xml";
string author = atbxInputValues[2].Text;
string website = atbxInputValues[3].Text;
string contacts = atbxInputValues[4].Text;
// Language
if (language.Length < 2)
{
MessageBox.Show("The language name must be at least two characters in length!", "Language", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
isCorrect = false;
}
foreach (string lang in Language.LanguageList)
{
if (language == lang)
{
MessageBox.Show("A translation in this language exists already!" + Environment.NewLine + "Change the language name.", "Language", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
isCorrect = false;
}
}
// Language file name
if (fileName.Length < 2)
{
MessageBox.Show("The language file name must be at least two characters in length!", "Language File Name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
isCorrect = false;
}
if (Directory.Exists(Data.LanguageDir))
{
string[] asFileNames = Directory.GetFiles(Data.LanguageDir);
foreach (string path in asFileNames)
{
if (fileName == Path.GetFileName(path))
{
MessageBox.Show("This file name exists already!" + Environment.NewLine + "Change the file name.", "Language File Name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
isCorrect = false;
}
}
}
else
{
MessageBox.Show("Could not find the language files directory!", "Language Files Directory", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
isCorrect = false;
}
if (isCorrect)
{
if (Language.GenerateNewLangFile(fileName, language, author, website, contacts))
{
Configs.Language = language;
string sMassage = "The new language file was successfully created." + Environment.NewLine + "Restart the program and edit the translation.";
MessageBox.Show(sMassage, "New Translation", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
return;
}
}
this.Close();
}