public PlotResult CalculatePlot(double aspectRatio, DependencyGraph <string> graph, AssemblyFilterPreferences filterPreferences) { const double widthInches = 100; var heightInches = (double)(int)(widthInches / aspectRatio); // node [color=lightblue2, style=filled]; // page=""8.5,11"" // size=""7.5, 10"" // ratio=All // widthInches = 75; // heightInches = 100; var extraCommands = string.Format("size=\"{0},{1}\"\r\n center=\"\"\r\n ratio=All\r\n node[width=.25,hight=.375,fontsize=12,color=lightblue2,style=filled]", widthInches, heightInches); var dotCommand = new DotCommandBuilder().GenerateDotCommand(graph, filterPreferences, extraCommands); // a temp file to store image var tempFile = _tempFileManager.CreateTemporaryFile(); // generate dot image var dot = new DOTClass(); dot.ToPNG(dotCommand).Save(tempFile); var dotImage = Image.FromFile(tempFile); // generate SVG var svgXml = dot.ToSvg(dotCommand); return(new PlotResult { DotCommand = dotCommand, Image = dotImage, SvgXml = svgXml }); }
public static PlotResult CalculatePlot(double aspectRatio, DependencyGraph<string> graph, AssemblyFilterPreferences filterPreferences) { const double widthInches = 100; var heightInches = (double)(int)(widthInches / aspectRatio); // node [color=lightblue2, style=filled]; // page=""8.5,11"" // size=""7.5, 10"" // ratio=All // widthInches = 75; // heightInches = 100; var extraCommands = $"size=\"{widthInches},{heightInches}\"\r\n center=\"\"\r\n ratio=All\r\n node[width=.25,hight=.375,fontsize=12,color=lightblue2,style=filled]"; var dotCommand = DotCommandBuilder.Generate(graph, filterPreferences, extraCommands); // a temp file to store image var tempFile = TemporaryFileManager.CreateTemporaryFile(); // generate dot image var dot = new DOTClass(); dot.ToPNG(dotCommand).Save(tempFile); var dotImage = Image.FromFile(tempFile); // generate SVG var svgXml = dot.ToSvg(dotCommand); return new PlotResult { DotCommand = dotCommand, Image = dotImage, SvgXml = svgXml }; }
//private bool _valid; public Dot() { try { dot = new DOTClass(); } catch (AccessViolationException) { throw new DotAccessException(); } catch (COMException) { throw new DotInitException(); } }
/// <summary> /// Builds the class content control. /// </summary> /// <param name="classData">The class data.</param> /// <returns></returns> public static Control BuildClassContentControl(DOTClass classData) { Table table = new Table(); table.ID = "tblContent" + classData.Period; table.Style.Add("width", "100%"); table.CellPadding = 5; TableRow row = null; int count = 0; foreach (StudentProfile profile in classData.Students) { if ((count % 5) == 0) { if (row != null) table.Rows.Add(row); row = new TableRow(); } TableCell td1 = new TableCell { CssClass = "ProfileImg" }; Image studentImg = new Image { ImageUrl = "~/images/" + profile.Image }; LiteralControl name = new LiteralControl { Text = "<br />" + profile.Name }; LiteralControl homeTown = new LiteralControl { Text = "<br />" + profile.Hometown }; td1.Controls.Add(studentImg); td1.Controls.Add(name); td1.Controls.Add(homeTown); if (row != null) { row.Cells.Add(td1); } count++; } if(row != null) table.Rows.Add(row); return table; }
/// <summary> /// Loads the DOT classes. /// </summary> /// <returns></returns> public static List<DOTClass> LoadDOTClasses() { List<DOTClass> classes = new List<DOTClass>(); XmlDocument doc = new XmlDocument(); doc.Load(HttpContext.Current.Server.MapPath("StudentProfiles.xml")); const string xpath = "studentprofiles"; XmlNode node = doc.SelectSingleNode(xpath); if (node != null) { foreach(XmlNode classNode in node.ChildNodes) { DOTClass dotClass = new DOTClass(); List<StudentProfile> profiles = new List<StudentProfile>(); dotClass.Period = classNode.Attributes.GetNamedItem("period").Value; XmlNode dayNode = classNode.SelectSingleNode("day"); if (dayNode != null) { dotClass.DayClassImage = dayNode.Attributes.GetNamedItem("image").Value; foreach (XmlNode childNode in dayNode.ChildNodes) { StudentProfile profile = new StudentProfile { ClassTime = "Day", Name = childNode.Attributes.GetNamedItem("name").Value, Image = childNode.Attributes.GetNamedItem("image").Value, Hometown = childNode.Attributes.GetNamedItem("hometown").Value, Testimonial = childNode.Attributes.GetNamedItem("testimonial").Value }; profiles.Add(profile); } } XmlNode eveningNode = classNode.SelectSingleNode("evening"); if (eveningNode != null) { dotClass.EveningClassImage = eveningNode.Attributes.GetNamedItem("image").Value; foreach (XmlNode childNode in eveningNode.ChildNodes) { StudentProfile profile = new StudentProfile { ClassTime = "Evening", Name = childNode.Attributes.GetNamedItem("name").Value, Image = childNode.Attributes.GetNamedItem("image").Value, Hometown = childNode.Attributes.GetNamedItem("hometown").Value, Testimonial = childNode.Attributes.GetNamedItem("testimonial").Value }; profiles.Add(profile); } } dotClass.Students = profiles; classes.Add(dotClass); } } return classes; }
/// <summary> /// Builds the class header control. /// </summary> /// <param name="classData">The class data.</param> /// <returns></returns> public static Control BuildClassHeaderControl(DOTClass classData) { Table table = new Table(); table.ID = "tblHeader" + classData.Period; table.Style.Add("width", "100%"); TableRow row = new TableRow(); TableCell tdDay; TableCell tdEvening; if (!string.IsNullOrEmpty(classData.DayClassImage)) { tdDay = new TableCell(); tdDay.Style.Add("text-align", "center"); Image img1 = new Image { ImageUrl = "~/images/" + classData.DayClassImage }; LiteralControl lit1 = new LiteralControl { Text = "<br />Day Class" }; tdDay.Controls.Add(img1); tdDay.Controls.Add(lit1); row.Cells.Add(tdDay); } if (!string.IsNullOrEmpty(classData.EveningClassImage)) { tdEvening = new TableCell(); tdEvening.Style.Add("text-align", "center"); Image img2 = new Image { ImageUrl = "~/images/" + classData.EveningClassImage }; LiteralControl lit2 = new LiteralControl { Text = "<br />Evening Class" }; tdEvening.Controls.Add(img2); tdEvening.Controls.Add(lit2); row.Cells.Add(tdEvening); } foreach (TableCell cell in row.Cells) { cell.Style.Add("width", (100 / row.Cells.Count) + "%"); } table.Rows.Add(row); return table; }