public TreeNodeProviderBase(IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, SelectorType selectorType) { this.dependencyPropertyService = dependencyPropertyService; this.namespaceProvider = new NamespaceProvider <TDependencyObject, TStyle, TDependencyProperty>(dependencyPropertyService); this.selectorType = selectorType; }
public StyleService(IDependencyPropertyService <DependencyObject, Style, DependencyProperty> dependencyService, IMarkupExtensionParser markupExtensionParser) { this.dependencyService = dependencyService; this.markupExtensionParser = markupExtensionParser; this.typeNameResolver = new CssTypeHelper <DependencyObject, DependencyProperty, Style>(markupExtensionParser, dependencyService); }
private static void EnsureParents(IDomElement <TDependencyObject> domElement, ISwitchableTreeNodeProvider <TDependencyObject> switchableTreeNodeProvider, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, INativeStyleService <TStyle, TDependencyObject, TDependencyProperty> nativeStyleService, IDictionary <TDependencyObject, StyleUpdateInfo> styleUpdateInfos) { var current = domElement.Parent; while (current != null) { var styleUpdateInfo = current.StyleInfo = current.StyleInfo ?? (styleUpdateInfos.ContainsKey(current.Element) ? styleUpdateInfos[current.Element] : GetNewStyleUpdateInfo(current, dependencyPropertyService, nativeStyleService)); if ((styleUpdateInfo.DoMatchCheck & switchableTreeNodeProvider.CurrentSelectorType) == switchableTreeNodeProvider.CurrentSelectorType) { return; } object a; "ClassList".Measure(() => a = current.ClassList); //"Id".Measure(() => a = current.Id); "TagName".Measure(() => a = current.TagName); "AssemblyQualifiedNamespaceName".Measure(() => a = current.AssemblyQualifiedNamespaceName); //"HasAttribute".Measure(() => a = current.HasAttribute("Name")); /*// a = domElement.Parent; */ a = current.ChildNodes; current = current.Parent; } }
public static void PrintHerarchyDebugInfo <TDependencyObject, TStyle, TDependencyProperty>( this ITreeNodeProvider <TDependencyObject> treeNodeProvider, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, TDependencyObject styleResourceReferenceHolder, TDependencyObject startFrom ) where TDependencyObject : class where TStyle : class where TDependencyProperty : class { Debug.WriteLine(""); Debug.WriteLine("------------------"); Debug.WriteLine("Print FrameworkElement hierarchy:"); Debug.WriteLine("----------------"); Debug.WriteLine("----------------"); var s = startFrom ?? styleResourceReferenceHolder; Recursive(treeNodeProvider, dependencyPropertyService, s, 0, treeNodeProvider.GetParent(s)); Debug.WriteLine(""); Debug.WriteLine("Print DomElement hierarchy:"); Debug.WriteLine("----------------"); var sDom = treeNodeProvider.GetDomElement(s); RecursiveDom(treeNodeProvider, sDom, 0, (IDomElement <TDependencyObject>)sDom.Parent); Debug.WriteLine("----------------"); Debug.WriteLine("----------------"); }
public static void PrintHerarchyDebugInfo <TDependencyObject, TStyle, TDependencyProperty>( this ITreeNodeProvider <TDependencyObject, TDependencyProperty> treeNodeProvider, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, TDependencyObject styleResourceReferenceHolder, TDependencyObject startFrom, SelectorType type ) where TDependencyObject : class where TStyle : class where TDependencyProperty : class { Debug.WriteLine(""); Debug.WriteLine("------------------"); Debug.WriteLine("Print FrameworkElement hierarchy: " + type.ToString()); Debug.WriteLine("----------------"); Debug.WriteLine("----------------"); var s = startFrom ?? styleResourceReferenceHolder; Recursive(treeNodeProvider, dependencyPropertyService, s, 0, treeNodeProvider.GetParent(s, type), type); Debug.WriteLine(""); Debug.WriteLine("Print DomElement hierarchy: " + type.ToString()); Debug.WriteLine("----------------"); var sDom = treeNodeProvider.GetDomElement(s); RecursiveDom(treeNodeProvider, sDom, 0, type == SelectorType.VisualTree ? sDom.Parent : sDom.LogicalParent, type); Debug.WriteLine("----------------"); Debug.WriteLine("----------------"); }
public CanvasControlHarness( IDependencyPropertyService propertyService, ICanvasRenderer renderer, IVisualService visualService) : base(propertyService, renderer, visualService) { }
public static void Recursive <TDependencyObject, TStyle, TDependencyProperty>( this ITreeNodeProvider <TDependencyObject> treeNodeProvider, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, TDependencyObject element, int level, TDependencyObject expectedParent ) where TDependencyObject : class where TStyle : class where TDependencyProperty : class { if (element == null) { return; } if (expectedParent != treeNodeProvider.GetParent(element)) { Debug.WriteLine("!!!!!"); Debug.WriteLine($"Expected parent: { dependencyPropertyService.GetName(expectedParent) }"); Debug.WriteLine($"Actual parent: { dependencyPropertyService.GetName(treeNodeProvider.GetParent(element)) }"); Debug.WriteLine("!!!!!"); } Debug.WriteLine(new String(' ', level) + element.GetType().Name + "#" + dependencyPropertyService.GetName(element)); var children = treeNodeProvider.GetChildren(element); foreach (var child in children) { Recursive(treeNodeProvider, dependencyPropertyService, child, level + 1, element); } }
public StyleService(IDependencyPropertyService <BindableObject, Style, BindableProperty> dependencyService, IMarkupExtensionParser markupExtensionParser) { this.dependencyService = dependencyService; this.markupExtensionParser = markupExtensionParser; this.typeNameResolver = new CssTypeHelper <BindableObject, BindableProperty, Style>(markupExtensionParser, dependencyService); this.typeConverterProvider = new XamarinTypeConverterProvider(); }
private static void SetupStyleInfo( IDomElement <TDependencyObject> domElement, StyleSheet styleSheet, Dictionary <TDependencyObject, StyleUpdateInfo> styleUpdateInfos, ISwitchableTreeNodeProvider <TDependencyObject> switchableTreeNodeProvider, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, INativeStyleService <TStyle, TDependencyObject, TDependencyProperty> nativeStyleService, bool styleChanged, bool styleSheetRemoved) { var styleUpdateInfo = "get styleUpdateInfo".Measure(() => domElement.StyleInfo = domElement.StyleInfo ?? (styleUpdateInfos.ContainsKey(domElement.Element) ? styleUpdateInfos[domElement.Element] : GetNewStyleUpdateInfo(domElement, dependencyPropertyService, nativeStyleService))); var styleSheetFromDom = "GetStyleSheet".Measure(() => dependencyPropertyService.GetStyleSheet(domElement.Element)); if (styleSheetFromDom != null && styleSheetFromDom != styleSheet) { // another stylesheet's domelement SetupStyleInfo(domElement, styleSheetFromDom, styleUpdateInfos, switchableTreeNodeProvider, dependencyPropertyService, nativeStyleService, styleChanged, false); return; } "set styleUpdateInfo values".Measure(() => { if (!styleSheetRemoved) { styleUpdateInfo.CurrentStyleSheet = styleSheet; } if (styleChanged) { styleUpdateInfo.OldMatchedSelectors = new List <string>(); } styleUpdateInfo.CurrentMatchedSelectors.Clear(); styleUpdateInfo.DoMatchCheck |= switchableTreeNodeProvider.CurrentSelectorType; styleUpdateInfos[domElement.Element] = styleUpdateInfo; }); "fill DomElement".Measure(() => { object a; "ClassList".Measure(() => a = domElement.ClassList); "Id".Measure(() => a = domElement.Id); "TagName".Measure(() => a = domElement.TagName); "NamespaceUri".Measure(() => a = domElement.AssemblyQualifiedNamespaceName); //"HasAttribute".Measure(() => a = domElement.HasAttribute("Name")); /*// a = domElement.Parent; */ }); foreach (var child in domElement.ChildNodes) { SetupStyleInfo(child, styleSheet, styleUpdateInfos, switchableTreeNodeProvider, dependencyPropertyService, nativeStyleService, styleChanged, styleSheetRemoved); } }
public VisualWithLogicalFallbackTreeNodeProvider(IDependencyPropertyService <DependencyObject, Style, DependencyProperty> dependencyPropertyService, ITreeNodeProvider <DependencyObject> visualTreeNodeProvider, ITreeNodeProvider <DependencyObject> logicalTreeNodeProvider ) : base(dependencyPropertyService, SelectorType.VisualTree) { this.VisualTreeNodeProvider = visualTreeNodeProvider; this.LogicalTreeNodeProvider = logicalTreeNodeProvider; }
public SwitchableTreeNodeProvider(IDependencyPropertyService <DependencyObject, DependencyObject, Style, DependencyProperty> dependencyPropertyService, VisualWithLogicalFallbackTreeNodeProvider visualTreeNodeProvider, LogicalTreeNodeProvider logicalTreeNodeProvider ) : base(dependencyPropertyService) { this.visualTreeNodeProvider = visualTreeNodeProvider; this.logicalTreeNodeProvider = logicalTreeNodeProvider; currentTreeNodeProvider = logicalTreeNodeProvider; }
public SwitchableTreeNodeProvider(IDependencyPropertyService <DependencyObject, Style, DependencyProperty> dependencyPropertyService, ITreeNodeProvider <DependencyObject> visualTreeNodeProvider, ITreeNodeProvider <DependencyObject> logicalTreeNodeProvider ) : base(dependencyPropertyService, SelectorType.LogicalTree) { this.visualTreeNodeProvider = visualTreeNodeProvider; this.logicalTreeNodeProvider = logicalTreeNodeProvider; currentTreeNodeProvider = logicalTreeNodeProvider; }
private static StyleUpdateInfo GetNewStyleUpdateInfo(IDomElement <TDependencyObject, TDependencyProperty> domElement, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, INativeStyleService <TStyle, TDependencyObject, TDependencyProperty> nativeStyleService) { var initialStyle = nativeStyleService.GetStyle(domElement.Element); return(new StyleUpdateInfo { MatchedType = domElement.Element.GetType(), InitialStyle = initialStyle }); }
public CanvasControl( IDependencyPropertyService propertyService, ICanvasRenderer renderer, IVisualService visualService) { _propertyService = propertyService; _renderer = renderer; _visualService = visualService; // TODO: Should this be moved into an initialize method? _propertyService.SetSource(this); _visualService.SetSource(this); }
private static StyleSheet GetStyleSheetFromTree(IDomElement <TDependencyObject, TDependencyProperty> domElement, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService) { var current = domElement; StyleSheet styleSheet = null; while (current != null && (styleSheet = dependencyPropertyService.GetStyleSheet(current.Element)) == null) { current = current.Parent; } return(styleSheet); }
private static void SetupStyleInfo( IDomElement <TDependencyObject, TDependencyProperty> domElement, StyleSheet styleSheet, Dictionary <TDependencyObject, StyleUpdateInfo> styleUpdateInfos, ITreeNodeProvider <TDependencyObject, TDependencyProperty> treeNodeProvider, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, INativeStyleService <TStyle, TDependencyObject, TDependencyProperty> nativeStyleService, bool styleChanged, bool styleSheetRemoved, SelectorType type) { if (!domElement.IsReady) { return; } var styleUpdateInfo = domElement.StyleInfo = domElement.StyleInfo ?? (styleUpdateInfos.ContainsKey(domElement.Element) ? styleUpdateInfos[domElement.Element] : GetNewStyleUpdateInfo(domElement, dependencyPropertyService, nativeStyleService)); styleUpdateInfos[domElement.Element] = styleUpdateInfo; var styleSheetFromDom = dependencyPropertyService.GetStyleSheet(domElement.Element); if (styleSheetFromDom != null && styleSheetFromDom != styleSheet) { // another stylesheet's domelement SetupStyleInfo(domElement, styleSheetFromDom, styleUpdateInfos, treeNodeProvider, dependencyPropertyService, nativeStyleService, styleChanged, false, type); return; } if (!styleSheetRemoved) { styleUpdateInfo.CurrentStyleSheet = styleSheet; } if (styleChanged) { styleUpdateInfo.OldMatchedSelectors = new LinkedHashSet <ISelector>(); } styleUpdateInfo.CurrentMatchedSelectors.Clear(); styleUpdateInfo.CurrentMatchedResourceKeys.Clear(); styleUpdateInfo.DoMatchCheck |= type; var children = type == SelectorType.VisualTree ? domElement.ChildNodes : domElement.LogicalChildNodes; foreach (var child in children) { SetupStyleInfo(child, styleSheet, styleUpdateInfos, treeNodeProvider, dependencyPropertyService, nativeStyleService, styleChanged, styleSheetRemoved, type); } }
private static StyleUpdateInfo GetNewStyleUpdateInfo(IDomElement <TDependencyObject> domElement, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, INativeStyleService <TStyle, TDependencyObject, TDependencyProperty> nativeStyleService) { if (dependencyPropertyService.GetInitialStyle(domElement.Element) == null) { dependencyPropertyService.SetInitialStyle(domElement.Element, nativeStyleService.GetStyle(domElement.Element)); } return(new StyleUpdateInfo { MatchedType = domElement.Element.GetType() }); }
public BaseCss(IDependencyPropertyService <TDependencyObject, TUIElement, TStyle, TDependencyProperty> dependencyPropertyService, ITreeNodeProvider <TDependencyObject> treeNodeProvider, IStyleResourcesService applicationResourcesService, INativeStyleService <TStyle, TDependencyObject, TDependencyProperty> nativeStyleService, string defaultCssNamespace, IMarkupExtensionParser markupExpressionParser, Action <Action> uiInvoker) { this.dependencyPropertyService = dependencyPropertyService; this.treeNodeProvider = treeNodeProvider; this.applicationResourcesService = applicationResourcesService; this.nativeStyleService = nativeStyleService; this.markupExpressionParser = markupExpressionParser; this.uiInvoker = uiInvoker; CssParser.Initialize(defaultCssNamespace); }
private static void SetAttachedToToNull(List <RenderInfo <TDependencyObject> > copy, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, ITreeNodeProvider <TDependencyObject, TDependencyProperty> treeNodeProvider, INativeStyleService <TStyle, TDependencyObject, TDependencyProperty> nativeStyleService) { var removedStyleSheets = copy .Where(x => x.RenderTargetKind == RenderTargetKind.Stylesheet && x.ChangeKind == ChangeKind.Remove) .Select(x => x.StyleSheet) .Distinct() .ToList(); foreach (var removedStyleSheet in removedStyleSheets) { ReevaluateStylesheetInSubTree(treeNodeProvider.GetDomElement((TDependencyObject)removedStyleSheet.AttachedTo), removedStyleSheet, dependencyPropertyService, nativeStyleService); removedStyleSheet.AttachedTo = null; } }
private static void SetAttachedToToNewStyleSheet(List <RenderInfo <TDependencyObject> > copy, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, ITreeNodeProvider <TDependencyObject, TDependencyProperty> treeNodeProvider, INativeStyleService <TStyle, TDependencyObject, TDependencyProperty> nativeStyleService) { var addedStyleSheets = copy .Where(x => x.RenderTargetKind == RenderTargetKind.Stylesheet && x.ChangeKind == ChangeKind.New) .Select(x => new { x.StyleSheet, x.StyleSheetHolder }) .Distinct() .ToList(); foreach (var item in addedStyleSheets) { var domElement = treeNodeProvider.GetDomElement(item.StyleSheetHolder); item.StyleSheet.AttachedTo = item.StyleSheetHolder; ReevaluateStylesheetInSubTree(domElement, domElement.StyleInfo?.CurrentStyleSheet, dependencyPropertyService, nativeStyleService); } }
public BaseCss(IDependencyPropertyService <TDependencyObject, TUIElement, TStyle, TDependencyProperty> dependencyPropertyService, ITreeNodeProvider <TDependencyObject> treeNodeProvider, IStyleResourcesService applicationResourcesService, INativeStyleService <TStyle, TDependencyObject, TDependencyProperty> nativeStyleService, string defaultCssNamespace, IMarkupExtensionParser markupExpressionParser, Action <Action> uiInvoker, ICssFileProvider fileProvider) { this.dependencyPropertyService = dependencyPropertyService; this.treeNodeProvider = treeNodeProvider; this.applicationResourcesService = applicationResourcesService; this.nativeStyleService = nativeStyleService; this.markupExpressionParser = markupExpressionParser; this.uiInvoker = uiInvoker; this.cssTypeHelper = new CssTypeHelper <TDependencyObject, TUIElement, TDependencyProperty, TStyle>(markupExpressionParser, dependencyPropertyService); CssParser.Initialize(defaultCssNamespace, fileProvider); StyleSheet.GetParent = parent => treeNodeProvider.GetParent((TDependencyObject)parent); StyleSheet.GetStyleSheet = treeNode => dependencyPropertyService.GetStyleSheet((TDependencyObject)treeNode); }
private static void EnsureParents(IDomElement <TDependencyObject, TDependencyProperty> domElement, ITreeNodeProvider <TDependencyObject, TDependencyProperty> treeNodeProvider, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, INativeStyleService <TStyle, TDependencyObject, TDependencyProperty> nativeStyleService, IDictionary <TDependencyObject, StyleUpdateInfo> styleUpdateInfos, SelectorType type) { var current = type == SelectorType.VisualTree ? domElement.Parent : domElement.LogicalParent; while (current != null && current.IsReady) { var styleUpdateInfo = current.StyleInfo = current.StyleInfo ?? (styleUpdateInfos.ContainsKey(current.Element) ? styleUpdateInfos[current.Element] : GetNewStyleUpdateInfo(current, dependencyPropertyService, nativeStyleService)); if ((styleUpdateInfo.DoMatchCheck & type) != type) { return; } object a; a = current.ClassList; //"Id".Measure(() => a = current.Id); a = current.TagName; a = current.AssemblyQualifiedNamespaceName; //"HasAttribute".Measure(() => a = current.HasAttribute("Name")); /*// a = domElement.Parent; */ if (type == SelectorType.VisualTree) { a = current.ChildNodes; current = current.Parent; } else { a = current.LogicalChildNodes; current = current.LogicalParent; } } }
private static void ReevaluateStylesheetInSubTree(IDomElement <TDependencyObject> domElement, StyleSheet oldStyleSheet, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, INativeStyleService <TStyle, TDependencyObject, TDependencyProperty> nativeStyleService) { if (domElement.StyleInfo == null) { return; } if (domElement == null || domElement.StyleInfo.CurrentStyleSheet != oldStyleSheet) { return; } domElement.StyleInfo.CurrentStyleSheet = GetStyleSheetFromTree(domElement, dependencyPropertyService); foreach (var child in domElement.ChildNodes) { ReevaluateStylesheetInSubTree(child, oldStyleSheet, dependencyPropertyService, nativeStyleService); } }
private static void ReevaluateStylesheetInSubTree(IDomElement <TDependencyObject, TDependencyProperty> domElement, StyleSheet oldStyleSheet, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, INativeStyleService <TStyle, TDependencyObject, TDependencyProperty> nativeStyleService) { if (domElement.StyleInfo == null) { return; } if (domElement == null || !ReferenceEquals(domElement.StyleInfo.CurrentStyleSheet, oldStyleSheet)) { return; } domElement.StyleInfo.CurrentStyleSheet = GetStyleSheetFromTree(domElement, dependencyPropertyService); domElement.ClearAttributeWatcher(); foreach (var child in domElement.LogicalChildNodes.Concat(domElement.ChildNodes).Distinct().ToList()) { ReevaluateStylesheetInSubTree(child, oldStyleSheet, dependencyPropertyService, nativeStyleService); } }
public static void Recursive <TDependencyObject, TStyle, TDependencyProperty>( this ITreeNodeProvider <TDependencyObject, TDependencyProperty> treeNodeProvider, IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService, TDependencyObject element, int level, TDependencyObject expectedParent, SelectorType type ) where TDependencyObject : class where TStyle : class where TDependencyProperty : class { if (element == null) { return; } var providerParent = treeNodeProvider.GetParent(element, type); if (expectedParent != providerParent) { Debug.WriteLine($"!!!!! element: '{element.ToString()}'"); Debug.WriteLine($"Expected parent: { dependencyPropertyService.GetName(expectedParent) } {expectedParent.GetType().Name} '{expectedParent.ToString()}'"); Debug.WriteLine($"Provider parent: { (providerParent != null ? dependencyPropertyService.GetName(providerParent) : "NULL!") } {(providerParent != null ? treeNodeProvider.GetParent(element, type).GetType().Name : "NULL!")}"); Debug.WriteLine("!!!!!"); } Debug.WriteLine(new String(' ', level * 2) + element.GetType().Name + "#" + dependencyPropertyService.GetName(element)); var children = treeNodeProvider.GetChildren(element, type); foreach (var child in children) { Recursive(treeNodeProvider, dependencyPropertyService, child, level + 1, element, type); } }
public VisualTreeNodeProvider(IDependencyPropertyService <BindableObject, BindableObject, Style, BindableProperty> dependencyPropertyService) : base(dependencyPropertyService) { }
public LogicalTreeNodeProvider(IDependencyPropertyService <DependencyObject, DependencyObject, Style, DependencyProperty> dependencyPropertyService) : base(dependencyPropertyService) { }
public TreeNodeProviderBase(IDependencyPropertyService <TDependencyObject, TStyle, TDependencyProperty> dependencyPropertyService) { this.dependencyPropertyService = dependencyPropertyService; }
public TreeNodeProvider(IDependencyPropertyService <DependencyObject, Style, DependencyProperty> dependencyPropertyService) : base(dependencyPropertyService) { this.applicationDependencyObject = new ApplicationDependencyObject(Application.Current); }
public CssTypeHelper(IMarkupExtensionParser markupExpressionParser, IDependencyPropertyService <TDependencyObject, TUIElement, TStyle, TDependencyProperty> dependencyPropertyService) { this.markupExpressionParser = markupExpressionParser; this.dependencyPropertyService = dependencyPropertyService; }