/// <summary>
/// Offers clipboard interface support for copying test run results.
/// </summary>
/// <param name="sender">The source object.</param>
/// <param name="e">The event arguments.</param>
protected virtual void OnClipboardButtonClick(object sender, EventArgs e)
{
Button b = (Button)sender;
string tag = (string)b.Tag;
string text = string.Empty;
switch (tag)
{
case "CopyAllChecked":
StringBuilder sb = new StringBuilder();
int count = 0;
foreach (KeyValuePair <object, TreeViewItem> item in resultsTreeView.GetCheckedItemsAndContainers())
{
// Only want the actual leaf nodes
TestMethodData tmd = item.Key as TestMethodData;
if (tmd != null)
{
sb.AppendLine(tmd.GetResultReport());
count++;
}
}
if (count == 0)
{
sb.AppendLine("There were no checked results.");
text = sb.ToString();
}
else
{
text = "There were " +
count.ToString() +
" results checked." +
Environment.NewLine +
Environment.NewLine +
sb.ToString();
}
break;
case "CopyResults":
IProvideResultReports result = resultsTreeView.SelectedItem as IProvideResultReports;
if (result != null)
{
text = result.GetResultReport();
}
break;
default:
case "Close":
ClipboardContents.Text = string.Empty;
ClipboardHelperGrid.Visibility = Visibility.Collapsed;
return;
}
SetClipboardText(text);
}