mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-08-19 21:23:25 +08:00
feat.AirApp重构工程
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user