Пример #1
0
        /// <summary>
        /// Inserts the given HTML code inside or outside of this Html element
        /// There are 4 possible insert positions:
        /// Outside-Before<TAG>Inside-Before InnerHTML Inside-After</TAG>Ouside-After
        /// </summary>
        /// <param name="elem"></param>
        /// <param name="s_Html"></param>
        /// <param name="b_AtBegin"></param>
        /// <param name="b_Inside"></param>
        public void InsertHTML(IHTMLElement elem, string s_Html, bool b_AtBegin, bool b_Inside)
        {
            if (elem == null)
            {
                return;
            }
            string bs_Where;

            if (b_Inside)
            {
                if (b_AtBegin)
                {
                    bs_Where = "afterBegin";
                }
                else
                {
                    bs_Where = "beforeEnd";
                }
            }
            else // Outside
            {
                if (b_AtBegin)
                {
                    bs_Where = "beforeBegin";
                }
                else
                {
                    bs_Where = "afterEnd";
                }
            }
            elem.insertAdjacentHTML(bs_Where, s_Html);
        }
Пример #2
0
        /// <summary>
        /// 受信
        /// </summary>
        private void    Receive()
        {
            string returnhtml;

            while (!string.IsNullOrEmpty(returnhtml = Environment.Is64BitProcess ? CmdPop64(): CmdPop32()))
            {
                if (_error)
                {
                    // エラー表示した場合は標準メッセージをスキップ
                    _error = false;
                    continue;
                }
                string returnhtml2 = HtmlEncode(returnhtml);
                if (returnhtml2.StartsWith("ERR:"))
                {
                    returnhtml2 = "<font color=\"#ff0000\">" + returnhtml2.Remove(0, 4) + "</font>";
                    _error      = true;
                }
                DateTime dt   = DateTime.Now;
                string   html = "<div class=\"result\"><div class=\"icon\"><img></div><div id=\"box1\"><div class=\"output\"><pre>";
                html += returnhtml2;
                html += string.Format("</pre></div></div><div id=\"box2\">{0:D2}:{1:D2}</div></div>", dt.Hour, dt.Minute);

                IHTMLElement elm2 = _htmlDoc2.body;
                elm2.insertAdjacentHTML("beforeend", html);
                ScrollBottom(_htmlDoc2);
            }
            this.brow.IsEnabled = true;
            this.edit.IsEnabled = true;
            this.edit.Focus();
            this.Title = Directory.GetCurrentDirectory();
        }
Пример #3
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            //Implement logic to insert Javascript and div elements to the browser

            HTMLDocument oDocument = (HTMLDocument)oWebbrowser.Document;

            IHTMLElement oHead = (IHTMLElement)IHTMLElementCollection)oDocument.all.tags("head")).item(null, 0);

            IHTMLScriptElement scriptObject = (IHTMLScriptElement)oDocument.createElement("script");
            scriptObject.type = @"text/javascript";
            scriptObject.text = "function hidediv(){document.getElementById('mydiv').style.visibility = 'hidden';}";
            ((HTMLHeadElement)oHead).appendChild((IHTMLDOMNode)scriptObject);


            IHTMLElement body = (IHTMLElement)oDocument.body;
            body.insertAdjacentHTML("afterBegin", "&lt;div id=\"mydiv\" style=\"position:absolute;z-index:2000000;top:50%;left:50%;width:300px;height:300px;margin-top:-150px;margin-left:-150px;background:#000;\"/>Hello World
& lt; a href =\"javascript:hidediv();\">close&lt;/a>&lt;/div>");
Пример #4
0
        /// <summary>
        /// 送信
        /// </summary>
        private void    Send()
        {
            if (!this.edit.IsFocused)
            {
                this.edit.Focus();
            }

            string command     = this.edit.Text;
            int    nTextLength = command.Length;

            if (0 == nTextLength)
            {
                command = "\n";
            }
            else
            {
                _rngBuf.Add(command);
            }

            string   szCommand2 = HtmlEncode(command);
            DateTime dt         = DateTime.Now;
            string   html       = string.Format("<div id=\"box2\">既読<br>{0:D2}:{1:D2}</div><div id=\"box1\"class=\"input\"><pre>", dt.Hour, dt.Minute);

            html += "\n" == szCommand2 ? "⏎": szCommand2;
            html += "</pre></div>";

            IHTMLElement elm2 = _htmlDoc2.body;

            elm2.insertAdjacentHTML("beforeend", html);
            ScrollBottom(_htmlDoc2);

            this.edit.Text      = "";
            this.brow.IsEnabled = false;
            this.edit.IsEnabled = false;
            bool rc = Environment.Is64BitProcess ? CmdRun64(command): CmdRun32(command);
        }
