Пример #1
0
        void RenderButton(RenderContext context, Boolean hasDropDown, Boolean bDropUp, Action <TagBuilder> onRender)
        {
            var     parentCB   = IsParentCommandBar;
            var     parentTB   = IsParentToolBar;
            Boolean hasCommand = GetBindingCommand(nameof(Command)) != null;
            Boolean insideBar  = IsParentToolBar || IsParentCommandBar;
            var     button     = new TagBuilder("button", "btn", IsInGrid);

            onRender?.Invoke(button);
            if (!Block && !insideBar && !IsInGrid)
            {
                button.AddCssClass("a2-inline");
            }
            if (Parent is Toolbar && Style == ButtonStyle.Default)
            {
                button.AddCssClass("btn-tb");
            }
            else if (IsParentCommandBar)
            {
                button.AddCssClass("btn-cb");
            }
            AddSize(button);
            if (IconAlign == IconAlign.Top)
            {
                button.AddCssClass("icon-top");
            }

            var styleBind = GetBinding(nameof(Style));

            if (styleBind != null)
            {
                button.MergeAttribute(":class", $"'btn-' + {styleBind.GetPathFormat(context)}");
            }
            else if (Style != ButtonStyle.Default)
            {
                button.AddCssClass($"btn-{Style.ToString().ToLowerInvariant()}");
            }
            button.AddCssClassBool(Rounded, "btn-rounded");
            if (hasDropDown && !hasCommand)
            {
                button.MergeAttribute("toggle", String.Empty);
            }
            MergeAttributes(button, context, MergeAttrMode.NoTabIndex & ~MergeAttrMode.Content);             // dinamic

            if (TabIndex != 0)
            {
                button.MergeAttribute("tabindex", TabIndex.ToString());
            }
            if (!HasContent && (Icon != Icon.NoIcon))
            {
                button.AddCssClass("btn-icon");
            }
            MergeDisabled(button, context, nativeControl: true);
            button.MergeAttribute("v-settabindex", String.Empty);
            button.RenderStart(context);
            RenderIcon(context, Icon);

            var contBind = GetBinding(nameof(Content));

            if (contBind != null)
            {
                var cont = new TagBuilder("span");
                cont.MergeAttribute("v-text", contBind.GetPathFormat(context));
                cont.Render(context);
            }

            RenderContent(context);

            if (hasDropDown)
            {
                if (!hasCommand)
                {
                    RenderCaret(context, bDropUp);
                }
            }
            button.RenderEnd(context);
            if (hasDropDown && hasCommand)
            {
                var open = new TagBuilder("button", "btn btn-caret")
                           .MergeAttribute("toggle", String.Empty);
                if (Style != ButtonStyle.Default)
                {
                    open.AddCssClass($"btn-{Style.ToString().ToLowerInvariant()}");
                }
                MergeVisibilityAttribures(open, context);                 // Visible only
                AddSize(open);
                open.RenderStart(context);
                RenderCaret(context, bDropUp);
                open.RenderEnd(context);
            }
        }
