mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-08-19 17:43:24 +08:00
36 lines
971 B
C#
36 lines
971 B
C#
using Avalonia.Controls;
|
|
using Avalonia.Layout;
|
|
using Avalonia.Media;
|
|
using LanMountainDesktop.AirAppSdk;
|
|
|
|
namespace LanMountainDesktop.AirAppTemplate;
|
|
|
|
/// <summary>
|
|
/// 桌面组件控件。主进程内渲染,构造函数可接收 <see cref="AirAppComponentContext"/>。
|
|
/// </summary>
|
|
public sealed class MyComponent : UserControl
|
|
{
|
|
private readonly TextBlock _text = new()
|
|
{
|
|
FontSize = 18,
|
|
FontWeight = FontWeight.Bold,
|
|
HorizontalAlignment = HorizontalAlignment.Center,
|
|
VerticalAlignment = VerticalAlignment.Center
|
|
};
|
|
|
|
public MyComponent(AirAppComponentContext context)
|
|
{
|
|
_text.Text = $"Hello AirApp: {context.ComponentId}";
|
|
Content = new StackPanel
|
|
{
|
|
Spacing = 8,
|
|
HorizontalAlignment = HorizontalAlignment.Center,
|
|
VerticalAlignment = VerticalAlignment.Center,
|
|
Children =
|
|
{
|
|
_text
|
|
}
|
|
};
|
|
}
|
|
}
|