Пример #5
0
        /// <summary>
        /// Constructor del nodo
        /// </summary>
        /// <param name="padre">Nodo padre en el arbol de capitulos. Nulo si es la raiz</param>
        /// <param name="nodo">Nodo HTML header correspondiente. Nulo si es la raiz</param>
        public NodoArbol(NodoArbol padre, IHTMLElement nodo)
        {
            this.Padre = padre;
            this.Nodo = nodo;
            Hijos = new ArrayList();
            Nivel = NivelNodo( nodo );
            Archivo = "";

            // Guardar la lista de los todos las referencias de este nodo ( nodos <A> con la propiedad "name")
            listaANames = new ArrayList();
            if( nodo != null )
            {
                IHTMLElementCollection col = (IHTMLElementCollection) nodo.children;
                foreach( IHTMLElement hijo in col )
                {
                    if (hijo is IHTMLAnchorElement)
                    {
                        // Remove empty spaces, because they will fail into the CHM.
                        // The anchors to this will be replace too after.
                        //listaANames.Add( ((IHTMLAnchorElement)hijo).name.Replace( " " , "" ) );
                        string processedName = ToSafeFilename( ((IHTMLAnchorElement)hijo).name );
                        listaANames.Add(processedName);
                    }
                }
                if( listaANames.Count == 0 )
                {
                    // Si no tiene ningun nombre, darle uno artificial:
                    int numero = UltimoNumeroAname++;
                    string nombreNodo = "NODO" + numero.ToString().Trim();
                    string tagA = "<a name=\"" + nombreNodo + "\">";
                    nodo.insertAdjacentHTML( "afterBegin" , tagA );
                    listaANames.Add( nombreNodo );
                }
            }
        }
 /// <summary>
 /// Inserts the given HTML code inside or outside of this Html element
 /// There are 4 possible insert positions:
 /// Outside-Before<TAG>Inside-Before InnerHTML Inside-After</TAG>Ouside-After
 /// </summary>
 /// <param name="elem"></param>
 /// <param name="s_Html"></param>
 /// <param name="b_AtBegin"></param>
 /// <param name="b_Inside"></param>
 public void InsertHTML(IHTMLElement elem, string s_Html, bool b_AtBegin, bool b_Inside)
 {
     if (elem == null)
         return;
     string bs_Where;
     if (b_Inside)
     {
         if (b_AtBegin) bs_Where = "afterBegin";
         else bs_Where = "beforeEnd";
     }
     else // Outside
     {
         if (b_AtBegin) bs_Where = "beforeBegin";
         else bs_Where = "afterEnd";
     }
     elem.insertAdjacentHTML(bs_Where, s_Html);
 }
