public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { if (SkipRender(context)) { return; } var section = new TagBuilder("a2-sheet-section-tree"); var isBind = GetBinding(nameof(ItemsSource)); if (isBind != null) { String path = isBind.GetPath(context); var(Path, Prop) = SplitToPathProp(path); section.MergeAttribute(":items-source", Path); section.MergeAttribute("prop-name", Prop); } section.RenderStart(context); var tml = new TagBuilder("template"); tml.MergeAttribute("slot-scope", "row"); tml.RenderStart(context); using (var scope = new ScopeContext(context, "row.item")) { foreach (var r in Children) { r.RenderElement(context, (tr) => tr.MergeAttribute(":class", "row.rowCssClass()")); } } tml.RenderEnd(context); section.RenderEnd(context); }
void RenderPaneTemplate(RenderContext context) { if (ItemsPanel == null) { return; } if (!(ItemsPanel is DataGrid)) { throw new XamlException("Only DataGrid panel is supported"); } var dg = ItemsPanel as DataGrid; var tml = new TagBuilder("template"); tml.MergeAttribute("slot", "pane"); tml.MergeAttribute("slot-scope", "root"); tml.RenderStart(context); using (var ctx = new ScopeContext(context, "itm", null)) { ItemsPanel.RenderElement(context, (tag) => { tag.MergeAttribute(":is-item-active", "root.isItemActive"); tag.MergeAttribute(":hit-item", "root.hit"); tag.MergeAttribute(":items-source", "root.items"); if (ListSize != null && !ListSize.Height.IsEmpty && dg.FixedHeader) { // for fixed headers only tag.MergeStyle("height", ListSize.Height.ToString()); tag.MergeStyle("max-height", ListSize.Height.ToString()); } }); } tml.RenderEnd(context); }
public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { if (SkipRender(context)) { return; } var td = new TagBuilder("td"); onRender?.Invoke(td); Bind isBind = GetBinding(nameof(ItemsSource)); if (isBind != null) { td.MergeAttribute("v-for", $"(cell, cellIndex) in {isBind.GetPath(context)}"); td.MergeAttribute(":key", "cellIndex"); using (var scope = new ScopeContext(context, "cell")) { RenderCell(td, context); } } else { RenderCell(td, context); } }
internal override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { if (SkipRender(context)) { return; } var scopeBind = GetBinding(nameof(Scope)); if (scopeBind == null) { throw new XamlException("Scope must be specified for Slot component"); } var tag = new TagBuilder("template", null, IsInGrid); tag.MergeAttribute("v-if", $"!!{scopeBind.GetPathFormat(context)}"); tag.MergeAttribute("v-for", $"{SLOT_ITEM} in [{scopeBind.GetPath(context)}]"); tag.RenderStart(context); using (var ctx = new ScopeContext(context, SLOT_ITEM)) { foreach (var c in Children) { c.RenderElement(context); } } tag.RenderEnd(context); if (Fallback != null) { var fb = new TagBuilder("template"); fb.MergeAttribute("v-if", $"!{scopeBind.GetPathFormat(context)}"); fb.RenderStart(context); Fallback.RenderElement(context); fb.RenderEnd(context); } }
public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { if (SkipRender(context)) { return; } var panel = new TagBuilder("a2-tab-panel", null, IsInGrid); onRender?.Invoke(panel); MergeAttributes(panel, context); panel.AddCssClassBool(Border, "bordered"); panel.AddCssClassBool(FullPage, "full-page"); panel.AddCssClassBool(Overflow, "overflow"); panel.AddCssClass($"tab-pos-{TabPosition.ToString().ToLowerInvariant()}"); if (MinHeight != null) { panel.MergeStyleUnit("min-height", MinHeight.Value); } if (Width != null) { panel.MergeStyle("width", Width.Value); } var isBind = GetBinding(nameof(ItemsSource)); if (isBind != null) { panel.MergeAttribute(":items", isBind.GetPath(context)); if (Tabs.Count != 1) { throw new XamlException("If ItemsSource is specified, then only one Tab allowed in the collection"); } panel.RenderStart(context); var tml = new TagBuilder("template"); tml.MergeAttribute("slot", "items"); tml.MergeAttribute("slot-scope", "tabitem"); tml.RenderStart(context); using (var cts = new ScopeContext(context, "tabitem.item", isBind.Path, _replaceScope)) { Tabs[0].RenderTemplate(context); } tml.RenderEnd(context); RenderHeaderTemplate(context); RenderHeader(context); panel.RenderEnd(context); } else { panel.RenderStart(context); RenderTabs(context); RenderHeader(context); panel.RenderEnd(context); } }
void RenderBody(RenderContext context) { if (Rows.Count == 0) { return; } var tbody = new TagBuilder("tbody").RenderStart(context); Bind isBind = GetBinding(nameof(ItemsSource)); if (isBind != null) { var repeatAttr = $"(row, rowIndex) in {isBind.GetPath(context)}"; using (new ScopeContext(context, "row")) { if (Rows.Count == 1) { Rows[0].RenderElement(context, (tag) => { tag.MergeAttribute("v-for", repeatAttr); }); } else { var tml = new TagBuilder("template"); tml.MergeAttribute("v-for", repeatAttr); tml.RenderStart(context); using (var cts = new ScopeContext(context, "row")) { var rNo = 0; foreach (var row in Rows) { row.RenderElement(context, (tag) => tag.MergeAttribute(":key", $"'r{rNo}:' + rowIndex")); rNo += 1; } } tml.RenderEnd(context); } } } else { foreach (var row in Rows) { row.RenderElement(context); } } tbody.RenderEnd(context); }
void RenderHeaderTemplate(RenderContext context) { if (!(Tabs[0].Header is UIElementBase tabHeader)) { return; } var tml = new TagBuilder("template"); tml.MergeAttribute("slot", "header"); tml.MergeAttribute("slot-scope", "tabitem"); tml.RenderStart(context); using (var cts = new ScopeContext(context, "tabitem.item", _replaceScope)) { tabHeader.RenderElement(context); } tml.RenderEnd(context); }
void RenderNewPane(RenderContext context) { if (NewPane == null) { return; } var npTag = new TagBuilder("template"); npTag.MergeAttribute("slot", "new-pane"); npTag.MergeAttribute("slot-scope", "newNane"); npTag.RenderStart(context); using (var ctx = new ScopeContext(context, "newPane.elem", null)) { NewPane.RenderElement(context); } npTag.RenderEnd(context); }
void RenderRowDetails(RenderContext context) { if (RowDetails == null) { return; } var rdtag = new TagBuilder("template"); rdtag.MergeAttribute("slot", "row-details"); rdtag.MergeAttribute("slot-scope", "details"); rdtag.RenderStart(context); using (var ctx = new ScopeContext(context, "details.row", null)) { RowDetails.Content.RenderElement(context); } rdtag.RenderEnd(context); }
internal override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { if (SkipRender(context)) { return; } var panel = new TagBuilder("a2-tab-panel", null, IsInGrid); onRender?.Invoke(panel); MergeAttributes(panel, context); panel.AddCssClassBool(Border, "bordered"); panel.AddCssClassBool(FullPage, "full-page"); var isBind = GetBinding(nameof(ItemsSource)); if (isBind != null) { panel.MergeAttribute(":items", isBind.GetPath(context)); if (Tabs.Count != 1) { throw new XamlException("If ItemsSource is specified, then only one Tab allowed in the collection"); } panel.RenderStart(context); var tml = new TagBuilder("template"); tml.MergeAttribute("slot", "items"); tml.MergeAttribute("slot-scope", "tabitem"); tml.RenderStart(context); using (var cts = new ScopeContext(context, "tabitem.item", _replaceScope)) { Tabs[0].RenderTemplate(context); } tml.RenderEnd(context); RenderHeaderTemplate(context); RenderHeader(context); panel.RenderEnd(context); } else { panel.RenderStart(context); RenderTabs(context); RenderHeader(context); panel.RenderEnd(context); } }
public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { if (SkipRender(context)) { return; } var sect = new TagBuilder("a2-sheet-section"); MergeAttributes(sect, context); sect.RenderStart(context); var tml = new TagBuilder("template"); var isBind = GetBinding(nameof(ItemsSource)); if (isBind != null) { tml.MergeAttribute("v-for", $"(item, itemIndex) of {isBind.GetPath(context)}"); tml.RenderStart(context); using (var scope = new ScopeContext(context, "item", isBind.Path)) { foreach (var r in Children) { r.RenderElement(context); } } tml.RenderEnd(context); } else { tml.RenderStart(context); foreach (var r in Children) { r.RenderElement(context); } tml.RenderEnd(context); } sect.RenderEnd(context); }
internal void RenderColumn(RenderContext context, Int32 colIndex) { CheckValid(); var column = new TagBuilder("data-grid-column"); SetColumnRole(column); MergeBindingAttribute(context, column, "header", nameof(Header), Header); MergeBindingAttributeBool(column, context, "v-if", nameof(If), If); MergeBoolAttribute(column, context, nameof(Editable), Editable); if (_noPadding) { column.MergeAttribute(":no-padding", "true"); } if (Sort != null) { column.MergeAttribute(":sort", Sort.Value.ToString().ToLowerInvariant()); } if (SortProperty != null) { column.MergeAttribute("sort-prop", SortProperty); } if (Small != null) { column.MergeAttribute(":small", Small.Value.ToString().ToLowerInvariant()); } var boldBind = GetBinding(nameof(Bold)); if (boldBind != null) { column.MergeAttribute("bold", $"{{{boldBind.GetPath(context)}}}"); } else if (Bold != null) { column.MergeAttribute("bold", Bold.Value.ToString().ToLowerInvariant()); } MergeBoolAttribute(column, context, nameof(Fit), Fit); if (Width != null) { column.MergeAttribute("width", Width.Value); } var iconBind = GetBinding(nameof(Icon)); if (iconBind != null) { column.MergeAttribute("bind-icon", iconBind.Path /*without context*/); } else if (Icon != Icon.NoIcon) { column.MergeAttribute("icon", Icon.ToString().ToKebabCase()); } if (Wrap != WrapMode.Default) { column.MergeAttribute("wrap", Wrap.ToString().ToKebabCase(), true); } var markBind = GetBinding(nameof(Mark)); if (markBind != null) { column.MergeAttribute("mark", markBind.Path /*!without context!*/); } else if (Mark != null) { throw new XamlException("The Mark property must be a binding"); } CreateEditable(); Boolean isTemplate = Content is UIElementBase; String tmlId = null; if (!isTemplate) { // always content without a SEMICOLON! var bindProp = GetBinding(nameof(Content)); if (bindProp != null) { column.MergeAttribute("content", bindProp.Path /*!without context!*/); if (bindProp.DataType != DataType.String) { column.MergeAttribute("data-type", bindProp.DataType.ToString()); } if (bindProp.HideZeros) { column.MergeAttribute(":hide-zeros", "true"); } if (!String.IsNullOrEmpty(bindProp.Format)) { column.MergeAttribute("format", bindProp.Format); } } else if (Content != null) { throw new XamlException($"The Content property must be a binding ({Content})"); } } Bind ctBind = GetBinding(nameof(ControlType)); if (ctBind != null) { column.MergeAttribute(":control-type", ctBind.Path /*!without context!*/); } else if (ControlType != ColumnControlType.Default) { column.MergeAttribute("control-type", ControlType.ToString().ToLowerInvariant()); } var alignProp = GetBinding(nameof(Align)); if (alignProp != null) { column.MergeAttribute(":align", alignProp.Path /*!without context!*/, true); } else if (Align != TextAlign.Default) { column.MergeAttribute("align", Align.ToString().ToLowerInvariant(), true); } if (isTemplate) { tmlId = $"col{colIndex}"; column.MergeAttribute("id", tmlId); } var cmdBind = GetBindingCommand(nameof(Command)); if (cmdBind != null) { column.MergeAttribute(":command", cmdBind.GetCommand(context, indirect: true)); } column.RenderStart(context); column.RenderEnd(context); if (isTemplate) { var templ = new TagBuilder("template"); templ.MergeAttribute("slot", tmlId); templ.MergeAttribute("slot-scope", "cell"); templ.RenderStart(context); using (var ctx = new ScopeContext(context, "cell.row", null)) { (Content as UIElementBase).RenderElement(context); } templ.RenderEnd(context); } }