private void Button_OK_Click(object sender, RoutedEventArgs e)
{
if (TextBox_Name.Text.Length == 0)
{
WindowMessage.ShowDialog(string.Format("Invalid '{0}' input.", Label_Name.Content), "Error saving", WindowMessageButtons.OK, WindowMessageImage.Error, this);
return;
}
if (App.PokerTypeManager.GetPokerTypesCopy().Any(o => o.Name.ToLowerInvariant().Equals(TextBox_Name.Text.ToLowerInvariant())))
{
WindowMessage.ShowDialog("Cannot save. Duplicate names.", "Error saving", WindowMessageButtons.OK, WindowMessageImage.Error, this);
return;
}
try
{
PokerType.LevelLength = TimeSpan.Parse(TextBox_LevelLength.Text);
}
catch
{
WindowMessage.ShowDialog(string.Format("Invalid '{0}' input.", Label_LevelLength.Content), "Error saving", WindowMessageButtons.OK, WindowMessageImage.Error, this);
return;
}
try
{
new Regex(TextBox_RegexWindowTitle.Text);
}
catch
{
WindowMessage.ShowDialog(string.Format("Invalid '{0}' input.", Label_RegexWindowTitle.Content), "Error saving", WindowMessageButtons.OK, WindowMessageImage.Error, this);
return;
}
try
{
new Regex(TextBox_RegexWindowClass.Text);
}
catch
{
WindowMessage.ShowDialog(string.Format("Invalid '{0}' input.", Label_RegexWindowClass.Content), "Error saving", WindowMessageButtons.OK, WindowMessageImage.Error, this);
return;
}
PokerType.Name = TextBox_Name.Text;
//PokerType.LevelLength = TimeSpan.Parse(TextBox_LevelLength.Text);
PokerType.RegexWindowTitle = new Regex(TextBox_RegexWindowTitle.Text);
PokerType.RegexWindowClass = new Regex(TextBox_RegexWindowClass.Text);
Saved = true;
Close();
}