diff --git a/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/Templates/TemplateBase.razor.cs b/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/Templates/TemplateBase.razor.cs index 14271eb8..804e7b8b 100644 --- a/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/Templates/TemplateBase.razor.cs +++ b/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/Templates/TemplateBase.razor.cs @@ -8,16 +8,23 @@ using System.Text; using System.Threading.Tasks; using AXSharp.Connector; +using System.Globalization; namespace AXSharp.Presentation.Blazor.Controls.Templates { public abstract class TemplateBase : RenderableComponentBase { + /// + /// Gets the tooltip or human readable name of the Onliner. + /// protected string ToolTipOrHumanReadable => string.IsNullOrEmpty(Onliner.AttributeToolTip) - ? Onliner.HumanReadable + ? Onliner.GetHumanReadable(CultureInfo.CurrentUICulture) : Onliner.AttributeToolTip; + /// + /// Gets the symbol of the Onliner. + /// protected string Symbol => Onliner.Symbol; private IJSObjectReference? module; @@ -29,31 +36,60 @@ public IJSRuntime JSRuntime set; } + /// + /// The Onliner associated with this template. + /// [Parameter] public virtual OnlinerBase Onliner { get; set; } + /// + /// Indicates whether the control is read-only. + /// [Parameter] public bool IsReadOnly { get; set; } + /// + /// Indicates whether the label should be hidden. + /// [Parameter] public bool HideLabel { get; set; } = false; + /// + /// The unit of measurement for the value. + /// [Parameter] public string? Unit { get; set; } + /// + /// The format string for displaying the value. + /// [Parameter] public string? Format { get; set; } + /// + /// The last known value of the Onliner. + /// protected T LastValue { get; set; } + /// + /// Gets or sets the current value of the Onliner. + /// protected T Value { get { if (!HasFocus) { - LastValue = Onliner.Cyclic; // if is only readed, update LastValue for "HasFocus" case - return Onliner.Cyclic; + switch(Onliner) + { + case OnlinerBase onlinerString: + LastValue = (T)(object)onlinerString.GetCyclic(CultureInfo.CurrentUICulture); + break; + case OnlinerBase onliner: + LastValue = onliner.Cyclic; + break; + } + return LastValue; } else { @@ -78,9 +114,13 @@ protected override Task OnInitializedAsync() return base.OnInitializedAsync(); } + /// + /// Gets the label for the control based on the Onliner's attribute name and units. + /// + /// protected string GetLabel() { - return Onliner.AttributeName + (string.IsNullOrWhiteSpace(Onliner.AttributeUnits) ? null : $" [{Onliner.AttributeUnits}]"); + return Onliner.GetAttributeName(CultureInfo.CurrentUICulture) + (string.IsNullOrWhiteSpace(Onliner.AttributeUnits) ? null : $" [{Onliner.AttributeUnits}]"); } } }