Пример #2
0
        public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            var dialog = new TagBuilder("div", "modal");

            dialog.MergeAttribute("id", context.RootId);
            dialog.MergeAttribute("v-cloak", String.Empty);
            dialog.AddCssClassBoolNo(UserSelect, "user-select");
            dialog.MergeAttribute("data-controller-attr", GetControllerAttributes());
            dialog.AddCssClassBool(Maximize, "maximize");
            dialog.AddCssClassBool(ButtonOnTop, "button-on-top");

            if (!String.IsNullOrEmpty(TestId) && context.IsDebugConfiguration)
            {
                dialog.MergeAttribute("test-id", TestId);
            }


            if (Maximize)
            {
                dialog.MergeAttribute("v-maximize", "true");
            }
            else
            {
                SetSize(dialog);
            }

            dialog.RenderStart(context);

            if (ShowWaitCursor)
            {
                new TagBuilder("wait-cursor", "dialog")
                .MergeAttribute(":ready", "$data.$ready")
                .Render(context, TagRenderMode.Normal);
            }

            if (CollectionView != null)
            {
                CollectionView.RenderStart(context, tag =>
                {
                    tag.AddCssClass("cw-dialog");
                });
            }

            RenderHeader(context);
            RenderLoadIndicator(context);

            var content = new TagBuilder("div", "modal-content");

            OnCreateContent(content);
            if (Height != null)
            {
                content.MergeStyle("min-height", Height.Value);
            }
            if (Padding != null)
            {
                Padding.MergeStyles("padding", content);
            }
            content.AddCssClassBool(IsContentIsIFrame, "content-iframe");             // bug fix (3px height)
            if (Background != BackgroundStyle.Default)
            {
                content.AddCssClass("background-" + Background.ToString().ToKebabCase());
            }
            content.AddCssClassBool(Overflow, "overflow");
            content.RenderStart(context);
            if (Taskpad != null)
            {
                var gridContent = new TagBuilder("div", "dialog-grid-content");
                var grid        = new TagBuilder("div", "dialog-grid");
                if (Taskpad is Taskpad tp && tp.Width != null)
                {
                    if (tp.Position == TaskpadPosition.Left)
                    {
                        grid.MergeStyle("grid-template-columns", $"{tp.Width.Value} 1fr");
                        gridContent.MergeStyle("grid-column", "2");
                    }
                    else
                    {
                        grid.MergeStyle("grid-template-columns", $"1fr {tp.Width.Value}");
                        gridContent.MergeStyle("grid-column", "1");
                    }
                }
                grid.RenderStart(context);
                gridContent.RenderStart(context);
                RenderChildren(context);
                gridContent.RenderEnd(context);
                Taskpad.RenderElement(context);
                grid.RenderEnd(context);
            }
            else
            {
                RenderChildren(context);
            }

            content.RenderEnd(context);

            RenderFooter(context);

            if (CollectionView != null)
            {
                CollectionView.RenderEnd(context);
            }

            RenderAccelCommands(context);
            RenderContextMenus();

            dialog.RenderEnd(context);
        }
Пример #3
0
        void RenderCell(TagBuilder td, RenderContext context)
        {
            MergeAttributes(td, context);

            var boldBind   = GetBinding(nameof(Bold));
            var italicBind = GetBinding(nameof(Italic));

            if (boldBind != null || italicBind != null)
            {
                var sb = new StringBuilder("{");
                if (boldBind != null)
                {
                    sb.Append($"bold: {boldBind.GetPath(context)}, ");
                }
                if (italicBind != null)
                {
                    sb.Append($"italic: {italicBind.GetPath(context)}, ");
                }
                sb.RemoveTailComma();
                sb.Append("}");
                td.MergeAttribute(":class", sb.ToString());
            }
            td.AddCssClassBoolNo(Bold, "bold");
            td.AddCssClassBoolNo(Italic, "italic");
            td.AddCssClassBool(Gray, "gray");


            if (Align != TextAlign.Left)
            {
                td.AddCssClass("text-" + Align.ToString().ToLowerInvariant());
            }

            if (VAlign != VerticalAlign.Default)
            {
                td.AddCssClass($"valign-{VAlign.ToString().ToLowerInvariant()}");
            }

            if (Content is ITableControl)
            {
                td.AddCssClass("ctrl");
            }

            MergeContent(td, context);

            var colSpanBind = GetBinding(nameof(ColSpan));

            if (colSpanBind != null)
            {
                td.MergeAttribute(":colspan", colSpanBind.GetPath(context));
            }
            else
            {
                MergeAttributeInt32(td, context, nameof(ColSpan), "colspan", ColSpan);
            }
            var rowSpanBind = GetBinding(nameof(RowSpan));

            if (rowSpanBind != null)
            {
                td.MergeAttribute(":rowspan", rowSpanBind.GetPath(context));
            }
            else
            {
                MergeAttributeInt32(td, context, nameof(RowSpan), "rowspan", RowSpan);
            }

            td.RenderStart(context);
            RenderContent(context);

            /*
             * no use, the content in the attribute
             * if (Validate)
             * {
             * var val = new TagBuilder("validator-control");
             * val.MergeAttribute(":item", "row");
             * val.MergeAttribute("prop", "Sum");
             * val.Render(context);
             * }*/
            td.RenderEnd(context);
        }
