/// <summary> /// /// </summary> private void AugmentCoverageShapesWithTrackingInfo() { if (this.ViewData != null && this.ViewData.Length > 0) { XmlDocument doc = new XmlDocument(); doc.LoadXml(this.ViewData); XmlNodeList trackedShapeNodes = doc.SelectNodes("XsymFile/Metadata/TrkMetadata/ShapeID"); foreach (XmlNode shapeNode in trackedShapeNodes) { string shapeId = shapeNode.InnerText.Replace("'", ""); if (!this.coverageShapes.ContainsKey(shapeId)) { OrchShape os = new OrchShape(); os.Id = shapeId; string xpath = "//ShapeInfo[ShapeID='" + shapeId + "']/shapeText"; XmlNode node = doc.SelectSingleNode(xpath); if (node != null) { os.Text = node.InnerText; this.coverageShapes.Add(os.Id, os); } } } } return; }
/// <summary> /// /// </summary> /// <param name="g"></param> /// <param name="shape"></param> private static void GetSelectionAreas(Graphics g, BaseShape shape, Orchestration orchestration, bool drawHotspots) { try { foreach (BaseShape bc in shape.Shapes) { if (bc is ReceiveShape || bc is SendShape || bc is MessageAssignmentShape || bc is VariableAssignmentShape) { OrchShape os = CreateOrchShape(bc); if (os != null) { orchestration.ShapeMap.Add(os); if (drawHotspots) { DrawDebugRect(g, os.SelectionArea.GetRectangle()); } } } GetSelectionAreas(g, bc, orchestration, drawHotspots); } } catch (Exception ex) { string message = ex.Message; } }
/// <summary> /// /// </summary> /// <param name="g"></param> private static void DrawCoverageRect(Graphics g, OrchShape os) { if (os != null && os.SelectionArea != null) { SelectionArea sa = os.SelectionArea; Font f = new Font("Arial", 8, FontStyle.Regular); int fontHeight = (int)f.GetHeight(); double shapeSuccessRate = os.GetSuccessRate(); string toolTipText = "Success Rate: " + (shapeSuccessRate == 0 ? "0" : shapeSuccessRate.ToString("###")) + "%"; int toolTipWidth = MeasureStringWidth(toolTipText, f); int toolTipHeight = f.Height + 6; int w = sa.Width + 6; int h = toolTipHeight; int x = sa.X - 2; int y = sa.Y - 2 - (h - ((h / 3))); float fttt = (float)toolTipWidth; float fw = (float)w; float fh = (float)h; float fx = (float)x; float fy = (float)y; Rectangle toolTipRect = new Rectangle(x, y, w, h); GraphicsPath gp = GetGpForShape(os); if (os.entryCount > 0) { if (shapeSuccessRate != 100) { // Blue g.FillRegion(new SolidBrush(Color.FromArgb(20, 0, 0, 255)), new Region(gp)); } else { // Green g.FillRegion(new SolidBrush(Color.FromArgb(20, 0, 255, 0)), new Region(gp)); } } else { // Red g.FillRegion(new SolidBrush(Color.FromArgb(20, 255, 0, 0)), new Region(gp)); } gp.Dispose(); g.FillRegion(new SolidBrush(Color.LemonChiffon), new Region(toolTipRect)); g.DrawRectangle(new Pen(Color.Black, 0.5f), toolTipRect); g.DrawString(toolTipText, f, new SolidBrush(Color.Black), ((sa.X + (sa.Width / 2)) - (fttt / 2)) + 3, y + 3); } return; }
/// <summary> /// /// </summary> /// <param name="g"></param> /// <param name="shape"></param> /// <param name="orchestration"></param> private static void DrawCoverageAreas(Graphics g, BaseShape shape, Orchestration orchestration, BaseShape parent) { foreach (BaseShape bc in shape.Shapes) { try { if (bc is CallShape || bc is CompensateShape || bc is ConstructShape || bc is DelayShape || //bc is ListenShape || //bc is MessageAssignmentShape || bc is ReceiveShape || bc is RulesShape || bc is SuspendShape || bc is TerminateShape || bc is ThrowShape || bc is TransformShape || bc is VariableAssignmentShape || bc is SendShape) { OrchShape os = CreateOrchShape(bc); if (os != null) { if (orchestration.CoverageShapes.ContainsKey(os.Id)) { OrchShape osTmp = orchestration.CoverageShapes[os.Id] as OrchShape; os.exitCount = osTmp.exitCount; os.entryCount = osTmp.entryCount; } orchestration.ShapeMap.Add(os); DrawCoverageRect(g, os); } } DrawCoverageAreas(g, bc, orchestration, shape); } catch (Exception ex) { TraceManager.SmartTrace.TraceError(ex); } } }
/// <summary> /// /// </summary> /// <param name="bc"></param> /// <returns></returns> private static OrchShape CreateOrchShape(BaseShape bc) { OrchShape os = null; XLANGView.TrkMetadata data = bc.Relationship as XLANGView.TrkMetadata; if (data != null) { os = new OrchShape(); os.Text = bc.Text; os.Id = data.ShapeID; // Rectangle selRect = new Rectangle( // bc.DesignSurfaceClientLocation.X-5, // bc.DesignSurfaceClientLocation.Y-7, // bc.NativeSize.Width, // bc.NativeSize.Height); Rectangle selRect = new Rectangle( bc.DesignSurfaceClientLocation.X - 5, bc.DesignSurfaceClientLocation.Y - 7, bc.Width, bc.Height); os.SelectionArea = new SelectionArea( selRect.X, selRect.Y, selRect.Width, selRect.Height); switch (bc.GetType().ToString()) { case "Microsoft.VisualStudio.EFT.SendShape": os.ShapeType = ShapeType.SendShape; break; case "Microsoft.VisualStudio.EFT.ReceiveShape": os.ShapeType = ShapeType.ReceiveShape; break; case "Microsoft.VisualStudio.EFT.VariableAssignmentShape": os.ShapeType = ShapeType.VariableAssignment; break; case "Microsoft.VisualStudio.EFT.MessageAssignmentShape": os.ShapeType = ShapeType.MessageAssignment; break; } } return(os); }
/// <summary> /// /// </summary> /// <param name="g"></param> /// <param name="shape"></param> private static void GetSelectionAreas(Graphics g, BaseShape shape, Orchestration orchestration, bool drawHotspots) { try { foreach (BaseShape bc in shape.Shapes) { //if (bc is ReceiveShape || // bc is SendShape || // bc is MessageAssignmentShape || // bc is VariableAssignmentShape || // bc is TransformShape)//NJB adding transform if (!bc.HasChildShapes) // Only shapes with no children should be clickable. - CD 20140408 { OrchShape os = CreateOrchShape(bc); if (os != null) { orchestration.ShapeMap.Add(os); if (drawHotspots) { DrawDebugRect(g, os.SelectionArea.GetRectangle()); } } } // Exit gracefully rather than throwing an exception - CD 20140408 else { GetSelectionAreas(g, bc, orchestration, drawHotspots); } } } catch (Exception ex) { string message = ex.Message; TraceManager.SmartTrace.TraceError(ex); } }
private void LoadReaderIntoShapes(SqlDataReader sr) { string shapeId = sr.GetGuid(0).ToString(); int inCount = sr.IsDBNull(1) ? 0 : sr.GetInt32(1); int outCount = sr.IsDBNull(2) ? 0 : sr.GetInt32(2); int minDuration = sr.IsDBNull(3) ? 0 : sr.GetInt32(3); int maxDuration = sr.IsDBNull(4) ? 0 : sr.GetInt32(4); int avgDuration = sr.IsDBNull(5) ? 0 : sr.GetInt32(5); if (!this.coverageShapes.ContainsKey(shapeId)) { OrchShape os = new OrchShape(); os.Id = shapeId; os.entryCount = inCount; os.exitCount = outCount; os.minDurationMillis = minDuration; os.maxDurationMillis = maxDuration; os.avgDurationMillis = avgDuration; this.coverageShapes.Add(os.Id, os); } }
/// <summary> /// /// </summary> /// <param name="os"></param> /// <returns></returns> private static GraphicsPath GetGpForShape(OrchShape os) { float radius = 3.2f; int x = os.SelectionArea.X; int y = os.SelectionArea.Y; int width = os.SelectionArea.Width; int height = os.SelectionArea.Height; GraphicsPath gp1 = new GraphicsPath(); gp1.AddLine(x + radius, y, x + width - (radius * 2), y); gp1.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90); gp1.AddLine(x + width, y + radius, x + width, y + height - (radius * 2)); gp1.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); gp1.AddLine(x + width - (radius * 2), y + height, x + radius, y + height); gp1.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90); gp1.AddLine(x, y + height - (radius * 2), x, y + radius); gp1.AddArc(x, y, radius * 2, radius * 2, 180, 90); gp1.CloseFigure(); return(gp1); }
/// <summary> /// /// </summary> public XmlDocument GetShapeMetricsAsDom() { if (this.coverageShapes != null && this.coverageShapes.Count > 0) { MemoryStream ms = new MemoryStream(); XmlTextWriter xtw = new XmlTextWriter(ms, Encoding.ASCII); xtw.WriteStartDocument(true); xtw.WriteStartElement("CoverageShapes"); foreach (DictionaryEntry de in this.coverageShapes) { OrchShape os = de.Value as OrchShape; if (os != null) { xtw.WriteStartElement("CoverageShape"); xtw.WriteElementString("Id", os.Id); foreach (OrchShape shape in this.ShapeMap) { if (shape.Id == os.Id) { xtw.WriteElementString("Text", shape.Text); break; } } xtw.WriteElementString("EntryCount", os.entryCount.ToString()); xtw.WriteElementString("ExitCount", os.exitCount.ToString()); double successRate = 0; if (os.entryCount > 0 && os.exitCount > 0) { successRate = (((double)os.exitCount) / ((double)os.entryCount)) * 100; xtw.WriteElementString("SuccessRate", successRate.ToString("###")); } else { xtw.WriteElementString("SuccessRate", "0"); } xtw.WriteElementString("MaxDurationMillis", os.maxDurationMillis.ToString()); xtw.WriteElementString("MinDurationMillis", os.minDurationMillis.ToString()); xtw.WriteElementString("AvgDurationMillis", os.avgDurationMillis.ToString()); xtw.WriteEndElement(); //CoverageShape } } xtw.WriteEndElement(); //CoverageShapes xtw.WriteEndDocument(); xtw.Flush(); ms.Seek(0, SeekOrigin.Begin); XmlDocument doc = new XmlDocument(); doc.Load(ms); xtw.Close(); return(doc); } return(null); }