static void Main(string[] args) { // Create the UI var div = new Div(); div.AppendChild(new Heading("JaxDug Sample")); div.AppendChild(new Paragraph("This is a sample page rendered from C# code.")); var button = new Button("Click me!"); div.AppendChild(button); // Add some logic to it var count = 0; button.Click += (s, e) => { count++; button.Text = $"Clicked {count} times"; }; // Publishing makes an object available at a given URL // The user should be directed to http://localhost:8080/shared-button UI.Publish("/page1", div); UI.Publish("/shared-button", button); // Don't exit the app until someone hits return Console.ReadLine(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); ContentLoader.LoadTileTextures(Content); ContentLoader.LoadShaders(Content); ContentLoader.LoadFonts(Content); gameWorld = new Dungeon(); camera = new Camera(GraphicsDevice.Viewport); graphics.SynchronizeWithVerticalRetrace = false; font = ContentLoader.GetFont("x32"); uiRoot = new Div(); uiRoot.SetMargin(300, 0, 0, 0); uiRoot.LayoutDirection = LayoutDirection.Horizontal; var helloButton = new Button("Hello World!"); helloButton.SetMargin(50, 50, 50, 50); helloButton.SetPadding(50, 50, 50, 50); var howdyButton = new Button("Howdy"); howdyButton.SetMargin(50, 50, 50, 50); uiRoot.AppendChild(helloButton); uiRoot.AppendChild(howdyButton); }
public Element CreateElement() { var heading = new Heading("Upload Files"); var subtitle = new Paragraph("Upload files to the app"); var uploadForm = new Form(); uploadForm.Action = "/files/upload"; uploadForm.Method = "POST"; uploadForm.EncodingType = "multipart/form-data"; uploadForm.AppendChild(new Input(InputType.File) { Name = "file" }); uploadForm.AppendChild(new Input(InputType.Submit) { Value = "Upload" }); var app = new Div(); app.AppendChild(heading); app.AppendChild(subtitle); app.AppendChild(uploadForm); return(app); }
public Anchor AddTab(string tabName, Element content, bool active) { if (_hasActiveTab == true && active == true) { throw new ArgumentException("Es darf nur ein Tab Aktiv sein", nameof(active)); } _hasActiveTab |= active; Anchor anchor = new Anchor("n/A", tabName) { ClassName = "nav-item nav-link" + (active ? " active" : "") }; anchor.SetAttribute("data-toggle", "tab"); anchor.SetAttribute("role", "tab"); anchor.SetAttribute("aria-selected", active ? "true" : "false"); _navigationDiv.AppendChild(anchor); Div div = new Div { ClassName = "tab-pane fade" + (active ? " show active" : "") }; div.SetAttribute("role", "tabpanel"); div.SetAttribute("aria-labelledby", anchor.Id); div.AppendChild(content); _contentDiv.AppendChild(div); anchor.SetAttribute("aria-controls", div.Id); anchor.HRef = "#" + div.Id; _contentDiv.AppendChild(div); return(anchor); }
private void CreateUI() { Style.Width = "100%"; Style.Display = "flex"; FirstCol = new Div(); AppendChild(FirstCol); SecondCol = new Div(); AppendChild(SecondCol); ThirdCol = new Div(); AppendChild(ThirdCol); ImageView = new Image(); FirstCol.AppendChild(ImageView); TextLabel = new Label(); SecondCol.AppendChild(TextLabel); DetailTextLabel = new Label(); SecondCol.AppendChild(DetailTextLabel); CustomView = new Div(); ThirdCol.AppendChild(CustomView); }
protected override Element PopulateAppElement() { Stopwatch stopwatchMain = new Stopwatch(); stopwatchMain.Start(); Div testDiv = new Div(); //Grid grid = new Grid(); Loading loading = new Loading(); //grid.AppendChild(loading); testDiv.AppendChild(loading); NavigationBar navigationBar = CreateNavigationBar(); if (navigationBar != null) { navigationBar.AddStyling(StylingOption.MarginBottom, 3); //grid.AddRow().AppendCollum(navigationBar); testDiv.AppendChild(navigationBar); } Stopwatch stopwatchCreatePage = new Stopwatch(); Element WaitForInitAndCreatePage() { try { Initialize(); } catch (Exception e) { Error(e, "Beim initialisieren der Seite ist auf dem Server ein Fehler aufgetreten.", loading); throw; } try { return(CreatePage()); } catch (Exception e) { Error(e, "Beim erstellen der Seite ist auf dem Server ein Fehler aufgetreten.", loading); throw; } } Task.Run((Func <Element>)WaitForInitAndCreatePage).ContinueWith(task => { testDiv.AppendChild(task.Result); stopwatchCreatePage.Stop(); Console.WriteLine($"\t\tSended Website Content: {testDiv.OuterHtml.Length}Byte\r\n\t\tElapsedTime from CreatePage: {stopwatchCreatePage.ElapsedMilliseconds}ms"); testDiv.RemoveChild(loading); }); stopwatchMain.Stop(); Console.WriteLine($"\tSended Website Content: {testDiv.OuterHtml.Length}Byte\r\n\tElapsedTime in PopulateAppElement: {stopwatchMain.ElapsedMilliseconds}ms"); stopwatchCreatePage.Start(); return(testDiv); }
public Loading(string text = "Please Wait, Loading...") : base("div") { ClassName = "modal fade show"; SetAttribute("tabindex", "-1"); SetAttribute("role", "dialog"); Style.PaddingRight = "17px"; Style.Display = "block"; Div dialogWrapper = new Div() { ClassName = "modal-dialog" }; dialogWrapper.SetAttribute("role", "document"); AppendChild(dialogWrapper); contentWrapper = new Div() { ClassName = "modal-content" }; dialogWrapper.AppendChild(contentWrapper); Div headerWrapper = new Div() { ClassName = "modal-header" }; contentWrapper.AppendChild(headerWrapper); _loadingText = new Heading(5, text) { ClassName = "modal-title" }; headerWrapper.AppendChild(_loadingText); bodyWrapper = new Div() { ClassName = "modal-body" }; contentWrapper.AppendChild(bodyWrapper); Div progressDiv = new Div() { ClassName = "progress" }; bodyWrapper.AppendChild(progressDiv); _progressBarDiv = new Div() { ClassName = "progress-bar progress-bar-striped progress-bar-animated w-100" }; _progressBarDiv.SetAttribute("role", "progressbar"); progressDiv.AppendChild(_progressBarDiv); SetAttribute("aria-labelledby", _loadingText.Id.ToString()); }
public Element CreateElement() { var heading = new Heading("Draw"); var subtitle = new Paragraph("Click to draw a masterpiece"); var toolSel = new Select(); toolSel.AppendChild(new Option { Text = "Boxes", Value = "box" }); toolSel.AddOption("Circles", "circle"); var canvas = new Canvas { Width = 320, Height = 240, }; var context = canvas.GetContext2D(); canvas.Click += (s, e) => { var radius = 10; context.BeginPath(); if (toolSel.Value == "box") { context.Rect(e.OffsetX - radius, e.OffsetY - radius, 2 * radius, 2 * radius); } else { context.Arc(e.OffsetX, e.OffsetY, radius, 0, 2 * Math.PI, true); } context.Fill(); }; canvas.Style.Cursor = "pointer"; canvas.Style.BorderColor = "#CCC"; canvas.Style.BorderStyle = "solid"; canvas.Style.BorderWidth = "1px"; var clearbtn = new Button("Clear") { Type = ButtonType.Submit, ClassName = "btn btn-danger", }; clearbtn.Click += (s, e) => { context.ClearRect(0, 0, canvas.Width, canvas.Height); }; clearbtn.Style.Display = "block"; var app = new Div(); app.AppendChild(heading); app.AppendChild(subtitle); app.AppendChild(new Div(toolSel)); app.AppendChild(canvas); app.AppendChild(clearbtn); return(app); }
public NavigationBar(string brandName, string brandAddress, Anchor lastAnchor, bool showLocalDateTime) : base("nav") { ClassName = "navbar navbar-expand-sm navbar-light"; Style.BackgroundColor = "#e3f2fd"; Anchor brandAnchor = new Anchor(brandAddress, brandName) { ClassName = "navbar-brand" }; AppendChild(brandAnchor); Div navigationDiv = new Div() { ClassName = "collapse navbar-collapse" }; _navigationList = new List(false) { ClassName = "navbar-nav mr-auto" }; AppendChild(navigationDiv); navigationDiv.AppendChild(_navigationList); if (showLocalDateTime) { Div showLocalDateTimeDiv = new Div() { ClassName = "navbar-nav mr-5" }; navigationDiv.AppendChild(showLocalDateTimeDiv); _showLocalDateTimeTimer = new Timer(400); _showLocalDateTimeTimer.Elapsed += (sender, args) => { try { showLocalDateTimeDiv.Text = DateTime.Now.ToString(CultureInfo.GetCultureInfo("de-de")); if (_navBarOpenDateTime.AddMinutes(-30) > DateTime.Now) { Console.WriteLine("Die Navigationsleiste ist länger als 30 Minuten offen -> der Refresh wird gestoppt"); return; } } catch (Exception e) { Console.WriteLine(e); } }; _showLocalDateTimeTimer.Start(); } lastAnchor.ClassName = "navbar-brand"; navigationDiv.AppendChild(lastAnchor); }
public StylableAnchor AddEntry(string text, bool active = false) { StylableAnchor anchor = new StylableAnchor("#", text) { ClassName = "dropdown-item" + (active == true ? " active" : "") }; _dropDownMenu.AppendChild(anchor); return(anchor); }
protected void CreateToolbarStructure(bool twoRow) { if (_hasJewel) { _elmJewelPlaceholder = new Div(); _elmJewelPlaceholder.Id = "jewelcontainer"; _elmJewelPlaceholder.ClassName = "ms-cui-jewel-container"; _elmJewelPlaceholder.Style.Display = "none"; } if (twoRow) { _elmTopBar1 = new Div(); _elmTopBar1.ClassName = "ms-cui-topBar1"; _elmTopBar1.Style.Display = "none"; _elmTopBar2 = new Div(); _elmTopBar2.ClassName = "ms-cui-topBar2"; if (_hasJewel) { _elmTopBar2.AppendChild(_elmJewelPlaceholder); } _elmToolbarTopBars = new Div(); _elmToolbarTopBars.ClassName = "ms-cui-ribbonTopBars"; _elmToolbarTopBars.AppendChild(_elmTopBar1); _elmToolbarTopBars.AppendChild(_elmTopBar2); // Create peripheral content placeholders as necessary _elmQATRowCenter = (Div)Browser.Document.GetById(ClientID + "-" + RibbonPeripheralSection.QATRowCenter); _elmQATRowRight = (Div)Browser.Document.GetById(ClientID + "-" + RibbonPeripheralSection.QATRowRight); if (!CUIUtility.IsNullOrUndefined(_elmQATRowCenter)) { _elmQATRowCenter.ParentNode.RemoveChild(_elmQATRowCenter); _elmTopBar1.AppendChild(_elmQATRowCenter); _elmQATRowCenter.Style.Display = "inline-block"; _elmTopBar1.Style.Display = "block"; Utility.SetUnselectable(_elmQATRowCenter, true, false); } if (!CUIUtility.IsNullOrUndefined(_elmQATRowRight)) { _elmQATRowRight.ParentNode.RemoveChild(_elmQATRowRight); _elmTopBar1.AppendChild(_elmQATRowRight); _elmQATRowRight.Style.Display = "inline-block"; _elmTopBar1.Style.Display = "block"; Utility.SetUnselectable(_elmQATRowRight, true, false); } } // Initialize the outer DOM element of this component EnsureDOMElement(); }
private Element CreateAppElement() { appElement.AppendChild(_list); List <string> pathList = new List <string>() { "display-alert", "entry-listview", "shared-button", "button", "todo", "draw", "files", "dotmatrixclock", "editor", "monkeys", "refreshlistview", "searchbar", "slider", "switch-listview", "timepicker", "tipcalc", "weatherapp", "xuzzle", "webview", "picker" }; foreach (string path in pathList) { Div pathElement = new Div { ClassName = "list-group-item", Style = { Cursor = "pointer", FontWeight = "bold" }, Text = path }; pathElement.SetAttribute("href", pathElement.Document.Window.Location + path); pathElement.Click += (sender, args) => { Console.WriteLine(pathElement.Document.Window.Location); pathElement.Document.Window.Location = pathElement.GetAttribute("href", ""); }; appElement.AppendChild(pathElement); } return(appElement); }
protected static Element ToggleInputRender(AdaptiveToggleInput toggleInput, ElementAdaptiveRenderContext context) { var htmlLabelId = GenerateRandomId(); var uiElement = new Div() .AddClass("ac-input") .Style("width", "100%"); var uiCheckboxInput = new Input(InputType.Checkbox) .SetAttr("id", htmlLabelId) .SetAttr("type", "checkbox") .SetAttr("name", toggleInput.Id) .SetAttr("data-ac-valueOn", toggleInput.ValueOn ?? bool.TrueString) .SetAttr("data-ac-valueOff", toggleInput.ValueOff ?? bool.FalseString) .Style("display", "inline-block") .Style("vertical-align", "middle") .Style("margin", "0px"); if (toggleInput.Value == toggleInput.ValueOn) { uiCheckboxInput.SetAttr("checked", string.Empty); } var uiLabel = CreateLabel(htmlLabelId, toggleInput.Title, context); return((Element)uiElement.AppendChild(uiCheckboxInput).AppendChild(uiLabel)); }
public TimeFliesLikeADoughnutPage() { InitializeComponent(); var document = Window.Document; var mouseMove = new HtmlObservable(h => document.MouseMove += h, h => document.MouseMove -= h); var text = "time flies like a doughnut"; var container = new Div { Style = { Width = "100%", Height = "100%", FontFamily = "Consolas, monospace", Overflow = "hidden" } }; document.Body.AppendChild(container); for (var i = 0; i < text.Length; i++) { var j = i; var s = new Span { InnerText = text[j].ToString(), Style = { Position = "absolute" } }; container.AppendChild(s); mouseMove.Delay(TimeSpan.FromMilliseconds((double)j * 100.0)).Subscribe (mouseEvent => { s.Style.Top = mouseEvent.ClientY + "px"; s.Style.Left = mouseEvent.ClientX + j * 10 + 15 + "px"; }); } }
public TabNavigation(bool asCardStyle = false, bool includeAddButton = false) : base("div") { Nav navElement = new Nav(); _navigationDiv = new Div { ClassName = "nav nav-tabs" }; if (asCardStyle) { ClassName = "card text-center"; navElement.ClassName = "card-header"; _navigationDiv.ClassName += " card-header-tabs"; } _navigationDiv.SetAttribute("role", "tablist"); navElement.AppendChild(_navigationDiv); _contentDiv = new Div { ClassName = "tab-content" }; base.AppendChild(navElement); base.AppendChild(_contentDiv); if (includeAddButton) { AddButton = new Button(StylingColor.Primary, true, Button.ButtonSize.Small, false, "+"); AddButton.AddStyling(StylingOption.MarginTop, 1); AddButton.AddStyling(StylingOption.MarginRight, 3); AddButton.AddStyling(StylingOption.Height, 50); _navigationDiv.AppendChild(AddButton); } }
public TextInputGroup(string labelText, string textBoxDescriptionMessage, int sizeInPx = -1, string validFeedback = "", string inValidFeedback = "", bool feedbackAsTooltip = false, bool centeredText = false) { ClassName = "input-group"; Div div1 = new Div { ClassName = "input-group-prepend", Style = { Width = sizeInPx } }; AppendChild(div1); Div div2 = new Div { ClassName = "input-group-text w-100", Text = labelText }; div1.AppendChild(div2); TextInput = new StylableTextInput(); TextInput.SetAttribute("type", "text"); TextInput.ClassName = "form-control" + (centeredText ? " text-center" : ""); TextInput.SetAttribute("placeholder", textBoxDescriptionMessage); TextInput.SetAttribute("aria-label", textBoxDescriptionMessage); TextInput.SetAttribute("aria-describedby", div2.Id); AppendChild(TextInput); ValidationFeedback.AppendValidationFeedbackElements(this, validFeedback, inValidFeedback, feedbackAsTooltip); }
public TextAreaInputGroup(string labelText, string textBoxDescriptionMessage, int sizeInPx = -1) { ClassName = "input-group"; Div div1 = new Div { ClassName = "input-group-prepend", Style = { Width = sizeInPx } }; AppendChild(div1); Div div2 = new Div { ClassName = "input-group-text w-100", Text = labelText }; div1.AppendChild(div2); TextArea = new TextArea(); TextArea.SetAttribute("type", "text"); TextArea.ClassName = "form-control"; TextArea.SetAttribute("placeholder", textBoxDescriptionMessage); TextArea.SetAttribute("aria-label", textBoxDescriptionMessage); TextArea.SetAttribute("aria-describedby", div2.Id); AppendChild(TextArea); }
private Element MainPage() { var page = new Div(); page.AppendChild(new TextNode("Login successful")); return(page); }
//("col-3", "col-9") public VerticalPillNavigation(string navigationDivWrapperClassName, string contentDivWrapperClassName, bool asCardStyle = false) : base("div") { ClassName = "row" + (asCardStyle ? " ml-0" : ""); Div navigationDivWrapper = new Div { ClassName = navigationDivWrapperClassName + (asCardStyle ? " card text-center card-header rounded" : "") }; AppendChild(navigationDivWrapper); _navigationDiv = new Div { ClassName = "nav flex-column nav-pills" }; _navigationDiv.SetAttribute("role", "tablist"); _navigationDiv.SetAttribute("aria-orientation", "vertical"); navigationDivWrapper.AppendChild(_navigationDiv); Div contentDivWrapper = new Div { ClassName = contentDivWrapperClassName }; AppendChild(contentDivWrapper); _contentDiv = new Div { ClassName = "tab-content" }; contentDivWrapper.AppendChild(_contentDiv); }
private static Element RawXhtmlToHtmlTag(XElement element) { var htmlTag = new Div() { Title = element.Name.LocalName }; foreach (var node in element.Nodes()) { switch (node.NodeType) { case XmlNodeType.Text: htmlTag.AppendChild(new Span(((XText)node).Value)); break; case XmlNodeType.Element: htmlTag.AppendChild(RawXhtmlToHtmlTag((XElement)node)); break; } } foreach (var attribute in element.Attributes()) { switch (attribute.Name.LocalName.ToLowerInvariant()) { case "style": // Style needs to be parsed out into the Styles attribute of the HtmlTag. // But we don't ever expect the markdown processor to return it, so we don't need to handle it for now. throw new InvalidOperationException(); case "class": var classNames = attribute.Value.Split(' ').Where(className => !string.IsNullOrWhiteSpace(className)); foreach (var className in classNames) { htmlTag.ClassName = className.Trim(); } break; default: htmlTag.SetAttribute(attribute.Name.LocalName, attribute.Value); break; } } return(htmlTag); }
public void ValueBubblesDown() { var p = new Div(); var b = new Input(); p.AppendChild(b); p.Receive(Message.Event(b.Id, "change", "please work")); Assert.AreEqual("please work", b.Value); }
public void ShowError(Exception exception, string msg) { _progressBarDiv.ClassName += " bg-danger"; _loadingText.Text = msg; Div footer = new Div { ClassName = "modal-footer" }; contentWrapper.AppendChild(footer); TextInputGroup inputGroup = new TextInputGroup("", "Passwort", inValidFeedback: "Falsches Passwort", centeredText: true) { IsHidden = true }; Button button = new Button(StylingColor.Info, true, text: "Infos anzeigen"); button.Click += (sender, args) => { if (inputGroup.IsHidden == true) { inputGroup.IsHidden = false; } else { if (inputGroup.TextInput.Value == "huhu") { Span span = new Span(exception.ToString()); footer.AppendChild(span); footer.RemoveChild(inputGroup); footer.RemoveChild(button); } else { inputGroup.TextInput.SetValidation(false, true); } } }; footer.AppendChild(inputGroup); footer.AppendChild(button); }
public void AddFormElement(StylableElement content) { Div div1 = new Div { ClassName = "input-group-append" }; AppendChild(div1); div1.AppendChild(content); }
public T AppendCollum <T>(T content, int sizing = 0, bool autoSize = false) where T : Element { Div newChild = new Div() { ClassName = "col" + (sizing > 0 ? $"-{sizing}" : "") + (autoSize == true ? "-auto" : "") }; newChild.AppendChild(content); AppendChild(newChild); return(content); }
static void Main(string[] args) { var count = 0; var div = new Div(); div.AppendChild(new Heading(1, "JaxDug OOUI Sample")); div.AppendChild(new Paragraph("This is a sample that shows using WASM.")); var para = new Paragraph(""); div.AppendChild(para); var button = new Button("Click Me"); div.AppendChild(button); button.Click += (s, e) => { count++; para.Text = $"You have clicked the button {count} times"; }; UI.Publish("/", div); }
public Element CreateElement() { var heading = new Heading("Draw"); var subtitle = new Paragraph("Click to draw a masterpiece"); var canvas = new Canvas { Width = 320, Height = 240, }; var context = canvas.GetContext2D(); canvas.Clicked += (s, e) => { context.BeginPath(); context.Rect(e.OffsetX - 5, e.OffsetY - 5, 10, 10); context.Fill(); }; canvas.Style.Cursor = "pointer"; canvas.Style.BorderColor = "#CCC"; canvas.Style.BorderStyle = "solid"; canvas.Style.BorderWidth = "1px"; var clearbtn = new Button("Clear") { Type = ButtonType.Submit, ClassName = "btn btn-danger", }; clearbtn.Clicked += (s, e) => { context.ClearRect(0, 0, canvas.Width, canvas.Height); }; clearbtn.Style.Display = "block"; var app = new Div(); app.AppendChild(heading); app.AppendChild(subtitle); app.AppendChild(canvas); app.AppendChild(clearbtn); return(app); }
public T AppendCustomElement <T>(T content, bool asExternalFormControl = true) where T : Element { Div contentDivWrapper = new Div() { ClassName = $"input-group-{GetClassType()} {(asExternalFormControl == true ? "form-control" : "")}" }; contentDivWrapper.AppendChild(content); AppendChild(contentDivWrapper); return(content); }
public void EventReceptionBubblesDown() { var p = new Div(); var b = new Button(); p.AppendChild(b); var clicked = false; b.Click += (s, e) => { clicked = true; }; p.Receive(Message.Event(b.Id, "click")); Assert.IsTrue(clicked); }
public IActionResult Clicker() { var count = 0; var head = new Heading { Text = "Click away!" }; var label = new Label { Text = "0" }; var btn = new Button { Text = "Increase" }; btn.Click += (sender, e) => { count++; label.Text = count.ToString(); }; var div = new Div(); div.AppendChild(head); div.AppendChild(label); div.AppendChild(btn); return(new ElementResult(div)); }
public App() { Root = new Div() { Style = { ["max-width"] = "600px", MarginTop = "100px", } }; Element = new Div(); Element .AppendChild(new Center()) .AppendChild(Root); Navigate(LoginPage()); }