Пример #4
0
        public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            if (SkipRender(context))
            {
                return;
            }
            var ul = new TagBuilder("a2-list", null, IsInGrid);

            onRender?.Invoke(ul);
            var isBind = GetBinding(nameof(ItemsSource));

            ul.AddCssClassBool(Striped, "striped");
            ul.AddCssClassBool(Border, "border");
            ul.AddCssClassBool(Flush, "flush");
            ul.AddCssClassBool(Compact, "compact");
            ul.MergeAttribute("group-by", GroupBy);
            if (BorderStyle != BorderStyle.None)
            {
                ul.AddCssClass($"border-{BorderStyle.ToString().ToKebabCase()}");
            }
            if (MarkerStyle != RowMarkerStyle.None)
            {
                ul.MergeAttribute("mark-style", MarkerStyle.ToString().ToKebabCase());
            }
            if (Select != null)
            {
                ul.MergeAttribute(":selectable", Select.Value.ToString().ToLowerInvariant());
            }
            ul.AddCssClass(Style.ToString().ToKebabCase());
            //ul.MergeAttribute(":command", "()=> $navigate()");

            if (Background != BackgroundStyle.Default)
            {
                ul.AddCssClass("background-" + Background.ToString().ToKebabCase());
            }

            var mbind = GetBinding(nameof(Mark));

            if (mbind != null)
            {
                ul.MergeAttribute("mark", mbind.Path /*without scope, property name*/);
            }
            else if (Mark != null)
            {
                throw new XamlException("The Mark property must be a binding");
            }

            if (isBind != null)
            {
                ul.MergeAttribute(":items-source", isBind.GetPath(context));
                ul.MergeAttribute("v-lazy", isBind.GetPath(context));
            }
            MergeAttributes(ul, context);
            if (Height != null)
            {
                ul.MergeStyle("height", Height.Value);
            }
            if (MaxHeight != null)
            {
                ul.MergeStyle("max-height", MaxHeight.Value);
            }
            if (AutoSelect != AutoSelectMode.None)
            {
                ul.MergeAttribute("auto-select", AutoSelect.ToString().ToKebabCase());
            }
            ul.RenderStart(context);
            RenderBody(context, isBind != null);
            RenderEmptyPanel(context);
            ul.RenderEnd(context);
        }
Пример #5
0
 internal override void MergeAttributes(TagBuilder tag, RenderContext context, MergeAttrMode mode = MergeAttrMode.All)
 {
     base.MergeAttributes(tag, context, mode);
     tag.AddCssClassBool(Block, "block");
 }
Пример #6
0
        void RenderHyperlink(RenderContext context, Boolean inGrid, Action <TagBuilder> onRender = null, Boolean inside = false)
        {
            Boolean bHasDropDown = DropDown != null;

            var tag = new TagBuilder("a", "a2-hyperlink", inGrid);

            onRender?.Invoke(tag);
            var attrMode = MergeAttrMode.All;

            if (inside)
            {
                attrMode &= ~MergeAttrMode.Visibility;
            }
            MergeAttributes(tag, context, attrMode);
            MergeCommandAttribute(tag, context);
            tag.AddCssClassBool(Block, "block");
            if (!Block)
            {
                tag.AddCssClass("a2-inline");
            }

            if (Size != ControlSize.Default)
            {
                switch (Size)
                {
                case ControlSize.Small:
                    tag.AddCssClass("small");
                    break;

                default:
                    throw new XamlException("Only ControlSize.Small is supported for the Hyperlink");
                }
            }

            if (bHasDropDown)
            {
                tag.MergeAttribute("toggle", String.Empty);
            }

            tag.RenderStart(context);

            RenderIcon(context, Icon);
            var cbind = GetBinding(nameof(Content));

            if (cbind != null)
            {
                new TagBuilder("span")
                .MergeAttribute("v-text", cbind.GetPathFormat(context))
                .Render(context);
            }
            else if (Content is UIElementBase)
            {
                (Content as UIElementBase).RenderElement(context);
            }
            else if (Content != null)
            {
                context.Writer.Write(context.Localize(Content.ToString()));
            }


            tag.RenderEnd(context);
        }
