Пример #1
0
        /// <summary>
        /// スタイルシートを適用します。
        /// </summary>
        public void ApplyStyleSheet()
        {
            if (!Configuration.AppliesStyleSheet)
            {
                return;
            }

            try {
                var document = Browser.Document;
                if (document == null)
                {
                    return;
                }

                var gameframe = document.GetElementById("game_frame");
                if (gameframe == null)
                {
                    if (document.Url.AbsolutePath.Contains(".swf?"))
                    {
                        gameframe = document.Body;
                    }
                }

                if (gameframe == null)
                {
                    return;
                }


                var target = gameframe.Document;

                if (target != null)
                {
                    mshtml.IHTMLStyleSheet ss = ((mshtml.IHTMLDocument2)target.DomDocument).createStyleSheet("", 0);

                    ss.cssText = Configuration.StyleSheet;


                    StyleSheetApplied = true;
                }
            } catch (Exception ex) {
                BrowserHost.AsyncRemoteRun(() =>
                                           BrowserHost.Proxy.SendErrorReport(ex.ToString(), "スタイルシートの適用に失敗しました。"));
            }
        }
Пример #2
0
        private void WebBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            //Try to load a css override from ~/.edseditor/style.css first then fallback to installed default

            string csspath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".edseditor");

            csspath = Path.Combine(csspath, "style.css");

            if (!File.Exists(csspath))
            {
                csspath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "style.css");
            }

            if (!File.Exists(csspath))
            {
                return;
            }

            string text = System.IO.File.ReadAllText(csspath);

            mshtml.HTMLDocument    CurrentDocument = (HTMLDocument)webBrowser1.Document.DomDocument;
            mshtml.IHTMLStyleSheet styleSheet      = CurrentDocument.createStyleSheet("", 0);
            styleSheet.cssText = text;
        }