private void SaveTreeViewCategory(XmlWriter writer, TreeViewItem categoryItem, SvgTestCategory testCategory) { int total = 0, unknowns = 0, failures = 0, successes = 0, partials = 0; writer.WriteStartElement("category"); writer.WriteAttributeString("label", testCategory.Label); ItemCollection treeItems = categoryItem.Items; for (int j = 0; j < treeItems.Count; j++) { TreeViewItem treeItem = treeItems[j] as TreeViewItem; if (treeItem != null) { SvgTestInfo testInfo = treeItem.Tag as SvgTestInfo; if (testInfo != null) { testInfo.WriteXml(writer); total++; SvgTestState testState = testInfo.State; switch (testState) { case SvgTestState.Unknown: unknowns++; break; case SvgTestState.Failure: failures++; break; case SvgTestState.Success: successes++; break; case SvgTestState.Partial: partials++; break; } } } } writer.WriteEndElement(); testCategory.SetValues(total, unknowns, failures, successes, partials); }
private void LoadTreeViewCategory(XmlReader reader, TreeViewItem categoryItem, SvgTestCategory testCategory) { int total = 0, unknowns = 0, failures = 0, successes = 0, partials = 0; int itemCount = 0; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (string.Equals(reader.Name, "test", StringComparison.OrdinalIgnoreCase)) { SvgTestInfo testInfo = new SvgTestInfo(reader); if (!testInfo.IsEmpty) { TextBlock headerText = new TextBlock(); headerText.Text = string.Format("({0:D3}) - {1}", itemCount, testInfo.Title); headerText.Margin = new Thickness(3, 0, 0, 0); Ellipse bullet = new Ellipse(); bullet.Height = 16; bullet.Width = 16; bullet.Fill = testInfo.StateBrush; bullet.Stroke = Brushes.DarkGray; bullet.StrokeThickness = 1; BulletDecorator decorator = new BulletDecorator(); decorator.Bullet = bullet; decorator.Margin = new Thickness(0, 0, 10, 0); decorator.Child = headerText; TreeViewItem treeItem = new TreeViewItem(); treeItem.Header = decorator; treeItem.Padding = new Thickness(3); treeItem.FontSize = 12; treeItem.FontWeight = FontWeights.Normal; treeItem.Tag = testInfo; categoryItem.Items.Add(treeItem); itemCount++; total++; SvgTestState testState = testInfo.State; switch (testState) { case SvgTestState.Unknown: unknowns++; break; case SvgTestState.Failure: failures++; break; case SvgTestState.Success: successes++; break; case SvgTestState.Partial: partials++; break; } } } } else if (reader.NodeType == XmlNodeType.EndElement) { if (string.Equals(reader.Name, "category", StringComparison.OrdinalIgnoreCase)) { break; } } } testCategory.SetValues(total, unknowns, failures, successes, partials); }