-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTuiButton.cs
More file actions
35 lines (30 loc) · 1.07 KB
/
Copy pathTuiButton.cs
File metadata and controls
35 lines (30 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using Microsoft.AspNetCore.Components;
using Tedd.TUI;
using System;
namespace Tedd.TUI.Platform.Blazor.Components;
public class TuiButton : TuiComponentBase
{
private Button _button = new Button();
public override UIElement Element => _button;
[Parameter] public string Text { get; set; } = "";
[Parameter] public BoxStyle BoxStyle { get; set; } = BoxStyle.Single;
[Parameter] public ButtonShadowStyle ShadowStyle { get; set; } = ButtonShadowStyle.None;
[Parameter] public ConsoleColor ShadowBackground { get; set; } = ConsoleColor.Black;
[Parameter] public EventCallback OnClick { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
_button.Click += (s, e) =>
{
InvokeAsync(async () => await OnClick.InvokeAsync());
};
}
protected override void ApplyProperties()
{
base.ApplyProperties();
_button.Content = Text;
_button.BoxStyle = BoxStyle;
_button.ShadowStyle = ShadowStyle;
_button.ShadowBackground = ShadowBackground;
}
}