Esempio n. 1
0
        void OnSboStatementDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (webSboStatement.Document != null)
            {
                IHTMLDocument2 currentDocument = (IHTMLDocument2)webSboStatement.Document.DomDocument;

                int             length     = currentDocument.styleSheets.length;
                IHTMLStyleSheet styleSheet = currentDocument.createStyleSheet(@"", length + 1);
                styleSheet.cssText = Css.SboStatements;
            }
        }
Esempio n. 2
0
        private static void SetupWebBrowserCSS(WebBrowser browser)
        {
            IHTMLDocument2 doc = (IHTMLDocument2)browser.Document;

            if (doc == null)
            {
                return;
            }

            IHTMLStyleSheet ss = doc.createStyleSheet("", 0);

            ss.cssText = GetCSSStyle(browser);
        }
Esempio n. 3
0
        private void WebBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            IHTMLDocument2  doc = (webBrowser1.Document.DomDocument) as IHTMLDocument2;
            IHTMLStyleSheet ss  = doc.createStyleSheet("", 0);

            if (BlackBg == true)
            {
                ss.cssText = "body {background-color: #000000;}"; // GetCssText();
            }
            else
            {
                ss.cssText = "body {background-color: #FFFFFF;}";
            }
        }
Esempio n. 4
0
        void webLogs_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            logDoc    = webLogs.Document;
            logDocRaw = (IHTMLDocument2)logDoc.DomDocument;
            IHTMLStyleSheet ss = logDocRaw.createStyleSheet("", 0);

            ss.cssText = Properties.Resources.defaultTemplate;

            var myScript = logDoc.CreateElement("script");

            ((IHTMLScriptElement)myScript.DomElement).text = Properties.Resources.hoverJavaScript;

            // logDoc.Body.AppendChild(myStyle);
            logDoc.Body.AppendChild(myScript);
            Debug.WriteLine(logDoc.Body.InnerHtml);
        }
Esempio n. 5
0
        // Add CSS styling to the webBrowser object
        private void InitCSS()
        {
            IHTMLDocument2 document = (webBrowserDescription.Document.DomDocument) as IHTMLDocument2;

            // The first parameter is the url, the second is the index of the added style sheet.
            IHTMLStyleSheet styleSheet = document.createStyleSheet("", 0);

            // Change the font for everything in the document. Font list taken from the Github readme page
            int index = styleSheet.addRule("*", "font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\";");

            // Edit existing rules
            // styleSheet.cssText = @"h1 { color: blue; }";

            // Remove existing rules
            // styleSheet.removeRule(index);
        }
Esempio n. 6
0
        private void AdaptChangelog(object sender, EventArgs e)
        {
            IHTMLDocument2 doc = (wbChangelog.Document.DomDocument) as IHTMLDocument2;
            // The first parameter is the url, the second is the index of the added style sheet.
            IHTMLStyleSheet ss = doc.createStyleSheet("", 0);

            // Now that you have the style sheet you have a few options:
            // 1. You can just set the content as text.
            ss.cssText = @"#pageHeaderContainer { display: none; } .cookiePolicyNotice { display: none; } .toTop { display: none !important; } #main { padding-top: 10px !important; } .articleList > li:not(:first-child) { margin-top: 20px !important; } #content > .section { margin-top: 10px; }";

            HtmlElement        head     = wbChangelog.Document.GetElementsByTagName("head")[0];
            HtmlElement        scriptEl = wbChangelog.Document.CreateElement("script");
            IHTMLScriptElement element  = (IHTMLScriptElement)scriptEl.DomElement;

            element.text = @"function check() { if (typeof $ === 'undefined' || window.ada) { return; } $(document).ready(function() { if($('.contentTitle').text() !== 'Artikel') { $('.contentTitle').prepend('<a onclick=\'window.history.back();\'><<</a> '); window.ada = true; } }); }";
            head.AppendChild(scriptEl);
            wbChangelog.Document.InvokeScript("check");
        }
Esempio n. 7
0
        // When the WebBrowser control's document is fully loaded:
        // Style the web page with Resources/styles.css and add LinkClicked event handlers to all the hyperlinks.
        private void wb_Licenses_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            // Get our styles.css resource
            ResourceManager res        = new ResourceManager(RESOURCE_LIB_NAME, typeof(ZeroMunge).Assembly);
            string          stylesheet = (string)res.GetObject("stylesheet");

            // Set the web page's stylesheet
            IHTMLDocument2  doc = (IHTMLDocument2)wb_Licenses.Document.DomDocument;
            IHTMLStyleSheet ss  = doc.createStyleSheet("", 0);

            ss.cssText = @stylesheet;


            // Add LinkClicked event handlers to all the links in the page
            foreach (HtmlElement link in wb_Licenses.Document.Links)
            {
                link.Click += wb_Licenses_LinkClicked;
            }
        }
Esempio n. 8
0
        /// <summary>
        /// This is called when the initial html/body framework is set up,
        /// or when document.DocumentText is set.  At this point, the
        /// document is editable.
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">navigation args</param>
        private void this_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            TableEditor = new HtmlTableHelper(this);

            SetBackgroundColor(BackColor);

            IHTMLStyleSheet style = htmlDoc.createStyleSheet("", 0);

            style.cssText = @"table, th, td { border-collapse: collapse; border-color: black } "; //table, th, td { border: 1px solid black; }

            Ready(sender);

            // register for change notification
            IMarkupContainer2 cont2 = (IMarkupContainer2)htmlDoc;
            uint m_cookie;

            cont2.RegisterForDirtyRange(this, out m_cookie);

            // register for key/mouse events
            SetEditDesigner();
        }
        private void AddStyles()
        {
            try
            {
                if (webBrowser.Document != null)
                {
                    IHTMLDocument2 currentDocument = (IHTMLDocument2)webBrowser.Document.DomDocument;

                    int             length     = currentDocument.styleSheets.length;
                    IHTMLStyleSheet styleSheet = currentDocument.createStyleSheet(@"", length + 1);
                    //length = currentDocument.styleSheets.length;
                    //styleSheet.addRule("body", "background-color:blue");
                    TextReader reader = new StreamReader(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Styles/table_style.css"));
                    string     style  = reader.ReadToEnd();
                    styleSheet.cssText = style;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public void InitializeStyleSheet()
 {
     css         = doc.createStyleSheet("", 0);
     css.cssText = File.ReadAllText("github-markdown.css");
 }
Esempio n. 11
0
 public void GetPage()
 {
     doc = (webBrowser1.Document.DomDocument) as IHTMLDocument2;
     ss = doc.createStyleSheet("", 0);
     url = webBrowser1.Url.ToString();
     title = webBrowser1.DocumentTitle;
 }
Esempio n. 12
0
        void webLogs_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            logDoc = webLogs.Document;
            logDocRaw = (IHTMLDocument2)logDoc.DomDocument;
            IHTMLStyleSheet ss = logDocRaw.createStyleSheet("", 0);
            ss.cssText = Properties.Resources.defaultTemplate;

            var myScript = logDoc.CreateElement("script");
            ((IHTMLScriptElement)myScript.DomElement).text = Properties.Resources.hoverJavaScript;

            // logDoc.Body.AppendChild(myStyle);
            logDoc.Body.AppendChild(myScript);
            Debug.WriteLine(logDoc.Body.InnerHtml);
        }
Esempio n. 13
0
 public IHTMLStyleSheet createStyleSheet(string bstrHref, int lIndex)
 {
     return(_innerDoc2.createStyleSheet(bstrHref, lIndex));
 }