Esempio n. 1
0
        public static string ConstructorHtml(MainContent content)
        {
            if (string.IsNullOrEmpty(content.Body))
            {
                return(string.Empty);
            }

            var cssBuilder = new StringBuilder();
            var jsBuilder  = new StringBuilder();

            content.Css.ForEach(o => cssBuilder.Append(string.Format(_cssTemplate, o)));
            content.Js.ForEach(o => jsBuilder.Append(string.Format(_jsTemplate, o)));

            var titleColor = ((SolidColorBrush)((ResourceDictionary)Application.Current.Resources.ThemeDictionaries[StorageInfo.Instance.AppTheme == ElementTheme.Dark?"Dark":"Light"])["BrushToolBarForeground"]).Color.ToString();

            if (titleColor.Length == 9)
            {
                titleColor = titleColor.Replace("#FF", "#");
            }
            var    header = string.Format(_headerTemplate, content.Image, titleColor, content.Title, titleColor, content.Image_Source);
            string body   = "";

            if (StorageInfo.Instance.AppTheme == ElementTheme.Dark)
            {
                var backgroundColor = ((SolidColorBrush)((ResourceDictionary)Application.Current.Resources.ThemeDictionaries["Dark"])["BrushPrimary"]).Color.ToString();
                body = "<body class=\"dudu-night\">" + content.Body + "</body>";
                body = body.Replace("class=\"main-wrap content-wrap\"", "class=\"main-wrap content-wrap\" style=\"background:" + backgroundColor + "\"");
            }
            else
            {
                body = "<body>" + content.Body + "</body>";
            }
            var script = _notifyScript;

            if (StorageInfo.Instance.NeedLazyLoadImage)
            {
                body    = LazyImageHandle(body);
                script += _lazyLoadScript;
            }
            var source = string.Format(_htmlTemplate, cssBuilder.ToString(), jsBuilder.ToString(), body, script);

            source = source.Replace("<div class=\"img-place-holder\"></div>", header);

            return(source);
        }
Esempio n. 2
0
 public static void ArrangeMainContent(MainContent content)
 {
     content.Body = ConstructorHtml(content);
 }