Пример #1
0
        public static void Initialize(IEnumerable <Assembly> resourceSearchAssemblies, IDictionary <string, List <string> > cssNamespaceMapping = null)
        {
            if (initialized)
            {
                return;
            }

            cssNamespaceMapping = cssNamespaceMapping ?? DefaultCssNamespaceMapping;

            TypeHelpers.Initialze(cssNamespaceMapping, false);

            var defaultCssNamespace       = cssNamespaceMapping.Keys.First();
            var dependencyPropertyService = new DependencyPropertyService();
            var markupExtensionParser     = new MarkupExtensionParser();
            var cssTypeHelper             = new CssTypeHelper <DependencyObject, DependencyProperty, Style>(markupExtensionParser, dependencyPropertyService);

            instance = new BaseCss <DependencyObject, Style, DependencyProperty>(
                dependencyPropertyService,
                new TreeNodeProvider(dependencyPropertyService),
                new StyleResourceService(),
                new StyleService(dependencyPropertyService),
                defaultCssNamespace,
                markupExtensionParser,
                RunOnUIThread,
                new CssFileProvider(resourceSearchAssemblies, cssTypeHelper)
                );

            LoadedDetectionHelper.Initialize();

            CompositionTarget.Rendering += RenderingHandler;

            initialized = true;
        }
Пример #2
0
        public static void Initialize(IEnumerable <Assembly> resourceSearchAssemblies)
        {
            if (initialized)
            {
                return;
            }

            instance = new BaseCss <DependencyObject, DependencyObject, Style, DependencyProperty>(
                new DependencyPropertyService(),
                new LogicalTreeNodeProvider(new DependencyPropertyService()),
                new StyleResourceService(),
                new StyleService(new DependencyPropertyService()),
                DomElementBase <DependencyObject, DependencyProperty> .GetPrefix(typeof(Button)),
                new MarkupExtensionParser(),
                RunOnUIThread,
                new CssFileProvider(resourceSearchAssemblies)
                );

            LoadedDetectionHelper.Initialize();

            LoadedDetectionHelper.SubTreeAdded   += LoadedDetectionHelper_SubTreeAdded;
            LoadedDetectionHelper.SubTreeRemoved += LoadedDetectionHelper_SubTreeRemoved;

            CompositionTarget.Rendering += RenderingHandler;

            initialized = true;
        }
Пример #3
0
        public static void Reset()
        {
            if (!initialized)
            {
                return;
            }

            CompositionTarget.Rendering -= RenderingHandler;

            LoadedDetectionHelper.Reset();

            instance = null;

            initialized = false;
        }
Пример #4
0
        public static void Initialize(IEnumerable <Assembly> resourceSearchAssemblies)
        {
            if (initialized)
            {
                return;
            }

            var mapping = new Dictionary <string, List <string> >
            {
                {
                    "http://schemas.microsoft.com/winfx/2006/xaml/presentation",
                    new List <string>
                    {
                        typeof(Windows.UI.Xaml.Data.Binding).AssemblyQualifiedName.Replace(".Binding,", ","),
                        typeof(Windows.UI.Xaml.Shapes.Rectangle).AssemblyQualifiedName.Replace(".Rectangle,", ","),
                        typeof(Windows.UI.Xaml.Controls.Button).AssemblyQualifiedName.Replace(".Button,", ","),
                        typeof(Windows.UI.Xaml.FrameworkElement).AssemblyQualifiedName.Replace(".FrameworkElement,", ","),
                        typeof(Windows.UI.Xaml.Documents.Run).AssemblyQualifiedName.Replace(".Run,", ",")
                    }
                }
            };

            TypeHelpers.Initialze(mapping, false);

            var dependencyPropertyService = new DependencyPropertyService();
            var markupExtensionParser     = new MarkupExtensionParser();
            var cssTypeHelper             = new CssTypeHelper <DependencyObject, DependencyProperty, Style>(markupExtensionParser, dependencyPropertyService);

            instance = new BaseCss <DependencyObject, Style, DependencyProperty>(
                dependencyPropertyService,
                new LogicalTreeNodeProvider(dependencyPropertyService),
                new StyleResourceService(),
                new StyleService(dependencyPropertyService),
                DomElementBase <DependencyObject, DependencyProperty> .GetAssemblyQualifiedNamespaceName(typeof(Button)),
                markupExtensionParser,
                RunOnUIThread,
                new CssFileProvider(resourceSearchAssemblies, cssTypeHelper)
                );

            LoadedDetectionHelper.Initialize();

            CompositionTarget.Rendering += RenderingHandler;

            initialized = true;
        }
Пример #5
0
        public static void Initialize()
        {
            if (initialized)
            {
                return;
            }

            LoadedDetectionHelper.Initialize();

            LoadedDetectionHelper.SubTreeAdded   += LoadedDetectionHelper_SubTreeAdded;
            LoadedDetectionHelper.SubTreeRemoved += LoadedDetectionHelper_SubTreeRemoved;

            CompositionTarget.Rendering += (sender, e) =>
            {
                instance.ExecuteApplyStyles();
            };

            initialized = true;
        }
Пример #6
0
        public static void Initialize()
        {
            if (initialized)
            {
                return;
            }

            LoadedDetectionHelper.Initialize();

            LoadedDetectionHelper.SubTreeAdded   += LoadedDetectionHelper_SubTreeAdded;
            LoadedDetectionHelper.SubTreeRemoved += LoadedDetectionHelper_SubTreeRemoved;

            dispatcherTimer          = new DispatcherTimer();
            dispatcherTimer.Interval = TimeSpan.FromMilliseconds(16);
            dispatcherTimer.Tick    += (s, e) =>
            {
                Initialize();
                instance.ExecuteApplyStyles();
            };
            dispatcherTimer.Start();

            initialized = true;
        }