/// <summary> /// Utility method for quickly formatting a text without having /// to create a TextileFormatter with an IOutputter. /// </summary> /// <param name="input">The string to format</param> /// <returns>The formatted version of the string</returns> public static string FormatString(string input) { StringBuilderOutputter output = new StringBuilderOutputter(); TextileFormatter formatter = new TextileFormatter(output); formatter.Format(input); return(output.GetFormattedText()); }
public DressingRoom() { InitializeComponent(); m_textileOutput = new Textile.StringBuilderOutputter(); m_textileFormatter = new Textile.TextileFormatter(m_textileOutput); System.Reflection.Assembly thisExe = System.Reflection.Assembly.GetExecutingAssembly(); var absolutePathToCustomCss = Path.ChangeExtension(Application.ExecutablePath, ".css"); Stream css; if (File.Exists(absolutePathToCustomCss)) { css = new FileStream(absolutePathToCustomCss, FileMode.Open, FileAccess.Read, FileShare.Read); } else { css = thisExe.GetManifestResourceStream("DressingRoom.Default.css"); } string styleContent; using (css) { using (StreamReader rdr = new StreamReader(css)) { styleContent = rdr.ReadToEnd(); } } m_webBrowser.DocumentText = String.Format(@"<html> <head> <base id='base' /> <style> {0} </style> </head> <body id='body'> </body> </html>", styleContent); var ni = m_textInput.NativeInterface; ni.SetCaretLineBack(Colour(0xdc, 0xff, 0xff)); ni.SetCaretLineVisible(true); m_textInput.Selection.ForeColor = Color.Transparent; m_textInput.Selection.ForeColorUnfocused = Color.Transparent; m_textInput.Selection.BackColor = Color.FromArgb(224, 224, 224); m_textInput.Selection.BackColorUnfocused = Color.FromArgb(240, 240, 240); ni.SetWrapMode((int)WrapMode.Word); SetWrapAwareHomeEndKeys(); // disable links, since we operate on the assumption we can simply substitute the contents of <body> m_webBrowser.AllowNavigation = false; UpdateWindowTitle(); }