Example #1
0
        public static void Initialize()
        {
            if (initialized)
            {
                return;
            }

            initialized = true;

            var dispatcher = Application.Current?.Dispatcher ?? Dispatcher.CurrentDispatcher;
            IDependencyPropertyService <DependencyObject, DependencyObject, Style, DependencyProperty> dependencyPropertyService =
                new DependencyPropertyService();
            var visualTreeNodeProvider  = new VisualTreeNodeProvider(dependencyPropertyService);
            var logicalTreeNodeProvider = new LogicalTreeNodeProvider(dependencyPropertyService);
            var markupExtensionParser   = new MarkupExtensionParser();
            var cssTypeHelper           = new CssTypeHelper <DependencyObject, DependencyObject, DependencyProperty, Style>(markupExtensionParser, dependencyPropertyService);

            instance = new BaseCss <DependencyObject, DependencyObject, Style, DependencyProperty>(
                dependencyPropertyService,
                new SwitchableTreeNodeProvider(
                    dependencyPropertyService,
                    new VisualWithLogicalFallbackTreeNodeProvider(dependencyPropertyService, visualTreeNodeProvider, logicalTreeNodeProvider),
                    logicalTreeNodeProvider),
                new StyleResourceService(),
                new StyleService(new DependencyPropertyService(), new MarkupExtensionParser()),
                DomElementBase <DependencyObject, DependencyProperty> .GetPrefix(typeof(System.Windows.Controls.Button)),
                markupExtensionParser,
                dispatcher.Invoke,
                new CssFileProvider(cssTypeHelper)
                );

            CompositionTarget.Rendering += RenderingHandler();

            LoadedDetectionHelper.Initialize();
        }
Example #2
0
        public static void Initialize()
        {
            if (initialized)
            {
                return;
            }

            initialized = true;

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

            TypeHelpers.Initialze(mapping);

            CompositionTarget.Rendering += RenderingHandler();

            var dispatcher = Application.Current?.Dispatcher ?? Dispatcher.CurrentDispatcher;
            IDependencyPropertyService <DependencyObject, Style, DependencyProperty> dependencyPropertyService =
                new DependencyPropertyService();
            var visualTreeNodeProvider  = new VisualTreeNodeProvider(dependencyPropertyService);
            var logicalTreeNodeProvider = new LogicalTreeNodeProvider(dependencyPropertyService);
            var visualTreeNodeWithLogicalFallbackProvider = new VisualWithLogicalFallbackTreeNodeProvider(dependencyPropertyService, visualTreeNodeProvider, logicalTreeNodeProvider);
            var markupExtensionParser      = new MarkupExtensionParser();
            var cssTypeHelper              = new CssTypeHelper <DependencyObject, DependencyProperty, Style>(markupExtensionParser, dependencyPropertyService);
            var switchableTreeNodeProvider = new SwitchableTreeNodeProvider(dependencyPropertyService, visualTreeNodeWithLogicalFallbackProvider, logicalTreeNodeProvider);
            var defaultCssNamespace        = DomElementBase <DependencyObject, DependencyProperty> .GetAssemblyQualifiedNamespaceName(typeof(System.Windows.Controls.Button));

            instance = new BaseCss <DependencyObject, Style, DependencyProperty>(
                dependencyPropertyService,
                switchableTreeNodeProvider,
                new StyleResourceService(),
                new StyleService(new DependencyPropertyService(), new MarkupExtensionParser()),
                defaultCssNamespace,
                markupExtensionParser,
                dispatcher.Invoke,
                new CssFileProvider(cssTypeHelper)
                );

            // Warmup(markupExtensionParser, defaultCssNamespace);

            LoadedDetectionHelper.Initialize();
        }