Пример #7
0
        /// <summary>
        /// ポップアップを表示します
        /// </summary>
        /// <param name="html">表示するHTML</param>
        public void Show(string html)
        {
            HTMLDocument hd   = iectv.DomDocument;
            HTMLBody     body = (HTMLBody)hd.body;
            IHTMLElement root = hd.getElementById("popupBase");

            // ポップアップのルートが作成されていなければ
            if (root == null)
            {
                // ポップアップの基本となる要素を挿入
                body.insertAdjacentHTML("afterBegin", "<dl><div id=\"popupBase\" style=\"" + fontHtml + "\"></div></dl>");
                root = hd.getElementById("popupBase");
            }

            // ポップアップ元を作成
            root.insertAdjacentHTML("beforeEnd",
                                    String.Format("<div id=\"p{0}\" style=\"border: solid gray 1px; padding: 3px; background: window; overflow: auto; position: absolute;\"></div>", childCount));

            // 表示内容を設定
            IHTMLElement div = hd.getElementById("p" + childCount);

            div.innerHTML = html;


            // ポップアップの最大幅を求める
            int maxWidth  = body.clientWidth;
            int maxHeight = body.clientHeight / 2 + body.clientHeight / 3; // 画面の3/2

            // 要素が最大縦幅より大きくならないように調整
            width  = Math.Min(div.offsetWidth + 25, maxWidth);
            height = Math.Min(div.offsetHeight, maxHeight);

            // ポップアップ位置を調整 (レスの右上に配置)
            Point point = PopupLocation;
            // NTwin23
            //if (img)
            //{
            //    point = new Point(point.X + adjustImg.X, point.Y + adjustImg.Y);
            //}
            // NTwin23

            // pointをクライアント座標に変換
            Point clientPos = new Point(
                point.X - body.scrollLeft,
                point.Y - body.scrollTop);

            // 上と左のはみ出しチェック
            if (clientPos.X < 0)
            {
                point.X = body.scrollLeft;
            }
            if (clientPos.Y < 0)
            {
                point.Y = body.scrollTop;
            }

            // 幅がクライアント幅を超えていたら調整
            if (clientPos.X + width > body.clientWidth)
            {
                int sub_w = (body.clientWidth - width);
                point.X = (body.scrollLeft + Math.Max(0, sub_w));
            }

            // 高さがクライアント幅を超えていたら調整
            if (clientPos.Y + height > body.clientHeight)
            {
                int sub_h = (body.clientHeight - height);
                point.Y = (body.scrollTop + Math.Max(0, sub_h));
            }

            // サイズを設定
            div.style.pixelLeft   = point.X;
            div.style.pixelTop    = point.Y;
            div.style.pixelWidth  = width;
            div.style.pixelHeight = height;

            // 色を設定
            div.style.backgroundColor = backColorHtml;
            div.style.color           = foreColorHtml;
            childCount++;
        }
Пример #8
0
        /// <summary>
        /// Tree section node constructor
        /// </summary>
        /// <param name="parent">Parent section of the section to create. null if the node to create is the root section.</param>
        /// <param name="node">HTML header tag for this section</param>
        /// <param name="ui">Application log. It can be null</param>
        public NodoArbol(NodoArbol parent, IHTMLElement node, UserInterface ui)
        {
            this.Padre = parent;
            this.Nodo = node;
            Hijos = new ArrayList();
            Nivel = NivelNodo( node );
            Archivo = "";

            // Guardar la lista de los todos las referencias de este nodo ( nodos <A> con la propiedad "name")
            listaANames = new ArrayList();
            if( node != null )
            {
                IHTMLElementCollection col = (IHTMLElementCollection) node.children;
                foreach( IHTMLElement hijo in col )
                {
                    if (hijo is IHTMLAnchorElement)
                    {
                        // Remove empty spaces, because they will fail into the CHM.
                        // The anchors to this will be replace too after.
                        //listaANames.Add( ((IHTMLAnchorElement)hijo).name.Replace( " " , "" ) );
                        string processedName = ToSafeFilename( ((IHTMLAnchorElement)hijo).name );
                        if (processedName == null || processedName.Trim() == "")
                            // It seems on HTML 5 and XHTML <a id="foo"> is used...
                            processedName = ToSafeFilename( hijo.id );
                        if( processedName != null && processedName.Trim() != "" )
                            listaANames.Add(processedName);
                    }
                }
                if( listaANames.Count == 0 )
                {
                    // Si no tiene ningun nombre, darle uno artificial:
                    int numero = UltimoNumeroAname++;
                    string nombreNodo = "NODO" + numero.ToString().Trim();
                    string tagA = "<a name=\"" + nombreNodo + "\">";
                    try
                    {
                        node.insertAdjacentHTML("afterBegin", tagA);
                        listaANames.Add(nombreNodo);
                    }
                    catch (Exception ex)
                    {
                        if( ui != null )
                            ui.log( new Exception("There was an error trying to add the tag " +
                                tagA + " to the node " + node.outerHTML + " (wrong HTML syntax?). If " +
                                "the source document is HTML, try to add manually an <a> tag manually. " +
                                "The application needs a node of this kind on each section title " +
                                "to make links to point it", ex ) );
                    }
                }
            }
        }