Loading src/WatermarkClock/Context.cs +14 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,20 @@ namespace WatermarkClock } } private double _fontSize = 28; public double FontSize { get => _fontSize; set { if (SetField(ref _fontSize, value)) { OnPropertyChanged(); } } } private Brush _olBrs; public Brush OutlineBrush Loading src/WatermarkClock/MainWindow.xaml.cs +23 −4 Original line number Diff line number Diff line using System; using System.Windows.Media; using System.Windows.Threading; using WatermarkClock.Templates; namespace WatermarkClock { Loading @@ -9,14 +12,30 @@ namespace WatermarkClock { public MainWindow() { InitializeComponent(); new WatermarkClockWindow(new Context() var ctx = new Context() { MarkPosition = MarkPosition.TopRight, Output = "Hello", Padding = 16, TextBrush = Brushes.Gray }).Show(); TextBrush = Brushes.White, FontSize = 28 }; var dt = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(16) };dt.Start(); dt.Tick += (_1, _2) => { ctx.Output = new TextTemplateEngine() { Templates = { new BaseTime() } }.Replace("{DatetimeF}"); }; InitializeComponent(); new WatermarkClockWindow(ctx).Show(); } } } No newline at end of file src/WatermarkClock/Templates/BaseTime.cs +4 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,10 @@ namespace WatermarkClock.Templates var dt = DateTime.Now; return input .Replace("{datetimeF}", dt.ToString("f")) .Replace("{DatetimeF}", dt.ToString("F")) .Replace("{datetimeS}", dt.ToString("s")) .Replace("{DatetimeS}", dt.ToString("s")) .Replace("{year}", dt.Year.ToString("0000")) .Replace("{month}", dt.Month.ToString()) .Replace("{Month}", dt.Month.ToString("00")) Loading src/WatermarkClock/WatermarkClockWindow.xaml +0 −4 Original line number Diff line number Diff line Loading @@ -13,12 +13,8 @@ Background="Transparent" AllowsTransparency="True" Title="WatermarkClockWindow"> <WindowChrome.WindowChrome> <WindowChrome GlassFrameThickness="-1" /> </WindowChrome.WindowChrome> <Grid IsHitTestVisible="False"> <TextBlock IsHitTestVisible="False" FontSize="28" HorizontalAlignment="Stretch" VerticalAlignment="Center" TextAlignment="Center" Loading src/WatermarkClock/WatermarkClockWindow.xaml.cs +12 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ namespace WatermarkClock ChangePadding(); ChangePosition(); ChangeTextBrush(); ChangeFontSize(); } protected override void OnStateChanged(EventArgs e) Loading Loading @@ -76,6 +77,12 @@ namespace WatermarkClock ChangeTextBrush(); return; } case nameof(_context.FontSize): { ChangeFontSize(); return; } } } Loading Loading @@ -118,6 +125,11 @@ namespace WatermarkClock Text.Foreground = _context.TextBrush; } private void ChangeFontSize() { Text.FontSize = _context.FontSize; } private void ChangePadding() { var p = (double)_context.Padding; Loading Loading
src/WatermarkClock/Context.cs +14 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,20 @@ namespace WatermarkClock } } private double _fontSize = 28; public double FontSize { get => _fontSize; set { if (SetField(ref _fontSize, value)) { OnPropertyChanged(); } } } private Brush _olBrs; public Brush OutlineBrush Loading
src/WatermarkClock/MainWindow.xaml.cs +23 −4 Original line number Diff line number Diff line using System; using System.Windows.Media; using System.Windows.Threading; using WatermarkClock.Templates; namespace WatermarkClock { Loading @@ -9,14 +12,30 @@ namespace WatermarkClock { public MainWindow() { InitializeComponent(); new WatermarkClockWindow(new Context() var ctx = new Context() { MarkPosition = MarkPosition.TopRight, Output = "Hello", Padding = 16, TextBrush = Brushes.Gray }).Show(); TextBrush = Brushes.White, FontSize = 28 }; var dt = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(16) };dt.Start(); dt.Tick += (_1, _2) => { ctx.Output = new TextTemplateEngine() { Templates = { new BaseTime() } }.Replace("{DatetimeF}"); }; InitializeComponent(); new WatermarkClockWindow(ctx).Show(); } } } No newline at end of file
src/WatermarkClock/Templates/BaseTime.cs +4 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,10 @@ namespace WatermarkClock.Templates var dt = DateTime.Now; return input .Replace("{datetimeF}", dt.ToString("f")) .Replace("{DatetimeF}", dt.ToString("F")) .Replace("{datetimeS}", dt.ToString("s")) .Replace("{DatetimeS}", dt.ToString("s")) .Replace("{year}", dt.Year.ToString("0000")) .Replace("{month}", dt.Month.ToString()) .Replace("{Month}", dt.Month.ToString("00")) Loading
src/WatermarkClock/WatermarkClockWindow.xaml +0 −4 Original line number Diff line number Diff line Loading @@ -13,12 +13,8 @@ Background="Transparent" AllowsTransparency="True" Title="WatermarkClockWindow"> <WindowChrome.WindowChrome> <WindowChrome GlassFrameThickness="-1" /> </WindowChrome.WindowChrome> <Grid IsHitTestVisible="False"> <TextBlock IsHitTestVisible="False" FontSize="28" HorizontalAlignment="Stretch" VerticalAlignment="Center" TextAlignment="Center" Loading
src/WatermarkClock/WatermarkClockWindow.xaml.cs +12 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ namespace WatermarkClock ChangePadding(); ChangePosition(); ChangeTextBrush(); ChangeFontSize(); } protected override void OnStateChanged(EventArgs e) Loading Loading @@ -76,6 +77,12 @@ namespace WatermarkClock ChangeTextBrush(); return; } case nameof(_context.FontSize): { ChangeFontSize(); return; } } } Loading Loading @@ -118,6 +125,11 @@ namespace WatermarkClock Text.Foreground = _context.TextBrush; } private void ChangeFontSize() { Text.FontSize = _context.FontSize; } private void ChangePadding() { var p = (double)_context.Padding; Loading