Пример #1
0
        private string MarkupConverterRTFToHTML(string rtfString)
        {
            string html      = "";
            var    rtfSource = rtfString;

            if (rtfSource != null)
            {
                using (WebBrowser web = new WebBrowser())
                {
                    web.CreateControl();
                    web.DocumentText = rtfSource;
                    while (web.DocumentText != rtfSource)
                    {
                        Application.DoEvents();
                    }
                    web.Document.ExecCommand("SelectAll", false, null);
                    web.Document.ExecCommand("Copy", false, null);
                }

                using (RichTextBox rtBox = new RichTextBox())
                {
                    rtBox.Paste();
                }

                html = Clipboard.GetData(DataFormats.Html) as string;
            }
            return(html);
        }
Пример #2
0
        public void RenderDescription(string text)
        {
            var webBrowser = new WebBrowser();

            webBrowser.CreateControl(); // only if needed
            webBrowser.DocumentText = ($"<html><body>{text}</body></html>");
            Application.DoEvents();
            webBrowser.Document.ExecCommand("SelectAll", false, null);
            webBrowser.Document.ExecCommand("Copy", false, null);
            textRender.Paste();
        }
Пример #3
0
 public bool Open(string u)
 {
     Controls.Add(b);
     b.CreateControl();
     CreateControl();
     Show();
     url     = u;
     loaded  = false;
     loadpct = 0;
     b.Navigate(url);
     return(true);
 }
Пример #4
0
        void Application_ItemSend(object item, ref bool cancel)
        {
            var useMarkdown = false;
            var mailItem    = item as MailItem;
            var meetingItem = item as MeetingItem;

            if (mailItem != null)
            {
                useMarkdown = Utility.GetUserProperty <bool>(mailItem, Constants.EnableMarkdownModeFlag);
                if (useMarkdown)
                {
                    mailItem.HTMLBody = RenderMarkdown(mailItem.Body);
                }
            }
            else if (meetingItem != null)
            {
                useMarkdown = Utility.GetUserProperty <bool>(meetingItem, Constants.EnableMarkdownModeFlag);
                if (useMarkdown)
                {
                    // Use web browser to convert HTML to RTF
                    var webBrowser = new WebBrowser();
                    var htmlText   = RenderMarkdown(meetingItem.Body);
                    webBrowser.CreateControl();
                    webBrowser.DocumentText = htmlText;
                    while (webBrowser.DocumentText != htmlText)
                    {
                        System.Windows.Forms.Application.DoEvents();
                    }
                    if (webBrowser.Document != null)
                    {
                        webBrowser.Document.ExecCommand("SelectAll", false, null);
                        webBrowser.Document.ExecCommand("Copy", false, null);
                    }
                    var i = new RichTextBox();
                    i.Paste();

                    meetingItem.RTFBody = Encoding.ASCII.GetBytes(i.Rtf);
                    webBrowser.Dispose();
                }
            }
        }
        public void SetupBrowser()
        {
            RenderWindow rw = (Root.Instance.RenderSystem as D3D9RenderSystem).PrimaryWindow;
            Control      c  = (Control)rw.GetCustomAttribute("HWND");

            // dummy label used to 'unfocus' the browser
            dummy          = new Label();
            dummy.Size     = new Size(1, 1);
            dummy.Location = new Point(1, 1);
            Controls.Add(dummy);
            dummy.CreateControl();

            b = new WebBrowser();
            PositionBrowser();
            Controls.Add(b);
            b.CreateControl();
            b.BringToFront();
            c.Controls.Add(this);

            CreateControl();
        }
        static void BuildFile(string fileName, string classFileName)
        {
            WebBrowser wBrowser = new WebBrowser();

            wBrowser.CreateControl();
            wBrowser.Navigate(new Uri(WebUI.ResultsWebServer.Uri, "ServicesList.aspx"));
            WebBrowserHelper.Wait(wBrowser);

            HtmlDocument doc      = WebBrowserHelper.GetDocument(wBrowser);
            string       template = wBrowser.DocumentText;

            GenerateDocument(wBrowser);
            int bodyidx = template.IndexOf("<body>");

            template = template.Substring(0, bodyidx);
            StringBuilder body = new StringBuilder(doc.Body.OuterHtml);

            body.Replace("FONT-SIZE: 8.25pt;", "");
            body.Replace("FONT-FAMILY: Tahoma;", "");
            body.Replace("MARGIN: -7px;", "");
            body.Replace("</BODY>", "<br><span style='color: gray;'>Generated by : " + FreeCL.RTL.ApplicationInfo.ProductName + ", version :" + FreeCL.RTL.ApplicationInfo.ProductVersion + "</span></body>");


            string       result = template + body.ToString() + "\r\n</html>";
            FileStream   fs     = new FileStream(fileName, FileMode.Create);
            StreamWriter sw     = new StreamWriter(fs, Encoding.UTF8);

            sw.Write(result);
            sw.Flush();
            sw.Dispose();
            wBrowser.Dispose();

            fs = new FileStream(classFileName, FileMode.Create);
            string className = Path.GetFileNameWithoutExtension(classFileName);

            sw = new StreamWriter(fs, Encoding.BigEndianUnicode);
            sw.Write("import java.applet.*;\r\n\r\n");
            sw.Write("public class ");
            sw.Write(className);
            sw.Write(" extends Applet{\r\npublic String d(){\r\n");
            int           i = 0;
            int           cnt;
            StringBuilder substr;
            int           var_num = 0;

            while (i < result.Length)
            {
                cnt = 16384;
                if (i + cnt > result.Length)
                {
                    cnt = result.Length - i;
                }
                substr = new StringBuilder(result.Substring(i, cnt));
                substr.Replace("\"", "\\\"");
                substr.Replace("\r", "\\r");
                substr.Replace("\n", "\\n");
                sw.Write("String s");
                sw.Write(var_num.ToString());
                var_num++;
                sw.Write(" = ");
                sw.Write("\"" + substr.ToString() + "\";\r\n");
                i += 16384;
            }
            sw.Write("return ");
            for (i = 0; i < var_num; i++)
            {
                sw.Write("s");
                sw.Write(i.ToString());
                if (i + 1 < var_num)
                {
                    sw.Write("+");
                }
            }
            sw.Write(";\r\n}\r\n}");
            sw.Flush();
            sw.Dispose();
            wBrowser.Dispose();
        }