public AutocompleteDropdown(
            string label,
            TextType textType = TextType.TreatAsText,
            int delayMilisec  = Magics.AutocompleteDefaultDelay)
        {
            _cnt.ClassName = GetType().FullNameWithoutGenerics();

            var lbl = new HTMLLabelElement {
                HtmlFor = _input.Id, TextContent = label
            };

            _cnt.AppendChild(lbl);

            _cnt.AppendChild(_input);
            _cnt.AppendChild(_options);
            HideOptions();

            DocumentUtil.AddMouseDownListener(_cnt, x => {
                if (!x.HasHtmlTarget())
                {
                    return;
                }
                var htmlTarget = x.HtmlTarget();

                if (htmlTarget.IsElementOrItsDescendant(_cnt))
                {
                    //clicked inside control (focus stays within logical control) thus do nothing
                    return;
                }

                HideOptions();
            });

            _input.OnFocus += ev => {
                if (_ignoreNextFocus)
                {
                    _ignoreNextFocus = false;
                    return;
                }

                ShowOptions();

                if (!_input.HasFocus())
                {
                    //non user generated (isTrusted == false) events don't invoke default action in Chrome
                    _ignoreNextFocus = true;
                    _input.Focus();
                }
            };
            _input.OnKeyDown += ev => {
                switch (ev.KeyCode)
                {
                case Magics.KeyCodeEscape:
                    if (OptionsVisible)
                    {
                        ev.PreventDefault();
                        ev.StopPropagation();
                        HideOptions();
                    }
                    break;

                case Magics.KeyCodeEnter:
                case Magics.KeyCodeArrowUp:
                case Magics.KeyCodeArrowDown:
                    ev.PreventDefault();
                    OnKeyboardEvent(AutocompleteSrcType.KeyDown, ev);
                    break;

                case Magics.KeyCodeBackspace:
                    OnKeyboardEvent(AutocompleteSrcType.KeyDown, ev);     //it is not called onkeypress
                    break;

                case Magics.KeyCodeTab:
                    HideOptions();
                    break;

                default: break;
                }
            };
            _input.OnKeyPress += ev => {
                switch (ev.KeyCode)
                {
                case Magics.KeyCodeBackspace:
                case Magics.KeyCodeEnter:
                case Magics.KeyCodeArrowUp:
                case Magics.KeyCodeArrowDown:
                    ev.PreventDefault();
                    break;

                default:
                    OnKeyboardEvent(AutocompleteSrcType.KeyPressed, ev);
                    break;
                }
            };

            _textType     = textType;
            _delayMilisec = delayMilisec;
        }
        private HorizontalTabbedView(Action <HorizontalTabbedView> addTabs)
        {
            _container = new HTMLDivElement {
                Id        = UniqueIdGenerator.GenerateAsString(),
                ClassName = GetType().FullName
            };

            _tabHandleContainer = new HTMLDivElement {
                ClassName = Magics.CssClassTabHandleContainer
            };

            _tabContentContainer = new HTMLDivElement {
                ClassName = Magics.CssClassTabContentContainer
            };

            _container.AppendChild(_tabHandleContainer);
            _container.AppendChild(_tabContentContainer);

            _tabHandleContainer.OnClick += ev => {
                if (!ev.HasHtmlTarget())
                {
                    return;
                }

                var target = ev.HtmlTarget();

                if (target == _tabHandleContainer)
                {
                    return;
                }

                var newActiveTabHandle = target.GetParentElementHavingParent(_tabHandleContainer);
                var newActiveTabIdx    = _tabHandleContainer.Children.IndexOfUsingEquals(newActiveTabHandle);

                if (_activeTab == newActiveTabIdx)
                {
                    Logger.Debug(GetType(), "already active tab selected {0}", _activeTab);
                    return;
                }

                Logger.Debug(GetType(), "switching tab from {0} to {1}", _activeTab, newActiveTabIdx);

                if (newActiveTabIdx < 0 || newActiveTabIdx >= _tabContents.Count)
                {
                    Logger.Error(GetType(), "there's no tab at index {0}. ignoring tab switch", newActiveTabIdx);
                    return;
                }

                if (_activeTab >= 0)
                {
                    _tabHandleContainer.Children[_activeTab].ClassList.Remove(Magics.CssClassActive);
                    _tabContentContainer.RemoveAllChildren();
                }

                ActivateTab(newActiveTabIdx);
            };

            addTabs(this);

            DocumentUtil.AddElementAttachedToDocumentListener(_container, () => {
                if (_measured)
                {
                    return;
                }

                var formerlyFocused = Document.ActiveElement;
                Logger.Debug(GetType(), "Measuring tab heights in onAttached");

                // measure tab content
                var oldVis = _tabContentContainer.Style.Visibility;
                _tabContentContainer.Style.Visibility = Visibility.Hidden;

                _tabContents.ForEachI((i, tab) => {
                    _tabContentContainer.RemoveAllChildren();
                    _tabContentContainer.AppendChild(tab);
                });

                _tabContentContainer.RemoveAllChildren();
                _tabContentContainer.Style.Visibility = oldVis;
                _measured = true;

                //assure that focused element within tab stays focused(it may have been lost during measurement process above)
                if (_tabContents.Any())
                {
                    ActivateTab(_activeTab);
                    if (formerlyFocused != Document.ActiveElement)
                    {
                        formerlyFocused.TryFocusElement();
                    }
                }
            });

            //activate first tab
            if (_tabContents.Any())
            {
                ActivateTab(0);
            }
        }
Exemple #3
0
        private static void OnClick(MouseEvent <HTMLButtonElement> mouseEvent)
        {
            MeshType type;

            if (typePicker.SelectedIndex < 0)
            {
                type = MeshType.Square;
            }
            else
            {
                type = MeshTypeFromString(typePicker.Value);
            }
            int width;
            int height;

            if (!ParseSize(sizeInput.Value, type, out width, out height))
            {
                return;
            }
            Mesh mesh = MakeMesh(width, height, type, difficultyPicker.SelectedIndex);

            display.Mesh = mesh;

            worker = new Worker(Extensions.Window().URL.createObjectURL(new Blob(new BlobDataObject[]
            {
                @"
self.onmessage = function(e) { 
  if (e.data.href) {
    try { 
      importScripts(e.data.href);
    } catch (error) {
      console.log(e.data.href);  
      console.log(error);
    }
  } else {
    TwistNTurnBridge.WorkerSpawn.WorkerSpawn_OnMessage(e);
  }
}"
            }, new BlobPropertyBag()
            {
                Type = "text/javascript"
            })));
            progressBar                       = Document.CreateElement <HTMLProgressElement>("progress");
            progressBar.Max                   = mesh.Intersections.Count;
            progressBar.Style.Position        = Position.Absolute;
            progressBar.Style.Margin          = "auto";
            progressBar.Style.Top             = "0";
            progressBar.Style.Bottom          = "0";
            progressBar.Style.Left            = "0";
            progressBar.Style.Right           = "0";
            progressBar.Style.ZIndex          = "100";
            progressBar.Style.BackgroundColor = "white";
            displayHost.AppendChild(progressBar);
            generateButton.Disabled = true;
            worker.OnMessage       += AppWorker_OnMessage;
            string to_load = Window.Location.Href.Substring(0, Window.Location.Href.LastIndexOf('/') + 1) + "bridge.min.js";

            worker.PostMessage(new InitialReuqest()
            {
                href = to_load
            });
            to_load = Window.Location.Href.Substring(0, Window.Location.Href.LastIndexOf('/') + 1) + "bridge.console.min.js";
            worker.PostMessage(new InitialReuqest()
            {
                href = to_load
            });
            to_load = Window.Location.Href.Substring(0, Window.Location.Href.LastIndexOf('/') + 1) + "bridge.meta.min.js";
            worker.PostMessage(new InitialReuqest()
            {
                href = to_load
            });
            to_load = Window.Location.Href.Substring(0, Window.Location.Href.LastIndexOf('/') + 1) + "newtonsoft.json.min.js";
            worker.PostMessage(new InitialReuqest()
            {
                href = to_load
            });
            to_load = Window.Location.Href.Substring(0, Window.Location.Href.LastIndexOf('/') + 1) + "TwistNTurnBridge.min.js";
            worker.PostMessage(new InitialReuqest()
            {
                href = to_load
            });
            to_load = Window.Location.Href.Substring(0, Window.Location.Href.LastIndexOf('/') + 1) + "TwistNTurnBridge.meta.min.js";
            worker.PostMessage(new InitialReuqest()
            {
                href = to_load
            });
            worker.PostMessage(JsonConvert.SerializeObject(new GenerateRequest()
            {
                Width = width, Height = height, Type = type, Difficulty = difficultyPicker.SelectedIndex
            }));
        }
