88using System . Text ;
99using System . Threading . Tasks ;
1010using AXSharp . Connector ;
11+ using System . Globalization ;
1112
1213
1314namespace AXSharp . Presentation . Blazor . Controls . Templates
1415{
1516 public abstract class TemplateBase < T > : RenderableComponentBase
1617 {
18+ /// <summary>
19+ /// Gets the tooltip or human readable name of the Onliner.
20+ /// </summary>
1721 protected string ToolTipOrHumanReadable => string . IsNullOrEmpty ( Onliner . AttributeToolTip )
18- ? Onliner . HumanReadable
22+ ? Onliner . GetHumanReadable ( CultureInfo . CurrentUICulture )
1923 : Onliner . AttributeToolTip ;
2024
25+ /// <summary>
26+ /// Gets the symbol of the Onliner.
27+ /// </summary>
2128 protected string Symbol => Onliner . Symbol ;
2229
2330 private IJSObjectReference ? module ;
@@ -29,31 +36,60 @@ public IJSRuntime JSRuntime
2936 set ;
3037 }
3138
39+ /// <summary>
40+ /// The Onliner associated with this template.
41+ /// </summary>
3242 [ Parameter ]
3343 public virtual OnlinerBase < T > Onliner { get ; set ; }
3444
45+ /// <summary>
46+ /// Indicates whether the control is read-only.
47+ /// </summary>
3548 [ Parameter ]
3649 public bool IsReadOnly { get ; set ; }
3750
51+ /// <summary>
52+ /// Indicates whether the label should be hidden.
53+ /// </summary>
3854 [ Parameter ]
3955 public bool HideLabel { get ; set ; } = false ;
4056
57+ /// <summary>
58+ /// The unit of measurement for the value.
59+ /// </summary>
4160 [ Parameter ]
4261 public string ? Unit { get ; set ; }
4362
63+ /// <summary>
64+ /// The format string for displaying the value.
65+ /// </summary>
4466 [ Parameter ]
4567 public string ? Format { get ; set ; }
4668
69+ /// <summary>
70+ /// The last known value of the Onliner.
71+ /// </summary>
4772 protected T LastValue { get ; set ; }
4873
74+ /// <summary>
75+ /// Gets or sets the current value of the Onliner.
76+ /// </summary>
4977 protected T Value
5078 {
5179 get
5280 {
5381 if ( ! HasFocus )
5482 {
55- LastValue = Onliner . Cyclic ; // if is only readed, update LastValue for "HasFocus" case
56- return Onliner . Cyclic ;
83+ switch ( Onliner )
84+ {
85+ case OnlinerBase < string > onlinerString :
86+ LastValue = ( T ) ( object ) onlinerString . GetCyclic ( CultureInfo . CurrentUICulture ) ;
87+ break ;
88+ case OnlinerBase < T > onliner :
89+ LastValue = onliner . Cyclic ;
90+ break ;
91+ }
92+ return LastValue ;
5793 }
5894 else
5995 {
@@ -78,9 +114,13 @@ protected override Task OnInitializedAsync()
78114 return base . OnInitializedAsync ( ) ;
79115 }
80116
117+ /// <summary>
118+ /// Gets the label for the control based on the Onliner's attribute name and units.
119+ /// </summary>
120+ /// <returns></returns>
81121 protected string GetLabel ( )
82122 {
83- return Onliner . AttributeName + ( string . IsNullOrWhiteSpace ( Onliner . AttributeUnits ) ? null : $ " [{ Onliner . AttributeUnits } ]") ;
123+ return Onliner . GetAttributeName ( CultureInfo . CurrentUICulture ) + ( string . IsNullOrWhiteSpace ( Onliner . AttributeUnits ) ? null : $ " [{ Onliner . AttributeUnits } ]") ;
84124 }
85125 }
86126}
0 commit comments