示例#1
0
        public static HTMLSpanElement Label(string c, float X, float Y, float width, float height, bool IsBold = false, bool IsTiny = false, string classr = "", bool ac = true)
        {
            var lbl = new HTMLSpanElement()
            {
                className = classr + BaseClass(!string.IsNullOrWhiteSpace(classr), ac)
            };

            lbl.innerHTML = c.HtmlEscape();
            lbl.SetBounds(X, Y, width, height);
            SetBT(lbl, IsBold, IsTiny);

            return(lbl);
        }
示例#2
0
        public static HTMLSpanElement Label(string Caption, float X, float Y, float width, float height, bool IsBold = false, bool IsTiny = false, string classr = "", string Alignment = "left", string Forecolor = null, bool ac = true)
        {
            var lbl = new HTMLSpanElement()
            {
                className = classr + BaseClass(!string.IsNullOrWhiteSpace(classr), ac)
            };

            lbl.innerHTML = Caption.HtmlEscape();
            lbl.SetBounds(X, Y, width, height);
            if (Alignment != "left")
            {
                lbl.style.textAlign = Alignment;
            }
            SetBT(lbl, IsBold, IsTiny);
            if (Forecolor != null)
            {
                lbl.style.color = Forecolor;
            }

            return(lbl);
        }
示例#3
0
        public override void Render()
        {
            if (!HasRendered)
            {
                HasRendered = true;
                int currentX = 0;
                foreach (var item in Items)
                {
                    var spanItme = item;
                    spanItme.Menu     = this;
                    spanItme.MainItem = true;

                    var width = Math.Max((int)GetTextWidth(item.Caption, Settings.DefaultFont) + 16, 50);

                    var span = new HTMLSpanElement()
                    {
                        className = "control menu-item", innerText = item.Caption
                    };
                    span.onclick = (ev) =>
                    {
                        if (spanItme.Items.Count == 0)
                        {
                            return;
                        }

                        if (spanItme.Visible)
                        {
                            spanItme.CloseMenu();
                        }
                        else
                        {
                            spanItme.ShowMenu();
                        }
                    };
                    span.onmouseenter = (ev) =>
                    {
                        if (Items != null)
                        {
                            bool open = false;
                            for (int i = 0; i < Items.Count; i++)
                            {
                                if (Items[i].Visible)
                                {
                                    open = true;
                                    Items[i].CloseMenu();
                                    break;
                                }
                            }
                            if (open)
                            {
                                spanItme.ShowMenu();
                            }
                        }
                    };
                    span.SetBounds(currentX, 0, width, 24);
                    spanItme.Span = span;
                    this.Content.appendChild(span);

                    currentX += width;
                }
            }
            base.Render();
        }