Exemple #4
0
 public void Add(ToDoItem todoItem)
 {
     _todoItemList.Add(todoItem);
     _divItemList.AppendChild(todoItem.DivItem);
 }
        public static void Main()
        {
            var canvas = new HTMLTextAreaElement
            {
                Id       = "canvas",
                ReadOnly = true,
                Rows     = 50,
                Cols     = 50
            };

            var div = new HTMLDivElement();

            var inputX = new HTMLInputElement()
            {
                Type         = InputType.Number,
                DefaultValue = "0",
                Value        = "8",
            };
            var inputY = new HTMLInputElement()
            {
                Type         = InputType.Number,
                DefaultValue = "0",
                Value        = "7"
            };
            var inputZ = new HTMLInputElement()
            {
                Type         = InputType.Number,
                DefaultValue = "0",
                Value        = "6"
            };

            var button = new HTMLButtonElement
            {
                InnerHTML = "Render",
                OnClick   = (ev) =>
                {
                    if (double.TryParse(inputX.Value, out double x) &&
                        double.TryParse(inputY.Value, out double y) &&
                        double.TryParse(inputZ.Value, out double z))
                    {
                        string url = "https://anchat.azurewebsites.net/api/render/" + $"{x}/{y}/{z}";

                        jQuery.GetJSON(
                            url, null,
                            delegate(object data, string s, jqXHR jqXHR)
                        {
                            canvas.Value = data["rendered"].ToString();

                            int w = int.Parse(data["width"].ToString());
                            int h = int.Parse(data["height"].ToString());

                            canvas.Cols = Math.Max(canvas.Cols, w);
                            canvas.Rows = Math.Max(canvas.Rows, h);
                        });
                    }
                }
            };

            // Add the Button to the page
            div.AppendChild(new HTMLLabelElement {
                TextContent = "X:"
            });
            div.AppendChild(inputX);
            div.AppendChild(new HTMLBRElement());
            div.AppendChild(new HTMLLabelElement {
                TextContent = "Y:"
            });
            div.AppendChild(inputY);
            div.AppendChild(new HTMLBRElement());
            div.AppendChild(new HTMLLabelElement {
                TextContent = "Z:"
            });
            div.AppendChild(inputZ);
            div.AppendChild(new HTMLBRElement());
            div.AppendChild(button);
            Document.Body.AppendChild(div);
            Document.Body.AppendChild(new HTMLHRElement());
            Document.Body.AppendChild(canvas);
        }
    }
Exemple #6
0
        public static void NewTab(string name = null, Graph G = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                name = "sheet " + _tabID;
            }

            var canvas = new HTMLCanvasElement();

            canvas.Id        = "Tab" + _tabID;
            canvas.Width     = (int)(Window.InnerWidth);
            canvas.Height    = (int)(Window.InnerHeight);
            canvas.ClassName = "IAmAGraphCanvas";

            canvas.OnShow += delegate
            {
                canvas.Width  = canvas.ParentElement.ClientWidth;
                canvas.Height = canvas.ParentElement.ClientHeight;
            };

            if (G == null)
            {
                G = new Graph();
            }
            var graphCanvas = new GraphCanvas(G);
            var tc          = new TabCanvas(canvas, graphCanvas);

            tc.Invalidate();

            var tabPane = new HTMLDivElement();

            tabPane.ClassName = "tab-pane active";
            tabPane.Id        = "Tab" + _tabID;
            tabPane.AppendChild(canvas);

            var tabControlContent = Document.GetElementById("TabControlContent");

            foreach (var child in tabControlContent.Children)
            {
                child.ClassName = "tab-pane";
            }
            tabControlContent.AppendChild(tabPane);

            var tab = new HTMLLIElement();

            tab.ClassName = "active";

            var anchor = new HTMLAnchorElement();

            anchor.SetAttribute("data-toggle", "tab");
            anchor.TextContent         = name;
            anchor.Href                = "#Tab" + _tabID;
            _canvasLookup[anchor.Href] = tc;
            _currentTabCanvas          = anchor.Href;

            tab.AppendChild(anchor);

            var tabControl = Document.GetElementById("TabControl");

            foreach (var child in tabControl.Children)
            {
                child.ClassName = "narf";
            }
            tabControl.InsertBefore(tab, _newSheetTab);

            _tabID++;
        }
Exemple #7
0
        static void AddHR(HTMLDivElement div)
        {
            HTMLHRElement hr = Document.CreateElement <HTMLHRElement>("hr");

            div.AppendChild(hr);
        }
Exemple #8
0
        public void Show(Point location)
        {
            if (ActivePopupMenu != this)
            {
                if (ActivePopupMenu != null)
                {
                    ActivePopupMenu.Close();
                }
                ActivePopupMenu = this;
            }

            if (Base != null)
            {
                Base.Remove();
                Base = null;
            }

            Base = new HTMLDivElement();
            Base.Style.Position = Position.Absolute;

            Base.Style.BorderColor = BorderColor;
            Base.Style.BorderStyle = BorderStyle.Solid;
            Base.Style.BorderWidth = BorderWidth.Thin;
            Base.Style.Padding     = "2px";
            Base.Style.Margin      = "0";

            Base.OnMouseDown = (ev) => { ev.StopPropagation(); };

            Base.Style.BackgroundColor = BackgroundColor;
            int ubound = Items.Count - 1;

            int y = 3;

            for (int i = 0; i < Items.Count; i++)
            {
                // Add Menu Item / Generate Div :D
                var inObj = Items[i];
                var item  = inObj.GenerateDiv();

                if (inObj.BeginGroup)
                {
                    var div = new HTMLDivElement();
                    div.Style.Position = Position.Absolute;
                    y += 1;

                    jQuery.Select(div).
                    Css("left", 8).
                    Css("width", 202). // static as set now, need to change
                    Css("height", 1).
                    Css("top", y);

                    div.Style.BackgroundColor = BeginGroupColor;

                    Base.AppendChild(div);

                    y += 3;
                }

                jQuery.Select(item).Css("top", y);
                Base.AppendChild(item);

                if (inObj.OnClick != null)
                {
                    item.OnClick = inObj.OnClick;
                }

                y += 24;
            }

            jQuery.Select(Base).
            Css("left", location.X).
            Css("top", location.Y).
            Css("width", 214).
            Css("height", y);

            Base.Style.Overflow = Overflow.Visible;
            Base.Style.ZIndex   = int.MaxValue.ToString();
            // need to make the width min-width 100%
            // Fill Content :D
            //Base.Style.MinWidth = "100%";
            //Base.Style.MinHeight = "100%";

            Form.WindowHolder.AppendChild(Base);
        }
Exemple #9
0
        private static void LoadPlayArea()
        {
            var menuDiv = new HTMLDivElement
            {
                Id = "menu"
            };

            var pressStartTitle = new HTMLAnchorElement
            {
                Href      = "javascript:BridgeTetris.Tetris.play()",
                InnerHTML = "Press Space to Play."
            };

            menuDiv.AppendChild(BridgeTetris.Tetris.InsideParagraph(pressStartTitle, "start"));

            var nextPieceCanvas = new HTMLCanvasElement
            {
                Id = "upcoming"
            };

            menuDiv.AppendChild(BridgeTetris.Tetris.InsideParagraph(nextPieceCanvas));

            var scoreParagraph = new List <Node>();

            scoreParagraph.Add(new HTMLLabelElement
            {
                InnerHTML = "score "
            });

            scoreParagraph.Add(new HTMLSpanElement
            {
                Id        = "score",
                InnerHTML = "00000"
            });

            menuDiv.AppendChild(BridgeTetris.Tetris.InsideParagraph(scoreParagraph));

            var rowsParagraph = new List <Node>();

            rowsParagraph.Add(new HTMLLabelElement
            {
                InnerHTML = "rows "
            });

            rowsParagraph.Add(new HTMLSpanElement
            {
                Id        = "rows",
                InnerHTML = "0"
            });

            menuDiv.AppendChild(BridgeTetris.Tetris.InsideParagraph(rowsParagraph));

            var tetrisCourtCanvas = new HTMLCanvasElement
            {
                Id     = "canvas",
                Width  = 200,
                Height = 400
            };

            var tetrisDiv = new HTMLDivElement
            {
                Id = "tetris"
            };

            tetrisDiv.AppendChild(menuDiv);
            tetrisDiv.AppendChild(tetrisCourtCanvas);

            Document.Body.AppendChild(tetrisDiv);
        }
        public override void Render()
        {
            HasRendered = true;
            if (Type == RibbonType.Full)
            {
                if (ApplicationIcon != null)
                {
                    ApplicationIcon.Delete();
                }
                ApplicationIcon = Div("application-icon");
                var appIconImage = Div("fav-icon");
                appIconImage.style.background     = RibbonButton.GetImageStringURI(IconURL);
                appIconImage.style.backgroundSize = "100% 100%";

                ApplicationIcon.AppendChild(appIconImage);

                Content.AppendChild(ApplicationIcon);
            }

            if (RibbonPages != null && RibbonPages.Count > 0)
            {
                int width = 58;
                for (int i = 0; i < RibbonPages.Count; i++)
                {
                    if (Content.contains(RibbonPages[i]))
                    {
                        RibbonPages[i].Content.Delete();
                        RibbonPages[i].RibbonHeader.Delete();
                    }
                    RibbonPages[i].Render();

                    if (Type == RibbonType.Compact)
                    {
                        if (!RibbonPages[i].Content.className.Contains("ribbonpage-compact"))
                        {
                            RibbonPages[i].Content.classList.add("ribbonpage-compact");
                        }
                    }
                    else
                    {
                        if (RibbonPages[i].Content.className.Contains("ribbonpage-compact"))
                        {
                            RibbonPages[i].Content.classList.remove("ribbonpage-compact");
                        }
                    }

                    int index = i;

                    if (i == selectedindex)
                    {
                        RibbonPages[i].RibbonHeader             = Div("ribbonpageheader ribbonpageheader-active" + (Type == RibbonType.Full ? "" : " ribbonpageheader-compact"));
                        RibbonPages[i].Content.style.visibility = "visible";
                    }
                    else
                    {
                        RibbonPages[i].RibbonHeader             = Div("ribbonpageheader ribbonpageheader-hidden" + (Type == RibbonType.Full ? "" : " ribbonpageheader-compact"));
                        RibbonPages[i].Content.style.visibility = "hidden";
                    }

                    RibbonPages[i].RibbonHeader.onmousedown = (ev) =>
                    {
                        SelectedIndex = index;
                    };
                    RibbonPages[i].RibbonHeader.ontouchstart = (ev) =>
                    {
                        SelectedIndex = index;
                    };

                    RibbonPages[i].RibbonHeader.innerHTML = RibbonPages[i].Caption;

                    int inwidth = 24;

                    if (!string.IsNullOrEmpty(RibbonPages[i].Caption))
                    {
                        inwidth += (int)GetTextWidth(RibbonPages[i].Caption, Settings.DefaultFont);
                    }

                    RibbonPages[i].RibbonHeader.style.left  = width + "px";
                    RibbonPages[i].RibbonHeader.style.width = inwidth + "px";

                    Content.AppendChild(RibbonPages[i].RibbonHeader);
                    Content.AppendChild(RibbonPages[i]);

                    width += inwidth;
                }
            }
            SelectedIndex = selectedindex;
        }
