public string GetHtmlStringByBrowserElement(IBrowserElement element) { try { StringBuilder rawHtmlBuilder = new StringBuilder(); switch (element.Type) { case BrowserElementType.Card: BrowserCard card = element as BrowserCard; switch (card.CardType) { case BrowserCardType.HeaderDescriptionAndButtonWithIcon: string cardHtml2 = GetHtmlToAppendByBrowserCard(card); rawHtmlBuilder.Append(cardHtml2); break; default: string cardHtml3 = GetHtmlToAppendByBrowserCard(card); rawHtmlBuilder.Append(cardHtml3); break; } break; case BrowserElementType.BrowserBoxSelection: // Not implemented yet BrowserBoxSelection boxSelection = element as BrowserBoxSelection; rawHtmlBuilder.Append(GetHtmlToAppendByBrowserBoxSelection(boxSelection)); break; case BrowserElementType.Title: BrowserTitle titleElement = element as BrowserTitle; rawHtmlBuilder.Append(GetHtmlToAppendByBrowserTitle(titleElement)); break; case BrowserElementType.Text: BrowserText textElement = element as BrowserText; rawHtmlBuilder.Append(GetHtmlToAppendByBrowserTextElement(textElement)); break; case BrowserElementType.Checkbox: BrowserCheckBox checkBoxElement = element as BrowserCheckBox; rawHtmlBuilder.Append(GetHtmlToAppendByCheckBox(checkBoxElement)); break; case BrowserElementType.Button: BrowserButton browserButton = element as BrowserButton; rawHtmlBuilder.Append(GetHtmlToAppendByBrowserButton(browserButton)); break; case BrowserElementType.TextBox: BrowserTextBox browserTextBox = element as BrowserTextBox; rawHtmlBuilder.Append(GetHtmlToAppendByBrowserTextBox(browserTextBox)); break; case BrowserElementType.Password: BrowserPasswordTextBox browserPasswordTextBox = element as BrowserPasswordTextBox; rawHtmlBuilder.Append(GetHtmlToAppendByBrowserPasswordTextBox(browserPasswordTextBox)); break; case BrowserElementType.DropDown: BrowserDropDown dropDown = element as BrowserDropDown; rawHtmlBuilder.Append(GetHtmlToAppendByBrowserDropDown(dropDown)); break; case BrowserElementType.ProgressBar: BrowserProgressbar progressBar = element as BrowserProgressbar; rawHtmlBuilder.Append(GetHtmlToAppendByBrowserProgressBar(progressBar)); break; case BrowserElementType.Icon: BrowserButtonIcon icon = element as BrowserButtonIcon; rawHtmlBuilder.Append(GetHtmlToAppendByIcon(icon)); break; } return(rawHtmlBuilder.ToString()); } catch (Exception e) { ProvideError(e); return(""); } }
public string GetDefaultStyleSettings(IBrowserElement browserElement, bool excludeOverflow = false, bool excludeWidthAndHeight = false) { string returner = ""; if (!excludeWidthAndHeight) { if (!string.IsNullOrEmpty((browserElement.Width))) { Stylesheet width = new Stylesheet("width", browserElement.Width); returner += width; } if (!string.IsNullOrEmpty((browserElement.Height))) { Stylesheet height = new Stylesheet("height", browserElement.Height); returner += height; } } if (!string.IsNullOrEmpty((browserElement.Cursor))) { Stylesheet cursor = new Stylesheet("cursor", browserElement.Cursor); returner += cursor; } if (!string.IsNullOrEmpty((browserElement.Margin))) { Stylesheet margin = new Stylesheet("margin", browserElement.Margin); returner += margin; } if (!string.IsNullOrEmpty((browserElement.Padding))) { Stylesheet padding = new Stylesheet("padding", browserElement.Padding); returner += padding; } if (!string.IsNullOrEmpty(browserElement.BackgroundColor)) { Stylesheet backgroundColor = new Stylesheet("background-color", browserElement.BackgroundColor); returner += backgroundColor; } if (!string.IsNullOrEmpty(browserElement.Opacity)) { Stylesheet opacity = new Stylesheet("opacity", browserElement.Opacity); returner += opacity; } if (browserElement.ScrollBarX) { Stylesheet scrollBarX = new Stylesheet("overflow-x", "scroll"); returner += scrollBarX; } else { Stylesheet scrollBarX = new Stylesheet("overflow-x", "hidden"); returner += scrollBarX; } if (!excludeOverflow) { if (browserElement.ScrollBarY) { Stylesheet scrollBarY = new Stylesheet("overflow-y", "scroll"); returner += scrollBarY; } else { Stylesheet scrollBarY = new Stylesheet("overflow-y", "hidden"); returner += scrollBarY; } } if (browserElement.BorderStyle != BorderStyle.none) { if (string.IsNullOrEmpty(browserElement.BorderWidth)) { browserElement.BorderWidth = "1px"; } if (string.IsNullOrEmpty(browserElement.BorderColor)) { browserElement.BorderColor = "black"; } string borderStyle = browserElement.BorderStyle.ToString(); if (browserElement.BorderStyle == BorderStyle.doublee) { borderStyle = "double"; } string border = new Stylesheet("border", $"{browserElement.BorderWidth} {borderStyle} {browserElement.BorderColor}").ToString(); returner += border; } return(returner); }
public DelayedBrowserElement(IBrowserElement wrappedElement, DelayedBrowser browser) { this.wrappedElement = wrappedElement; this.browser = browser; }