Пример #1
0
        LayerFrame Text(TextOverlaySettings Settings, string Text)
        {
            var control = Generate(Settings, Text, ConvertColor(Settings.BackgroundColor));

            control.Label.FontSize = Settings.FontSize;

            control.Border.Padding = new Thickness(Settings.HorizontalPadding,
                                                   Settings.VerticalPadding,
                                                   Settings.HorizontalPadding,
                                                   Settings.VerticalPadding);

            control.Label.Foreground       = new SolidColorBrush(ConvertColor(Settings.FontColor));
            control.Border.BorderThickness = new Thickness(Settings.BorderThickness);
            control.Border.BorderBrush     = new SolidColorBrush(ConvertColor(Settings.BorderColor));

            control.Border.CornerRadius = new CornerRadius(Settings.CornerRadius);

            Settings.PropertyChanged += (S, E) =>
            {
                switch (E.PropertyName)
                {
                case nameof(Settings.BackgroundColor):
                    control.Border.Background = new SolidColorBrush(ConvertColor(Settings.BackgroundColor));
                    break;

                case nameof(Settings.FontColor):
                    control.Label.Foreground = new SolidColorBrush(ConvertColor(Settings.FontColor));
                    break;

                case nameof(Settings.BorderThickness):
                    control.Border.BorderThickness = new Thickness(Settings.BorderThickness);
                    break;

                case nameof(Settings.BorderColor):
                    control.Border.BorderBrush = new SolidColorBrush(ConvertColor(Settings.BorderColor));
                    break;

                case nameof(Settings.FontSize):
                    control.Label.FontSize = Settings.FontSize;
                    break;

                case nameof(Settings.HorizontalPadding):
                case nameof(Settings.VerticalPadding):
                    control.Border.Padding = new Thickness(Settings.HorizontalPadding,
                                                           Settings.VerticalPadding,
                                                           Settings.HorizontalPadding,
                                                           Settings.VerticalPadding);
                    break;

                case nameof(Settings.CornerRadius):
                    control.Border.CornerRadius = new CornerRadius(Settings.CornerRadius);
                    break;
                }
            };

            return(control);
        }
Пример #2
0
        LayerFrame Text(TextOverlaySettings Settings, string Text)
        {
            var control = Generate(Settings, Text, Settings.BackgroundColor.ToWpfColor());

            var vm = new TextOverlayReactor(Settings);

            control.Label.BindOne(FontFamilyProperty, vm.FontFamily);
            control.Label.BindOne(FontSizeProperty, vm.FontSize);

            // Border.PaddingProperty is different from PaddingProperty
            control.Border.BindOne(Border.PaddingProperty, vm.Padding);

            control.Label.BindOne(ForegroundProperty, vm.Foreground);
            control.Border.BindOne(BackgroundProperty, vm.Background);

            control.Border.BindOne(Border.BorderThicknessProperty, vm.BorderThickness);
            control.Border.BindOne(Border.BorderBrushProperty, vm.BorderBrush);
            control.Border.BindOne(Border.CornerRadiusProperty, vm.CornerRadius);

            return(control);
        }