Commit a3a1030b authored by shrabbit's avatar shrabbit
Browse files

wan

parent b73ab524
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -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
+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
{
@@ -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
+4 −0
Original line number Diff line number Diff line
@@ -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"))
+0 −4
Original line number Diff line number Diff line
@@ -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"
+12 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ namespace WatermarkClock
            ChangePadding();
            ChangePosition();
            ChangeTextBrush();
            ChangeFontSize();
        }

        protected override void OnStateChanged(EventArgs e)
@@ -76,6 +77,12 @@ namespace WatermarkClock
                    ChangeTextBrush();
                    return;
                }

                case nameof(_context.FontSize):
                {
                    ChangeFontSize();
                    return;
                }
            }
        }

@@ -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;