示例#1
0
        /// <summary>
        /// Returns HTML text to display in web view, from given markdown file
        /// </summary>
        /// <param name="markdownFilename">markdown filename, relative to the asset folder</param>
        /// <returns>HTML text</returns>
        private static string GetHtmlText(string markdownFilename)
        {
            IPlatform platform     = DependencyService.Get <IPlatform>();
            string    markdownText = platform.LoadAssetText(markdownFilename);

            if (markdownFilename.EndsWith("version.md"))
            {
                markdownText = markdownText.Replace("%VERSION%", GetCurrentVersionText());
            }

            string htmlText = HtmlConverter.FromMarkdown(markdownText);

            if (markdownFilename.EndsWith("manual.md"))
            {
                htmlText = "<style> img { max-width: 90vw; }</style>" + htmlText;
            }

            htmlText = htmlText.Replace(".svg\"", ".svg\" class=\"svg-img\"");

            if (Styles.ThemeHelper.CurrentTheme == Model.Theme.Light)
            {
                htmlText = "<style> body { color: black; background-color: white; } .svg-img { filter: invert(100%); } </style>" + htmlText;
            }
            else
            {
                htmlText = HtmlConverter.AddTextColorStyles(
                    htmlText,
                    "white",
                    "black",
                    App.GetResourceColor("AccentColor"));
            }

            return(htmlText);
        }
示例#2
0
        /// <summary>
        /// Formats layer description
        /// </summary>
        /// <param name="layer">layer to format description</param>
        /// <returns>formatted description text</returns>
        private static string FormatLayerDescription(Layer layer)
        {
            string desc = HtmlConverter.FromHtmlOrMarkdown(layer.Description);

            return(HtmlConverter.AddTextColorStyles(
                       desc,
                       App.GetResourceColor("ElementTextColor"),
                       App.GetResourceColor("PageBackgroundColor"),
                       App.GetResourceColor("AccentColor")));
        }