public static void SetInnerText(DOMElement element, string innerText) { DOMElement textNode = (DOMElement)Script.Literal("document.createTextNode({0})", innerText); RemoveAllChildren(element); element.AppendChild(textNode); }
void LoadCoordsGmap() { try { ManualResetEvent waitEvent = new ManualResetEvent(false); winFormsBrowserView2.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { // Wait until main document of the web page is loaded completely. if (e.IsMainFrame) { if (this.tbCoords.Text != null) { waitEvent.Set(); DOMDocument document = winFormsBrowserView2.Browser.GetDocument(); DOMInputElement searchgmap = (DOMInputElement)document.GetElementById("searchboxinput"); searchgmap.Value = tbCoords.Text; searchgmap.Click(); DOMElement searchbutton = document.GetElementById("searchbox-searchbutton"); searchbutton.Click(); } } }; } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
static void Main(string[] args) { using (Browser browser = BrowserFactory.Create()) { ManualResetEvent waitEvent = new ManualResetEvent(false); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMElement documentElement = document.DocumentElement; // Get the div with id = "root". DOMNode divRoot = documentElement.QuerySelector("#root"); // Get all paragraphs. List <DOMNode> paragraphs = divRoot.QuerySelectorAll("p"); foreach (var paragraph in paragraphs) { Console.Out.WriteLine("paragraph.NodeValue = " + ((DOMElement)paragraph).InnerText); } waitEvent.Set(); } }; browser.LoadHTML( "<html><body><div id='root'>" + "<p>paragraph1</p>" + "<p>paragraph2</p>" + "<p>paragraph3</p>" + "</div></body></html>"); waitEvent.WaitOne(); } }
private Component Mount(string elementRef, bool replace, bool enableLayouts) { if (Element != null) { throw new InvalidOperationException("Component is already mounted."); } _replaceElement = replace; if (enableLayouts && !string.IsNullOrEmpty(Layout)) { var layoutComponent = RazorComponent.Instantiate(Layout, Context); layoutComponent.BodyComponent = this; layoutComponent.MountAsPage(elementRef); return(layoutComponent); } else { Element = new DOMElement(elementRef); // Render after Init/InitAsync have run synchronously, plus again after // InitAsync's task completes (where applicable) Init(); var initAsyncTask = InitAsync(); Render(); _firstRenderCompletedTask = initAsyncTask?.ContinueWith(_ => { Render(); }); return(this); } }
public Form1() { InitializeComponent(); browser = BrowserFactory.Create(); BrowserView browserView = new WinFormsBrowserView(browser); browser.DialogHandler = new WinFormsDefaultDialogHandler((Control)browserView); this.Controls.Add((Control)browserView.GetComponent()); browserView.Browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMElement link3Element = document.GetElementById("link3"); DOMEventHandler link3Event = delegate(object domEventSender, DOMEventArgs domEventArgs) { if (domEventArgs.Type == DOMEventType.OnFocus) { Console.Out.WriteLine("link3 gets focus"); } if (domEventArgs.Type == DOMEventType.OnBlur) { Console.Out.WriteLine("Remove focus from link3"); } }; link3Element.AddEventListener(DOMEventType.OnFocus | DOMEventType.OnBlur, link3Event, false); DOMElement elementFocused = null; foreach (DOMElement element in document.GetElementsByTagName("a")) { Thread.Sleep(2000); element.Focus(); elementFocused = element; } if (elementFocused != null) { Thread.Sleep(2000); elementFocused.Blur(); } } }; browserView.Browser.LoadHTML(@"<html> <body> <a id='link1' href='#'>The link 1</a> <a id='link2' href='#'>The link 2</a> <a id='link3' href='#'>The link 3</a> <script type='text/javascript'> var link2 = document.getElementById('link2'); link2.addEventListener('focus', function () { console.log('link2 gets focus'); }); link2.addEventListener('blur', function () { console.log('Remove focus from link2'); }); </script> </body> </html>"); }
public PhotoBrowsingUsingKeysControl(DOMElement[] focusControls) { for (int i = 0; i < focusControls.Length; i++) { DomEvent.AddHandler(focusControls[i], "keydown", new DomEventHandler(KeyDown)); } }
internal static string SerializeForm(FormElement form) { DOMElement[] formElements = form.Elements; StringBuilder formBody = new StringBuilder(); int count = formElements.Length; for (int i = 0; i < count; i++) { DOMElement element = formElements[i]; string name = (string)Type.GetField(element, "name"); if (name == null || name.Length == 0) { continue; } string tagName = element.TagName.ToUpperCase(); if (tagName == "INPUT") { InputElement inputElement = (InputElement)element; string type = inputElement.Type; if ((type == "text") || (type == "password") || (type == "hidden") || (((type == "checkbox") || (type == "radio")) && (bool)Type.GetField(element, "checked"))) { formBody.Append(name.EncodeURIComponent()); formBody.Append("="); formBody.Append(inputElement.Value.EncodeURIComponent()); formBody.Append("&"); } } else if (tagName == "SELECT") { SelectElement selectElement = (SelectElement)element; int optionCount = selectElement.Options.Length; for (int j = 0; j < optionCount; j++) { OptionElement optionElement = (OptionElement)selectElement.Options[j]; if (optionElement.Selected) { formBody.Append(name.EncodeURIComponent()); formBody.Append("="); formBody.Append(optionElement.Value.EncodeURIComponent()); formBody.Append("&"); } } } else if (tagName == "TEXTAREA") { formBody.Append(name.EncodeURIComponent()); formBody.Append("="); formBody.Append(((string)Type.GetField(element, "value")).EncodeURIComponent()); formBody.Append("&"); } } return(formBody.ToString()); }
// MVC implementation of PageRequestManager.js / _onFormElementActive() internal static string SerializeSubmitButton(DOMElement element, int offsetX, int offsetY) { // element: the form element that is active // offsetX/Y: if the element is an image button, the coordinates of the click if (element.Disabled) { return null; } string name = (string)Type.GetField(element, "name"); if (name != null) { string tagName = element.TagName.ToUpperCase(); string encodedName = name.EncodeURIComponent(); InputElement inputElement = (InputElement)element; if (tagName == "INPUT") { string type = inputElement.Type; if (type == "submit") { return encodedName + "=" + inputElement.Value.EncodeURIComponent(); } else if (type == "image") { return encodedName + ".x=" + offsetX + "&" + encodedName + ".y=" + offsetY; } } else if ((tagName == "BUTTON") && (name.Length != 0) && (inputElement.Type == "submit")) { return encodedName + "=" + inputElement.Value.EncodeURIComponent(); } } return null; }
public void EnableDynamicValidation() { DOMElement[] elements = Elements; for (int i = 0; i < elements.Length; i++) { DOMElement element = elements[i]; if (ValidationUtil.ElementSupportsEvent(element, "onpropertychange")) { // IE // DDB #227842: IE (before version 8) sometimes incorrectly fires the OnPropertyChange event // for 'value' asynchronously when the element's CSS class is changed, which throws our // validation library into an infinite loop and hangs the user's browser. We disable real- // time validation in downlevel versions of IE to prevent this situation. // 'documentMode' documented at http://msdn.microsoft.com/en-us/library/cc196988(VS.85).aspx object compatMode = Script.Literal("document.documentMode"); if (compatMode != null && (int)compatMode >= 8) { DomEvent.AddHandler(element, "propertychange", _onPropertyChangeHandler); } } else { // Firefox, Safari, Opera, Chrome DomEvent.AddHandler(element, "input", _onInputHandler); } // Everybody else DomEvent.AddHandler(element, "change", _onChangeHandler); DomEvent.AddHandler(element, "blur", _onBlurHandler); } }
public Form1() { InitializeComponent(); //Change address bar by event OnClick DOMEventHandler domEvent = delegate(object sender1, DOMEventArgs e1) { DOMEventType eventType = e1.Type; }; browserView.Browser.FinishLoadingFrameEvent += delegate(object sender2, FinishLoadingEventArgs e2) { if (e2.IsMainFrame) { DOMDocument document = e2.Browser.GetDocument(); DOMElement documentElement = document.DocumentElement; documentElement.AddEventListener(DOMEventType.OnClick, domEvent, false); } try { //toolStripDebug.Text = browserView.Browser.GetDocument().GetElementByClassName("cdr_frm").GetElementByTagName("input").GetAttribute("value").ToString(); toolStripAddress.Text = browserView.Browser.URL.ToString(); this.Text = browserView.Browser.Title; } catch { } }; }
public static void UpdateDomElement(DOMElement target, InsertionMode insertionMode, string content) { if (target != null) { switch (insertionMode) { case InsertionMode.Replace: target.InnerHTML = content; break; case InsertionMode.InsertBefore: if (content != null && content.Length > 0) { // Trimming here may be a bit too aggressive. It is done to make behavior consistent across // browsers (since IE normalizes whitespace BEFORE building its internal data structures). // However, it may end up trimming whitespace left intentionally by the developer. target.InnerHTML = content + target.InnerHTML.TrimStart(); } break; case InsertionMode.InsertAfter: if (content != null && content.Length > 0) { // See comment for InsertBefore re: Trimming target.InnerHTML = target.InnerHTML.TrimEnd() + content; } break; } } }
public Form1() { InitializeComponent(); browser = BrowserFactory.Create(); BrowserView browserView = new WinFormsBrowserView(browser); browserView.Browser.DialogHandler = new WinFormsDefaultDialogHandler((Control)browserView.GetComponent()); this.Controls.Add((Control)browserView.GetComponent()); browserView.Browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { Browser myBrowser = e.Browser; DOMDocument document = myBrowser.GetDocument(); DOMElement link = document.GetElementById("button"); if (link != null) { link.Click(); } } }; browserView.Browser.LoadHTML("<html><body><button id='button' " + "onclick=\"alert('Button has been clicked!');\">Click Me!</button>" + "</body></html>"); }
public static void RemoveAllChildren(DOMElement element) { while (element.FirstChild != null) { element.RemoveChild(element.FirstChild); } }
protected virtual void initialiseElementsInternal(bool setElementsInitialisedFlagOnFinish) { ItemElement = Document.GetElementById(ClientID); if (setElementsInitialisedFlagOnFinish) elementsInitialised = true; }
public AjaxContext(WebRequest request, DOMElement updateTarget, DOMElement loadingElement, InsertionMode insertionMode) { _request = request; _updateTarget = updateTarget; _loadingElement = loadingElement; _insertionMode = insertionMode; }
private InputElement FindSubmitButton(DOMElement element) { // element: the form element that is active if (element.Disabled) { return(null); } string tagName = element.TagName.ToUpperCase(); InputElement inputElement = (InputElement)element; if (tagName == "INPUT") { string type = inputElement.Type; if (type == "submit" || type == "image") { return(inputElement); } } else if ((tagName == "BUTTON") && (inputElement.Type == "submit")) { return(inputElement); } return(null); }
private static bool IsSelectInputElement(DOMElement element) { if (element.TagName.ToUpperCase() == "SELECT") { return true; } return false; }
public WindowMain() { Browser browser = BrowserFactory.Create(); browserView = new WPFBrowserView(browser); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMNode root = document.GetElementById("root"); DOMNode textNode = document.CreateTextNode("Some text"); DOMElement paragraph = document.CreateElement("p"); paragraph.AppendChild(textNode); root.AppendChild(paragraph); } }; Content = browserView; Width = 1024; Height = 768; this.Loaded += WindowMain_Loaded; }
public object Validate(string value, ValidationContext context) { // ignore the value - we actually need to look at the DOM Elements DOMElement[] elements = context.FieldContext.Elements; if (elements.Length == 0) { // nothing to validate, so return success return(true); } DOMElement sampleElement = elements[0]; if (IsTextualInputElement(sampleElement)) { return(ValidateTextualInput((InputElement)sampleElement)); } if (IsRadioInputElement(sampleElement)) { return(ValidateRadioInput(elements)); } if (IsSelectInputElement(sampleElement)) { return(ValidateSelectInput(((SelectElement)sampleElement).Options)); } // can't validate, so just report success return(true); }
public Form1() { InitializeComponent(); browser = BrowserFactory.Create(); BrowserView browserView = new WinFormsBrowserView(browser); browserView.Browser.DialogHandler = new WinFormsDefaultDialogHandler((Control)browserView.GetComponent()); this.Controls.Add((Control)browserView.GetComponent()); DOMEventHandler domEvent = delegate(object sender, DOMEventArgs e) { DOMEventType eventType = e.Type; Console.Out.WriteLine("handleEvent = " + eventType); }; browserView.Browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); DOMElement documentElement = document.DocumentElement; documentElement.AddEventListener(DOMEventType.OnClick | DOMEventType.OnMouseDown | DOMEventType.OnMouseUp | DOMEventType.OnKeyDown, domEvent, false); } }; browserView.Browser.LoadURL("http://www.teamdev.com"); }
internal static FormContext ParseJsonOptions(JsonValidationOptions options) { // First hook up the form logic FormElement formElement = (FormElement)Document.GetElementById(options.FormId); DOMElement validationSummaryElement = (!ValidationUtil.StringIsNullOrEmpty(options.ValidationSummaryId)) ? Document.GetElementById(options.ValidationSummaryId) : null; FormContext formContext = new FormContext(formElement, validationSummaryElement); formContext.EnableDynamicValidation(); formContext.ReplaceValidationSummary = options.ReplaceValidationSummary; // Then hook up the field logic for (int i = 0; i < options.Fields.Length; i++) { JsonValidationField field = options.Fields[i]; DOMElement[] fieldElements = GetFormElementsWithName(formElement, field.FieldName); DOMElement validationMessageElement = (!ValidationUtil.StringIsNullOrEmpty(field.ValidationMessageId)) ? Document.GetElementById(field.ValidationMessageId) : null; FieldContext fieldContext = new FieldContext(formContext); ArrayList.AddRange((ArrayList)(object)fieldContext.Elements, fieldElements); fieldContext.ValidationMessageElement = validationMessageElement; fieldContext.ReplaceValidationMessageContents = field.ReplaceValidationMessageContents; // Hook up rules for (int j = 0; j < field.ValidationRules.Length; j++) { JsonValidationRule rule = field.ValidationRules[j]; Validator validator = ValidatorRegistry.GetValidator(rule); if (validator != null) { Validation validation = new Validation(); validation.FieldErrorMessage = rule.ErrorMessage; validation.Validator = validator; ArrayList.Add((ArrayList)(object)fieldContext.Validations, validation); } } fieldContext.EnableDynamicValidation(); ArrayList.Add((ArrayList)(object)formContext.Fields, fieldContext); } // hook up callback so that it can be executed by the AJAX code ArrayList registeredValidatorCallbacks = (ArrayList)Type.GetField(formElement, "validationCallbacks"); if (registeredValidatorCallbacks == null) { registeredValidatorCallbacks = new ArrayList(); Type.SetField(formElement, "validationCallbacks", registeredValidatorCallbacks); } Type.InvokeMethod(registeredValidatorCallbacks, "push", (ValidationCallback) delegate() { return(ValidationUtil.ArrayIsNullOrEmpty(formContext.Validate("submit"))); }); return(formContext); }
protected override void initialiseElementsInternal(bool setElementsInitialisedFlagOnFinish) { base.initialiseElementsInternal(false); ImageElement = Document.GetElementById(ImageID); if (setElementsInitialisedFlagOnFinish) elementsInitialised = true; }
protected override void initialiseElementsInternal(bool setElementsInitialisedFlagOnFinish) { base.initialiseElementsInternal(false); PicElement = showPic ? Document.GetElementById(PicID) : null; if (setElementsInitialisedFlagOnFinish) elementsInitialised = true; }
public HelloWorld(DOMElement te) { this.te = te; te.InnerHTML = "hello"; DomEventHandler handler = new DomEventHandler(DoSomething); DomEvent.AddHandler(te, "click", handler); }
private static bool IsSelectInputElement(DOMElement element) { if (element.TagName.ToUpperCase() == "SELECT") { return(true); } return(false); }
private void MarkValidationFired() { DOMElement[] elements = Elements; for (int i = 0; i < elements.Length; i++) { DOMElement element = elements[i]; Type.SetField(element, _hasValidationFiredTag, true); // mark all as validation fired } }
public void IntentarSubirVideos_Tick(object sender, EventArgs e) { TiempoDeSubir++; progressBar1.Maximum = 60 * 30; try { progressBar1.Value = TiempoDeSubir; } catch { } if (TiempoDeSubir > 60 * 30 && descasar >= 24) { descasar++; TiempoDeSubir = 0; } if (descasar >= 48) { descasar = 0; } if (TiempoDeSubir > 60 * 30 && descasar < 24) { if (VideosNuevos() > -1) { descasar++; TiempoDeSubir = 0; string CanalDondeSubir = Directory.GetParent(DirDeVideosDeVideos[0]).Name; string URLdelCanalDondeSubir = canales.FirstOrDefault(xt => xt.Nombre.Contains(CanalDondeSubir)).URL; waitEvent.Reset(); BrowserView.Browser.LoadURL(URLdelCanalDondeSubir); dialogHandler.DireccionDeVideo = DirDeVideosDeVideos[0]; BrowserView.Browser.DialogHandler = dialogHandler; waitEvent.WaitOne(); Thread.Sleep(3000); DOMDocument document = BrowserView.Browser.GetDocument(); DOMNode div = document.GetElementById("start-upload-button-single"); DOMElement input = div.GetElementByTagName("button"); //Coordinates of the input element int x = input.BoundingClientRect.X; int y = input.BoundingClientRect.Y; //Modify to click on element. Otherwise - beside x += 1; y += 1; BeginInvoke(new Action(() => { BrowserView.InputSimulator.SimulateMouseButtonEvent(MouseButton.Left, MouseButtonState.Pressed, 1, x, y); //Simulate the button click Thread.Sleep(50); BrowserView.InputSimulator.SimulateMouseButtonEvent(MouseButton.Left, MouseButtonState.Released, 1, x, y); })); Thread.Sleep(25000); Directory.Delete(DirDeVideosDeVideos[0]); canales.Remove(canales.FirstOrDefault(xt => xt.Nombre.Contains(CanalDondeSubir))); } } }
protected override void initialiseElementsInternal(bool setElementsInitialisedFlagOnFinish) { base.initialiseElementsInternal(false); PicElement = Document.GetElementById(PicID); MessageBodyElement = Document.GetElementById(MessageBodyID); if (setElementsInitialisedFlagOnFinish) elementsInitialised = true; }
private static bool IsRadioInputElement(DOMElement element) { if (element.TagName.ToUpperCase() == "INPUT") { string inputType = ((string)Type.GetField(element, "type")).ToUpperCase(); if (inputType == "RADIO") { return true; } } return false; }
private static object ValidateRadioInput(DOMElement[] elements) { for (int i = 0; i < elements.Length; i++) { DOMElement element = elements[i]; if ((bool)Type.GetField(element, "checked")) { return true; // at least one is selected, so OK } } return false; // failure }
public PopupArea(View view) { Popups = (Popup[])new Array(); Animate = bool.Parse(view.InitAnimatePopups.Value); areaHolder = Document.GetElementById("ChatClientPopupAreaHolder"); areaHolder.Style.Width = PopupWidth.ToString() + "px"; }
public MultiSelectorBehaviour(DOMElement container, HtmlAutoCompleteBehaviour htmlAutoComplete, InputElement hiddenOutput) { this.container = container; this.hiddenOutput = hiddenOutput; this.HtmlAutoComplete = htmlAutoComplete; this.HtmlAutoComplete.ItemChosen = htmlAutoComplete_ItemChosen; selections = new PairListField(hiddenOutput); InitialiseInitialSelections(); DomEvent.AddHandler(this.container, "click", this.OnClick); }
private void OnReady() { JQueryAPI.JQuery(".CalendarAddLink").click(delegate(object o) { clicked = (DOMElement) Script.Literal("{0}.originalEvent.srcElement.parentElement", o); DateTime dt = new DateTime((string) Script.Literal("{0}.date", clicked)); EventCreatorController.Instance.ShowPopup(dt, null, null, EventAdded); return false; }); }
private void EventAdded(EventInfo eventInfo) { if (eventInfo != null) { DivElement div = (DivElement) Document.CreateElement("div"); div.ClassName = "CalendarItemToday"; div.InnerHTML = String.Format("<b>{0}</b>", eventInfo.name); clicked.InsertBefore(div); clicked = null; } }
private static bool IsElementInHierarchy(DOMElement parent, DOMElement child) { while (child != null) { if (parent == child) { return(true); } child = child.ParentNode; } return(false); }
private static bool IsRadioInputElement(DOMElement element) { if (element.TagName.ToUpperCase() == "INPUT") { string inputType = ((string)Type.GetField(element, "type")).ToUpperCase(); if (inputType == "RADIO") { return(true); } } return(false); }
private static object ValidateRadioInput(DOMElement[] elements) { for (int i = 0; i < elements.Length; i++) { DOMElement element = elements[i]; if ((bool)Type.GetField(element, "checked")) { return(true); // at least one is selected, so OK } } return(false); // failure }
private Component Mount(string elementRef, bool replace, bool enableLayouts) { if (Element != null) { throw new InvalidOperationException("Component is already mounted."); } _replaceElement = replace; if (enableLayouts && !string.IsNullOrEmpty(Layout)) { var layoutComponent = RazorComponent.Instantiate(Layout, Context); layoutComponent.BodyComponent = this; layoutComponent.MountAsPage(elementRef); return(layoutComponent); } else { Element = new DOMElement(elementRef); // Render after Init/InitAsync have run synchronously, plus again after // InitAsync's task completes (where applicable) Init(); var url = Context.Url; if (url[url.Length - 1] == '/') { url = url.Substring(0, url.Length - 1); } var segments = url.Split(new char[] { '/' }); var idSegments = segments[segments.Length - 1]; int num; Task initAsyncTask; if (idSegments.Length > 0 && int.TryParse(idSegments, out num)) { initAsyncTask = InitAsync(num); } else { initAsyncTask = InitAsync(); } Render(); _firstRenderCompletedTask = initAsyncTask?.ContinueWith(_ => { Render(); }); return(this); } }
private static object ValidateSelectInput(DOMElementCollection optionElements) { for (int i = 0; i < optionElements.Length; i++) { DOMElement element = optionElements[i]; if ((bool)Type.GetField(element, "selected")) { if (!ValidationUtil.StringIsNullOrEmpty((string)Type.GetField(element, "value"))) { return(true); // at least one is selected, so OK } } } return(false); // failure }
private List <DOMElement> _ParseRaw() { // Top collection List <DOMElement> collection = new List <DOMElement>(); DOMElement parsedElement = null; // Initial position int currentPosition = 0; // Loop through HTML while (currentPosition < _HTML.Length) { // Get next character char chr = _HTML[currentPosition]; if (chr == '<') { parsedElement = _ParseTag(currentPosition); collection.Add(parsedElement); if (parsedElement is HTMLContent) { currentPosition = parsedElement.EndPosition + 0; } else { currentPosition = parsedElement.EndPosition + 1; } } else { parsedElement = _ParseContent(currentPosition); if (!_CaptureWhitespace && string.IsNullOrWhiteSpace(((HTMLContent)parsedElement).Value)) { // Don't add the whitespace element if we're not capturing it } else { // Non-whitespace or we're okay with capturing whitespace collection.Add(parsedElement); } currentPosition = parsedElement.EndPosition + 0; } // Advance cursor to next element } return(collection); }
private static bool IsTextualInputElement(DOMElement element) { if (element.TagName.ToUpperCase() == "INPUT") { string inputType = ((string)Type.GetField(element, "type")).ToUpperCase(); switch (inputType) { case "TEXT": case "PASSWORD": case "FILE": return true; } } if (element.TagName.ToUpperCase() == "TEXTAREA") { return true; } return false; }
public FormContext(FormElement formElement, DOMElement validationSummaryElement) { FormElement = formElement; _validationSummaryElement = validationSummaryElement; Type.SetField(formElement, _formValidationTag, this); // need to retrieve the actual <ul> element, since that will be dynamically modified if (validationSummaryElement != null) { DOMElementCollection ulElements = validationSummaryElement.GetElementsByTagName("ul"); if (ulElements.Length > 0) { _validationSummaryULElement = ulElements[0]; } } _onClickHandler = Form_OnClick; _onSubmitHandler = Form_OnSubmit; }
private void DisplaySuccess() { DOMElement validationSummaryElement = _validationSummaryElement; if (validationSummaryElement != null) { DOMElement validationSummaryULElement = _validationSummaryULElement; if (validationSummaryULElement != null) { // delete all children validationSummaryULElement.InnerHTML = ""; } DomElement.RemoveCssClass(validationSummaryElement, _validationSummaryErrorCss); DomElement.AddCssClass(validationSummaryElement, _validationSummaryValidCss); } }
private static DOMElement[] GetFormElementsWithName(FormElement formElement, string name) { ArrayList allElementsWithNameInForm = new ArrayList(); DOMElementCollection allElementsWithName = Document.GetElementsByName(name); for (int i = 0; i < allElementsWithName.Length; i++) { DOMElement thisElement = allElementsWithName[i]; if (IsElementInHierarchy(formElement, thisElement)) { ArrayList.Add(allElementsWithNameInForm, thisElement); } } return((DOMElement[])allElementsWithNameInForm); }
static void Main(string[] args) { using (Browser browser = BrowserFactory.Create()) { ManualResetEvent waitEvent = new ManualResetEvent(false); browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e) { // Wait until main document of the web page is loaded completely. if (e.IsMainFrame) { DOMDocument document = e.Browser.GetDocument(); List <DOMNode> divs = document.GetElementsByTagName("div"); foreach (DOMNode div in divs) { if (div.NodeType == DOMNodeType.ElementNode) { DOMElement divElement = (DOMElement)div; Console.Out.WriteLine(@"class = {0}; offsetTop = {1}; offsetLeft = {2}; offsetWidth = {3}; offsetHeight = {4} ; clientTop = {5}; clientLeft = {6}; clientWidth = {7}; clientHeight = {8} ; scrollTop = {9}; scrollLeft = {10}; scrollWidth = {11}; scrollHeight = {12}" , divElement.GetAttribute("class") , divElement.OffsetTop , divElement.OffsetLeft , divElement.OffsetWidth , divElement.OffsetHeight , divElement.ClientTop , divElement.ClientLeft , divElement.ClientWidth , divElement.ClientHeight , divElement.ScrollTop , divElement.ScrollLeft , divElement.ScrollWidth , divElement.ScrollHeight ); } } waitEvent.Set(); } }; browser.LoadURL("http://www.google.com"); waitEvent.WaitOne(); Thread.Sleep(100000); } }
private void DisplayError() { if (_validationSummaryElement != null) { if (_validationSummaryULElement != null) { // replace all children with the current error list ValidationUtil.RemoveAllChildren(_validationSummaryULElement); for (int i = 0; i < _errors.Length; i++) { DOMElement liElement = Document.CreateElement("li"); ValidationUtil.SetInnerText(liElement, (string)_errors[i]); _validationSummaryULElement.AppendChild(liElement); } } DomElement.RemoveCssClass(_validationSummaryElement, _validationSummaryValidCss); DomElement.AddCssClass(_validationSummaryElement, _validationSummaryErrorCss); } }
public void Show(DOMElement anchor, int minWidth, int maxWidth, int topOffset, int leftOffset, bool rightAlign) { container.Style.Display = container.ChildNodes.Length > 0 ? "" : "none"; if (container.ChildNodes.Length > 0) { JQueryObject jq = JQueryAPI.JQuery(anchor); int anchorOffsetHeight = anchor == null ? 0 : anchor.OffsetHeight; int anchorOffsetWidth = anchor == null ? 0 : anchor.OffsetWidth; if (minWidth == 0 && maxWidth == 0) { minWidth = anchorOffsetWidth; maxWidth = anchorOffsetWidth; } int nudgeLeft = Browser.Agent == Browser.InternetExplorer ? -2 : 0; int nudgeTop = Browser.Agent == Browser.InternetExplorer ? -2 : 0; int nudgeWidth = Browser.Agent == Browser.InternetExplorer ? 0 : -2; container.Style.Left = jq.Offset().Left + nudgeLeft + leftOffset + "px"; container.Style.Top = jq.Offset().Top + anchorOffsetHeight + nudgeTop - 1 + topOffset + "px"; container.Style.Width = "auto"; if (container.OffsetWidth < minWidth) container.Style.Width = minWidth + nudgeWidth + "px"; else if (container.OffsetWidth > maxWidth) container.Style.Width = maxWidth + nudgeWidth + "px"; if (rightAlign) { Trace.Write("" + jq.Offset().Left + ", " + nudgeLeft + ", " + anchor.ClientWidth + ", " + container.ClientWidth); container.Style.Left = (jq.Offset().Left + nudgeLeft + anchor.ClientWidth - container.ClientWidth) + "px"; } } }
public Marker(GMarker gMarker) { this.gMarker = gMarker; Hover = Document.CreateElement("UL"); GEvent.addListener(gMarker, "mouseout", delegate() { try { Script.Literal("htm();"); } catch (Exception e) { } }); GEvent.addListener(gMarker, "click", delegate() { //this.view.uiPlacesMultiSelector.AddItem(name, k.ToString()); }); GEvent.addListener(gMarker, "mouseover", delegate() { Script.Literal("stt({0});", Hover.InnerHTML); }); GEvent.addListener(gMarker, "mouseout", delegate() { try { Script.Literal("htm();"); } catch (Exception e) { } }); }
public void InitialiseFromStub(RoomStub roomStub, DOMElement roomList, StateStub[] controllerStateStore) { stub = roomStub; Guid = stub.guid; Name = stub.name; Url = stub.url; Pinable = stub.pinable; pinned = stub.pinned; starred = stub.starred; Starrable = stub.starrable; isStarredByDefault = stub.isStarredByDefault; ReadOnly = stub.readOnly; IsPhotoChatRoom = stub.isPhotoChatRoom; IsPrivateChatRoom = stub.isPrivateChatRoom; IsNewPhotoAlertsRoom = stub.isNewPhotoAlertsRoom; Presence = stub.presence; tokenDateTimeTicks = stub.tokenDateTimeTicks; token = stub.token; hasArchive = stub.hasArchive; state = new StateStub(); state.Initialise( stub.guid, stub.selected, stub.guest, stub.newMessages, stub.totalMessages, stub.latestItem, stub.latestItemSeen, stub.latestItemOld, stub.listOrder, stub.tokenDateTimeTicks, stub.token); addToStateStoreIfNotAlreadyThere(controllerStateStore, state); html = new RoomHtml(stub, LoggedIn); string outerClientID = roomStub.parentClientID + "_Room_" + Guid + "_Outer"; DOMElement newNode = Document.CreateElement("span"); newNode.ID = outerClientID; newNode.InnerHTML = html.ToHtml(); roomList.AppendChild(newNode.FirstChild); InitialiseElements(outerClientID); genericInitialise(); }
public void InitialiseFromElement(DOMElement e, StateStub[] controllerStateStore) { Guid = e.Attributes.GetNamedItem("roomGuid").Value; Name = e.Attributes.GetNamedItem("roomName").Value; Url = e.Attributes.GetNamedItem("roomUrl").Value; Pinable = bool.Parse(e.Attributes.GetNamedItem("roomPinable").Value); pinned = bool.Parse(e.Attributes.GetNamedItem("roomPinned").Value); starred = bool.Parse(e.Attributes.GetNamedItem("roomStarred").Value); Starrable = bool.Parse(e.Attributes.GetNamedItem("roomStarrable").Value); isStarredByDefault = bool.Parse(e.Attributes.GetNamedItem("roomIsStarredByDefault").Value); ReadOnly = bool.Parse(e.Attributes.GetNamedItem("roomReadOnly").Value); IsPhotoChatRoom = bool.Parse(e.Attributes.GetNamedItem("roomIsPhotoChatRoom").Value); IsPrivateChatRoom = bool.Parse(e.Attributes.GetNamedItem("roomIsPrivateChatRoom").Value); IsNewPhotoAlertsRoom = bool.Parse(e.Attributes.GetNamedItem("roomIsNewPhotoAlertsRoom").Value); Presence = (PresenceState)int.ParseInvariant(e.Attributes.GetNamedItem("roomPresence").Value); Icon = e.Attributes.GetNamedItem("roomIcon").Value; tokenDateTimeTicks = e.Attributes.GetNamedItem("roomTokenDateTimeTicks").Value; token = e.Attributes.GetNamedItem("roomToken").Value; hasArchive = bool.Parse(e.Attributes.GetNamedItem("roomHasArchive").Value); hiddenFromRoomList = bool.Parse(e.Attributes.GetNamedItem("roomHiddenFromRoomList").Value); isStreamRoom = bool.Parse(e.Attributes.GetNamedItem("roomisStreamRoom").Value); state = new StateStub(); state.Initialise( Guid, bool.Parse(e.Attributes.GetNamedItem("roomSelected").Value), bool.Parse(e.Attributes.GetNamedItem("roomGuest").Value), int.ParseInvariant(e.Attributes.GetNamedItem("roomNewMessages").Value), int.ParseInvariant(e.Attributes.GetNamedItem("roomTotalMessages").Value), e.Attributes.GetNamedItem("roomLatestItem").Value, e.Attributes.GetNamedItem("roomLatestItemSeen").Value, e.Attributes.GetNamedItem("roomLatestItemOld").Value, int.ParseInvariant(e.Attributes.GetNamedItem("roomListOrder").Value), tokenDateTimeTicks, token); addToStateStoreIfNotAlreadyThere(controllerStateStore, state); stub = new RoomStub( Parent.ClientID, Guid, Name, Url, Pinned, Starred, isStarredByDefault, Pinable, Starrable, Selected, Guest, NewMessages, TotalMessages, LatestItem, LatestItemSeen, LatestItemOld, ReadOnly, state.listOrder, IsPhotoChatRoom, IsPrivateChatRoom, IsNewPhotoAlertsRoom, Presence, Icon, tokenDateTimeTicks, token, hasArchive, hiddenFromRoomList, isStreamRoom); html = new RoomHtml(stub, LoggedIn); InitialiseElements(""); genericInitialise(); }
/// <summary>Removes a DOM node from the document. The body node will be ignored if passed in.</summary> /// <param name="node">The node to remove</param> /// <returns></returns> public extern static void removeNode(DOMElement node);
public void AddToRoomsList(DOMElement parent) { parent.AppendChild(RoomElement); }
private void RemoveAllChildren(DOMElement dOMElement) { dOMElement.InnerHTML = ""; }
public HtmlAutoCompleteBehaviour(InputElement input, InputElement hiddenInput, DOMElement anchor, bool isSuggest, InputElement parametersHiddenField) { DOMAttribute cometAtt = input.GetAttributeNode(HtmlAutoCompleteAttributes.CometServiceUrl); remoteSuggestionsGetter = new WebServiceRemoteSuggestionsGetter( input.GetAttributeNode(HtmlAutoCompleteAttributes.WebServiceUrl).Value, input.GetAttributeNode(HtmlAutoCompleteAttributes.WebServiceMethod).Value ); this.mode = isSuggest == true ? HtmlAutoCompleteMode.Suggest : HtmlAutoCompleteMode.Complete; this.input = input; this.hiddenInput = hiddenInput; this.anchor = anchor == null ? input : anchor; DomEvent.AddHandler(input, "blur", delegate(DomEvent e) { Window.SetTimeout(DoBlur, 250); }); DomEvent.AddHandler(input, "keydown", this.HandleKeyDown); DomEvent.AddHandler(input, "keyup", this.HandleKeyUp); DomEvent.AddHandler(input, "focus", CallOnFocus); DOMAttribute waterMarkNode = input.GetAttributeNode(HtmlAutoCompleteAttributes.Watermark); if (waterMarkNode != null) { watermarker = new WatermarkExtender(input, input.GetAttributeNode(HtmlAutoCompleteAttributes.Watermark).Value); } DOMAttribute popupLeftNode = input.GetAttributeNode(HtmlAutoCompleteAttributes.PopupLeftOffset); popupLeftOffset = popupLeftNode == null ? 0 : int.ParseInvariant(popupLeftNode.Value); DOMAttribute popupTopNode = input.GetAttributeNode(HtmlAutoCompleteAttributes.PopupTopOffset); popupTopOffset = popupTopNode == null ? 0 : int.ParseInvariant(popupTopNode.Value); DOMAttribute rightAlignNode = input.GetAttributeNode(HtmlAutoCompleteAttributes.RightAlign); rightAlign = rightAlignNode == null ? false : bool.Parse(rightAlignNode.Value); if (input.GetAttributeNode(HtmlAutoCompleteAttributes.PopupLeftOffset) != null) { popupLeftOffset = int.ParseInvariant(input.GetAttributeNode(HtmlAutoCompleteAttributes.PopupLeftOffset).Value); } Parameters = new PairListField(parametersHiddenField); Suggestions.OnSuggestionsChanged = delegate() { DisplaySuggestionsInPopupMenu(); }; this.remoteSuggestionsGetter.OnAllSuggestionsReceived = delegate() { RemoveLowPrioritySuggestionsAndSetRemainingSuggestionsToLowPriority(); HideAjaxIcon(); }; this.remoteSuggestionsGetter.OnSuggestionsRequested = delegate() { ShowAjaxIcon(); }; this.remoteSuggestionsGetter.OnSuggestionReceived = delegate(Suggestion[] newSuggestions) { Trace.Write("Received" + newSuggestions.Length + "suggestions"); if (TransformReceivedSuggestions != null) { AddSuggestions(TransformReceivedSuggestions(newSuggestions, maxNumberOfItemsToGet)); } else { AddSuggestions(newSuggestions); } }; this.remoteSuggestionsGetter.OnAbortCurrentRequest= delegate() { HideAjaxIcon(); }; }
public void SetHeader(DOMElement el) { header = el; }
public static bool ElementSupportsEvent(DOMElement element, string eventAttributeName) { return (bool)Script.Literal("({0} in {1})", eventAttributeName, element); }
public static JQueryObject JQuery(DOMElement e) { return null; }