/// <summary> /// /// </summary> /// <param name="orchestration"></param> /// <returns></returns> public static Rectangle GetOrchImageSize(Orchestration orchestration) { OrchViewer ov = new OrchViewer(); string text1 = string.Empty; Rectangle maxRect = new Rectangle(0, 0, 0, 0); if (orchestration.ViewData != string.Empty) { int width = 1; int height = 1; Bitmap bmp = new Bitmap(width, height); Graphics memGraphic = Graphics.FromImage(bmp); XLANGView.XsymFile.ReadXsymFromString(ov.Root, orchestration.ViewData, false, ref text1); PageSettings ps = new PageSettings(); Rectangle marginBounds = new Rectangle(0, 0, width, height); PrintPageEventArgs args = new PrintPageEventArgs( memGraphic, marginBounds, marginBounds, ps); maxRect = ov.DoPrintWithSize(args); ps = null; args = null; memGraphic.Dispose(); bmp.Dispose(); } ov.Dispose(); return(maxRect); }
public Bitmap GetImage(bool includeCoverage) { return(OrchViewer.GetOrchestationImage(this, includeCoverage)); }
public Bitmap GetImage() { return(OrchViewer.GetOrchestationImage(this, false)); }
public bool SaveAsImage(string fileName) { return(OrchViewer.SaveOrchestrationToJpg(this, fileName)); }
/// <summary> /// /// </summary> /// <param name="orchestration"></param> /// <returns></returns> public static Bitmap GetOrchestationImage(Orchestration orchestration, bool drawWithCoverage) { OrchViewer ov = new OrchViewer(); string text1 = string.Empty; if (orchestration.ViewData != string.Empty) { XLANGView.XsymFile.ReadXsymFromString(ov.Root, orchestration.ViewData, false, ref text1); PageSettings ps = new PageSettings(); Rectangle maxRect = GetOrchImageSize(orchestration); Bitmap realBmp = new Bitmap(maxRect.Width, maxRect.Height); Graphics realGraphic = Graphics.FromImage(realBmp); PrintPageEventArgs realArgs = new PrintPageEventArgs( realGraphic, maxRect, maxRect, ps); // Set background colour realGraphic.FillRectangle(new SolidBrush(Color.White), maxRect); // Draw the orch image ov.DoPrintWithSize(realArgs); bool drawHotspots = false; try { // Decide whether we need hotspots or not object drawHotspotsObj = new AppSettingsReader().GetValue("ShowHotSpots", typeof(int)); if (drawHotspotsObj != null) { int tmp = Convert.ToInt32(drawHotspotsObj); if (tmp == 1) { drawHotspots = true; } } } catch (Exception ex) { TraceManager.SmartTrace.TraceError(ex); } GetSelectionAreas(realGraphic, ov.Root, orchestration, drawHotspots); if (drawWithCoverage) { DrawCoverageAreas(realGraphic, ov.Root, orchestration, null); } ps = null; realArgs = null; ov.Dispose(); realGraphic.Dispose(); return(realBmp); } else { string errorText = "Unable to load image for orchestration"; Font f = new Font("Arial", 9, FontStyle.Bold); int fontHeight = (int)f.GetHeight() + 5; int errorWidth = MeasureStringWidth(errorText, f); int nameWidth = MeasureStringWidth(orchestration.Name, f); int w = Math.Max(errorWidth, nameWidth) + 50; int h = 100; SolidBrush titleBrush = new SolidBrush(Color.Black); Bitmap bmp = new Bitmap(w, h); Graphics g = Graphics.FromImage(bmp); g.FillRectangle(new SolidBrush(Color.White), 0, 0, w, h); g.DrawString(errorText, f, titleBrush, (bmp.Width / 2) - (errorWidth / 2), 10); g.DrawString(orchestration.Name, f, titleBrush, (bmp.Width / 2) - (nameWidth / 2), 10 + fontHeight); return(bmp); } }