/// <summary>
/// Calls MingleCard.Update() to update the card with contents of the text box.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnPropertyTextBoxLostFocus(object sender, RoutedEventArgs e)
{
e.Source = _thisCard;
string me = new StackFrame().GetMethod().Name;
var tb = sender as TextBox;
if (tb.Text == tb.Tag as string)
{
e.Handled = true;
return;
}
switch (tb.DataContext.GetType().Name)
{
case "Card":
// The name of the field is "cardXXXXXX", so we strip the "card" prefix from the
// name of the TextBox.
_thisCard.AddCardAttributeFilterToPostData(
tb.Name.Replace("card", string.Empty).ToLowerInvariant(), tb.Text);
break;
case "CardProperty":
// The DataContext of the TextBox is a MinglePropertyDefinition object. So, we
// take its name and pass it over to AddPropertyPostData.
_thisCard.AddPropertyFilterToPostData((tb.DataContext as CardProperty).Name, tb.Text);
break;
}
try
{
if (!string.IsNullOrEmpty(cardName.Text))
{
_thisCard.Update();
descriptionBrowser.Refresh();
}
else
{
MessageBox.Show(ThoughtWorksCoreLib.Resources.MingleCardNameNullOrEmpty);
}
}
catch (Exception ex)
{
TraceLog.Exception(me, ex);
MessageBox.Show(ex.Message);
}
e.Handled = true;
}