public void HandleUrl(Uri uri)
 {
     var key = uri.Query.Substring(uri.Query.IndexOf('=') + 1);
     var data = (from item in _recentLinks where item.Key == key select item).FirstOrDefault();
     if (data == null)
     {
         Debug.Fail("page has more links than we can currently handle");
         return; // give up.
     }
     var content = data.Data;
     try
     {
         var doc = new XmlDocument();
         var conflict = Conflict.CreateFromConflictElement(XmlUtilities.GetDocumentNodeFromRawXml(content, doc));
         var html = "<html>" + conflict.HtmlDetails + "</html>";
         if (HtmlAdjuster != null)
             html = HtmlAdjuster(html);
         if (string.IsNullOrEmpty(html))
         {
             MessageBox.Show("Sorry, no conflict details are recorded for this conflict (it might be an old one). Here's the content:\r\n" + content);
             return;
         }
         using (var conflictForm = new ConflictDetailsForm())
         {
             conflictForm.SetDocumentText(html);
             conflictForm.ShowDialog(Form.ActiveForm);
             return;
         }
     }
     catch (Exception)
     {
     }
     MessageBox.Show("Sorry, conflict details aren't working for this conflict (it might be an old one). Here's the content:\r\n" + content);//uri.ToString());
 }
        public void HandleUrl(Uri uri, string annotationFilePath)
        {
            var key = uri.Query.Substring(uri.Query.IndexOf('=') + 1);
            var data = (from item in _recentLinks where item.Key == key select item).FirstOrDefault();
            if (data == null)
            {
                Debug.Fail("page has more links than we can currently handle");
                return; // give up.
            }
            var content = data.Data;
            try
            {
                var doc = new XmlDocument();
                var conflict = Conflict.CreateFromConflictElement(XmlUtilities.GetDocumentNodeFromRawXml(content, doc));
                var html = @"<html>" + conflict.HtmlDetails + @"</html>";
                if (HtmlAdjuster != null)
                    html = HtmlAdjuster(html);
                if (string.IsNullOrEmpty(html))
                {
                    MessageBox.Show(LocalizationManager.GetString("Messages.NoDetailsRecorded", "Sorry, no conflict details are recorded for this conflict (it might be an old one). Here's the content:") + "\r\n" + content);
                    return;
                }
                using (var conflictForm = new ConflictDetailsForm())
                {
                    doc.LoadXml(content);
                    var detailAttr = doc.DocumentElement.Attributes["htmlDetails"];
                    if (detailAttr != null)
                        doc.DocumentElement.SetAttribute("htmlDetails", "...(see above)...");
                    MemoryStream mStream = new MemoryStream();
                    var settings = new XmlWriterSettings() {NewLineOnAttributes = true, Encoding = Encoding.UTF8, Indent = true};
                    var writer = XmlWriter.Create(mStream, settings);
                    doc.WriteContentTo(writer);
                    writer.Flush();
                    mStream.Flush();
                    mStream.Position = 0;
                    var prettyContent = new StreamReader(mStream).ReadToEnd();

                    // Insert the technical details into the original HTML right at the end.
                    int endOfBody = html.LastIndexOf("</body>");
                    var techHtml = html.Substring(0, endOfBody)
                        + "<div style='margin-top:10pt'>Source file: "
                        + annotationFilePath.Replace("<", "&lt;").Replace(">", "&gt;")
                        + "</div><PRE>"
                        + prettyContent.Replace("<", "&lt;").Replace(">", "&gt;")
                        + "</PRE>"
                        + html.Substring(endOfBody);

                    conflictForm.TechnicalDetails = techHtml;
                    conflictForm.SetDocumentText(html);
                    conflictForm.ShowDialog(Form.ActiveForm);
                    return;
                }
            }
            catch (Exception)
            {
            }
            MessageBox.Show(LocalizationManager.GetString("Messages.DetailsNotWorking", "Sorry, conflict details aren't working for this conflict (it might be an old one). Here's the content:") + "\r\n" + content);//uri.ToString());
        }