Exemple #11
0
        //show the default jquery ui demo
        private static void ShowDemo()
        {
            HTMLDivElement contendElement = new HTMLDivElement();

            #region accordion
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Accordion"
                });
                var accordion = new HTMLDivElement();
                accordion.AppendChild(new HTMLHeadingElement(HeadingType.H3)
                {
                    TextContent = "Section 1"
                });
                var accSec1 = new HTMLDivElement();
                accSec1.AppendChild(new HTMLParagraphElement()
                {
                    TextContent = "Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque.Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc.Nam a nibh.Donec suscipit eros.Nam mi.Proin viverra leo ut odio.Curabitur malesuada.Vestibulum a velit eu ante scelerisque vulputate."
                });
                accordion.AppendChild(accSec1);


                accordion.AppendChild(new HTMLHeadingElement(HeadingType.H3)
                {
                    TextContent = "Section 2"
                });
                var accSec2 = new HTMLDivElement();
                accSec2.AppendChild(
                    new HTMLParagraphElement()
                {
                    TextContent = "Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna."
                });
                accordion.AppendChild(accSec2);

                accordion.AppendChild(new HTMLHeadingElement(HeadingType.H3)
                {
                    TextContent = "Section 3"
                });
                var accSec3 = new HTMLDivElement();
                accSec3.AppendChild(
                    new HTMLParagraphElement()
                {
                    TextContent = "Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui."
                });
                var accSec3Li = new HTMLUListElement();
                accSec3Li.AppendChild(new HTMLLIElement()
                {
                    TextContent = "List item one"
                });
                accSec3Li.AppendChild(new HTMLLIElement()
                {
                    TextContent = "List item two"
                });
                accSec3Li.AppendChild(new HTMLLIElement()
                {
                    TextContent = "List item three"
                });
                accSec3.AppendChild(accSec3Li);
                accordion.AppendChild(accSec3);



                accordion.AppendChild(new HTMLHeadingElement(HeadingType.H3)
                {
                    TextContent = "Section 4"
                });
                var accSec4 = new HTMLDivElement();
                accSec4.AppendChild(
                    new HTMLParagraphElement()
                {
                    TextContent = "Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est."
                });
                accSec4.AppendChild(
                    new HTMLParagraphElement()
                {
                    TextContent = "Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos."
                });
                accordion.AppendChild(accSec4);

                accordion.Accordion(new AccordionParameter()
                {
                    HeightStyle = Bridge.jQueryUI.HeightStyles.Content
                });
                contendElement.AppendChild(accordion);
            }
            #endregion

            #region autocomplete
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Autocomplete"
                });
                var autocmpl = new HTMLInputElement();
                autocmpl.Autocomplete(new AutocompleteParameter()
                {
                    Source = new AutocompleteSource[]
                    {
                        new AutocompleteSource("ActionScript"),
                        new AutocompleteSource("AppleScript"),
                        new AutocompleteSource("Asp"),
                        new AutocompleteSource("BASIC"),
                        new AutocompleteSource("C"),
                        new AutocompleteSource("C#"),
                        new AutocompleteSource("C++"),
                        new AutocompleteSource("Clojure"),
                        new AutocompleteSource("COBOL"),
                        new AutocompleteSource("ColdFusion"),
                        new AutocompleteSource("Erlang"),
                        new AutocompleteSource("Fortran"),
                        new AutocompleteSource("Groovy"),
                        new AutocompleteSource("Haskell"),
                        new AutocompleteSource("Java"),
                        new AutocompleteSource("JavaScript"),
                        new AutocompleteSource("Lisp"),
                        new AutocompleteSource("Perl"),
                        new AutocompleteSource("PHP"),
                        new AutocompleteSource("Python"),
                        new AutocompleteSource("Ruby"),
                        new AutocompleteSource("Scala"),
                        new AutocompleteSource("Scheme"),
                    },

                    AppendTo = contendElement
                });
                contendElement.AppendChild(autocmpl);
            }
            #endregion

            #region buttons
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Buttons"
                });
                var btn = new HTMLButtonElement()
                {
                    TextContent = "Button"
                };
                btn.Button();
                contendElement.AppendChild(btn);

                var icnBtn = new HTMLButtonElement()
                {
                    TextContent = "button with icon"
                };
                icnBtn.Button(new ButtonParameter()
                {
                    Icon = "ui-icon-gear", ShowLabel = false
                });
                contendElement.AppendChild(icnBtn);
            }
            #endregion

            #region checkboxradio
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Checkboxes"
                });
                var outerFieldset = new HTMLFieldSetElement();
                outerFieldset.AppendChild(new HTMLLabelElement()
                {
                    TextContent = "Hotel Ratings: "
                });

                HTMLLabelElement lbl1 = new HTMLLabelElement()
                {
                    HtmlFor = "checkbox-1", TextContent = "2 Star"
                };
                HTMLInputElement cb1 = new HTMLInputElement()
                {
                    Type = InputType.Checkbox, Name = "checkbox-1", Id = "checkbox-1"
                };
                HTMLLabelElement lbl2 = new HTMLLabelElement()
                {
                    HtmlFor = "checkbox-2", TextContent = "3 Star"
                };
                HTMLInputElement cb2 = new HTMLInputElement()
                {
                    Type = InputType.Checkbox, Name = "checkbox-2", Id = "checkbox-2"
                };
                HTMLLabelElement lbl3 = new HTMLLabelElement()
                {
                    HtmlFor = "checkbox-3", TextContent = "4 Star"
                };
                HTMLInputElement cb3 = new HTMLInputElement()
                {
                    Type = InputType.Checkbox, Name = "checkbox-3", Id = "checkbox-3"
                };
                HTMLLabelElement lbl4 = new HTMLLabelElement()
                {
                    HtmlFor = "checkbox-4", TextContent = "5 Star"
                };
                HTMLInputElement cb4 = new HTMLInputElement()
                {
                    Type = InputType.Checkbox, Name = "checkbox-4", Id = "checkbox-4"
                };
                outerFieldset.AppendChild(lbl1);
                outerFieldset.AppendChild(cb1);
                outerFieldset.AppendChild(lbl2);
                outerFieldset.AppendChild(cb2);
                outerFieldset.AppendChild(lbl3);
                outerFieldset.AppendChild(cb3);
                outerFieldset.AppendChild(lbl4);
                outerFieldset.AppendChild(cb4);
                cb1.Checkboxradio();
                cb2.Checkboxradio();
                cb3.Checkboxradio();
                cb4.Checkboxradio();
                contendElement.AppendChild(outerFieldset);

                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Radio"
                });
                var outerFieldset2 = new HTMLFieldSetElement();
                outerFieldset2.AppendChild(new HTMLLabelElement()
                {
                    TextContent = "Select a Location: "
                });

                HTMLLabelElement rlbl1 = new HTMLLabelElement()
                {
                    HtmlFor = "radio-1", TextContent = "New York"
                };
                HTMLInputElement rd1 = new HTMLInputElement()
                {
                    Type = InputType.Radio, Name = "radio-1", Id = "radio-1"
                };
                HTMLLabelElement rlbl2 = new HTMLLabelElement()
                {
                    HtmlFor = "radio-2", TextContent = "Paris"
                };
                HTMLInputElement rd2 = new HTMLInputElement()
                {
                    Type = InputType.Radio, Name = "radio-1", Id = "radio-2"
                };
                HTMLLabelElement rlbl3 = new HTMLLabelElement()
                {
                    HtmlFor = "radio-3", TextContent = "London"
                };
                HTMLInputElement rd3 = new HTMLInputElement()
                {
                    Type = InputType.Radio, Name = "radio-1", Id = "radio-3"
                };
                outerFieldset2.AppendChild(rlbl1);
                outerFieldset2.AppendChild(rd1);
                outerFieldset2.AppendChild(rlbl2);
                outerFieldset2.AppendChild(rd2);
                outerFieldset2.AppendChild(rlbl3);
                outerFieldset2.AppendChild(rd3);
                rd1.Checkboxradio();
                rd2.Checkboxradio();
                rd3.Checkboxradio();
                contendElement.AppendChild(outerFieldset2);
            }
            #endregion


            #region tabs
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Tabs"
                });
                var tabsdiv = new HTMLDivElement()
                {
                    Id = "tabs"
                };
                var tabList = new HTMLUListElement();
                tabList.AppendChild(new HTMLLIElement().AppendChild(new HTMLAnchorElement()
                {
                    Href = "#tabs-1", TextContent = "Nunc tincidunt"
                }).ParentElement);
                tabList.AppendChild(new HTMLLIElement().AppendChild(new HTMLAnchorElement()
                {
                    Href = "#tabs-2", TextContent = "Proin dolor"
                }).ParentElement);
                tabList.AppendChild(new HTMLLIElement().AppendChild(new HTMLAnchorElement()
                {
                    Href = "#tabs-3", TextContent = "Aenean lacinia"
                }).ParentElement);
                tabsdiv.AppendChild(tabList);
                tabsdiv.AppendChild(new HTMLDivElement()
                {
                    Id = "tabs-1"
                }.AppendChild(new HTMLParagraphElement()
                {
                    TextContent = "Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing. Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus."
                }).ParentElement);
                tabsdiv.AppendChild(new HTMLDivElement()
                {
                    Id = "tabs-2"
                }.AppendChild(new HTMLParagraphElement()
                {
                    TextContent = "Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus."
                }).ParentElement);
                tabsdiv.AppendChild(new HTMLDivElement()
                {
                    Id = "tabs-3"
                }.AppendChild(new HTMLParagraphElement()
                {
                    TextContent = "Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus."
                }).ParentElement.AppendChild(new HTMLParagraphElement()
                {
                    TextContent = "Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit."
                }).ParentElement);
                tabsdiv.Tabs();
                contendElement.AppendChild(tabsdiv);
            }
            #endregion

            #region dialog
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Dialog"
                });
                var btnNrm = new HTMLButtonElement()
                {
                    TextContent = "Dialog"
                };
                var btnMdl = new HTMLButtonElement()
                {
                    TextContent = "Modal Dialog"
                };
                btnNrm.Button(new ButtonParameter()
                {
                    Icon = "ui-icon-newwin"
                });
                btnMdl.Button(new ButtonParameter()
                {
                    Icon = "ui-icon-newwin"
                });

                btnNrm.OnClick += (ev) =>
                {
                    (new HTMLDivElement()
                    {
                        TextContent = "Hello I am an dialog"
                    }).Dialog(new DialogParameter()
                    {
                        Title = "Dialog"
                    });
                };
                btnMdl.OnClick += (ev) =>
                {
                    var dialogDiv = new HTMLDivElement()
                    {
                        TextContent = "I am a modal dialog"
                    };
                    dialogDiv.Dialog(new DialogParameter()
                    {
                        Title   = "Modal Dialog",
                        Modal   = true,
                        Buttons = new DialogButton[]
                        {
                            new DialogButton()
                            {
                                Click = () =>
                                {
                                    dialogDiv.DialogClose();
                                },
                                Text = "OK"
                            },
                            new DialogButton()
                            {
                                Click = () =>
                                {
                                    dialogDiv.DialogClose();
                                },
                                Text = "Cancel"
                            }
                        }
                    });
                };
                contendElement.AppendChild(btnNrm);
                contendElement.AppendChild(btnMdl);
            }
            #endregion


            #region slider
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Slider"
                });
                var slider = new HTMLDivElement();
                slider.Slider();
                contendElement.AppendChild(slider);
                var val = new HTMLParagraphElement()
                {
                    TextContent = "Value"
                };
                contendElement.AppendChild(val);
                slider.SliderSlide(new System.Action <Bridge.jQueryUI.JqueryEvents, SliderEvent>((ev, ui) =>
                {
                    val.TextContent = "Value: " + ui.Value;
                }));
            }
            #endregion

            #region datepicker
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Datepicker"
                });
                var inp = new HTMLInputElement();
                inp.Datepicker();
                contendElement.AppendChild(inp);
            }

            #endregion


            #region progressbar
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Progressbar"
                });
                var div = new HTMLDivElement();
                div.Progressbar(new ProgressbarParamter()
                {
                    Max = 100
                });
                contendElement.AppendChild(div);

                var btn = new HTMLButtonElement()
                {
                    TextContent = "Start",
                    OnClick     = (ev) =>
                    {
                        div.ProgressbarValue(0);

                        System.Threading.Tasks.Task.Run(async() =>
                        {
                            while (true)
                            {
                                int val = div.ProgressbarValue();
                                val++;
                                if (val > 100)
                                {
                                    return;
                                }
                                div.ProgressbarValue(val);
                                await System.Threading.Tasks.Task.Delay(100);
                            }
                        });
                    }
                };
                btn.Button();
                contendElement.AppendChild(btn);
            }
            #endregion

            #region selectmenu
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Selectmenu"
                });
                var sel = new HTMLSelectElement();
                sel.AppendChild(new HTMLOptionElement()
                {
                    TextContent = "Slower"
                });
                sel.AppendChild(new HTMLOptionElement()
                {
                    TextContent = "Slow"
                });
                sel.AppendChild(new HTMLOptionElement()
                {
                    TextContent = "Medium"
                });
                sel.AppendChild(new HTMLOptionElement()
                {
                    TextContent = "Fast"
                });
                sel.AppendChild(new HTMLOptionElement()
                {
                    TextContent = "Faster"
                });
                contendElement.AppendChild(sel);
                sel.Selectmenu(new SelectmenuParameter()
                {
                    AppendTo = contendElement
                });
            }
            #endregion


            #region menu
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Menu"
                });

                var menu = new HTMLUListElement();
                menu.Style.Width = "150px";
                menu.AppendChild(new HTMLLIElement()
                {
                    ClassName = "ui-state-disabled"
                }.AppendChild(new HTMLDivElement()
                {
                    TextContent = "Toys (n/a)"
                }).ParentNode);
                menu.AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Books"
                }).ParentNode);
                menu.AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Clothing"
                }).ParentNode);
                menu.AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Electronics"
                }).ParentNode
                                 .AppendChild(new HTMLUListElement()
                                              .AppendChild(new HTMLLIElement()
                {
                    ClassName = "ui-state-disabled"
                }.AppendChild(new HTMLDivElement()
                {
                    TextContent = "Home Entertainment"
                }).ParentNode).ParentNode
                                              .AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Car Hifi"
                }).ParentNode).ParentNode
                                              .AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Utilities"
                }).ParentNode).ParentNode
                                              ).ParentNode);
                menu.AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Movies"
                }).ParentNode);

                menu.AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Music"
                }).ParentNode
                                 .AppendChild(new HTMLUListElement()
                                              .AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Rock"
                }).ParentNode
                                                           .AppendChild(new HTMLUListElement()
                                                                        .AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Alternative"
                }).ParentNode).ParentNode
                                                                        .AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Classics"
                }).ParentNode).ParentNode
                                                                        ).ParentNode
                                                           ).ParentNode
                                              .AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Jazz"
                }).ParentNode
                                                           .AppendChild(new HTMLUListElement()
                                                                        .AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Freejazz"
                }).ParentNode).ParentNode
                                                                        .AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Big Band"
                }).ParentNode).ParentNode
                                                                        .AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Modern"
                }).ParentNode).ParentNode
                                                                        ).ParentNode
                                                           ).ParentNode
                                              .AppendChild(new HTMLLIElement().AppendChild(new HTMLDivElement()
                {
                    TextContent = "Pop"
                }).ParentNode).ParentNode
                                              ).ParentNode);
                menu.AppendChild(new HTMLLIElement()
                {
                    ClassName = "ui-state-disabled"
                }.AppendChild(new HTMLDivElement()
                {
                    TextContent = "Specials (n/a)"
                }).ParentNode);



                menu.Menu();
                contendElement.AppendChild(menu);
            }
            #endregion


            #region tooltip
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Tooltip"
                });

                var para   = new HTMLParagraphElement();
                var ttlink = new HTMLAnchorElement()
                {
                    Href = "#", TextContent = "Tooltips", Title = "That's what this widget is"
                };
                ttlink.Tooltip();
                para.AppendChild(ttlink);


                para.AppendChild(new Text(" can be attached to any element. When you hover the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip."));
                contendElement.AppendChild(para);
            }
            #endregion


            #region errorhigh
            {
                contendElement.AppendChild(new HTMLHeadingElement(HeadingType.H2)
                {
                    TextContent = "Highlight / Error"
                });
                var highlight = new HTMLDivElement();
                highlight.Highlight("Hey!", " Sample ui-state-highlight style.");
                contendElement.AppendChild(highlight);
                contendElement.AppendChild(new HTMLBRElement());
                var error = new HTMLDivElement();
                error.Error("Hey!", "Sample ui-state-error style.");
                contendElement.AppendChild(error);
            }
            #endregion



            contendElement.Dialog(new DialogParameter()
            {
                Buttons = new DialogButton[] {
                    new DialogButton()
                    {
                        Click = () => { contendElement.DialogClose(); },
                        Text  = "Close"
                    }
                },
                Height = 600,
                Width  = 900,
                Title  = "jQueryUi Demo Elements"
            });
        }
