public HTMLElement Div(Action <HTMLElement> Edit = null) { var Element = new Div_html().Main; Edit?.Invoke(Element); Main.AppendChild(Element); return(Element); }
public void StartElement(string name) { var element = Document.CreateElement(name); _currentElement.AppendChild(element); _stack.Push(_currentElement); _currentElement = element; }
public HTMLElement Count() { var Element = new Input_Count_html(); Main.AppendChild(Element.Main); return(Element.txt_Count); }
public static void AppendChildren(this HTMLElement parent, params HTMLElement[] elems) { foreach (var element in elems) { parent.AppendChild(element); } }
private static void AddNewTeacher(HTMLElement sender) { // Get name input and it's value HTMLInputElement input = (sender.ParentElement.ParentElement.GetElementsByClassName("form-group")[0].Children.Where(x => x.Id == ("teacher-name")).First() as HTMLInputElement); string newTeacherName = input.Value; if (newTeacherName == "") { return; } plan.teachers.Add(new User(newTeacherName, new bool[5], new int[5], new int[5])); HTMLElement div = Gid("teachers"); HTMLDivElement card = new HTMLDivElement(); card.ClassName = "card card-body"; card.InnerHTML += "<p><strong>" + newTeacherName + "</strong></p>"; HTMLButtonElement setHours = new HTMLButtonElement(); setHours.Name = (plan.teachers.Count - 1).ToString(); setHours.ClassName = "btn btn-primary teacher-click"; setHours.SetAttribute("data-toggle", "modal"); setHours.SetAttribute("data-target", "#setHoursModal"); setHours.InnerHTML = "Nastavit hodiny"; setHours.OnClick += (e) => { EditHoursClick(setHours, true); }; card.AppendChild(setHours); div.AppendChild(card); input.Value = ""; // Allow only one teacher Gid("add-new-teacher-modal-button").Remove(); }
public static void AddChartsRender(HTMLElement head) { var scriptChartsRender = new HTMLScriptElement() { Src = "ChartsRender.js", }; head.AppendChild(scriptChartsRender); }
public static void InsertChild(this HTMLElement element, int index, HTMLElement child) { if (index < element.ChildElementCount) { element.InsertBefore(child, element.Children[index]); } else { element.AppendChild(child); } }
public FileExplorer(HTMLElement element, FormFileExplorer owner = null) { Element = element; Owner = owner; LoadedExplorers.Add(this); Element.AddEventListener(EventType.MouseDown, (ev) => { if (Form.MovingForm == null) { Form.ActiveFileExplorer = this; if (Form.WindowHolderSelectionBox != null) { Form.WindowHolderSelectionBox.Remove(); Form.WindowHolderSelectionBox = null; } Form.WindowHolderSelectionBox = new HTMLDivElement(); Form.WindowHolderSelectionBox.Style.Position = Position.Absolute; Form.WindowHolderSelectionBox.Style.Visibility = Visibility.Visible; Form.WindowHolderSelectionBox.Style.BorderWidth = BorderWidth.Thin; Form.WindowHolderSelectionBox.Style.BorderStyle = BorderStyle.Solid; Form.WindowHolderSelectionBox.Style.BorderColor = "black"; Form.WindowHolderSelectionBox.Style.BackgroundColor = "grey"; Form.WindowHolderSelectionBox.Style.Opacity = "0.35"; Element.AppendChild(Form.WindowHolderSelectionBox); var mev = ev.As <MouseEvent>(); if (Form.ActiveFileExplorer.Owner != null) { Form.WindowHolderSelectionBoxXOff = Global.ParseInt(Form.ActiveFileExplorer.Owner.Left); Form.WindowHolderSelectionBoxYOff = Global.ParseInt(Form.ActiveFileExplorer.Owner.Top) + Form.ActiveFileExplorer.Owner.TitleBarHeight(); } else { Form.WindowHolderSelectionBoxXOff = 0; Form.WindowHolderSelectionBoxYOff = 0; } Form.WindowHolderSelectionBoxX = mev.ClientX - Form.WindowHolderSelectionBoxXOff + Element.ScrollLeft; Form.WindowHolderSelectionBoxY = mev.ClientY - Form.WindowHolderSelectionBoxYOff + Element.ScrollTop; Form.WindowHolderSelectionBox.Style.ZIndex = "0"; ClearSelection(); Form.Mouse_Down = true; Form.ActiveForm = null; } }); }
public static Dictionary <int, EditorCursorCoordinate> GetCoordinates(HTMLTextAreaElement element, Author[] authors) { var value = element.Value + "_"; div?.Remove(); div = Document.CreateElement("div"); Document.Body.AppendChild(div); var style = div.Style; var computed = Window.GetComputedStyle(element); style.WhiteSpace = WhiteSpace.PreWrap; style.WordWrap = "break-word"; style.Position = Position.Absolute; //style.Visibility = Visibility.Hidden; foreach (var prop in propeties) { style[prop] = computed[prop]; } var positions = authors.Select(a => a.Position) .Where(p => p < value.Length) .Concat(new[] { value.Length, value.Length + 1 }) .OrderBy() .Distinct() .ToArray(); div.TextContent = value.Substring(0, positions[0]); var result = new Dictionary <int, EditorCursorCoordinate>(); var j = 0; for (var i = 0; i < positions.Length - 1; i++) { var span = Document.CreateElement("span"); span.Style.BackgroundColor = colors[j++ % colors.Length]; span.TextContent = value.Substring(positions[i], positions[i + 1]); div.AppendChild(span); result[positions[i]] = new EditorCursorCoordinate { Top = span.OffsetTop + SafeIntParse(computed.BorderTopWidth), Left = span.OffsetLeft + SafeIntParse(computed.BorderLeftWidth), Height = SafeIntParse(computed.LineHeight) }; } div.Remove(); div = null; return(result); }
public static void AddHighcharts(HTMLElement head) { var scriptHighcharts = new HTMLScriptElement() { Src = "https://cdnjs.cloudflare.com/ajax/libs/highcharts/6.0.7/highcharts.js", CrossOrigin = "anonymous", }; scriptHighcharts.SetAttribute("integrity", "sha256-F0xKYvUdYPCgKKgKGtEjxwHXKSRbwKP+2mOlgGoR0Fs="); head.AppendChild(scriptHighcharts); }
public static void AddJquery(HTMLElement head) { var scriptJquery = new HTMLScriptElement() { Src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js", CrossOrigin = "anonymous", }; scriptJquery.SetAttribute("integrity", "sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="); head.AppendChild(scriptJquery); }
public SvgDefinitionContainer(RenderQueue renderQueue) { this.renderQueue = renderQueue; HtmlElement = SvgDocument.CreateElement("svg"); HtmlElement.Style.SetProperty("overflow", "hidden"); HtmlElement.Style.Width = "0px"; HtmlElement.Style.Height = "0px"; definitionsElement = SvgDocument.CreateElement("defs"); HtmlElement.AppendChild(definitionsElement); }
public static void AddBootstrap(HTMLElement head) { var scriptBootstrap = new HTMLScriptElement() { Src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js", CrossOrigin = "anonymous", }; scriptBootstrap.SetAttribute("integrity", "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"); head.AppendChild(scriptBootstrap); var linkBootstrap = new HTMLLinkElement() { Href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css", Rel = "stylesheet", }; linkBootstrap.SetAttribute("integrity", "sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"); linkBootstrap.SetAttribute("crossorigin", "anonymous"); head.AppendChild(linkBootstrap); }
public static void AppendTypos(HTMLElement control, params Union <string, Control, HTMLElement>[] typos) { if (typos != null) { int length = typos.Length; for (int i = 0; i < length; i++) { if (typos[i].Is <string>()) { control.AppendChild(Document.CreateTextNode((string)typos[i])); } else if (typos[i].Is <Control>()) { control.AppendChild((Control)typos[i]); } else if (typos[i].Is <HTMLElement>()) { control.AppendChild((HTMLElement)typos[i]); } } } }
//invisble div inside the black window that servers to hold the log elements private static HTMLElement CreateLogDiv(HTMLElement p_logWindow) { var __logDiv = Document.CreateElement("div"); p_logWindow.AppendChild(__logDiv); __logDiv.Style.CssFloat = Float.Left; __logDiv.Style.Width = "calc(100% - 10px)"; __logDiv.Style.Height = "calc(100% - 8px)"; __logDiv.Style.Overflow = Overflow.Hidden; return(__logDiv); }
static HTMLDivElement AppendSageDiv(string s) { if (_sageContainer.ChildElementCount > 0) { _sageContainer.RemoveChild(_sageContainer.Children[0]); } var div = new HTMLDivElement(); div.ClassName = "compute"; div.TextContent = s; _sageContainer.AppendChild(div); return(div); }
/// <summary> /// </summary> /// Overrides {@link goog.ui.ControlRenderer#decorate} by initializing the /// menu item to checkable based on whether the element to be decorated has /// extra stying indicating that it should be. /// <param name="item">Menu item instance to decorate the element.</param> /// <param name="element">Element to decorate.</param> /// <returns>Decorated element.</returns> public override HTMLElement decorate(goog.ui.Control item, HTMLElement element) { goog.asserts.assert(element != null); if (!this.hasContentStructure(element)) { element.AppendChild( this.createContent(new ControlContent(element.ChildNodes), item.getDomHelper())); } if (goog.dom.classlist.contains(element, le.getCssName("goog-option"))) { ((goog.ui.MenuItem)item).setCheckable(true); this.setCheckable((goog.ui.MenuItem)item, element, true); } return(base.decorate(item, element)); }
public void Log(string p_message) { var __p = Document.CreateElement("p"); _messageCounter++; __p.InnerHTML = p_message + "." + _messageCounter.ToString("000"); if (_logDiv.FirstChild != null) { _logDiv.InsertBefore(__p, _logDiv.FirstChild); } else { _logDiv.AppendChild(__p); } }
public ActionButtonsMenuBarView( Func <MenuItemModel, InputTypeButtonActionView> customButtonBuilder = null) { _buttonBuilder = customButtonBuilder ?? (x => { var res = new InputTypeButtonActionView(x.Label.Value); x.Label.Changed += (_, __, newValue, ___, ____) => res.ProperLabelElem.TextContent = newValue; res.Widget.SetAttribute(Magics.AttrDataMenuItemId, x.Id.ToString()); if (x.DescriptonOrNull != null) { res.Widget.Title = x.DescriptonOrNull; } return(res); }); _nav = DocumentUtil.CreateElementHavingClassName("nav", GetType().FullName); _nav.Id = UniqueIdGenerator.GenerateAsString(); _actionsCntnr = new HTMLDivElement(); _nav.AppendChild(_actionsCntnr); }
private void SetGradientStops() { RenderGradientStop[] gradientStops = GradientStops.ToArray(); HTMLElement htmlElement = HtmlElement; while (htmlElement.ChildNodes.Length > gradientStops.Length) { htmlElement.RemoveChild(htmlElement.LastElementChild); } while (htmlElement.ChildNodes.Length < gradientStops.Length) { htmlElement.AppendChild(SvgDocument.CreateElement("stop")); } for (int i = 0; i < gradientStops.Length; i++) { Element stopElement = (Element)htmlElement.ChildNodes[i]; stopElement.SetAttribute("stop-color", converter.ToColorString(gradientStops[i].Color)); stopElement.SetAttribute("stop-opacity", converter.ToImplicitValueString(Opacity * gradientStops[i].Color.A / 255)); stopElement.SetAttribute("offset", converter.ToImplicitValueString(gradientStops[i].Offset)); } }
public static void AppendAllChildren(this HTMLElement self, IEnumerable <HTMLElement> items) => items.ForEach(x => self.AppendChild(x));
public void Add(HtmlRenderResource svgDefinition) { renderQueue.InvokeAsync(() => definitionsElement.AppendChild(svgDefinition.HtmlElement)); }
public void AppendTo(HTMLElement el) { el.AppendChild(this.container); }
public HorizontalMenuBarView( Func <MenuItemModel, Tuple <HTMLElement, Action <string> > > customItemBuilder = null) { _itemBuilder = customItemBuilder ?? (x => { var el = new HTMLAnchorElement { Href = "#" }; return(Tuple.Create <HTMLElement, Action <string> >(el, y => el.TextContent = y)); }); _nav = DocumentUtil.CreateElementHavingClassName("nav", GetType().FullNameWithoutGenerics()); _nav.Id = UniqueIdGenerator.GenerateAsString(); _root = new HTMLElement("ul") { Id = UniqueIdGenerator.GenerateAsString() }; _nav.AppendChild(_root); _onItemClicked = ev => { if (!ev.HasHtmlTarget()) { return; } ev.PreventDefault(); var htmlTarget = ev.HtmlTarget(); var menuItemId = htmlTarget.GetAttribute(Magics.AttrDataMenuItemId); Logger.Debug(GetType(), "user activated menuItemId {0} in view", menuItemId); ActivateAllBut(_root, new List <HTMLElement>()); ItemActivated?.Invoke(Convert.ToInt32(menuItemId)); }; _onMouseOver = ev => { if (!ev.HasHtmlCurrentTarget()) { return; } var hoverOn = ev.HtmlCurrentTarget(); var active = new List <HTMLElement> { hoverOn }; var parent = hoverOn.ParentElement; while (parent != _root) { active.Add(parent); parent = parent.ParentElement; } ActivateAllBut(_root, active); hoverOn.Focus(); }; Document.Body.AddEventListener("click", ev => { //find out if clicked item is a descendant of menu - if not fold whole menu if (!ev.HasHtmlTarget()) { return; } if (ev.HtmlTarget().IsDescendantOf(_nav)) { return; } ActivateAllBut(_root, new List <HTMLElement>()); }); }
public void Refresh() { if (LoadedNodes == null) { LoadedNodes = new List <FileExplorerNode>(); } else if (LoadedNodes.Count > 0) { ClearItems(); } var nvt = NodeViewType; if (Path == DesktopPath) { // load the locations of the desktop items. nvt = NodeViewType.Medium_Icons; } string[] Files = Directory.GetFiles(Path); string[] Folders = Directory.GetDirectories(Path); for (int i = 0; i < Files.Length; i++) { LoadedNodes.Add(FileExplorerNode.CreateNode(Files[i], NodeViewType, this, true)); } for (int i = 0; i < Folders.Length; i++) { LoadedNodes.Add(FileExplorerNode.CreateNode(Folders[i], NodeViewType, this)); } // get the order type!! #TODO# sort items int x = 0; int y = 19; int j = 0; for (int i = 0; i < LoadedNodes.Count; i++) { if (LoadedNodes[i] != null && LoadedNodes[i].NodeBase != null) { jQuery.Select(LoadedNodes[i].NodeBase). Css("left", x). Css("top", y); Element.AppendChild(LoadedNodes[i].NodeBase); j++; y += 70; if (j > 8) { x += 78; y = 0; j = 0; } y += 19; } } }
public void Load(HTMLElement element, Component comp) { _comp = comp; _element = element; var config = new AjaxOptions { Url = _comp.Markup, // Serialize the msg into json //Data = new { value = JsonConvert.SerializeObject(msg) }, // Set the contentType of the request //ContentType = "application/json; charset=utf-8", Error = (jqXHR, d1, d2) => { return; }, // On response, call custom success method Success = (data, textStatus, jqXHR) => { var div = new HTMLDivElement(); var s = data.ToString(); var pattern = @"{{([a-zA-Z0-9_]+)}}"; var s2 = Regex.Replace(s, pattern, "<as_replace text=\"$1\"></as_replace>"); div.InnerHTML = s2; _element.AppendChild(div); var bs = div.QuerySelectorAll("[model]"); var inputs = div.GetElementsByTagName("input"); //inputs.Where(x => x.HasAttribute("model")).DoAction((e) => { e.OnInput = (y) => { var c = 2; }; }); foreach (var input in inputs) { var m = input.GetAttribute("model"); var inEl = input as HTMLInputElement; (_comp as INotifyPropertyChanged).PropertyChanged += (sender, args) => { if (args.PropertyName == m) { inEl.Value = sender.GetType().GetProperty(args.PropertyName).GetValue(sender).ToString(); } }; input.OnInput = (e) => { var val = (input as HTMLInputElement).Value; var p = _comp.GetType().GetProperty(m); p.SetValue(_comp, val); }; } var reps = div.GetElementsByTagName("as_replace"); foreach (var rep in reps) { var m = rep.GetAttribute("text"); (_comp as INotifyPropertyChanged).PropertyChanged += (sender, args) => { if (args.PropertyName == m) { rep.TextContent = sender.GetType().GetProperty(args.PropertyName).GetValue(sender).ToString(); } }; } } }; // Make the Ajax request jQuery.Ajax(config); }
public void AppendTo(HTMLElement el) { el.AppendChild(this.container); }
/// <summary> /// Render the navigation row (navigating months and maybe years). /// </summary> /// <param name="row">The parent element to render the component into.</param> /// <param name="simpleNavigation">Whether the picker should render a simple /// navigation menu that only contains controls for navigating to the next /// and previous month. The default navigation menu contains controls for /// navigating to the next/previous month, next/previous year, and menus for /// jumping to specific months and years.</param> /// <param name="showWeekNum">Whether week numbers should be shown.</param> /// <param name="fullDateFormat">The full date format. /// {@see goog.i18n.DateTimeSymbols}.</param> public override void renderNavigationRow(HTMLElement row, bool simpleNavigation, bool showWeekNum, string fullDateFormat) { // Populate the navigation row according to the configured navigation mode. HTMLTableDataCellElement cell, monthCell, yearCell; if (simpleNavigation) { cell = (HTMLTableDataCellElement)this.getDomHelper().createElement(goog.dom.TagName.TD); cell.ColSpan = showWeekNum ? 1 : 2; this.createButton_( cell, "\u00AB", le.getCssName(this.getBaseCssClass(), "previousMonth")); // << row.AppendChild(cell); cell = (HTMLTableDataCellElement)this.getDomHelper().createElement(goog.dom.TagName.TD); cell.ColSpan = showWeekNum ? 6 : 5; cell.ClassName = le.getCssName(this.getBaseCssClass(), "monthyear"); row.AppendChild(cell); cell = (HTMLTableDataCellElement)this.getDomHelper().createElement(goog.dom.TagName.TD); this.createButton_( cell, "\u00BB", le.getCssName(this.getBaseCssClass(), "nextMonth")); // >> row.AppendChild(cell); } else { monthCell = (HTMLTableDataCellElement)this.getDomHelper().createElement(goog.dom.TagName.TD); monthCell.ColSpan = 5; this.createButton_( monthCell, "\u00AB", le.getCssName(this.getBaseCssClass(), "previousMonth")); // << this.createButton_( monthCell, "", le.getCssName(this.getBaseCssClass(), "month")); this.createButton_( monthCell, "\u00BB", le.getCssName(this.getBaseCssClass(), "nextMonth")); // >> yearCell = (HTMLTableDataCellElement)this.getDomHelper().createElement(goog.dom.TagName.TD); yearCell.ColSpan = 3; this.createButton_( yearCell, "\u00AB", le.getCssName(this.getBaseCssClass(), "previousYear")); // << this.createButton_( yearCell, "", le.getCssName(this.getBaseCssClass(), "year")); this.createButton_( yearCell, "\u00BB", le.getCssName(this.getBaseCssClass(), "nextYear")); // << // If the date format has year ("y") appearing first before month ("m"), // show the year on the left hand side of the datepicker popup. Otherwise, // show the month on the left side. This check assumes the data to be // valid, and that all date formats contain month and year. if (fullDateFormat.IndexOf("y") < fullDateFormat.IndexOf("m")) { row.AppendChild(yearCell); row.AppendChild(monthCell); } else { row.AppendChild(monthCell); row.AppendChild(yearCell); } } }
public static void AppendAllChildren(this HTMLElement self, params HTMLElement[] items) => items.ForEach(x => self.AppendChild(x));
private void ShowTooltipOn(HTMLElement tooltipOn, TooltipMode mode, bool forceFullCycle = false) { var content = GetTooltipsOfElementOrNull(tooltipOn, mode); Logger.Debug(GetType(), "ShowTooltipOn starting forceFullCycle={0} mode={1}", forceFullCycle, mode); if (content == null) { Logger.Debug(GetType(), "tooltip show ignored as it would be empty"); return; } var contAndTt = GetOrCreateTooltipOn(tooltipOn, content, mode); var cont = contAndTt.Item1; var tt = contAndTt.Item2; Logger.Debug(GetType(), "ShowTooltipOn gotOrCreated id={0}", tt.Id); //tooltipOn.ParentElement.Style.Position = Position.Relative; tooltipOn.Style.Position = Position.Relative; if (!tooltipOn.HasAttribute(Magics.AttrDataMayBeTooltipContainer)) { if (tooltipOn.ParentElement != null) { tooltipOn.ParentElement.InsertAfter(cont, tooltipOn); } } else { tooltipOn.AppendChild(cont); } var ops = new List <TooltipOper>(); _pendingTooltipOps[tt] = ops; _tooltips.Set(tt, Tuple.Create(tt, mode)); if (forceFullCycle) { tt.ClassList.Remove(Magics.CssClassActive); tt.ClassList.Remove(Magics.CssClassInactive); tt.ClassList.Add(Magics.CssClassDisabled); } switch (GetTooltipState(tt)) { case TooltipState.EnabledShown: break; //already in the right state case TooltipState.Disabled: ops.AddRange( Immediate(Magics.CssClassDisabled, Magics.CssClassInactive), Lasting(Magics.CssClassInactive, Magics.CssClassActive, Magics.TooltipFadeInMs)); break; case TooltipState.EnabledHidden: //interrupted showning or hiding ops.Add(Lasting(Magics.CssClassInactive, Magics.CssClassActive, Magics.TooltipFadeInMs)); break; default: throw new ArgumentException("ShowTooltipOn unknown state"); } //autohide? if (mode == TooltipMode.PeekIntoErrors) { ops.AddRange( Lasting(Magics.CssClassActive, Magics.CssClassInactive, Magics.TooltipFadeOutMs), Immediate(Magics.CssClassInactive, Magics.CssClassDisabled)); } Logger.Debug(GetType(), "ShowTooltipOn scheduled {0} opers", ops.Count); ScheduleNextOperation(tt); }
public T Add(IElementBuilder child) { element.AppendChild(child.BuildElement()); return(this as T); }