public static void CreateHTMLFile(RadDiagram diagram, string jsRadSVGFilePath = RadSVGFilePath, string jsRadDiagramFilePath = RadDiagramFilePath) { string htmlContent = string.Empty; htmlContent += HTMLExportHelper.DocumentStart; htmlContent += HTMLExportHelper.HeadStart; htmlContent += LoadStringFromFile(jsRadSVGFilePath); htmlContent += LoadStringFromFile(jsRadDiagramFilePath); var serialization = diagram.Serialize(); htmlContent += "var diagramXML = '" + serialization.ToString().Replace(System.Environment.NewLine, " ") + "'; \n"; htmlContent += LoadStringFromFile(JSInteractionsFilePath); htmlContent += HTMLExportHelper.ScriptEnd; htmlContent += LoadStringFromFile(ExportStyleFilePath); htmlContent += HTMLExportHelper.HeadEnd; htmlContent += HTMLExportHelper.Body; htmlContent += HTMLExportHelper.DocumentEnd; try { var saveFileDialog = new SaveFileDialog() { Filter = "HTML (.html;*.htm)|*.html;*.htm|All Files (*.*)|*.*" }; var result = saveFileDialog.ShowDialog(); if (result == true) { using (var fileStream = saveFileDialog.OpenFile()) { using (var writer = new StreamWriter(fileStream)) { writer.Write(htmlContent); } } #if WPF Process.Start(saveFileDialog.FileName); #endif } } catch (Exception exc) { #if WPF if (exc is Win32Exception) { // error finding the file } else #endif if (exc is ObjectDisposedException || exc is FileNotFoundException) { //failed to start the default browser or HTML viewer } else { throw; } } }
public static void CreateHTMLFile(RadDiagram diagram, string jsRadSVGFilePath = RadSVGFilePath, string jsRadDiagramFilePath = RadDiagramFilePath) { string htmlContent = string.Empty; htmlContent += HTMLExportHelper.DocumentStart; htmlContent += HTMLExportHelper.HeadStart; htmlContent += LoadStringFromFile(jsRadSVGFilePath); htmlContent += LoadStringFromFile(jsRadDiagramFilePath); var serialization = diagram.Serialize(); htmlContent += "var diagramXML = '" + serialization.ToString().Replace(System.Environment.NewLine, " ") + "'; \n"; htmlContent += LoadStringFromFile(JSInteractionsFilePath); htmlContent += HTMLExportHelper.ScriptEnd; htmlContent += LoadStringFromFile(ExportStyleFilePath); htmlContent += HTMLExportHelper.HeadEnd; htmlContent += HTMLExportHelper.Body; htmlContent += HTMLExportHelper.DocumentEnd; try { var saveFileDialog = new SaveFileDialog() { Filter = "HTML (.html;*.htm)|*.html;*.htm|All Files (*.*)|*.*" }; var result = saveFileDialog.ShowDialog(); if (result == true) { using (var fileStream = saveFileDialog.OpenFile()) { using (var writer = new StreamWriter(fileStream)) { writer.Write(htmlContent); } } #if WPF Process.Start(saveFileDialog.FileName); #endif } } catch (Exception exc) { #if WPF if (exc is Win32Exception) { // error finding the file } else #endif if (exc is ObjectDisposedException || exc is FileNotFoundException) { //failed to start the default browser or HTML viewer } else throw; } }