private static void InsertMethods(HtmlElement parent, string name, IEnumerable<MethodInfo> methods) { // Setup initial conditions. if (methods.IsEmpty()) return; // Create the method container. var methodContainer = CreateElement(name); parent.AppendChild(methodContainer); // Insert each method. foreach (var methodInfo in methods) { var htmMethod = CreateElement("method"); htmMethod.SetAttribute("name", methodInfo.Name); htmMethod.SetAttribute("class", methodInfo.DeclaringType.FullName); methodContainer.AppendChild(htmMethod); } }
/// <summary> /// Creates the actual HtmlElement and prepares its parent /// associations. /// </summary> /// <param name="parentElement">The parent, containing HtmlElement.</param> private void CreateAndAppend(HtmlElement parentElement) { if (parentElement == null) { throw new ArgumentNullException("parentElement"); } if (_htmlElement == null) { HtmlElement element = HtmlPage.Document.CreateElement(_tag); SetHtmlElementInternal(element); parentElement.AppendChild(_htmlElement); } SetParentIfExists(parentElement); AppendSelfToParentControl(); }
private void InitializeHtml() { // Create Container Div Element _htmlDivContainerElement = System.Windows.Browser.HtmlPage.Document.CreateElement("div"); _htmlDivContainerElement.Id = this.HtmlDivContainerID; _htmlDivContainerElement.SetStyleAttribute("position", "absolute"); // Create A Element _htmlAnchorFocusElement = System.Windows.Browser.HtmlPage.Document.CreateElement("a"); _htmlAnchorFocusElement.SetAttribute("href", "#"); _htmlAnchorFocusElement.SetStyleAttribute("position", "absolute"); _htmlAnchorFocusElement.SetStyleAttribute("left", "0px"); _htmlAnchorFocusElement.SetStyleAttribute("top", "0px"); _htmlAnchorFocusElement.SetStyleAttribute("width", "0px"); _htmlAnchorFocusElement.SetStyleAttribute("height", "0px"); _htmlAnchorFocusElement.Id = this.HtmlAnchorFocusID; _htmlDivContainerElement.AppendChild(_htmlAnchorFocusElement); // Create Iframe Element _htmlIframeEditorElement = System.Windows.Browser.HtmlPage.Document.CreateElement("iframe"); _htmlIframeEditorElement.Id = this.HtmlIframeID; _htmlIframeEditorElement.SetAttribute("frameBorder", "0"); _htmlIframeEditorElement.SetAttribute("allowTransparency", "true"); _htmlIframeEditorElement.SetStyleAttribute("position", "relative"); _htmlIframeEditorElement.SetStyleAttribute("width", "100%"); _htmlIframeEditorElement.SetStyleAttribute("height", "100%"); _htmlDivContainerElement.AppendChild(_htmlIframeEditorElement); //System.Windows.Browser.HtmlPage.Document.Body.AppendChild(_htmlDivContainerElement); HtmlContainer.AppendChild(_htmlDivContainerElement); string initialText = !this.IsBrowserIE ? "<br/>" : ""; if (!string.IsNullOrEmpty(this.Text)) initialText = this.Text; StringBuilder sb = new StringBuilder(); sb.Append("setTimeout(function(){"); sb.Append(GetIframeDocumentScript()); if (this.IsBrowserIE) sb.AppendFormat("{0}.designMode = '{1}';", ScriptVariableIframeDocument, isReadOnly ? "Off" : "On"); sb.AppendFormat("{0}.open('text/html', 'replace');", ScriptVariableIframeDocument); sb.AppendFormat("{0}.write(\"{1}\");", ScriptVariableIframeDocument, this.GetInitialIframeOuterHTML()); sb.AppendFormat("{0}.close();", ScriptVariableIframeDocument); //sb.Append("setTimeout(function(){"); if (!this.IsBrowserIE) sb.AppendFormat("{0}.designMode = '{1}';", ScriptVariableIframeDocument, isReadOnly ? "Off" : "On"); StringBuilder sbInit = new StringBuilder(initialText); sbInit.Replace("\"", "\\\""); sbInit.Replace("\r", ""); sbInit.Replace("\n", ""); sb.AppendFormat("{0}.body.innerHTML = \"{1}\";", ScriptVariableIframeDocument, sbInit.ToString()); //sb.Append("}, 100);"); //sb.AppendFormat("document.getElementById('{0}').contentWindow.IsReady = true;", this.HtmlIframeID); sb.Append("var w;"); sb.AppendFormat("if({0}.parentWindow)", ScriptVariableIframeDocument); sb.AppendFormat(" w = {0}.parentWindow;", ScriptVariableIframeDocument); sb.AppendFormat("else if({0}.defaultView)", ScriptVariableIframeDocument); sb.AppendFormat(" w = {0}.defaultView;", ScriptVariableIframeDocument); sb.AppendFormat("else ", ScriptVariableIframeDocument); sb.AppendFormat(" w = {0}.parentWindow;", ScriptVariableIframeDocument); sb.Append("w.IsReady = true;"); sb.Append("}, 100);"); System.Windows.Browser.HtmlPage.Window.Eval(sb.ToString()); timerInitialize = new DispatcherTimer(); timerInitialize.Interval = TimeSpan.FromMilliseconds(100); timerInitialize.Tick += delegate { if (!_iframeInitialized) { timerInitialize.Stop(); if (_htmlIframeEditorElement == null) { Dispose(); return; } IntializeHandlersHtml(); if (!_iframeInitialized) timerInitialize.Start(); } }; timerInitialize.Start(); // _htmlInitialized = true; //ScratchHtml(); if (HtmlAnimationIframePlace != null) { HtmlAnimationPair hap = new HtmlAnimationPair(); hap.HtmlElementName = this.HtmlDivContainerID; //hap.HtmlContainerName = this.HtmlContainerID; hap.SLElement = ElementIframePlace; HtmlAnimationIframePlace.Pairs.Add(hap); HtmlAnimationIframePlace.ControlOwner = this; } Application.Current.RootVisual.MouseMove += new MouseEventHandler(RootVisual_MouseMove); }
private static void addObjectParameter(HtmlElement element, string name, string value) { var p = HtmlPage.Document.CreateElement("param"); p.SetAttribute("name", name); p.SetAttribute("value", value); element.AppendChild(p); }