mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-22 09:14:25 +08:00
0.1.3
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
d:DesignHeight="70"
|
||||
x:Class="LanMontainDesktop.Views.Components.ClockWidget">
|
||||
|
||||
<Border Padding="8"
|
||||
<Border x:Name="RootBorder"
|
||||
Padding="8"
|
||||
CornerRadius="8"
|
||||
BorderBrush="#80A5B4FC"
|
||||
BorderThickness="1"
|
||||
@@ -15,6 +16,7 @@
|
||||
<TextBlock x:Name="TimeTextBlock"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
TextAlignment="Center"
|
||||
FontSize="26"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="White" />
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Threading;
|
||||
|
||||
namespace LanMontainDesktop.Views.Components;
|
||||
@@ -44,4 +45,15 @@ public partial class ClockWidget : UserControl
|
||||
var now = DateTime.Now;
|
||||
TimeTextBlock.Text = now.ToString("HH:mm:ss", CultureInfo.CurrentCulture);
|
||||
}
|
||||
|
||||
public void ApplyCellSize(double cellSize)
|
||||
{
|
||||
var padding = Math.Clamp(cellSize * 0.12, 2, 14);
|
||||
RootBorder.Padding = new Thickness(padding);
|
||||
RootBorder.CornerRadius = new CornerRadius(Math.Clamp(cellSize * 0.16, 4, 18));
|
||||
|
||||
// Keep the time legible across dense and sparse grid layouts.
|
||||
TimeTextBlock.FontSize = Math.Clamp(cellSize * 0.42, 10, 56);
|
||||
TimeTextBlock.FontWeight = FontWeight.SemiBold;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user