Пример #7
0
        void RenderHyperlink(RenderContext context, Boolean inGrid, Action <TagBuilder> onRender = null, Boolean inside = false, Boolean addOn = false)
        {
            Boolean bHasDropDown = DropDown != null;

            var tag = new TagBuilder("a", "a2-hyperlink", inGrid);

            onRender?.Invoke(tag);
            var attrMode = MergeAttrMode.All;

            if (inside)
            {
                attrMode &= ~MergeAttrMode.Visibility;
            }
            MergeAttributes(tag, context, attrMode);
            MergeCommandAttribute(tag, context);
            tag.AddCssClassBool(Block, "block");
            tag.AddCssClassBool(Highlight, "highlight");
            if (!Block)
            {
                tag.AddCssClass("a2-inline");
            }

            if (Size != ControlSize.Default)
            {
                switch (Size)
                {
                case ControlSize.Small:
                    tag.AddCssClass("small");
                    break;

                case ControlSize.Large:
                    tag.AddCssClass("large");
                    break;

                case ControlSize.Normal:
                    tag.AddCssClass("normal");
                    break;

                default:
                    throw new XamlException("Only ControlSize.Small, ControlSize.Normal or ControlSize.Large is supported for the Hyperlink");
                }
            }

            if (bHasDropDown)
            {
                tag.MergeAttribute("toggle", String.Empty);
            }

            if (!String.IsNullOrEmpty(TestId) && context.IsDebugConfiguration)
            {
                tag.MergeAttribute("test-id", TestId);
            }

            tag.RenderStart(context);

            RenderIcon(context, Icon);
            var cbind = GetBinding(nameof(Content));

            if (cbind != null)
            {
                new TagBuilder("span")
                .MergeAttribute("v-text", cbind.GetPathFormat(context))
                .Render(context);
            }
            else if (Content is UIElementBase)
            {
                (Content as UIElementBase).RenderElement(context);
            }
            else if (Content != null)
            {
                context.Writer.Write(context.LocalizeCheckApostrophe(Content.ToString()));
            }

            if (bHasDropDown && !addOn && !HideCaret)
            {
                var bDropUp = (DropDown as DropDownMenu)?.IsDropUp;
                new TagBuilder("span", "caret")
                .AddCssClassBool(bDropUp, "up")
                .Render(context);
            }
            tag.RenderEnd(context);
        }
Пример #8
0
        internal override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            if (SkipRender(context))
            {
                return;
            }
            var td = new TagBuilder("td");

            onRender?.Invoke(td);

            MergeAttributes(td, context);

            var boldBind   = GetBinding(nameof(Bold));
            var italicBind = GetBinding(nameof(Italic));

            if (boldBind != null || italicBind != null)
            {
                var sb = new StringBuilder("{");
                if (boldBind != null)
                {
                    sb.Append($"bold: {boldBind.GetPath(context)}, ");
                }
                if (italicBind != null)
                {
                    sb.Append($"italic: {italicBind.GetPath(context)}, ");
                }
                sb.RemoveTailComma();
                sb.Append("}");
                td.MergeAttribute(":class", sb.ToString());
            }
            td.AddCssClassBoolNo(Bold, "bold");
            td.AddCssClassBoolNo(Italic, "italic");
            td.AddCssClassBool(Gray, "gray");

            MergeContent(td, context);

            if (Align != TextAlign.Left)
            {
                td.AddCssClass("text-" + Align.ToString().ToLowerInvariant());
            }

            if (VAlign != VerticalAlign.Default)
            {
                td.AddCssClass($"valign-{VAlign.ToString().ToLowerInvariant()}");
            }

            if (Content is ITableControl)
            {
                td.AddCssClass("ctrl");
            }

            Bind isBind = GetBinding(nameof(ItemsSource));

            if (isBind != null)
            {
                td.MergeAttribute("v-for", $"(cell, cellIndex) in {isBind.GetPath(context)}");
                td.MergeAttribute(":key", "cellIndex");
            }
            MergeAttributeInt32(td, context, nameof(ColSpan), "colspan", ColSpan);
            var rowSpanBind = GetBinding(nameof(RowSpan));

            if (rowSpanBind != null)
            {
                td.MergeAttribute(":rowspan", rowSpanBind.GetPath(context));
            }
            else
            {
                MergeAttributeInt32(td, context, nameof(RowSpan), "rowspan", RowSpan);
            }
            td.RenderStart(context);
            RenderContent(context);

            /*
             * Никакого толку, содержимое в атрибуте
             * if (Validate)
             * {
             * var val = new TagBuilder("validator-control");
             * val.MergeAttribute(":item", "row");
             * val.MergeAttribute("prop", "Sum");
             * val.Render(context);
             * }*/
            td.RenderEnd(context);
        }