protected virtual IEnumerable <KeyValuePair <string, object> > GetElementAttributes() { var attrs = AdditionalAttributes.MergeAttributes(Theme?.ElementAttributes).AppendClass(ElementClass ?? Theme?.ElementClass); var h = HeaderHeight ?? Theme?.HeaderHeight; if (h != null) { attrs = attrs.PrependStyle("padding-top:" + h); } return(attrs); }
protected override void OnInitialized() { Css = (string)AdditionalAttributes.GetValueOrDefault("class"); var expression = (MemberExpression)For.Body; IsRequired = expression.Member.GetCustomAttribute <RequiredAttribute>() != null ? true : false; var displayNameAttribute = expression.Member.GetCustomAttribute <DisplayAttribute>(); DisplayName = displayNameAttribute != null ? displayNameAttribute.Name : expression.Member.Name; }
protected override void BuildRenderTree(RenderTreeBuilder builder) { if (resolvedType is Type) { builder.OpenComponent(0, resolvedType); if (AdditionalAttributes.Any()) { builder.AddMultipleAttributes(1, AdditionalAttributes); } builder.CloseComponent(); } }
private string GetBaseClassAttributes() { if (AdditionalAttributes != null && AdditionalAttributes.TryGetValue("class", out var clsAttributeObj)) { var classAttributes = Convert.ToString(clsAttributeObj, CultureInfo.InvariantCulture); if (!string.IsNullOrWhiteSpace(classAttributes)) { return($"input-endorsement {classAttributes}"); } } return("input-endorsement"); }
/// <summary> /// OnInitialized 方法 /// </summary> protected override void OnInitialized() { base.OnInitialized(); if (AdditionalAttributes == null) { AdditionalAttributes = new Dictionary <string, object>(); } if (!AdditionalAttributes.TryGetValue("type", out var _)) { AdditionalAttributes["type"] = "button"; } ButtonIcon = Icon; OnClickButton = EventCallback.Factory.Create <MouseEventArgs>(this, async() => { if (IsAsync && ButtonType == ButtonType.Button) { IsAsyncLoading = true; ButtonIcon = LoadingIcon; IsDisabled = true; } if (IsAsync) { await Task.Run(async() => await InvokeAsync(HandlerClick)); } else { await HandlerClick(); } if (IsAsync && ButtonType == ButtonType.Button) { ButtonIcon = Icon; IsDisabled = false; IsAsyncLoading = false; } }); async Task HandlerClick() { if (OnClickWithoutRender != null) { await OnClickWithoutRender.Invoke(); } if (OnClick.HasDelegate) { await OnClick.InvokeAsync(); } } }
protected override void BuildRenderTree(RenderTreeBuilder builder) { if (Component is T) { int index = -1; builder.OpenComponent(++index, Component.GetType()); if (AdditionalAttributes?.Any() ?? false) { builder.AddMultipleAttributes(++index, AdditionalAttributes); } builder.CloseComponent(); } }
/// <inheritdoc /> protected override void BuildRenderTree(RenderTreeBuilder builder) { Requires.Argument(builder, nameof(builder)) .IsNotNull() .Check(); var sequenceGenerator = new SequenceGenerator(); builder.OpenElement(sequenceGenerator.GetNextValue(), TagName); builder.AddAttribute(sequenceGenerator.GetNextValue(), CLASS_ATTRIBUTE_NAME, CssClasses); builder.AddMultipleAttributes(sequenceGenerator.GetNextValue(), AdditionalAttributes?.Where(pair => pair.Key != CLASS_ATTRIBUTE_NAME)); builder.AddContent(sequenceGenerator.GetNextValue(), ChildContent); builder.CloseElement(); }
/// <summary> /// Removes a flag from the user's User Account Control attribute. /// </summary> /// <param name="flag">A flag from the predefined UserAccountControl flags.</param> /// <returns>True if removed, false otherwise.</returns> public bool RemoveUserAccountControlFlag(ActiveDirectory.UserAccountControl flag) { // Use the normal user account control attribute. uint newUserAccountControl = UserAccountControl & ~(uint)flag; if (SetStringAttribute("userAccountControl", newUserAccountControl.ToString())) { // Remove the userAccountControl attribute from the list so it is refreshed on the next request for it. AdditionalAttributes.Remove("userAccountControl"); return(true); } return(false); }
/// <summary> /// OnInitialized 方法 /// </summary> protected override void OnInitialized() { base.OnInitialized(); if (AdditionalAttributes != null && AdditionalAttributes.TryGetValue("placeholder", out var ph)) { PlaceHolder = ph?.ToString(); } if (string.IsNullOrEmpty(PlaceHolder) && FieldIdentifier.HasValue) { PlaceHolder = FieldIdentifier.Value.GetPlaceHolder(); } }
/// <summary> /// OnInitialized 方法 /// </summary> protected override void OnInitialized() { base.OnInitialized(); // TODO: 此处应该检查 html5 type 类型检查 if (AdditionalAttributes != null) { if (!AdditionalAttributes.TryGetValue("type", out var _)) { AdditionalAttributes.Add("type", IsPassword ? "password" : "text"); } } }
public VideoStreamInfo(Dictionary <string, object> dict) : base(dict) { Profile = AdditionalAttributes.GetValueAndRemove("profile")?.ToString(); Width = AdditionalAttributes.ContainsKey("width") ? Convert.ToInt32(AdditionalAttributes.GetValueAndRemove("width")) : (int?)null; Height = AdditionalAttributes.ContainsKey("height") ? Convert.ToInt32(AdditionalAttributes.GetValueAndRemove("height")) : (int?)null; CodedWidth = AdditionalAttributes.ContainsKey("coded_width") ? Convert.ToInt32(AdditionalAttributes.GetValueAndRemove("coded_width")) : (int?)null; CodedHeight = AdditionalAttributes.ContainsKey("coded_height") ? Convert.ToInt32(AdditionalAttributes.GetValueAndRemove("coded_height")) : (int?)null; HasBFrames = AdditionalAttributes.ContainsKey("has_b_frames") ? Convert.ToBoolean(AdditionalAttributes.GetValueAndRemove("has_b_frames")) : (bool?)null; SampleAspectRatio = AdditionalAttributes.GetValueAndRemove("sample_aspect_ratio")?.ToString(); DisplayAspectRatio = AdditionalAttributes.GetValueAndRemove("display_aspect_ratio")?.ToString(); PixFmt = AdditionalAttributes.GetValueAndRemove("pix_fmt")?.ToString(); Level = AdditionalAttributes.ContainsKey("level") ? Convert.ToInt32(AdditionalAttributes.GetValueAndRemove("level")) : (int?)null; Refs = AdditionalAttributes.ContainsKey("refs") ? Convert.ToInt32(AdditionalAttributes.GetValueAndRemove("refs")) : (int?)null; }
/// <summary> /// /// </summary> protected override void OnInitialized() { base.OnInitialized(); AdditionalAttributes?.Remove("data-placement"); AdditionalAttributes?.Remove("data-trigger"); if (SelectAdditionalAttributes == null) { SelectAdditionalAttributes = new Dictionary <string, object>(); } if (!SelectAdditionalAttributes.TryGetValue("data-trigger", out var _)) { SelectAdditionalAttributes["data-trigger"] = "hover focus"; } }
/// <summary> /// OnInitialized 方法 /// </summary> protected override void OnInitialized() { base.OnInitialized(); if (AdditionalAttributes != null && AdditionalAttributes.TryGetValue("type", out var t)) { Type = t.ToString() !; } // 设置 Number 类型 if (typeof(TValue).IsNumber()) { Type = "number"; } }
/// <inheritdoc /> protected override void OnParametersSet() { // Update computed state var href = (string?)null; if (AdditionalAttributes != null && AdditionalAttributes.TryGetValue("href", out var obj)) { href = Convert.ToString(obj); } _hrefAbsolute = href == null ? null : NavigationManger.ToAbsoluteUri(href).AbsoluteUri; _isActive = ShouldMatch(NavigationManger.Uri); UpdateCssClass(); }
public ImageFieldDefinition() { FieldType = BuiltInPublishingFieldTypes.Image; // RichTextMode/RichText should be set as follow to make sure field can be edited and displayed correctly // Skipping these atts would resul a pure HTML string on the publishing page layout // Enhance 'ImageFieldDefinition' - add default AdditionalAttributes #552 // https://github.com/SubPointSolutions/spmeta2/issues/552 AdditionalAttributes.Add(new FieldAttributeValue { Name = "RichTextMode", Value = "FullHtml" }); AdditionalAttributes.Add(new FieldAttributeValue { Name = "RichText", Value = "TRUE" }); }
private void AddInput(RenderTreeBuilder builder2, IMField field, IMPropertyInfo propertyInfo, Guid inpId) { if (field is IMPropertyField pf) { if (field is IMComplexField) { var appendMethod = typeof(RenderHelper).GetMethod(nameof(RenderHelper.AppendComplexType)).MakeGenericMethod(typeof(T), pf.PropertyType); appendMethod.Invoke(null, new object[] { builder2, propertyInfo, Model, inpId, this, field, MFormGridContext }); return; } bool isInFilterRow = AdditionalAttributes != null && AdditionalAttributes.ContainsKey("data-is-filterrow"); var method = typeof(RenderHelper).GetMethod(nameof(RenderHelper.AppendInput)).MakeGenericMethod(propertyInfo.PropertyType); method.Invoke(null, new object[] { builder2, propertyInfo, Model, inpId, this, isInFilterRow, field }); } }
private IReadOnlyDictionary <string, object> CalculateAdditionalAttributes() { var additionalAttributes = AdditionalAttributes?.ToDictionary(pair => pair.Key, pair => pair.Value) ?? new Dictionary <string, object>(); if (!additionalAttributes.ContainsKey(HtmlAttributeNames.CLASS)) { additionalAttributes.Add(HtmlAttributeNames.CLASS, string.Empty); } additionalAttributes[HtmlAttributeNames.CLASS] = CssBuilder .AddClass( additionalAttributes[HtmlAttributeNames.CLASS] as string, !string.IsNullOrWhiteSpace(additionalAttributes[HtmlAttributeNames.CLASS] as string)) .Build(); return(new ReadOnlyDictionary <string, object>(additionalAttributes)); }
/// <summary> /// OnInitialized 方法 /// </summary> protected override void OnInitialized() { base.OnInitialized(); if (string.IsNullOrEmpty(PlaceHolder) && FieldIdentifier.HasValue) { PlaceHolder = FieldIdentifier.Value.GetPlaceHolder(); } if (AdditionalAttributes != null && AdditionalAttributes.TryGetValue("type", out var t)) { var type = t.ToString(); if (!string.IsNullOrEmpty(type)) { Type = type; } } }
protected override void BuildRenderTree(RenderTreeBuilder builder) { var sequenceGenerator = new SequenceGenerator(); builder.OpenElement(sequenceGenerator.GetNextValue(), TagName); builder.AddAttribute(sequenceGenerator.GetNextValue(), "class", CssClasses); if (TagName == HtmlTagNames.BUTTON || TagName == HtmlTagNames.INPUT) { builder.AddAttribute(sequenceGenerator.GetNextValue(), "type", Type.GetCssClassPart()); } else { builder.AddAttribute(sequenceGenerator.GetNextValue(), "role", "button"); } builder.AddMultipleAttributes(sequenceGenerator.GetNextValue(), AdditionalAttributes?.Where(pair => pair.Key != "class")); builder.AddContent(sequenceGenerator.GetNextValue(), ChildContent); builder.CloseElement(); }
protected IEnumerable copyMatItem(PXAdapter adapter) { MatrixInventoryItem current1 = (MatrixInventoryItem)this.Base1.MatrixItems.Current; AdditionalAttributes current2 = this.Base3.AdditionalAttributes.Current; bool?selected = current1.Selected; bool flag = true; if (selected.GetValueOrDefault() == flag & selected.HasValue) { for (int index1 = 0; index1 < current2.AttributeIdentifiers.Length; ++index1) { int index2 = Array.IndexOf <string>(current1.AttributeIDs, current2.AttributeIdentifiers[index1]); current2.Values[index1] = current1.AttributeValues[index2]; } } this.Base3.AdditionalAttributes.Insert(current2); return(adapter.Get()); }
/// <summary> /// OnInitialized 方法 /// </summary> protected override void OnInitialized() { base.OnInitialized(); // 初始化 Tooltip 组件 if (Tooltip != null) { if (AdditionalAttributes == null) { AdditionalAttributes = new Dictionary <string, object>(); } AdditionalAttributes["data-placement"] = Tooltip.Placement.ToDescriptionString(); if (!AdditionalAttributes.TryGetValue("data-trigger", out var _) && !string.IsNullOrEmpty(Tooltip.Trigger)) { AdditionalAttributes["data-trigger"] = Tooltip.Trigger; } } }
/// <summary> /// OnParametersSet 方法 /// </summary> protected override void OnParametersSet() { // 不需要走 base.OnParametersSet 方法 AdditionalAttributes ??= new Dictionary <string, object>(); if (string.IsNullOrEmpty(PreviewUrl)) { AdditionalAttributes.Add("onclick", "$.bb_printview(this)"); Target = null; } else { AdditionalAttributes.Remove("onclick", out _); Target = "_blank"; } if (string.IsNullOrEmpty(ButtonIcon)) { ButtonIcon = "fa fa-print"; } }
/// <inheritdoc /> protected override void OnParametersSet() { // Update computed state var href = (string)null; if (AdditionalAttributes != null && AdditionalAttributes.TryGetValue("href", out var obj)) { href = Convert.ToString(obj); } _hrefAbsolute = href == null ? null : UriHelper.ToAbsoluteUri(href).AbsoluteUri; _isActive = ShouldMatch(UriHelper.GetAbsoluteUri()); _class = (string)null; if (AdditionalAttributes != null && AdditionalAttributes.TryGetValue("class", out obj)) { _class = Convert.ToString(obj); } UpdateCssClass(); }
/// <summary> /// OnInitialized 方法 /// </summary> protected override void OnInitialized() { base.OnInitialized(); if (AdditionalAttributes == null) { AdditionalAttributes = new Dictionary <string, object>(); } if (!AdditionalAttributes.TryGetValue("type", out var _)) { // 设置 Number 类型 if (typeof(TValue).IsNumber()) { AdditionalAttributes.Add("type", "number"); } else { AdditionalAttributes.Add("type", IsPassword ? "password" : "text"); } } }
/// <inheritdoc /> protected override void BuildInput(RenderTreeBuilder builder, int sequence) { builder.OpenElement(0, "div"); builder.AddAttribute(1, "class", "form-check"); { builder.OpenElement(0, "input"); builder.AddMultipleAttributes(1, AdditionalAttributes); builder.AddAttribute(2, "type", "checkbox"); builder.AddAttribute(3, "class", $"form-check-input {CssClass}"); builder.AddAttribute(4, "checked", BindConverter.FormatValue(CurrentValue)); builder.AddAttribute(5, "onchange", EventCallback.Factory.CreateBinder <bool>(this, __value => CurrentValue = __value, CurrentValue)); builder.CloseElement(); object placeholder = null; AdditionalAttributes?.TryGetValue("placeholder", out placeholder); builder.OpenElement(0, "label"); builder.AddAttribute(1, "class", "form-check-label"); builder.AddContent(0, placeholder ?? Label); builder.CloseElement(); } builder.CloseElement(); }
protected override void BuildRenderTree(RenderTreeBuilder builder) { BuildBulma(); string id = String.Empty; if (AdditionalAttributes.ContainsKey("id")) { id = AdditionalAttributes["id"].ToString(); } else { id = Guid.NewGuid().ToString(); CombinedAdditionalAttributes.Add("id", id); } CombinedAdditionalAttributes.Add("type", "checkbox"); builder.OpenElement(0, "div"); builder.AddAttribute(1, "class", "field"); builder.OpenComponent <InputCheckbox>(1); //builder.AddAttribute(2, "class", InputClassBuilder.ClassString); //builder.AddAttribute(2, "type", "checkbox"); builder.AddAttribute(3, "Value", Value); builder.AddAttribute(4, "ValueExpression", ValueExpression); builder.AddAttribute(5, "ValueChanged", ValueChanged); builder.AddAttribute(6, "AdditionalAttributes", CombinedAdditionalAttributes); builder.CloseComponent(); builder.OpenElement(7, "label"); builder.AddAttribute(8, "for", id); builder.AddContent(9, Label); builder.CloseElement(); builder.CloseElement(); }
/// <summary> /// inherited /// Builds the render tree for the component /// </summary> /// <param name="builder"></param> protected override void BuildRenderTree(RenderTreeBuilder builder) { var css = string.Empty; var viewData = new ViewData(ViewType, ViewParameters); if (AdditionalAttributes != null && AdditionalAttributes.TryGetValue("class", out var obj)) { css = Convert.ToString(obj, CultureInfo.InvariantCulture); } if (this.IsActive) { css = $"{css} active"; } this.UsedAttributes.Add("@onclick"); this.UsedAttributes.Add("onclick"); this.ClearDuplicateAttributes(); builder.OpenElement(0, "a"); builder.AddAttribute(1, "class", css); builder.AddMultipleAttributes(2, AdditionalAttributes); //builder.AddAttribute(3, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this, e => this.ViewManager.LoadViewAsync(viewData))); builder.AddAttribute(3, "onclick", EventCallback.Factory.Create <MouseEventArgs>(this, e => this.ViewManager.LoadViewAsync(viewData))); builder.AddContent(4, ChildContent); builder.CloseElement(); }
/// <summary> /// Add an extra process/thread attribute. /// </summary> /// <param name="attribute">The process attribute to add.</param> /// <remarks>The caller is responsible for disposing the attribute, this class does not hold a reference.</remarks> public void AddAttribute(ProcessAttribute attribute) { AdditionalAttributes.Add(attribute); }
public AudioStreamInfo(Dictionary <string, object> dict) : base(dict) { SampleFmt = AdditionalAttributes.GetValueAndRemove("sample_fmt")?.ToString(); SampleRate = AdditionalAttributes.ContainsKey("sample_rate") ? Convert.ToDouble(new Expression(AdditionalAttributes.GetValueAndRemove("sample_rate").ToString()).Evaluate()) : (double?)null; Channels = AdditionalAttributes.ContainsKey("channels") ? Convert.ToInt32(AdditionalAttributes.GetValueAndRemove("channels")) : (int?)null; ChannelLayout = AdditionalAttributes.GetValueAndRemove("channel_layout")?.ToString(); BitsPerSample = AdditionalAttributes.ContainsKey("bits_per_sample") ? Convert.ToInt32(AdditionalAttributes.GetValueAndRemove("bits_per_sample")) : (int?)null; }
protected override void BuildRenderTree(RenderTreeBuilder builder) { if (builder != null) { base.BuildRenderTree(builder); string container = "input"; if (AddOnBefore != null || AddOnAfter != null) { container = "groupWrapper"; _hasAffixWrapper = true; builder.OpenElement(1, "span"); builder.AddAttribute(2, "class", GroupWrapperClass); builder.AddAttribute(3, "style", Style); builder.OpenElement(4, "span"); builder.AddAttribute(5, "class", $"{PrefixCls}-wrapper {PrefixCls}-group"); } if (AddOnBefore != null) { _hasAffixWrapper = true; // addOnBefore builder.OpenElement(11, "span"); builder.AddAttribute(12, "class", $"{PrefixCls}-group-addon"); builder.AddContent(13, AddOnBefore); builder.CloseElement(); } if (Prefix != null || Suffix != null) { _hasAffixWrapper = true; builder.OpenElement(21, "span"); builder.AddAttribute(22, "class", AffixWrapperClass); if (container == "input") { container = "affixWrapper"; builder.AddAttribute(23, "style", Style); } if (WrapperRefBack != null) { builder.AddElementReferenceCapture(24, r => WrapperRefBack.Current = r); } } if (Prefix != null) { _hasAffixWrapper = true; // prefix builder.OpenElement(31, "span"); builder.AddAttribute(32, "class", $"{PrefixCls}-prefix"); builder.AddContent(33, Prefix); builder.CloseElement(); } // input builder.OpenElement(41, "input"); builder.AddAttribute(42, "class", ClassMapper.Class); if (container == "input") { builder.AddAttribute(43, "style", Style); } bool needsDisabled = Disabled; if (Attributes != null) { builder.AddMultipleAttributes(44, Attributes); if (!Attributes.TryGetValue("disabled", out object disabledAttribute)) { needsDisabled = ((bool?)disabledAttribute ?? needsDisabled) | Disabled; } } if (AdditionalAttributes != null) { builder.AddMultipleAttributes(45, AdditionalAttributes); if (!AdditionalAttributes.TryGetValue("disabled", out object disabledAttribute)) { needsDisabled = ((bool?)disabledAttribute ?? needsDisabled) | Disabled; } } builder.AddAttribute(50, "Id", Id); builder.AddAttribute(51, "type", Type); builder.AddAttribute(60, "placeholder", Placeholder); builder.AddAttribute(61, "value", CurrentValue); builder.AddAttribute(62, "disabled", needsDisabled); // onchange 和 onblur 事件会导致点击 OnSearch 按钮时不触发 Click 事件,暂时取消这两个事件 if (!IgnoreOnChangeAndBlur) { builder.AddAttribute(70, "onchange", CallbackFactory.Create(this, OnChangeAsync)); builder.AddAttribute(71, "onblur", CallbackFactory.Create(this, OnBlurAsync)); } builder.AddAttribute(72, "onkeypress", CallbackFactory.Create(this, OnKeyPressAsync)); builder.AddAttribute(73, "onkeydown", CallbackFactory.Create(this, OnkeyDownAsync)); builder.AddAttribute(74, "onkeyup", CallbackFactory.Create(this, OnKeyUpAsync)); builder.AddAttribute(75, "oninput", CallbackFactory.Create(this, OnInputAsync)); builder.AddAttribute(76, "onfocus", CallbackFactory.Create(this, OnFocusAsync)); builder.AddAttribute(77, "onmouseup", CallbackFactory.Create(this, OnMouseUpAsync)); builder.AddElementReferenceCapture(90, r => Ref = r); builder.CloseElement(); if (Suffix != null) { _hasAffixWrapper = true; // suffix builder.OpenElement(91, "span"); builder.AddAttribute(92, "class", $"{PrefixCls}-suffix"); builder.AddContent(93, Suffix); builder.CloseElement(); } if (Prefix != null || Suffix != null) { builder.CloseElement(); } if (AddOnAfter != null) { _hasAffixWrapper = true; // addOnAfter builder.OpenElement(100, "span"); builder.AddAttribute(101, "class", $"{PrefixCls}-group-addon"); builder.AddContent(102, AddOnAfter); builder.CloseElement(); } if (AddOnBefore != null || AddOnAfter != null) { builder.CloseElement(); builder.CloseElement(); } } }