Exemple #12
0
        private static HTMLDivElement DivPlayState()
        {
            HTMLDivElement playDiv = new HTMLDivElement();

            if (Program.gameVue.Zones[0].Cards.Length > 0)
            {
                HTMLLabelElement PlayerOneScoreLabel = new HTMLLabelElement();
                int playerOneScore      = Program.gameVue.Players[0].GetRessource("Score");
                int playerOneMultiplier = Program.gameVue.Players[0].GetRessource("Multiplier");
                PlayerOneScoreLabel.TextContent = string.Format("Player 1 : '{0}', Multiplier : '{1}'", playerOneScore, playerOneMultiplier);
                playDiv.AppendChild(PlayerOneScoreLabel);
                playDiv.AppendChild(new HTMLParagraphElement());
                HTMLLabelElement playerTwoScoreLabel = new HTMLLabelElement();
                int playerTwoScore      = Program.gameVue.Players[1].GetRessource("Score");
                int playerTwoMultiplier = Program.gameVue.Players[1].GetRessource("Multiplier");
                playerTwoScoreLabel.TextContent = $"Player 2 : {playerTwoScore}', Multiplier : '{playerTwoMultiplier}'";
                playDiv.AppendChild(playerTwoScoreLabel);

                if (Program.gameVue.Zones[0].Cards.Length > 0)
                {
                    GameVue.CardVue  topCard        = Program.gameVue.Zones[0].Cards[0];
                    HTMLDivElement   deckDiv        = new HTMLDivElement();
                    HTMLLabelElement deckTitleLabel = new HTMLLabelElement();
                    deckTitleLabel.TextContent = "Top deck";
                    deckDiv.AppendChild(deckTitleLabel);

                    HTMLDivElement topCardDiv = Program.GetCardDiv(topCard);
                    deckDiv.AppendChild(topCardDiv);

                    deckDiv.AppendChild(new HTMLParagraphElement());
                    deckDiv.AppendChild(new HTMLLabelElement()
                    {
                        TextContent = $"'{Program.gameVue.Zones[0].Cards.Length}' Cards left in the deck"
                    });

                    playDiv.AppendChild(deckDiv);
                }

                playDiv.AppendChild(new HTMLDivElement()
                {
                    TextContent = string.Format("Current player {0}", Program.gameVue.currentPlayer + 1)
                });
            }
            else
            {
                HTMLLabelElement PlayerOneScoreLabel = new HTMLLabelElement();
                int playerOneScore = Program.gameVue.Players[0].GetRessource("Score");
                PlayerOneScoreLabel.TextContent = string.Format("Player 1 : {0}", playerOneScore);
                playDiv.AppendChild(PlayerOneScoreLabel);
                playDiv.AppendChild(new HTMLParagraphElement());
                HTMLLabelElement playerTwoScoreLabel = new HTMLLabelElement();
                int playerTwoScore = Program.gameVue.Players[1].GetRessource("Score");
                playerTwoScoreLabel.TextContent = $"Player 2 : {playerTwoScore}'";
                playDiv.AppendChild(playerTwoScoreLabel);
                playDiv.AppendChild(new HTMLParagraphElement());

                string winnerMessage;
                if (playerOneScore > playerTwoScore)
                {
                    winnerMessage = "Player 1 Win!";
                }
                else
                {
                    winnerMessage = "Player 2 Win!";
                }

                HTMLLabelElement winnerLabel = new HTMLLabelElement
                {
                    TextContent = winnerMessage,
                };

                playDiv.AppendChild(winnerLabel);
            }

            return(playDiv);
        }
        public static IDataGridColumn <RecordT> Build <RecordT>(
            Func <DataGridModel <RecordT> > model,
            params Tuple <string, Func <RecordT, bool> >[] customSelection) where RecordT : new()
        {
            var header = new LocalValue <string>(string.Format(I18n.Translate("{0} of {1}"), 0, 0));

            var defaultActions = new List <HTMLElement> {
                new HTMLAnchorElement {
                    Href        = "#",
                    TextContent = I18n.Translate("All")
                }.With(x => {
                    x.OnClick += ev => {
                        ev.PreventDefault();
                        model().Selected.Replace(model().Items);
                    };
                }),
                new HTMLAnchorElement {
                    Href        = "#",
                    TextContent = I18n.Translate("None")
                }.With(x => {
                    x.OnClick += ev => {
                        ev.PreventDefault();
                        model().Selected.Clear();
                    };
                })
            };

            return(new DataGridColumn <RecordT, bool>(
                       header,
                       TextType.TreatAsText,
                       x => model().Selected.Contains(x),
                       x => LocalizationUtil.BoolToUnicodeCheckbox(x),
                       (x, exp) => exp.Export(x),
                       _ => Tuple.Create <HTMLElement, DataGridColumnControllerResult <bool> >(null,
                                                                                               new DataGridColumnControllerResult <bool> {
                FilterImpl = null,
                AggregationImpl = null,
                GroupingImpl = null,
                SortingImpl = null,
                IsGroupingActive = () => false
            }),
                       new SelectedItemsListener <RecordT>(model),
                       m => {
                var v = new InputCheckboxView("");
                v.Widget.ClassList.Add(Magics.CssClassIsSelectionHandler);

                v.BindReadWriteAndInitialize(m);
                return v;
            },
                       new List <Validate <bool> >(),
                       (x, toBeSelected) => {
                var isSelected = model().Selected.Contains(x);
                if (!isSelected && toBeSelected)
                {
                    model().Selected.InsertAt(0, x);
                }
                else if (isSelected && !toBeSelected)
                {
                    model().Selected.Delete(x);
                }
            },
                       null,
                       null,
                       true,
                       () => {
                var cntnr = new HTMLDivElement();
                cntnr.Style.Display = Display.Flex;
                cntnr.Style.FlexDirection = FlexDirection.Column;

                var customActions = customSelection.Select(x =>
                                                           new HTMLAnchorElement {
                    Href = "#",
                    TextContent = x.Item1
                }.With(y => {
                    y.OnClick += ev => {
                        ev.PreventDefault();
                        model().Selected.Replace(model().Items.Where(z => x.Item2(z)));
                    };
                })
                                                           );

                defaultActions
                .Concat(customActions)
                .ForEach(x => cntnr.AppendChild(x));

                return cntnr;
            },
                       dgmodel => {
                var mdl = dgmodel ?? model();
                if (mdl == null)
                {
                    throw new Exception("datagrid model is null");
                }

                // initialize
                var selectedCount = mdl.Selected.Length;
                var allCount = mdl.Items.Length;
                header.DoChange(string.Format(I18n.Translate("{0} of {1}"), selectedCount, allCount), false);

                mdl.Selected.Changed += (_, __, ___) => {
                    selectedCount = model().Selected.Length;
                    header.DoChange(string.Format(I18n.Translate("{0} of {1}"), selectedCount, allCount), false);
                };

                mdl.Items.Changed += (_, __, ___) => {
                    allCount = model().Items.Length;
                    header.DoChange(string.Format(I18n.Translate("{0} of {1}"), selectedCount, allCount), false);
                };
            }
                       ));
        }
