public static string ToScript([CanBeNull] this ICustomStyleProvider provider, [CanBeNull] string url, bool transparentBackgroundSupported)
        {
            if (provider == null || url == null)
            {
                return(null);
            }

            var style = provider.GetStyle(url, transparentBackgroundSupported);

            if (style == null)
            {
                return(null);
            }

            return($@"
var s = document.getElementById('__cm_style');
if (s && s.parentNode) s.parentNode.removeChild(s);
s = document.createElement('style');
s.id = '__cm_style';
s.innerHTML = {JsonConvert.SerializeObject(style)};
if (document.body){{
    document.body.appendChild(s);
}} else if (document.head){{
    var p = document.createElement('style');
    p.innerHTML = 'body{{display:none!important}}html{{background:black!important}}'
    document.head.appendChild(p);

    function onload(){{
        if (s.parentNode == document.head){{
            document.head.removeChild(p);
            document.head.removeChild(s);
            document.body.appendChild(s);
        }}
    }}

    document.head.appendChild(s);
    document.addEventListener('DOMContentLoaded', onload, false);
    window.addEventListener('load', onload, false);
}}");
        }
예제 #2
0
 public void SetStyleProvider(ICustomStyleProvider provider)
 {
     _styleProvider = provider;
 }
예제 #3
0
 public void SetStyleProvider(ICustomStyleProvider provider)
 {
     _requestHandler.StyleProvider = provider;
 }
예제 #4
0
 private void OnStyleProviderChanged(ICustomStyleProvider newValue) {
     _something.SetStyleProvider(newValue);
 }
예제 #5
0
 public void SetStyleProvider(ICustomStyleProvider provider) {
     _styleProvider = provider;
 }
예제 #6
0
 public void SetStyleProvider(ICustomStyleProvider provider) {
     _requestHandler.StyleProvider = provider;
 }
예제 #7
0
 private void OnStyleProviderChanged(ICustomStyleProvider newValue)
 {
     _something.SetStyleProvider(newValue);
 }