public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { if (CheckDisabledModel(context)) { return; } var input = new TagBuilder("a2-selector", null, IsInGrid); onRender?.Invoke(input); if (!String.IsNullOrEmpty(Delegate)) { input.MergeAttribute(":fetch", $"$delegate('{Delegate}')"); } if (!String.IsNullOrEmpty(Fetch)) { input.MergeAttribute("fetch-command", Fetch); } if (!String.IsNullOrEmpty(SetDelegate)) { input.MergeAttribute(":hitfunc", $"$delegate('{SetDelegate}')"); } input.MergeAttribute("display", DisplayProperty); if (PanelPlacement != DropDownPlacement.BottomLeft) { input.MergeAttribute("placement", PanelPlacement.ToString().ToKebabCase()); } if (Style != SelectorStyle.Default) { input.MergeAttribute("mode", Style.ToString().ToKebabCase()); } SetSize(input, nameof(Selector)); if (ListSize != null) { if (!ListSize.Width.IsEmpty) { input.MergeAttribute("list-width", ListSize.Width.ToString()); } if (!ListSize.Height.IsEmpty) { input.MergeAttribute("list-height", ListSize.Height.ToString()); } } if (ShowCaret.HasValue && ShowCaret.Value) { input.MergeAttribute(":caret", "true"); } if (ShowClear) { input.MergeAttribute(":has-clear", "true"); } var isBind = GetBinding(nameof(ItemsSource)); if (isBind != null) { input.MergeAttribute(":items-source", isBind.GetPath(context)); } MergeAttributes(input, context); MergeDisabled(input, context); MergeAlign(input, context, Align); MergeBindingAttributeString(input, context, "placeholder", nameof(Placeholder), Placeholder); MergeValue(input, context); MergeCustomValueItemProp(input, context, nameof(TextValue), "text"); MergeCreateNew(input, context); input.RenderStart(context); RenderAddOns(context); //RenderNewPane(context); RenderPaneTemplate(context); input.RenderEnd(context); }
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); } }
public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { if (CheckDisabledModel(context)) { return; } var input = new TagBuilder(TagName, null, IsInGrid); onRender?.Invoke(input); MergeAttributes(input, context); MergeDisabled(input, context); SetSize(input, nameof(TextBox)); if (Multiline) { MergeAttributeInt32(input, context, "rows", nameof(Rows), Rows); } if (Password) { input.MergeAttribute(":password", "true"); } if (Number) { input.MergeAttribute(":number", "true"); } if (AutoSize) { input.MergeAttribute(":auto-size", "true"); } if (UpdateTrigger != UpdateTrigger.Default) { input.MergeAttribute("update-trigger", UpdateTrigger.ToString().ToLowerInvariant()); } if (SpellCheck != null) { input.MergeAttribute(":spell-check", SpellCheck.Value.ToString().ToLowerInvariant()); } if (MaxHeight != null) { input.MergeAttribute("max-height", MaxHeight.Value); } if (Accel != null) { input.MergeAttribute("accel", Accel.GetKeyCode()); } var enterCmd = GetBindingCommand(nameof(EnterCommand)); if (enterCmd != null) { input.MergeAttribute(":enter-command", $"() => {enterCmd.GetCommand(context)}"); // FUNCTION!!! } if (ShowClear) { input.MergeAttribute(":has-clear", "true"); } if (ShowFilter) { input.MergeAttribute(":has-filter", "true"); } MergeAlign(input, context, Align); MergeBindingAttributeString(input, context, "placeholder", nameof(Placeholder), Placeholder); MergeValue(input, context); input.RenderStart(context); RenderAddOns(context); input.RenderEnd(context); }
public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { if (SkipRender(context)) { return; } TagBuilder page = null; Boolean isGridPage = (Toolbar != null) || (Taskpad != null) || (Pager != null); // render page OR colleciton view void addGridAction(TagBuilder tag) { if (!isGridPage) { return; } tag.AddCssClass("page-grid"); if (Taskpad != null) { if (Taskpad is Taskpad tp && tp.Width != null) { tag.MergeStyle("grid-template-columns", $"1fr {tp.Width.Value}"); } } } if (CollectionView != null) { CollectionView.RenderStart(context, (tag) => { tag.AddCssClass("page").AddCssClass("absolute"); addGridAction(tag); AddAttributes(tag); tag.MergeAttribute("id", context.RootId); }); } else { page = new TagBuilder("div", "page absolute"); page.MergeAttribute("id", context.RootId); addGridAction(page); AddAttributes(page); if (!isGridPage) { MergeAttributes(page, context, MergeAttrMode.Margin); } if (PrintPage != null) { page.AddCssClass("print-target"); page.AddCssClass(PrintPage.Orientation.ToString().ToLowerInvariant()); page.MergeAttribute("v-print-page", PrintPage.ToJson()); } page.RenderStart(context); } RenderTitle(context); if (isGridPage) { Toolbar?.RenderElement(context, (tag) => tag.AddCssClass("page-toolbar")); Taskpad?.RenderElement(context, (tag) => tag.AddCssClass("page-taskpad")); Pager?.RenderElement(context, (tag) => tag.AddCssClass("page-pager")); var content = new TagBuilder("div", "page-content"); if (ChildHasWrapper) { content.AddCssClass("with-wrapper"); } MergeAttributes(content, context, MergeAttrMode.Margin); content.RenderStart(context); RenderChildren(context); content.RenderEnd(context); } else { RenderChildren(context); } var outer = new TagBuilder("div", "page-canvas-outer").RenderStart(context); new TagBuilder("div", "page-canvas").MergeAttribute("id", "page-canvas").Render(context); outer.RenderEnd(context); if (CollectionView != null) { CollectionView.RenderEnd(context); } else { if (page == null) { throw new InvalidProgramException(); } page.RenderEnd(context); } }
void RenderBody(RenderContext context) { if (HasHeader) { var hTag = new TagBuilder("div", "list-item-header"); var bHead = GetBinding(nameof(Header)); if (bHead != null) { hTag.MergeAttribute("v-text", bHead.GetPathFormat(context)); } hTag.RenderStart(context); if (Header != null) { if (Header is UIElementBase) { (Header as UIElementBase).RenderElement(context); } else { context.Writer.Write(context.Localize(Header.ToString())); } } hTag.RenderEnd(context); } if (HasBody) { var hBody = new TagBuilder("div", "list-item-body"); var bBody = GetBinding(nameof(Content)); if (bBody != null) { hBody.MergeAttribute("v-text", bBody.GetPathFormat(context)); } hBody.RenderStart(context); if (Content is UIElementBase) { (Content as UIElementBase).RenderElement(context); } else if (Content != null) { context.Writer.Write(context.Localize(Content.ToString())); } hBody.RenderEnd(context); } if (HasFooter) { var fTag = new TagBuilder("div", "list-item-footer"); var bFoot = GetBinding(nameof(Footer)); if (bFoot != null) { fTag.MergeAttribute("v-text", bFoot.GetPathFormat(context)); } fTag.RenderStart(context); if (Footer != null) { if (Footer is UIElementBase) { (Footer as UIElementBase).RenderElement(context); } else { context.Writer.Write(context.Localize(Footer.ToString())); } } fTag.RenderEnd(context); } }
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); } 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())); } if (bHasDropDown && !addOn && !HideCaret) { var bDropUp = (DropDown as DropDownMenu)?.IsDropUp; new TagBuilder("span", "caret") .AddCssClassBool(bDropUp, "up") .Render(context); } tag.RenderEnd(context); }
internal void MergeCommandAttributes(TagBuilder tag, RenderContext context) { switch (Command) { case CommandType.Open: case CommandType.Report: if (CheckArgument) { var arg = GetBinding(nameof(Argument)); if (arg != null) { tag.MergeAttribute(":disabled", $"!({arg.GetPath(context)})", replaceExisting: true); } } else if (CheckReadOnly) { tag.MergeAttribute(":disabled", $"$isReadOnly({GetOptions(context)})", replaceExisting: true); } break; case CommandType.Create: if (CheckReadOnly) { tag.MergeAttribute(":disabled", $"$isReadOnly({GetOptions(context)})", replaceExisting: true); } break; case CommandType.Save: case CommandType.SaveAndClose: if (context.IsDataModelIsReadOnly) { tag.MergeAttribute(":disabled", "true", replaceExisting: true); } else { tag.MergeAttribute(":disabled", "!$canSave", replaceExisting: true); } break; case CommandType.Execute: MergeDisabled(tag, $"!$canExecute('{CommandName}', {CommandArgument(context, true)}, {GetOptions(context)})"); break; case CommandType.Append: case CommandType.Prepend: case CommandType.Remove: if (context.IsDataModelIsReadOnly) { tag.MergeAttribute(":disabled", "true", replaceExisting: true); } break; case CommandType.SelectChecked: { var arg = GetBinding(nameof(Argument)); if (arg != null) { tag.MergeAttribute(":disabled", $"!$hasChecked({arg.GetPath(context)})", replaceExisting: true); } } break; case CommandType.OpenSelected: case CommandType.OpenSelectedFrame: case CommandType.Select: case CommandType.ExecuteSelected: case CommandType.DbRemoveSelected: { var arg = GetBinding(nameof(Argument)); if (arg != null) { tag.MergeAttribute(":disabled", $"!$hasSelected({arg.GetPath(context)}, {GetOptionsValid(context)})", replaceExisting: true); } } break; case CommandType.RemoveSelected: if (context.IsDataModelIsReadOnly) { tag.MergeAttribute(":disabled", "true", replaceExisting: true); } else { var arg = GetBinding(nameof(Argument)); if (arg != null) { tag.MergeAttribute(":disabled", $"!$hasSelected({arg.GetPath(context)})", replaceExisting: true); } } break; case CommandType.Dialog: if (Action == DialogAction.EditSelected || Action == DialogAction.ShowSelected) { var arg = GetBinding(nameof(Argument)); if (arg != null) { tag.MergeAttribute(":disabled", $"!$hasSelected({arg.GetPath(context)})", replaceExisting: true); } } else if (CheckArgument) { var arg = GetBinding(nameof(Argument)); if (arg != null) { tag.MergeAttribute(":disabled", $"!({arg.GetPath(context)})", replaceExisting: true); } } break; case CommandType.Clear: { var arg = GetBinding(nameof(Argument)); if (arg != null) { tag.MergeAttribute("v-if", $"!({arg.GetPath(context)}.$isEmpty)", replaceExisting: true); } } break; } }
internal 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 (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)); } MergeBoolAttribute(dataGrid, context, nameof(Hover), Hover); MergeBoolAttribute(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)); } dataGrid.RenderStart(context); Int32 colIndex = 0; foreach (var col in Columns) { col.RenderColumn(context, colIndex); colIndex++; } RenderRowDetails(context); RenderEmptyPanel(context); dataGrid.RenderEnd(context); }
internal void RenderStart(RenderContext context, Action <TagBuilder> onRender = null) { if (context.IsDialog && RunAt == RunMode.ServerUrl) { throw new XamlException("RunAt='ServerUrl' is not allowed in dialogs"); } String cwTag = "collection-view"; if (RunAt == RunMode.Server) { cwTag = "collection-view-server"; } else if (RunAt == RunMode.ServerUrl) { cwTag = "collection-view-server-url"; } _outer = new TagBuilder(cwTag, "cw", IsInGrid); onRender?.Invoke(_outer); if (Parent is Page) { _outer.AddCssClass("cw-absolute"); } MergeAttributes(_outer, context); Bind itemsSource = GetBinding(nameof(ItemsSource)); if (itemsSource != null) { _outer.MergeAttribute(":items-source", itemsSource.GetPath(context)); } if (Sort != null) { _outer.MergeAttribute(":initial-sort", Sort.GetJsValue(context)); } if (Filter != null) { _outer.MergeAttribute(":initial-filter", Filter.GetJsValue(context)); _outer.MergeAttribute(":persistent-filter", Filter.GetPersistentValue(context)); if (RunAt == RunMode.Client) { if (String.IsNullOrEmpty(FilterDelegate)) { throw new XamlException("To filter on the client, a FilterDelegate is required"); } _outer.MergeAttribute(":filter-delegate", $"$delegate('{FilterDelegate}')"); } } if (GroupBy != null) { _outer.MergeAttribute(":initial-group", GroupBy.GetJsValue(context)); } if (PageSize != null) { _outer.MergeAttribute(":initial-page-size", PageSize.Value.ToString()); } _outer.RenderStart(context); _inner = new TagBuilder("template"); _inner.MergeAttribute("slot-scope", "Parent"); _inner.RenderStart(context); }
public 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); /* * 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); }
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); }
public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { if (CheckDisabledModel(context)) { return; } var combo = new TagBuilder("select", null, IsInGrid); onRender?.Invoke(combo); combo.MergeAttribute("is", "combobox"); combo.MergeAttribute("v-cloak", String.Empty); combo.MergeAttribute("display", DisplayProperty); if (Style != ComboBoxStyle.Default) { combo.AddCssClass($"combo-{Style.ToString().ToLowerInvariant()}"); } MergeAttributes(combo, context); MergeAlign(combo, context, Align); MergeBoolAttribute(combo, context, nameof(ShowValue), ShowValue); SetSize(combo, nameof(ComboBox)); MergeDisabled(combo, context); var isBind = GetBinding(nameof(ItemsSource)); if (isBind != null) { combo.MergeAttribute(":items-source", isBind.GetPath(context)); if (_children != null) { if (Children.Count != 1) { throw new XamlException("The ComboBox with the specified ItemsSource must have only one ComboBoxItem element"); } var elem = Children[0]; var contBind = elem.GetBinding("Content"); if (contBind == null) { throw new XamlException("ComboBoxItem. Content binging must be specified"); } combo.MergeAttribute(":name-prop", $"'{contBind.Path}'"); /*without context!*/ var valBind = elem.GetBinding("Value"); if (valBind == null) { throw new XamlException("ComboBoxItem. Value binging must be specified"); } combo.MergeAttribute(":value-prop", $"'{valBind.Path}'"); /*without context!*/ } } MergeValue(combo, context); combo.RenderStart(context); if (_children != null && isBind == null) { foreach (var ch in Children) { ch.RenderElement(context); } } RenderPopover(context); RenderHint(context); RenderLink(context); combo.RenderEnd(context); }
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); } 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 grid = new TagBuilder("div", "dialog-grid"); if (Taskpad is Taskpad tp && tp.Width != null) { grid.MergeStyle("grid-template-columns", $"1fr {tp.Width.Value}"); } grid.RenderStart(context); var gridContent = new TagBuilder("div", "dialog-grid-content"); gridContent.RenderStart(context); RenderChildren(context); gridContent.RenderEnd(context); Taskpad.RenderElement(context); grid.RenderEnd(context); } else { RenderChildren(context); } content.RenderEnd(context); RenderFooter(context); RenderAccelCommands(context); dialog.RenderEnd(context); }
internal void MergeAttributes(TagBuilder tag) { tag.MergeAttribute(":validator-options", ToJsObject()); }
public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null) { /* TODO: * 1. Horizontal splitter */ if (SkipRender(context)) { return; } var spl = new TagBuilder("div", "splitter"); onRender?.Invoke(spl); spl.MergeAttribute("key", Guid.NewGuid().ToString()); // disable vue reusing MergeAttributes(spl, context); if (Height != null) { spl.MergeStyle("height", Height.Value); } if (MinWidth != null) { spl.MergeStyle("min-width", MinWidth.Value); } spl.AddCssClass(Orientation.ToString().ToLowerInvariant()); // width GridLength p1w = GetWidth(Children[0]) ?? GridLength.Fr1(); GridLength p2w = GetWidth(Children[1]) ?? GridLength.Fr1(); String rowsCols = Orientation == Orientation.Vertical ? "grid-template-columns" : "grid-template-rows"; spl.MergeStyle(rowsCols, $"{p1w} 5px {p2w}"); spl.RenderStart(context); // first part var p1 = new TagBuilder("div", "spl-part spl-first"); p1.RenderStart(context); Children[0].RenderElement(context); p1.RenderEnd(context); new TagBuilder("div", "spl-handle") .MergeAttribute(Orientation == Orientation.Vertical ? "v-resize" : "h-resize", String.Empty) //.MergeAttribute("key", Guid.NewGuid().ToString()) // disable vue reusing .MergeAttribute("first-pane-width", p1w?.Value.ToString()) .MergeAttribute("data-min-width", GetMinWidth(Children[0])?.Value.ToString()) .MergeAttribute("second-min-width", GetMinWidth(Children[1])?.Value.ToString()) .Render(context); // second part var p2 = new TagBuilder("div", "spl-part spl-second"); p2.RenderStart(context); Children[1].RenderElement(context); p2.RenderEnd(context); // drag-handle new TagBuilder("div", "drag-handle") .Render(context); spl.RenderEnd(context); }
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); }