Skip to content

Commit e45aebf

Browse files
committed
merge
2 parents a7efa9c + 6a6a823 commit e45aebf

21 files changed

Lines changed: 547 additions & 62 deletions

File tree

GitVersion.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mode: ContinuousDeployment
2-
next-version: 0.46.0
2+
next-version: 0.47.0
33
branches:
44
main:
55
regex: ^master$|^main$

src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/Templates/TemplateBase.razor.cs

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,23 @@
88
using System.Text;
99
using System.Threading.Tasks;
1010
using AXSharp.Connector;
11+
using System.Globalization;
1112

1213

1314
namespace 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
}

src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Pages/_Host.cshtml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,8 @@
4242

4343
<script src="_framework/blazor.server.js"></script>
4444
<script src="/_content/Operon/js/javascript.js"></script>
45+
46+
<script src="~/js/theme.js"></script>
47+
<script>themeManager.init();</script>
4548
</body>
4649
</html>

src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Shared/MainLayout.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
@inject IJSRuntime JSRuntime
44

5-
<div class="sidebar">
5+
<div class="bg-background-light">
66
<NavMenu />
77
</div>
8-
<div class="main">
8+
<div class="bg-background">
99

1010
<div class="content px-4">
1111
@Body

src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Shared/NavMenu.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<header class="bg-primary-50">
2+
<Theme />
23
<div class="mx-auto max-w-screen-xl px-4 sm:px-6 lg:px-8">
34
<div class="flex h-16 items-center justify-between">
45
@* <div class="flex-1 md:flex md:items-center md:gap-12"> *@
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@inject ThemeService _themeService
2+
3+
<nav class="tab my-auto">
4+
<button type="button" class="btn btn-primary @(0 != 0 ? "active" : null)" @onclick="() => _themeService.SetLightAsync()">
5+
<Operon.Icons.HeroIcon Icon="sun" Type="Operon.Icons.IconType.Outline" Class="size-5" />
6+
</button>
7+
<button type="button" class="btn btn-primary @(0 != 0 ? "active" : null)" @onclick="() => _themeService.SetDarkAsync()">
8+
<Operon.Icons.HeroIcon Icon="moon" Type="Operon.Icons.IconType.Outline" Class="size-5" />
9+
</button>
10+
<button type="button" class="btn btn-primary @(0 != 0 ? "active" : null)" @onclick="() => _themeService.SetSystemAsync()">
11+
<Operon.Icons.HeroIcon Icon="computer-desktop" Type="Operon.Icons.IconType.Outline" Class="size-5" />
12+
</button>
13+
</nav>

src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Startup.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public void ConfigureServices(IServiceCollection services)
3131
services.AddRazorPages();
3232
services.AddServerSideBlazor();
3333
services.AddIxBlazorServices();
34+
35+
services.AddScoped<ThemeService>();
3436
}
3537

3638
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.JSInterop;
2+
using System.Threading.Tasks;
3+
4+
namespace ixBlazor.App
5+
{
6+
public class ThemeService
7+
{
8+
private readonly IJSRuntime _js;
9+
10+
public ThemeService(IJSRuntime js) => _js = js;
11+
12+
public ValueTask InitAsync() =>
13+
_js.InvokeVoidAsync("themeManager.init");
14+
15+
public ValueTask SetLightAsync() =>
16+
_js.InvokeVoidAsync("themeManager.setLight");
17+
18+
public ValueTask SetDarkAsync() =>
19+
_js.InvokeVoidAsync("themeManager.setDark");
20+
21+
public ValueTask SetSystemAsync() =>
22+
_js.InvokeVoidAsync("themeManager.setSystem");
23+
}
24+
}

0 commit comments

Comments
 (0)