private void RenderFiles() { if (leftFile == null && rightFile == null) { return; } Block result = null; if (leftFile == null) { result = rightFile.DiffWith(rightFile); } else if (rightFile == null) { result = leftFile.DiffWith(leftFile); } else { result = leftFile.DiffWith(rightFile); } // Render result :-) Graphics tempGraphics = CreateGraphics(); float longestLine = GetLongestLine(result, tempGraphics); int lines = GetNumberOfLines(result); int width = (int)Math.Ceiling(longestLine); bool evenLine = false; RenderResult graphics = RenderBlock(result, width, ref evenLine); // Set the fiels where we have something to set panelLeft.Controls.Clear(); panelRight.Controls.Clear(); if (leftFile != null) { panelLeft.Controls.Add(new PictureBox { Top = 0, Left = 0, Height = graphics.Left.Height, Width = graphics.Left.Width, Image = graphics.Left, }); } if (rightFile != null) { panelRight.Controls.Add(new PictureBox { Top = 0, Left = 0, Height = graphics.Right.Height, Width = graphics.Right.Width, Image = graphics.Right, }); } }
static void Main(string[] args) { ComparableXmlFile originalFile = new ComparableXmlFile(args[0]); ComparableXmlFile changedFile = new ComparableXmlFile(args[1]); Block diff = originalFile.DiffWith(changedFile); Assembly assembly = typeof(StructuredFileDiff.Cmd.Program).Assembly; string templateString = ReadResource(assembly, "XmlDiffTest.Resources.template.html"); string rowString = ReadResource(assembly, "XmlDiffTest.Resources.row.html"); Template htmlTemplate = Template.Parse(templateString); Template rowTemplate = Template.Parse(rowString); string tableContent = CreateTable(rowTemplate, diff, String.Empty, String.Empty); string output = htmlTemplate.Render(new { tableContent = tableContent, }); Console.WriteLine(output); }