private void SetContainedControlsParent(Interop.IHTMLElement element) { Interop.IHTMLElementCollection elementChildren = (Interop.IHTMLElementCollection)element.GetChildren(); if (elementChildren != null) { int i = elementChildren.GetLength(); for (int j = 0; j < i; j++) { Interop.IHTMLElement childElement = (Interop.IHTMLElement)elementChildren.Item(j, j); if (childElement != null) { object[] locals = new object[1]; childElement.GetAttribute("id", 0, locals); string str2 = locals[0] as String; System.Web.UI.Control control = _designerHost.Container.Components[str2] as System.Web.UI.Control; if (control != null && control.Parent != _control) { _control.Controls.Add(control); ControlDesigner controlDesigner = _designerHost.GetDesigner(control) as ControlDesigner; if (controlDesigner != null) { controlDesigner.OnSetParent(); } } else { SetContainedControlsParent(childElement); } } } } }
public Element GetChild(string name) { Interop.IHTMLElementCollection children = (Interop.IHTMLElementCollection)_peer.GetChildren(); Interop.IHTMLElement child = (Interop.IHTMLElement)children.Item(name, null); return(Element.GetWrapperFor(child, _owner)); }
private void CreateSourceList(Interop.IHTMLElement s) { if (_sources == null) { _sources = new SourceElementsCollection(s, base.HtmlEditor); _sources.OnInsertHandler += new CollectionInsertHandler(_sources_OnInsertHandler); _sources.OnClearHandler += new CollectionClearHandler(_sources_OnClearHandler); } else { _sources.OnInsertHandler -= new CollectionInsertHandler(_sources_OnInsertHandler); _sources.OnClearHandler -= new CollectionClearHandler(_sources_OnClearHandler); _sources.Clear(); Interop.IHTMLElement selectElement = (Interop.IHTMLElement)s; Interop.IHTMLElementCollection options = (Interop.IHTMLElementCollection)selectElement.GetChildren(); for (int i = 0; i < options.GetLength(); i++) { Interop.IHTMLElement el = (Interop.IHTMLElement)options.Item(i, i); object oe = new SourceElement(el, (HtmlEditor)base.HtmlEditor); _sources.Add(oe); } _sources.OnInsertHandler += new CollectionInsertHandler(_sources_OnInsertHandler); _sources.OnClearHandler += new CollectionClearHandler(_sources_OnClearHandler); } }
public Element GetChild(int index) { Interop.IHTMLElementCollection children = (Interop.IHTMLElementCollection)_peer.GetChildren(); Interop.IHTMLElement child = (Interop.IHTMLElement)children.Item(null, index); return(Element.GetWrapperFor(child, _owner)); }
private void _options_OnClearHandler() { Interop.IHTMLElement optgroup = base.GetBaseElement(); Interop.IHTMLDOMNode optNode = (Interop.IHTMLDOMNode)optgroup; Interop.IHTMLElementCollection subNodes = (Interop.IHTMLElementCollection)optgroup.GetChildren(); for (int i = 0; i < subNodes.GetLength(); i++) { optNode.removeChild((Interop.IHTMLDOMNode)subNodes.Item(i, i)); } }
internal SourceElementsCollection(Interop.IHTMLElement s, IHtmlEditor editor) : base() { selectElement = (Interop.IHTMLElement)s; Interop.IHTMLElementCollection options = (Interop.IHTMLElementCollection)selectElement.GetChildren(); for (int i = 0; i < options.GetLength(); i++) { Interop.IHTMLElement el = (Interop.IHTMLElement)options.Item(i, i); object oe = new SourceElement(el, (HtmlEditor)editor); InnerList.Add(oe); } }
public Element GetElementByID(string id) { Interop.IHTMLElement body = MSHTMLDocument.GetBody(); Interop.IHTMLElementCollection children = (Interop.IHTMLElementCollection)body.GetAll(); Interop.IHTMLElement element = (Interop.IHTMLElement)children.Item(id, 0); if (element == null) { return(null); } return(Element.GetWrapperFor(element, this)); }
internal OptionOnlyElementsCollection(Interop.IHTMLElement optGroup, IHtmlEditor editor) : base() { this.editor = editor; Interop.IHTMLElementCollection options = (Interop.IHTMLElementCollection)optGroup.GetChildren(); for (int i = 0; i < options.GetLength(); i++) { Interop.IHTMLElement el = (Interop.IHTMLElement)options.Item(i, i); OptionElement oe = null; oe = new OptionElement(el, editor); if (oe != null) { InnerList.Add(oe); } } }
private void _sources_OnClearHandler() { // we do not clear the collection here to protect the underlying conjunction between collection and element Interop.IHTMLElement selectElement = (Interop.IHTMLElement)base.GetBaseElement(); Interop.IHTMLDOMNode selNode = (Interop.IHTMLDOMNode)selectElement; if (selNode.hasChildNodes()) { Interop.IHTMLElementCollection options = (Interop.IHTMLElementCollection)selectElement.GetChildren(); for (int o = 0; o < options.GetLength(); o++) { Interop.IHTMLDOMNode childElement = (Interop.IHTMLDOMNode)options.Item(0, 0); // remove first node, because the collection will change immediately after removeChild call selNode.removeChild(childElement); } } }
public new void RemoveAt(int index) { if (index >= base.InnerList.Count || index < 0) { return; } base.InnerList.RemoveAt(index); Interop.IHTMLElementCollection options = (Interop.IHTMLElementCollection)selectElement.GetChildren(); for (int i = 0; i < options.GetLength(); i++) { Interop.IHTMLElement el = (Interop.IHTMLElement)options.Item(i, i); if (index == i) { Interop.IHTMLDOMNode no = (Interop.IHTMLDOMNode)el; no.removeNode(true); } } }
private void BuildCollection(Interop.IHTMLElement peer) { if (_options == null) { Interop.IHTMLElement select = peer.GetParentElement(); _options = new OptionOnlyElementsCollection(peer, base.HtmlEditor); Interop.IHTMLElementCollection coll = select.GetChildren() as Interop.IHTMLElementCollection; if (coll != null && coll.GetLength() > 0) { bool beginBlock = false; for (int i = 0; i < coll.GetLength(); i++) { Interop.IHTMLElement option = coll.Item(i, i) as Interop.IHTMLElement; if (option != null) { if (beginBlock && option.GetTagName().Equals("OPTGROUP")) { break; } if (beginBlock) { _options.Add(base.HtmlEditor.GenericElementFactory.CreateElement(option) as OptionElement); } if (option.Equals(peer)) { beginBlock = true; continue; } } } } _options.OnInsertHandler += new CollectionInsertHandler(_options_OnInsertHandler); _options.OnClearHandler += new CollectionClearHandler(_options_OnClearHandler); } else { _options.Clear(); } }
private void CreateOptionList(Interop.IHTMLSelectElement s) { if (_options == null) { _options = new OptionElementsCollection(s, base.HtmlEditor); _options.OnInsertHandler += new CollectionInsertHandler(_options_OnInsertHandler); _options.OnClearHandler += new CollectionClearHandler(_options_OnClearHandler); } else { Debug.WriteLine("Recreate List"); _options.OnInsertHandler -= new CollectionInsertHandler(_options_OnInsertHandler); _options.OnClearHandler -= new CollectionClearHandler(_options_OnClearHandler); _options.Clear(); Interop.IHTMLElement selectElement = (Interop.IHTMLElement)s; Interop.IHTMLElementCollection options = (Interop.IHTMLElementCollection)selectElement.GetChildren(); for (int i = 0; i < options.GetLength(); i++) { Interop.IHTMLElement el = (Interop.IHTMLElement)options.Item(i, i); IOptionElement oe = null; switch (el.GetTagName()) { case "OPTION": oe = new OptionElement(el, base.HtmlEditor); break; case "OPTGROUP": oe = new OptGroupElement(el, base.HtmlEditor); break; } if (oe != null) { _options.Add(oe); } } _options.OnInsertHandler += new CollectionInsertHandler(_options_OnInsertHandler); _options.OnClearHandler += new CollectionClearHandler(_options_OnClearHandler); } }
internal OptionElementsCollection(Interop.IHTMLSelectElement s, IHtmlEditor editor) : base() { selectElement = (Interop.IHTMLElement)s; Interop.IHTMLElementCollection options = (Interop.IHTMLElementCollection)selectElement.GetChildren(); for (int i = 0; i < options.GetLength(); i++) { Interop.IHTMLElement el = (Interop.IHTMLElement)options.Item(i, i); object oe = null; switch (el.GetTagName()) { case "OPTION": oe = new OptionElement(el, editor); break; case "OPTGROUP": oe = new OptGroupElement(el, editor); break; } if (oe != null) { InnerList.Add(oe); } } }