Beispiel #1
0
        internal override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            if (SkipRender(context))
            {
                return;
            }
            var cont = new TagBuilder("tree-view", null, IsInGrid);

            MergeAttributes(cont, context);
            var isBind = GetBinding(nameof(ItemsSource));

            if (isBind != null)
            {
                cont.MergeAttribute(":items", isBind.GetPath(context));
                cont.MergeAttribute(":expand", "$expand");                 // in BaseController
                if (Children.Count != 1)
                {
                    throw new XamlException("Only one TreeViewItem element is allowed for dynamic TreeView");
                }
                var ch = Children[0];
                cont.MergeAttribute(":options", GetOptions(context, ch));
            }
            if (AutoSelect != AutoSelectMode.None)
            {
                cont.MergeAttribute("auto-select", AutoSelect.ToString().ToKebabCase());
            }
            if (ExpandFirstItem)
            {
                cont.MergeAttribute(":expand-first-item", "true");
            }
            cont.RenderStart(context);
            cont.RenderEnd(context);
        }
Beispiel #2
0
        public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            if (SkipRender(context))
            {
                return;
            }
            var cont = new TagBuilder("tree-view", null, IsInGrid);

            MergeAttributes(cont, context);

            if (Height != null)
            {
                cont.MergeStyle("height", Height.Value);
            }
            if (Style != TreeViewStyle.Normal)
            {
                cont.AddCssClass($"tree-view-{Style.ToString().ToKebabCase()}");
            }
            if (Indent != null && Indent.Value == false)
            {
                cont.AddCssClass("no-indent");
            }

            var isBind = GetBinding(nameof(ItemsSource));

            if (isBind != null)
            {
                cont.MergeAttribute(":items", isBind.GetPath(context));
                cont.MergeAttribute(":expand", "$expand");                 // in BaseController
                if (Children.Count != 1)
                {
                    throw new XamlException("Only one TreeViewItem element is allowed for dynamic TreeView");
                }
                var ch = Children[0];
                cont.MergeAttribute(":options", GetOptions(context, ch));
            }
            if (AutoSelect != AutoSelectMode.None)
            {
                cont.MergeAttribute("auto-select", AutoSelect.ToString().ToKebabCase());
            }
            if (ExpandFirstItem)
            {
                cont.MergeAttribute(":expand-first-item", "true");
            }

            var dblClickBind = GetBindingCommand(nameof(DoubleClick));

            if (dblClickBind != null)
            {
                // Function!
                cont.MergeAttribute(":doubleclick", "() => " + dblClickBind.GetCommand(context));
            }

            cont.RenderStart(context);
            cont.RenderEnd(context);
        }
Beispiel #3
0
        internal 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");
            if (Select != null)
            {
                ul.MergeAttribute(":selectable", Select.Value.ToString().ToLowerInvariant());
            }
            ul.AddCssClass(Style.ToString().ToKebabCase());
            //ul.MergeAttribute(":command", "()=> $navigate()");

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

            var mbind = GetBinding(nameof(Mark));

            if (mbind != null)
            {
                ul.MergeAttribute("mark", mbind.GetPath(context));
            }
            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 (AutoSelect != AutoSelectMode.None)
            {
                ul.MergeAttribute("auto-select", AutoSelect.ToString().ToKebabCase());
            }
            ul.RenderStart(context);
            RenderBody(context, isBind != null);
            ul.RenderEnd(context);
        }
