Exemplo n.º 1
0
        private void CreateThemeFile(
            string descriptiveName,
            string imagePath,
            string backgroundColor,
            string mainTextColor,
            string secondaryTextColor,
            string fontFamily = "Georgia",
            int bottomMargin  = 100)
        {
            var file = new ThemeFile();

            var currentFolder = Environment.CurrentDirectory;
            var themePath     = Path.Combine(currentFolder, $"{descriptiveName}.onlyv");

            var theme = new OnlyVTheme();

            theme.Background.Colour = backgroundColor;

            theme.BodyText.Font.Family           = fontFamily;
            theme.BodyText.Font.Colour           = mainTextColor;
            theme.BodyText.DropShadow.Opacity    = 0.3;
            theme.BodyText.DropShadow.Depth      = 7;
            theme.BodyText.DropShadow.BlurRadius = 15;

            theme.TitleText.Font.Family           = fontFamily;
            theme.TitleText.Font.Colour           = secondaryTextColor;
            theme.TitleText.DropShadow.Opacity    = 0.3;
            theme.TitleText.DropShadow.Depth      = 7;
            theme.TitleText.DropShadow.BlurRadius = 15;

            theme.VerseNumbers.Colour = secondaryTextColor;

            theme.Dimensions.BottomMargin = bottomMargin;

            file.Create(themePath, theme, imagePath, overwrite: true);

            var result = file.Read(themePath);

            Assert.IsNotNull(result);

            var s1 = JsonConvert.SerializeObject(result.Theme);
            var s2 = JsonConvert.SerializeObject(theme);

            Assert.AreEqual(s1, s2);
        }
Exemplo n.º 2
0
        private void ApplyFormatting(BibleTextImage bibleTextImage, string themePath)
        {
            var cacheEntry = ThemeFile.Read(themePath);

            OnlyVTheme  theme;
            ImageSource backgroundImage;

            if (cacheEntry == null)
            {
                // must use default...
                theme           = new OnlyVTheme();
                backgroundImage = BitmapHelper.ConvertBitmap(Properties.Resources.Blue);
            }
            else
            {
                theme           = cacheEntry.Theme;
                backgroundImage = cacheEntry.BackgroundImage;
            }

            ApplyFormatting(bibleTextImage, theme, backgroundImage);
        }