77 lines
2.1 KiB
C#
77 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Layout;
|
|
using Avalonia.Markup.Xaml;
|
|
using Avalonia.Media;
|
|
|
|
namespace DispenserUI.Views.Controls;
|
|
|
|
public partial class LockedView : UserControl
|
|
{
|
|
public LockedView()
|
|
{
|
|
InitializeComponent();
|
|
|
|
WaterMark = this.FindControl<Grid>("WaterMark");
|
|
|
|
this.GetObservable(IsVisibleProperty).Subscribe(val =>
|
|
{
|
|
if (val)
|
|
{
|
|
DrawWaterMark();
|
|
}
|
|
});
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
}
|
|
|
|
private void DrawWaterMark()
|
|
{
|
|
WaterMark.RenderTransformOrigin = RelativePoint.Center;
|
|
WaterMark.RenderTransform = new RotateTransform(-45);
|
|
|
|
var wrapPanel = new WrapPanel();
|
|
var stackPanels = new List<StackPanel>();
|
|
for (int i = 0; i < 100; i++)
|
|
{
|
|
var stackPanel = new StackPanel
|
|
{
|
|
Margin = new Thickness(100),
|
|
Height = 50
|
|
};
|
|
|
|
// 创建提醒文字和时间文字
|
|
var textBlock = new TextBlock
|
|
{
|
|
Text = "设备已锁定,请联系管理员解锁!",
|
|
FontSize = 20,
|
|
VerticalAlignment = VerticalAlignment.Center,
|
|
HorizontalAlignment = HorizontalAlignment.Center,
|
|
Foreground = new SolidColorBrush(Colors.Gray),
|
|
Opacity = 0.5,
|
|
};
|
|
var timeTextBlock = new TextBlock
|
|
{
|
|
Text = DateTime.Now.ToString("yyyy年M月d日 dddd HH:mm:ss"),
|
|
FontSize = 12,
|
|
VerticalAlignment = VerticalAlignment.Center,
|
|
HorizontalAlignment = HorizontalAlignment.Center,
|
|
Foreground = new SolidColorBrush(Colors.Gray),
|
|
Opacity = 0.5,
|
|
};
|
|
stackPanel.Children.Add(textBlock);
|
|
stackPanel.Children.Add(timeTextBlock);
|
|
|
|
stackPanels.Add(stackPanel);
|
|
}
|
|
|
|
wrapPanel.Children.AddRange(stackPanels);
|
|
|
|
WaterMark.Children.Add(wrapPanel);
|
|
}
|
|
} |