Beispiel #4
0
        public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            if (SkipRender(context))
            {
                return;
            }
            var dataGrid = new TagBuilder("data-grid", null, IsInGrid);

            onRender?.Invoke(dataGrid);
            MergeBindingAttributeBool(dataGrid, context, ":compact", nameof(Compact), Compact);
            MergeAttributes(dataGrid, context, MergeAttrMode.Margin | MergeAttrMode.Visibility);
            dataGrid.MergeAttribute("key", Guid.NewGuid().ToString());             // disable vue reusing
            if (Height != null)
            {
                dataGrid.MergeStyle("height", Height.Value);
            }
            if (FixedHeader)
            {
                dataGrid.MergeAttribute(":fixed-header", "true");
            }
            if (HeadersVisibility == HeadersVisibility.None)
            {
                dataGrid.MergeAttribute(":hide-header", "true");
            }
            if (Style != DataGridStyle.Default)
            {
                dataGrid.AddCssClass($"data-grid-{Style.ToString().ToKebabCase()}");
            }

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

            if (RowDetails != null)
            {
                dataGrid.MergeAttribute(":row-details", "true");
                dataGrid.MergeAttribute("row-details-activate", RowDetails.Activate.ToString().ToLowerInvariant());
                var vBind = RowDetails.GetBinding("Visible");
                if (vBind != null)
                {
                    dataGrid.MergeAttribute("row-details-visible", vBind.Path /*!without context!*/);
                }
            }
            var isb = GetBinding(nameof(ItemsSource));

            if (isb != null)
            {
                dataGrid.MergeAttribute(":items-source", isb.GetPath(context));
            }
            MergeBoolAttributeIfExists(dataGrid, context, nameof(Hover), Hover);
            MergeBoolAttributeIfExists(dataGrid, context, nameof(Striped), Striped);
            MergeBoolAttribute(dataGrid, context, nameof(Border), Border);
            MergeBoolAttribute(dataGrid, context, nameof(Sort), Sort);
            dataGrid.MergeAttribute(":route-query", "$query");             // always!
            if (!String.IsNullOrEmpty(EmptyPanelDelegate))
            {
                dataGrid.MergeAttribute(":empty-panel-callback", $"$delegate('{EmptyPanelDelegate}')");
            }


            var dblClickBind = GetBindingCommand(nameof(DoubleClick));

            if (dblClickBind != null)
            {
                // Function!
                dataGrid.MergeAttribute(":doubleclick", "() => " + dblClickBind.GetCommand(context));
            }

            if (MarkerStyle != RowMarkerStyle.None)
            {
                dataGrid.MergeAttribute("mark-style", MarkerStyle.ToString().ToKebabCase());
            }

            var mbind = GetBinding(nameof(Mark));

            if (mbind != null)
            {
                dataGrid.MergeAttribute("mark", mbind.Path);                 // without context!!!
            }
            else if (Mark != MarkStyle.Default)
            {
                throw new XamlException("The Mark property must be a binding");
            }
            var rbbind = GetBinding(nameof(RowBold));

            if (rbbind != null)
            {
                dataGrid.MergeAttribute("row-bold", rbbind.GetPath(context));
            }
            else if (RowBold != null)
            {
                throw new XamlException("The RowBold property must be a binding");
            }

            // TODO: binding for GridLines ???
            if (GridLines != GridLinesVisibility.None)
            {
                dataGrid.MergeAttribute("grid", GridLines.ToString());
            }

            var groupByBind = GetBinding(nameof(GroupBy));

            if (groupByBind != null)
            {
                dataGrid.MergeAttribute(":group-by", groupByBind.GetPath(context));
            }
            else if (_groupBy != null)
            {
                dataGrid.MergeAttribute(":group-by", _groupBy.GetJsValue(context));
            }

            if (AutoSelect != AutoSelectMode.None)
            {
                dataGrid.MergeAttribute("auto-select", AutoSelect.ToString().ToKebabCase());
            }

            dataGrid.RenderStart(context);
            Int32 colIndex = 0;

            foreach (var col in Columns)
            {
                col.RenderColumn(context, colIndex);
                colIndex++;
            }
            RenderRowDetails(context);
            RenderEmptyPanel(context);
            RenderFooter(context);
            dataGrid.RenderEnd(context);
        }
Beispiel #5
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()");

            var dblClickBind = GetBindingCommand(nameof(DoubleClick));

            if (dblClickBind != null)
            {
                // Function!
                ul.MergeAttribute(":doubleclick", "() => " + dblClickBind.GetCommand(context));
            }

            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);
        }