Exemple #14
0
        public static void Main()
        {
            Random rnd = new Random();

            passwordPattern = null;

            var passwordLabel = new HTMLDivElement {
                Id = "passwordLabel"
            };
            var passwordList = new HTMLDivElement {
                Id = "passwords"
            };

            var button = new HTMLButtonElement
            {
                InnerHTML = "Generate Password",
                OnClick   = (ev) =>
                {
                    passwordList.InnerHTML += passwordPattern.GetPattern() + "<br/>";
                }
            };

            button.Disabled = true;

            var patternButton = new HTMLButtonElement
            {
                InnerHTML = "Random Pattern",
                OnClick   = (ev) =>
                {
                    passwordPattern = GetRandomPattern(rnd);
                    button.Disabled = false;
                    passwordPattern.Initialize(rnd);
                    //Console.WriteLine(passwordPattern.GetPatternTitle());
                    passwordLabel.InnerHTML = " " + passwordPattern.GetPatternTitle();
                }
            };

            var clearButton = new HTMLButtonElement
            {
                InnerHTML = "clear password list",
                OnClick   = (ev) =>
                {
                    passwordList.InnerHTML = string.Empty;
                }
            };

            Document.BgColor = "black";
            Document.FgColor = "White";

            Document.Body.AppendChild(patternButton);
            Document.Body.AppendChild(passwordLabel);
            Document.Body.AppendChild(new HTMLBRElement());

            var div = new HTMLDivElement();

            div.AppendChild(clearButton);
            div.AppendChild(button);
            Document.Body.AppendChild(div);
            Document.Body.AppendChild(new HTMLBRElement());
            Document.Body.AppendChild(passwordList);
        }
