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; }
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; }
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(); }
public static void Initialize(Element rootElement, Assembly[] resourceSearchAssemblies = null) { lock (lockObject) { if (initialized && rootElement == Css.rootElement) { return; } Reset(); var markupExtensionParser = new MarkupExtensionParser(); var dependencyPropertyService = new DependencyPropertyService(); var cssTypeHelper = new CssTypeHelper <BindableObject, BindableObject, BindableProperty, Style>(markupExtensionParser, dependencyPropertyService); instance = new BaseCss <BindableObject, BindableObject, Style, BindableProperty>( dependencyPropertyService, new LogicalTreeNodeProvider(dependencyPropertyService), new StyleResourceService(), new StyleService(dependencyPropertyService, markupExtensionParser), DomElementBase <BindableObject, Element> .GetPrefix(typeof(Button)), markupExtensionParser, Device.BeginInvokeOnMainThread, new CssFileProvider(resourceSearchAssemblies ?? new Assembly[0], cssTypeHelper) ); Css.rootElement = rootElement; VisualTreeHelper.SubTreeAdded += VisualTreeHelper_ChildAdded; VisualTreeHelper.SubTreeRemoved += VisualTreeHelper_ChildRemoved; VisualTreeHelper.Initialize(rootElement); if (rootElement is Application) { var application = rootElement as Application; if (application.MainPage == null) { PropertyChangedEventHandler handler = null; handler = (s, e) => { if (e.PropertyName == nameof(Application.MainPage)) { application.PropertyChanged -= handler; VisualTreeHelper.Include(application.MainPage); } }; application.PropertyChanged += handler; } } StartUiTimer(); initialized = true; } }
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(); }
public static void Reset() { if (!initialized) { return; } CompositionTarget.Rendering -= RenderingHandler; LoadedDetectionHelper.Reset(); instance = null; initialized = false; }
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(); }
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; }
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(); }
public static void Reset() { lock (lockObject) { if (initialized == false) { return; } VisualTreeHelper.SubTreeAdded -= VisualTreeHelper_ChildAdded; VisualTreeHelper.SubTreeRemoved -= VisualTreeHelper_ChildRemoved; VisualTreeHelper.Reset(); uiTimer?.Cancel(); uiTimer?.Dispose(); uiTimer = null; instance = null; initialized = false; } }
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(); }
public static void Initialize(Element rootElement, Assembly[] resourceSearchAssemblies = null, IDictionary <string, List <string> > cssNamespaceMapping = null) { lock (lockObject) { if (initialized && rootElement == Css.rootElement) { return; } Reset(); cssNamespaceMapping = cssNamespaceMapping ?? DefaultCssNamespaceMapping; TypeHelpers.Initialze(cssNamespaceMapping, true); var defaultCssNamespace = cssNamespaceMapping.Keys.First(); var markupExtensionParser = new MarkupExtensionParser(); var dependencyPropertyService = new DependencyPropertyService(); var cssTypeHelper = new CssTypeHelper <BindableObject, BindableProperty, Style>(markupExtensionParser, dependencyPropertyService); instance = new BaseCss <BindableObject, Style, BindableProperty>( dependencyPropertyService, new TreeNodeProvider(dependencyPropertyService), new StyleResourceService(), new StyleService(dependencyPropertyService, markupExtensionParser), defaultCssNamespace, markupExtensionParser, Device.BeginInvokeOnMainThread, new CssFileProvider(resourceSearchAssemblies ?? new Assembly[0], cssTypeHelper) ); Css.rootElement = rootElement; //VisualTreeHelper.SubTreeAdded += VisualTreeHelper_ChildAdded; //VisualTreeHelper.SubTreeRemoved += VisualTreeHelper_ChildRemoved; LoadedDetectionHelper.Initialize(rootElement); if (rootElement is Application) { var application = rootElement as Application; if (application.MainPage == null) { PropertyChangedEventHandler handler = null; handler = (s, e) => { if (e.PropertyName == nameof(Application.MainPage)) { application.PropertyChanged -= handler; //VisualTreeHelper.Include(application.MainPage); } }; application.PropertyChanged += handler; } } StartUiTimer(); initialized = true; } }
public static void Initialize(Element rootElement, Assembly[] resourceSearchAssemblies = null) { lock (lockObject) { if (initialized && rootElement == Css.rootElement) { return; } Reset(); var mapping = new Dictionary <string, List <string> > { { "http://xamarin.com/schemas/2014/forms", new List <string> { typeof(Xamarin.Forms.Button).AssemblyQualifiedName.Replace(".Button,", ","), } } }; TypeHelpers.Initialze(mapping, true); var markupExtensionParser = new MarkupExtensionParser(); var dependencyPropertyService = new DependencyPropertyService(); var cssTypeHelper = new CssTypeHelper <BindableObject, BindableProperty, Style>(markupExtensionParser, dependencyPropertyService); instance = new BaseCss <BindableObject, Style, BindableProperty>( dependencyPropertyService, new LogicalTreeNodeProvider(dependencyPropertyService), new StyleResourceService(), new StyleService(dependencyPropertyService, markupExtensionParser), DomElementBase <BindableObject, Element> .GetAssemblyQualifiedNamespaceName(typeof(Button)), markupExtensionParser, Device.BeginInvokeOnMainThread, new CssFileProvider(resourceSearchAssemblies ?? new Assembly[0], cssTypeHelper) ); Css.rootElement = rootElement; VisualTreeHelper.SubTreeAdded += VisualTreeHelper_ChildAdded; VisualTreeHelper.SubTreeRemoved += VisualTreeHelper_ChildRemoved; VisualTreeHelper.Initialize(rootElement); if (rootElement is Application) { var application = rootElement as Application; if (application.MainPage == null) { PropertyChangedEventHandler handler = null; handler = (s, e) => { if (e.PropertyName == nameof(Application.MainPage)) { application.PropertyChanged -= handler; VisualTreeHelper.Include(application.MainPage); } }; application.PropertyChanged += handler; } } StartUiTimer(); initialized = true; } }