Example #3
0
        public static void Initialize(IDictionary <string, List <string> > cssNamespaceMapping = null)
        {
            if (initialized)
            {
                return;
            }

            initialized = true;

            cssNamespaceMapping = cssNamespaceMapping ?? DefaultCssNamespaceMapping;

            TypeHelpers.Initialze(cssNamespaceMapping);

            var defaultCssNamespace       = cssNamespaceMapping.Keys.First();
            var dispatcher                = Application.Current?.Dispatcher ?? Dispatcher.CurrentDispatcher;
            var dependencyPropertyService = new DependencyPropertyService();
            var visualTreeNodeWithLogicalFallbackProvider = new TreeNodeProvider(dependencyPropertyService);
            var markupExtensionParser = new MarkupExtensionParser();
            var cssTypeHelper         = new CssTypeHelper <DependencyObject, DependencyProperty, Style>(markupExtensionParser, dependencyPropertyService);

            instance = new BaseCss <DependencyObject, Style, DependencyProperty>(
                dependencyPropertyService,
                visualTreeNodeWithLogicalFallbackProvider,
                new StyleResourceService(),
                new StyleService(new DependencyPropertyService(), new MarkupExtensionParser()),
                defaultCssNamespace,
                markupExtensionParser,
                dispatcher.Invoke,
                new CssFileProvider(cssTypeHelper)
                );


            // mix CompositionTarget.Rendering and DispatcherTimer for better UI responsiveness
            CompositionTarget.Rendering += RenderingHandler;

            timer          = new DispatcherTimer(DispatcherPriority.Render);
            timer.Interval = TimeSpan.FromMilliseconds(5);
            timer.Tick    += (s, e) =>
            {
                instance?.ExecuteApplyStyles();
            };
            timer.Start();

            // Warmup(markupExtensionParser, defaultCssNamespace);
            //Warm();

            LoadedDetectionHelper.Initialize();
        }
Example #4
0
        public static void Initialize(IDictionary <string, List <string> > cssNamespaceMapping = null)
        {
            if (initialized)
            {
                return;
            }

            initialized = true;

            cssNamespaceMapping = cssNamespaceMapping ?? DefaultCssNamespaceMapping;

            TypeHelpers.Initialze(cssNamespaceMapping);

            var defaultCssNamespace       = cssNamespaceMapping.Keys.First();
            var dispatcher                = Application.Current?.Dispatcher ?? Dispatcher.CurrentDispatcher;
            var dependencyPropertyService = new DependencyPropertyService();
            var visualTreeNodeWithLogicalFallbackProvider = new TreeNodeProvider(dependencyPropertyService);
            var markupExtensionParser = new MarkupExtensionParser();
            var cssTypeHelper         = new CssTypeHelper <DependencyObject, DependencyProperty, Style>(markupExtensionParser, dependencyPropertyService);

            instance = new BaseCss <DependencyObject, Style, DependencyProperty>(
                dependencyPropertyService,
                visualTreeNodeWithLogicalFallbackProvider,
                new StyleResourceService(),
                new StyleService(new DependencyPropertyService(), new MarkupExtensionParser()),
                defaultCssNamespace,
                markupExtensionParser,
                dispatcher.Invoke,
                new CssFileProvider(cssTypeHelper)
                );


            // add CompositionTarget.Rendering handler for startup
            CompositionTarget.Rendering += RenderingHandler;

            timer          = new System.Timers.Timer(16);
            timer.Elapsed += Timer_Elapsed;
            timer.Start();

            // Warmup(markupExtensionParser, defaultCssNamespace);
            //Warm();

            LoadedDetectionHelper.Initialize();
        }
Example #5
0
        public static void Initialize()
        {
            if (initialized)
            {
                return;
            }

            initialized = true;

            instance = new BaseCss <DependencyObject, DependencyObject, Style, DependencyProperty>(
                new DependencyPropertyService(),
                new LogicalTreeNodeProvider(new DependencyPropertyService()),
                new StyleResourceService(),
                new StyleService(new DependencyPropertyService(), new MarkupExtensionParser()),
                DomElementBase <DependencyObject, DependencyProperty> .GetPrefix(typeof(System.Windows.Controls.Button)),
                new MarkupExtensionParser(),
                Application.Current.Dispatcher.Invoke,
                new CssFileProvider()
                );

            CompositionTarget.Rendering += RenderingHandler();

            LoadedDetectionHelper.Initialize();
        }
Example #6
0
 public static void Initialize()
 {
     LoadedDetectionHelper.Initialize();
 }