Exemple #15
0
        public void Merge(string[] htmlFiles, string outPath)
        {
            _htmlOutputPath = Path.GetDirectoryName(outPath);
            var temp = Path.Combine(_htmlOutputPath, "Output2");

            Directory.CreateDirectory(temp);

            for (var i = 0; i < htmlFiles.Length; i++)
            {
                var htmlFile           = htmlFiles[i];
                var fileName           = Path.GetFileName(htmlFile);
                var tempOutputFilePath = Path.Combine(temp, fileName);
                File.Copy(htmlFile, tempOutputFilePath);
                htmlFiles[i] = tempOutputFilePath;

                using (var htmlDocument = new HTMLDocument(htmlFiles[i]))
                {
                    HTMLDivElement   anchorDivContainer = (HTMLDivElement)htmlDocument.CreateElement("div");
                    HTMLBodyElement  htmlDocumentBody   = (HTMLBodyElement)htmlDocument.Body;
                    HTMLHeadElement  head             = (HTMLHeadElement)htmlDocument.GetElementsByTagName("head")[0];
                    HTMLStyleElement htmlStyleElement = (HTMLStyleElement)htmlDocument.CreateElement("style");

                    var resetEvent = new AutoResetEvent(false);
                    htmlStyleElement.OnLoad  += (sender, e) => { resetEvent.Set(); };
                    htmlStyleElement.OnError += (sender, e) => { resetEvent.Set(); };

                    var cssContent = htmlDocument.CreateTextNode(_content);
                    htmlStyleElement.AppendChild(cssContent);
                    head.AppendChild(htmlStyleElement);
                    resetEvent.WaitOne();

                    anchorDivContainer.SetAttribute("class", "container");
                    anchorDivContainer.SetAttribute("align", "center");

                    var paragraphElement = GetParagraphElement(htmlDocument, "Navigation");
                    anchorDivContainer.AppendChild(paragraphElement);

                    if (i != 0)
                    {
                        var anchorBackward = GetAnchorElement(htmlDocument, "Backward");
                        anchorBackward.Href = Path.GetFileName(htmlFiles[i - 1]);
                        anchorDivContainer.AppendChild(anchorBackward);
                    }
                    else
                    {
                        HTMLAnchorElement anchorBackward = GetAnchorElement(htmlDocument, "Backward");
                        anchorBackward.Href = Path.GetFileName(htmlFiles[htmlFiles.Length - 1]);
                        anchorDivContainer.AppendChild(anchorBackward);
                    }

                    if (i != htmlFiles.Length - 1)
                    {
                        HTMLAnchorElement anchorForward = GetAnchorElement(htmlDocument, "Forward");
                        anchorForward.Href = Path.GetFileName(htmlFiles[i + 1]);
                        anchorDivContainer.AppendChild(anchorForward);
                    }
                    else
                    {
                        HTMLAnchorElement anchorForward = GetAnchorElement(htmlDocument, "Forward");
                        anchorForward.Href = Path.GetFileName(htmlFiles[0]);
                        anchorDivContainer.AppendChild(anchorForward);
                    }

                    Node firstChild = htmlDocumentBody.FirstChild;
                    htmlDocumentBody.InsertBefore(anchorDivContainer, firstChild);
                    var outputPath = Path.Combine(_htmlOutputPath, fileName);
                    htmlDocument.Save(outputPath);
                    htmlDocument.Dispose();
                    htmlFiles[i] = outputPath;
                    ClearDirectory(temp);
                }
            }
            var name = Path.GetFileNameWithoutExtension(outPath);

            SaveDocument($"{name}.mhtml", htmlFiles[0], htmlFiles.Length);
        }
Exemple #16
0
        public static void ShowTableDemo()
        {
            var div = new HTMLDivElement();

            var table = new HTMLTableElement();

            table.CreateTHead();
            var tHeadRow = new HTMLTableRowElement();

            tHeadRow.AppendChild(new HTMLTableHeaderCellElement()
            {
                TextContent = "Name"
            });
            tHeadRow.AppendChild(new HTMLTableHeaderCellElement()
            {
                TextContent = "Position"
            });
            tHeadRow.AppendChild(new HTMLTableHeaderCellElement()
            {
                TextContent = "Office"
            });
            tHeadRow.AppendChild(new HTMLTableHeaderCellElement()
            {
                TextContent = "Age"
            });
            tHeadRow.AppendChild(new HTMLTableHeaderCellElement()
            {
                TextContent = "StartDate"
            });
            tHeadRow.AppendChild(new HTMLTableHeaderCellElement()
            {
                TextContent = "Salary"
            });
            table.THead.AppendChild(tHeadRow);
            var tBody = new HTMLTableSectionElement(TableSectionType.Body);

            table.AppendChild(tBody);
            div.AppendChild(table);

            var data = Script.Get("tabledemoJsonData").ToDynamic();

            foreach (var dataRow in data)
            {
                var row = new HTMLTableRowElement();
                row.OnMouseEnter = (ev) => { row.ClassList.Add("highlight"); };
                row.OnMouseLeave = (ev) => { row.ClassList.Remove("highlight"); };

                row.OnMouseDown = (ev) => {
                    if (row.ClassList.Contains("selected"))
                    {
                        row.ClassList.Remove("selected");
                    }
                    else
                    {
                        row.ClassList.Add("selected");
                    }
                };

                row.AppendChild(new HTMLTableDataCellElement()
                {
                    TextContent = dataRow.Name
                });
                row.AppendChild(new HTMLTableDataCellElement()
                {
                    TextContent = dataRow.Position
                });
                row.AppendChild(new HTMLTableDataCellElement()
                {
                    TextContent = dataRow.Office
                });
                row.AppendChild(new HTMLTableDataCellElement()
                {
                    TextContent = dataRow.Age
                });
                row.AppendChild(new HTMLTableDataCellElement()
                {
                    TextContent = dataRow.StartDate
                });
                row.AppendChild(new HTMLTableDataCellElement()
                {
                    TextContent = dataRow.Salary
                });
                tBody.AppendChild(row);
            }
            div.Dialog(new DialogParameter()
            {
                Title = "Datatable Demo", Width = 960, Height = 600
            });

            div.DialogEventResize(
                (ev, ui) =>
            {
                table.DataTableDraw();
            }
                );



            table.DataTable(new DataTableParameter()
            {
                ScrollCollapse = true, ScrollY = "100%"
            });


            table.DataTableDraw();

            //Bridge.jQuery2.jQuery.Ajax(new Bridge.jQuery2.AjaxOptions
            //{
            //    Url = "TextFile1.txt",
            //    ContentType = "application/json; charset=utf-8",
            //    Success = delegate (dynamic data, string str, Bridge.jQuery2.jqXHR jqxhr)
            //    {
            //        var row = new HTMLTableRowElement();
            //        row.AppendChild(new HTMLTableColElement() { TextContent = data.Name });
            //        row.AppendChild(new HTMLTableColElement() { TextContent = data.Position });
            //        row.AppendChild(new HTMLTableColElement() { TextContent = data.Office });
            //        row.AppendChild(new HTMLTableColElement() { TextContent = data.Age });
            //        row.AppendChild(new HTMLTableColElement() { TextContent = data.StartDate });
            //        row.AppendChild(new HTMLTableColElement() { TextContent = data.Salary });
            //        tBody.AppendChild(row);
            //    }
            //});
        }
