public bool updateLastTime(HtmlElementInsertionOrientation where, DateTime newTime) { if (lastTimeTop == DateTime.MinValue && lastTimeBottom == DateTime.MinValue) { this.Document.GetElementById("firstdate").InnerHtml = newTime.ToLongDateString(); lastTimeBottom = newTime; lastTimeTop = newTime; return(true); } if (where == HtmlElementInsertionOrientation.AfterBegin) { if (lastTimeTop.Date != newTime.Date) { addDateToView(lastTimeTop.ToLongDateString(), where); this.Document.GetElementById("firstdate").InnerHtml = newTime.ToLongDateString(); lastTimeTop = newTime; return(true); } else { return(false); } } else { if (lastTimeBottom.Date != newTime.Date) { addDateToView(newTime.ToLongDateString(), where); lastTimeBottom = newTime; return(true); } else { return(false); } } }
public HtmlElement InsertAdjacentElement(HtmlElementInsertionOrientation orient, HtmlElement newElement) { IHTMLElement iHtmlElement = ((IHTMLElement2)NativeHtmlElement).InsertAdjacentElement(orient.ToString(), (IHTMLElement)newElement.DomElement); return(iHtmlElement != null ? new HtmlElement(shimManager, iHtmlElement) : null); }
/// <summary> /// 向指定HTML文档中附加js脚本。 /// </summary> /// <param name="doc">要安装js脚本的HTML文档顶级节点。</param> /// <param name="code">js脚本代码。</param> public static void AttachScript(IHTMLDocument doc, string code, HtmlElementInsertionOrientation orient) { string position = "beforeEnd"; switch (orient) { case HtmlElementInsertionOrientation.AfterBegin: position = "afterBegin"; break; case HtmlElementInsertionOrientation.AfterEnd: position = "afterEnd"; break; case HtmlElementInsertionOrientation.BeforeBegin: position = "beforeBegin"; break; } IHTMLElement head = GetDocHead(doc); IHTMLElement script = ((IHTMLDocument2)doc).createElement("script"); script.setAttribute("type", "text/javascript"); script.setAttribute("text", code); ((IHTMLElement2)head).insertAdjacentElement(position, script); }
public void addDateToView(string text, HtmlElementInsertionOrientation where) { var div = this.Document.CreateElement("p"); div.SetAttribute("className", "date notice"); div.InnerHtml = "* " + text + ""; this.Document.GetElementById("m").InsertAdjacentElement(where, div); }
public HtmlElement InsertAdjacentElement(HtmlElementInsertionOrientation orient, HtmlElement newElement) { System.Windows.Forms.UnsafeNativeMethods.IHTMLElement element = ((System.Windows.Forms.UnsafeNativeMethods.IHTMLElement2) this.NativeHtmlElement).InsertAdjacentElement(orient.ToString(), (System.Windows.Forms.UnsafeNativeMethods.IHTMLElement)newElement.DomElement); if (element == null) { return(null); } return(new HtmlElement(this.shimManager, element)); }
public HtmlElement InsertAdjacentElement(HtmlElementInsertionOrientation orient, HtmlElement newElement) { switch (orient) { case HtmlElementInsertionOrientation.BeforeBegin: element.Parent.InsertBefore(newElement.element, element); return(newElement); case HtmlElementInsertionOrientation.AfterBegin: element.InsertBefore(newElement.element, element.FirstChild); return(newElement); case HtmlElementInsertionOrientation.BeforeEnd: return(this.AppendChild(newElement)); case HtmlElementInsertionOrientation.AfterEnd: return(this.AppendChild(newElement)); } return(null); }
public HtmlElement InsertAdjacentElement(HtmlElementInsertionOrientation orient, HtmlElement newElement) { System.Windows.Forms.UnsafeNativeMethods.IHTMLElement element = ((System.Windows.Forms.UnsafeNativeMethods.IHTMLElement2) this.NativeHtmlElement).InsertAdjacentElement(orient.ToString(), (System.Windows.Forms.UnsafeNativeMethods.IHTMLElement) newElement.DomElement); if (element == null) { return null; } return new HtmlElement(this.shimManager, element); }
public HtmlElement InsertAdjacentElement (HtmlElementInsertionOrientation orient, HtmlElement newElement) { switch (orient) { case HtmlElementInsertionOrientation.BeforeBegin: element.Parent.InsertBefore (newElement.element, element); return newElement; case HtmlElementInsertionOrientation.AfterBegin: element.InsertBefore (newElement.element, element.FirstChild); return newElement; case HtmlElementInsertionOrientation.BeforeEnd: return this.AppendChild (newElement); case HtmlElementInsertionOrientation.AfterEnd: return this.AppendChild (newElement); } return null; }
public void addMessageToView(string from, string text, DateTime time, string editDt, string jabberId, string id, HtmlElementInsertionOrientation where = HtmlElementInsertionOrientation.BeforeEnd) { updateLastTime(where, time); var div = this.Document.CreateElement("p"); div.Id = "MSGID_" + id; text = prepareInnerHtml(text); var me = Regex.Match(text, "^/me\\s+"); var timeEl = "<i title=" + time.ToShortDateString() + " " + time.ToLongTimeString() + "><u>[</u>" + (highlightString != "" ? time.ToShortDateString() : "") + " " + time.ToLongTimeString() + "<u>] </u></i>"; if (!String.IsNullOrEmpty(editDt)) { timeEl += "<i class='edited' title='" + editDt + "'>(Edited)</i>"; } var color = JabberContact.getColorForNickname(from); string cssColor = ColorTranslator.ToHtml(color); string classNames = "from_" + from + " "; if (from == "self" || (!String.IsNullOrEmpty(jabberId) && jabberId.StartsWith(this.selfNickname))) { classNames += "self "; } if (me.Success) { div.InnerHtml = timeEl + "<span> *** <strong>" + from + "</strong> " + text.Substring(me.Length) + "</span>"; } else { classNames += "msg "; string avatar = "<tt class='avatar' style='background-color: " + cssColor + "; '></tt>"; string avatarFilename = Program.Jabber.avatar.GetAvatarIfAvailabe(jabberId); if (!string.IsNullOrEmpty(avatarFilename)) { avatar = "<tt class='avatar'><img src='" + avatarFilename + "'></tt>"; } div.InnerHtml = avatar + "<span class='wrap'>" + timeEl + "<strong style='color: " + cssColor + "'>" + from + ":</strong><span class='body'> " + text + "</span></span>"; } div.SetAttribute("className", classNames); //this.Document.Body.AppendChild(div); this.Document.GetElementById("m").InsertAdjacentElement(where, div); if (where == HtmlElementInsertionOrientation.BeforeEnd) { scrollDown(); } }
public void addMessageToView(ChatMessage message, HtmlElementInsertionOrientation where = HtmlElementInsertionOrientation.BeforeEnd) { addMessageToView(message.Sender, message.Body, message.Date, message.Editdt, message.SenderJid, message.Id, where); }
public HtmlElement InsertAdjacentElement(HtmlElementInsertionOrientation orient, HtmlElement newElement) { throw null; }
/// <include file='doc\HtmlElement.uex' path='docs/doc[@for="HtmlElement.InsertAdjacentElement"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public HtmlElement InsertAdjacentElement(HtmlElementInsertionOrientation orient, HtmlElement newElement) { UnsafeNativeMethods.IHTMLElement iHtmlElement = ((UnsafeNativeMethods.IHTMLElement2)this.NativeHtmlElement).InsertAdjacentElement(orient.ToString(), (UnsafeNativeMethods.IHTMLElement)newElement.DomElement); return iHtmlElement != null ? new HtmlElement(shimManager, iHtmlElement) : null; }
public HtmlElement InsertAdjacentElement(HtmlElementInsertionOrientation orient, HtmlElement newElement) {}