Exemple #17
0
        private void IncrementLine()
        {
            string cmd = CommandInput.Value;

            if (cmd.Length > 0)
            {
                CommandInput.Value = "";

                var SpanText = new HTMLSpanElement();
                FillHorizontalControlWithParent(SpanText, 2);
                SpanText.Style.WhiteSpace = WhiteSpace.NoWrap;
                SetCommandLineElement(SpanText);
                SpanText.InnerHTML = cmd;
                SpanText.Style.Top = (Global.ParseInt(CommandInput.Style.Height) * Line) + 3 + "px";
                CommandPanel.AppendChild(SpanText);
                CommandLines.Add(SpanText);
            }
            Line++;
            CommandInput.Style.Top = (Global.ParseInt(CommandInput.Style.Height) * Line) + "px";
            CommandPanel.ScrollTop = CommandPanel.ScrollHeight;

            if (cmd.ToLower() == "clear")
            {
                Reset();
            }
            else if (cmd.ToLower() == "toggle bodyoverlay")
            {
                ShowBodyOverLay = !ShowBodyOverLay;
            }
            else if (cmd.ToLower().StartsWith("cd "))
            {
                currentcd += "\\" + cmd.Substring(3);
                Text       = "Console - Path: " + currentcd;
            }
            else if (cmd.ToLower().StartsWith("dir"))
            {
                string location;

                if (cmd.ToLower().StartsWith("dir "))
                {
                    location = cmd.Substring("dir ".Length);
                }
                else
                {
                    location = currentcd;
                }

                foreach (string item in Directory.GetDirectories(location))
                {
                    WriteLine(item);
                }
                foreach (string item in Directory.GetFiles(location))
                {
                    WriteLine(item);
                }
            }
            else if (cmd.ToLower().StartsWith("createfile "))
            {
                string pathAndFile = currentcd + @"\" + cmd.Substring("createfile ".Length);

                File.WriteAllText(pathAndFile, "");

                FileExplorer.FileChangeAt(Path.GetDirectoryName(pathAndFile));
            }
            else if (cmd.ToLower().StartsWith("deletefile "))
            {
                string pathAndFile = currentcd + @"\" + cmd.Substring("deletefile ".Length);

                File.Delete(pathAndFile);

                FileExplorer.FileChangeAt(Path.GetDirectoryName(pathAndFile));
            }
            else if (cmd.ToLower().StartsWith("createdir "))
            {
                string pathAndFile = currentcd + @"\" + cmd.Substring("createdir ".Length);

                Directory.Create(pathAndFile);

                FileExplorer.FileChangeAt(Path.GetDirectoryName(pathAndFile));
            }
        }
Exemple #18
0
        private void CreateHtmlNode()
        {
            if (NodeBase == null)
            {
                NodeBase  = new HTMLDivElement();
                NodeImage = new HTMLDivElement();
                NodeText  = new HTMLSpanElement();

                //NodeBase.Style.ZIndex = "0";

                NodeBase.Style.Position  = Position.Absolute;
                NodeImage.Style.Position = Position.Absolute;
                NodeText.Style.Position  = Position.Absolute;

                NodeBase.AddEventListener(EventType.DblClick, (ev) =>
                {
                    if (!Form.MidleOfAction())
                    {
                        parent.ClearSelection();

                        if (IsFile)
                        {
                            Process.Start(FullPath);
                        }
                        else
                        {
                            if (parent.Owner == null)
                            {
                                var frm  = new FormFileExplorer(FullPath);
                                frm.Left = "50px";
                                frm.Top  = "50px";

                                frm.Show();
                            }
                            else
                            {
                                parent.Path = FullPath;
                                parent.Refresh();
                            }
                        }
                    }
                });

                NodeBase.AddEventListener(EventType.MouseUp, (ev) =>
                {
                    if (!Form.MidleOfAction())
                    {
                        // did i drag...
                        parent.ClearSelection(this);
                    }
                });

                NodeBase.AddEventListener(EventType.MouseDown, (ev) =>
                {
                    if (!Form.MidleOfAction())
                    {
                        int selectionCount = parent.GetSelectionCount(this);

                        if (NodeExplorerState == FileExplorerState.Selected)
                        {
                            if (selectionCount == 0)
                            {
                                parent.ClearSelection(this);
                            }
                            NodeExplorerState = FileExplorerState.Focused;
                        }
                        else
                        {
                            if (selectionCount == 0)
                            {
                                parent.ClearSelection(this);
                            }
                            NodeExplorerState = FileExplorerState.Focused;
                        }
                        ev.StopPropagation();
                    }
                });

                NodeBase.AddEventListener(EventType.MouseEnter, (ev) =>
                {
                    if (!Form.MidleOfAction())
                    {
                        if (NodeExplorerState == FileExplorerState.Focused || NodeExplorerState == FileExplorerState.HoverFocused)
                        {
                            NodeExplorerState = FileExplorerState.HoverFocused;
                        }
                        else if (NodeExplorerState == FileExplorerState.Selected || NodeExplorerState == FileExplorerState.HoverSelected)
                        {
                            NodeExplorerState = FileExplorerState.HoverSelected;
                        }
                        else
                        {
                            NodeExplorerState = FileExplorerState.Hover;
                        }
                        ev.StopPropagation();
                    }
                });

                NodeBase.AddEventListener(EventType.MouseLeave, (ev) =>
                {
                    if (!Form.MidleOfAction())
                    {
                        if (NodeExplorerState == FileExplorerState.HoverFocused || NodeExplorerState == FileExplorerState.Focused)
                        {
                            NodeExplorerState = FileExplorerState.Focused;
                        }
                        else if (NodeExplorerState == FileExplorerState.HoverSelected || NodeExplorerState == FileExplorerState.Selected)
                        {
                            NodeExplorerState = FileExplorerState.Selected;
                        }
                        else
                        {
                            NodeExplorerState = FileExplorerState.None;
                        }
                        ev.StopPropagation();
                    }
                });

                if (nodeViewType == NodeViewType.Medium_Icons)
                {
                    jQuery.Select(NodeImage).
                    Css("width", 48).
                    Css("height", 48).
                    Css("left", 14).
                    Css("top", 2);

                    NodeBase.Style.BorderStyle = BorderStyle.Solid;
                    NodeBase.Style.BorderWidth = BorderWidth.Thin;

                    HTMLImageElement img = new HTMLImageElement();

                    img.Style.MaxWidth  = "100%";
                    img.Style.MaxHeight = "100%";

                    img.Style.Position = Position.Absolute;
                    img.Style.Display  = Display.Block;

                    if (IsFile)
                    {
                        if (Icon == string.Empty)
                        {
                            img.SetAttribute("src", IconRepository.IMAGE_File);// NodeImage.Style.Background = FileExplorer.IMAGE_File;
                        }
                        else
                        {
                            img.SetAttribute("src", Icon);// NodeImage.Style.Background = FileExplorer.IMAGE_File;
                        }
                    }
                    else
                    {
                        img.SetAttribute("src", IconRepository.IMAGE_Folder);//NodeImage.Style.Background = FileExplorer.IMAGE_Folder;
                    }
                    Form.DisableStateDrag(img);

                    NodeImage.AppendChild(img);

                    NodeText.InnerHTML        = Name;
                    NodeText.Style.FontFamily = "Segoe UI";
                    NodeText.Style.FontSize   = "9.5pt";
                    NodeText.Style.TextAlign  = TextAlign.Center;
                    NodeText.Style.Cursor     = Cursor.Default;
                    NodeText.Style.TextShadow = "0px 2px 7px rgba(0, 0, 0, 0.5)";

                    // think you are looking for  text-overflow: ellipsis in combination with white-space: nowrap
                    NodeText.Style.TextOverflow = TextOverflow.Ellipsis;
                    NodeText.Style.WhiteSpace   = WhiteSpace.NoWrap;
                    NodeText.Style.Overflow     = Overflow.Hidden;


                    Form.SetInternalLabel(NodeText);

                    Form.ChangeStateTextSelection(NodeText, false);
                    Form.ChangeStateTextSelection(NodeImage, false);
                    Form.ChangeStateTextSelection(NodeBase, false);
                    Form.ChangeStateTextSelection(img, false);

                    jQuery.Select(NodeText).
                    Css("width", 74).
                    Css("height", 20).
                    Css("left", 2).
                    Css("top", 48);

                    NodeText.Style.Color = "white";

                    NodeBase.AppendChild(NodeImage);
                    NodeBase.AppendChild(NodeText);
                }
            }

            if (nodeViewType == NodeViewType.Medium_Icons)
            {
                if (nodeState == FileExplorerState.Focused ||
                    nodeState == FileExplorerState.HoverFocused)
                {
                    NodeText.Style.Overflow = Overflow.Visible;

                    jQuery.Select(NodeBase).
                    Css("width", 76 - NodeText.ClientWidth + NodeText.ScrollWidth).
                    Css("height", 50 + NodeText.ScrollHeight);
                }
                else
                {
                    jQuery.Select(NodeBase).
                    Css("width", 76).
                    Css("height", 70);

                    NodeText.Style.Overflow = Overflow.Hidden;
                }
            }

            // image 48x48

            switch (nodeState)
            {
            case FileExplorerState.None:
                NodeBase.Style.BackgroundColor = "";
                NodeBase.Style.BorderColor     = "rgba(255, 255, 255, 0)";
                break;

            case FileExplorerState.HoverSelected:
            case FileExplorerState.HoverFocused:
            case FileExplorerState.Hover:
                NodeBase.Style.BackgroundColor = "rgba(255, 255, 255, 0.2)";
                NodeBase.Style.BorderColor     = "rgba(255, 255, 255, 0.5)";
                break;

            case FileExplorerState.Selected:
            case FileExplorerState.Focused:
                NodeBase.Style.BackgroundColor = "rgba(255, 255, 255, 0.4)";
                NodeBase.Style.BorderColor     = "rgba(255, 255, 255, 0.5)";
                break;

            //case FileExplorerState.HoverSelected:
            //case FileExplorerState.HoverFocused:
            //    NodeBase.Style.BackgroundColor = "rgba(255, 255, 255, 0.4)";
            //    NodeBase.Style.BorderColor = "rgba(255, 255, 255, 0.6)";
            //    break;
            default:
                break;
            }
        }
Exemple #19
0
        public static void Main()
        {
            AddJquery(Document.Head);
            AddBootstrap(Document.Head);
            AddHighcharts(Document.Head);
            AddChartsRender(Document.Head);

            var divContainer = new HTMLDivElement()
            {
                ClassName = "container-fluid"
            };

            Document.Body.AppendChild(divContainer);

            AddDivAsRow(divContainer, "medianRatingByCountry");
            AddDivAsRow(divContainer, "countByCountry");
            AddDivAsRow(divContainer, "medianRatingByBrewery");
            AddDivAsRow(divContainer, "countByBrewery");
            AddDivAsRow(divContainer, "medianRatingByStyle");
            AddDivAsRow(divContainer, "countByStyle");
            AddDivAsRow(divContainer, "countByServingType");
            AddDivAsRow(divContainer, "medianRatingByFlavorProfile");
            AddDivAsRow(divContainer, "countByFlavorProfile");
            AddDivAsRow(divContainer, "medianAbvByDayOfWeek");
            divContainer.AppendChild(new HTMLHRElement());
            AddDivAsRow(divContainer, "additionalStats");

            var row = new HTMLDivElement {
                ClassName = "row"
            };

            divContainer.AppendChild(row);
            var col = new HTMLDivElement {
                ClassName = "mx-auto"
            };

            row.AppendChild(col);
            var formGroup = new HTMLDivElement {
                ClassName = "form-group"
            };

            col.AppendChild(formGroup);
            var input = new HTMLInputElement {
                Type = InputType.File, Accept = ".json"
            };

            formGroup.AppendChild(input);
            var small = new HTMLElement("small")
            {
                ClassList = { "form-text", "text-muted" }
            };

            formGroup.AppendChild(small);

            var button = new HTMLButtonElement
            {
                InnerHTML = "Process",
                ClassList = { "btn", "btn-primary" },
                OnClick   = (clickEvent) =>
                {
                    if (input.Files.Length > 0 && input.Files[0] != null)
                    {
                        var reader = new FileReader();
                        reader.OnLoad = loadEvent =>
                        {
                            var rawDataString = reader.Result.ToString();

                            var data = JsonConvert.DeserializeObject <IList <Checkin> >(rawDataString);

                            var dataAnalyzer = new DataAnalyzer();

                            var medianRating = dataAnalyzer.GetMedian(data.Where(c => c.RatingScore.HasValue).Select(c => c.RatingScore.Value));
                            var medianAbv    = dataAnalyzer.GetMedian(data.Where(c => c.BeerAbv.HasValue).Select(c => c.BeerAbv.Value));
                            var medianIbu    = dataAnalyzer.GetMedian(data.Where(c => c.BeerIbu.HasValue).Select(c => c.BeerIbu.Value));

                            var dataByFlavorProfile = data.Aggregate(new List <Checkin>(), (checkins, checkin) =>
                            {
                                if (!string.IsNullOrWhiteSpace(checkin.FlavorProfiles))
                                {
                                    var flavorProfiles = checkin.FlavorProfiles.Split(',');
                                    foreach (var flavorProfile in flavorProfiles)
                                    {
                                        var checkinCopy            = checkin.DeepCopy();
                                        checkinCopy.FlavorProfiles = flavorProfile;
                                        checkins.Add(checkinCopy);
                                    }
                                }
                                return(checkins);
                            });

                            var statsByCountry       = dataAnalyzer.GetStatistics(data.Where(d => !string.IsNullOrEmpty(d.BreweryCountry)), checkin => checkin.BreweryCountry, checkin => checkin.RatingScore);
                            var statsByBrewery       = dataAnalyzer.GetStatistics(data.Where(d => !string.IsNullOrEmpty(d.BreweryName)), checkin => checkin.BreweryName, checkin => checkin.RatingScore);
                            var statsByStyle         = dataAnalyzer.GetStatistics(data.Where(d => !string.IsNullOrEmpty(d.BeerType)), checkin => checkin.BeerType, checkin => checkin.RatingScore);
                            var statsByServingType   = dataAnalyzer.GetStatistics(data.Where(d => !string.IsNullOrEmpty(d.ServingType)), checkin => checkin.ServingType, checkin => checkin.RatingScore);
                            var statsByFlavorProfile = dataAnalyzer.GetStatistics(dataByFlavorProfile, checkin => checkin.FlavorProfiles, checkin => checkin.RatingScore);
                            var statsByDayOfWeek     = dataAnalyzer.GetStatistics(data, checkin => checkin.CreatedAt.DayOfWeek, checkin => checkin.BeerAbv);

                            var medianRatingByCountry = statsByCountry.OrderByDescending(item => item.Median).Select(item => new { name = item.Key, y = item.Median }).ToList();
                            var countByCountry        = statsByCountry.OrderByDescending(item => item.Count).Select(item => new { name = item.Key, y = item.Count }).ToList();

                            var medianRatingByBrewery = statsByBrewery.OrderByDescending(item => item.Median).Select(item => new { name = item.Key, y = item.Median }).ToList();
                            var countByBrewery        = statsByBrewery.OrderByDescending(item => item.Count).Select(item => new { name = item.Key, y = item.Count }).ToList();

                            var medianRatingByStyle = statsByStyle.OrderByDescending(item => item.Median).Select(item => new { name = item.Key, y = item.Median }).ToList();
                            var countByStyle        = statsByStyle.OrderByDescending(item => item.Count).Select(item => new { name = item.Key, y = item.Count }).ToList();

                            var countByServingType = statsByServingType.OrderByDescending(item => item.Count).Select(item => new { name = item.Key, y = item.Count }).ToList();

                            var medianRatingByFlavorProfile = statsByFlavorProfile.OrderByDescending(item => item.Median).Select(item => new { name = item.Key, y = item.Median }).ToList();
                            var countByFlavorProfile        = statsByFlavorProfile.OrderByDescending(item => item.Count).Select(item => new { name = item.Key, y = item.Count }).ToList();

                            var medianAbvByDayOfWeek = statsByDayOfWeek.OrderBy(item => item.Key).Select(item => new { name = item.Key.ToString(), y = Math.Round(item.Median, 2) }).ToList();
                            var countByDayOfWeek     = statsByDayOfWeek.OrderBy(item => item.Key).Select(item => new { name = item.Key.ToString(), y = item.Count }).ToList();

                            Document.GetElementById("additionalStats").AppendChild(new HTMLParagraphElement()
                            {
                                ClassName = "text-center",
                                InnerHTML = $"<b>{nameof(medianRating)}: {medianRating}, {nameof(medianAbv)}: {medianAbv}, {nameof(medianIbu)}: {medianIbu}</b>",
                            });

                            Script.Call("renderRatingAndCountColumnChart", nameof(medianRatingByCountry), nameof(countByCountry), medianRatingByCountry.ToArray(), countByCountry.ToArray());
                            Script.Call("renderAsPieChart", nameof(countByCountry), countByCountry.ToArray());
                            Script.Call("renderRatingAndCountColumnChart", nameof(medianRatingByBrewery), nameof(countByBrewery), medianRatingByBrewery.ToArray(), countByBrewery.ToArray());
                            Script.Call("renderAsPieChart", nameof(countByBrewery), countByBrewery.ToArray());
                            Script.Call("renderRatingAndCountColumnChart", nameof(medianRatingByStyle), nameof(countByStyle), medianRatingByStyle.ToArray(), countByStyle.ToArray());
                            Script.Call("renderAsPieChart", nameof(countByStyle), countByStyle.ToArray());
                            Script.Call("renderAsPieChart", nameof(countByServingType), countByServingType.ToArray());
                            Script.Call("renderRatingAndCountColumnChart", nameof(medianRatingByFlavorProfile), nameof(countByFlavorProfile), medianRatingByFlavorProfile.ToArray(), countByFlavorProfile.ToArray());
                            Script.Call("renderAsPieChart", nameof(countByFlavorProfile), countByFlavorProfile.ToArray());
                            Script.Call("renderValueAndCountColumnChart", nameof(medianAbvByDayOfWeek), nameof(countByDayOfWeek), medianAbvByDayOfWeek.ToArray(), countByDayOfWeek.ToArray());
                        };
                        reader.ReadAsText(input.Files[0]);
                    }
                }
            };

            col.AppendChild(button);
        }