private void OnMergedDictionariesChanged(object sender, NotifyCollectionChangedEventArgs e) { ResourceDictionary item; ResourcesChangeInfo catastrophicDictionaryChangeInfo; bool flag; List <ResourceDictionary> resourceDictionaries = null; List <ResourceDictionary> resourceDictionaries1 = null; if (e.Action == NotifyCollectionChangedAction.Reset) { catastrophicDictionaryChangeInfo = ResourcesChangeInfo.CatastrophicDictionaryChangeInfo; } else { if (e.NewItems == null || e.NewItems.Count <= 0) { flag = e.OldItems == null ? false : e.OldItems.Count > 0; } else { flag = true; } System.Diagnostics.Debug.Assert(flag, "The NotifyCollectionChanged event fired when no dictionaries were added or removed"); if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Replace) { resourceDictionaries = new List <ResourceDictionary>(e.OldItems.Count); for (int i = 0; i < e.OldItems.Count; i++) { item = (ResourceDictionary)e.OldItems[i]; resourceDictionaries.Add(item); this.RemoveParentOwners(item); } } if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Replace) { resourceDictionaries1 = new List <ResourceDictionary>(e.NewItems.Count); for (int j = 0; j < e.NewItems.Count; j++) { item = (ResourceDictionary)e.NewItems[j]; resourceDictionaries1.Add(item); if (!this.HasImplicitStyles && item.HasImplicitStyles) { this.HasImplicitStyles = true; } this.PropagateParentOwners(item); } } catastrophicDictionaryChangeInfo = new ResourcesChangeInfo(resourceDictionaries, resourceDictionaries1, false, false, null); } this.NotifyOwners(catastrophicDictionaryChangeInfo); }
private void NotifyOwners(ResourcesChangeInfo info) { bool isInitialized = this.IsInitialized; bool flag = !info.IsResourceAddOperation ? false : this.HasImplicitStyles; if (isInitialized || flag) { if (this.ownerFEs != null) { for (int i = 0; i < this.ownerFEs.Count; i++) { if (flag) { this.ownerFEs[i].ShouldLookupImplicitStyles = true; } if (isInitialized) { throw new NotImplementedException(); ////TreeWalkHelper.InvalidateOnResourcesChange(this.ownerFEs[i], null, info); } } } } }
private void WritePrivateFlag(ResourcesChangeInfo.PrivateFlags bit, bool value) { if (value) { ResourcesChangeInfo resourcesChangeInfo = this; resourcesChangeInfo.flags = (ResourcesChangeInfo.PrivateFlags)((byte)(resourcesChangeInfo.flags | bit)); return; } ResourcesChangeInfo resourcesChangeInfo1 = this; resourcesChangeInfo1.flags = (ResourcesChangeInfo.PrivateFlags)((byte)((byte)resourcesChangeInfo1.flags & (byte)(~bit))); }
private bool ReadPrivateFlag(ResourcesChangeInfo.PrivateFlags bit) { return (byte)(this.flags & bit) != 0; }
private void OnMergedDictionariesChanged(object sender, NotifyCollectionChangedEventArgs e) { ResourceDictionary item; ResourcesChangeInfo catastrophicDictionaryChangeInfo; bool flag; List<ResourceDictionary> resourceDictionaries = null; List<ResourceDictionary> resourceDictionaries1 = null; if (e.Action == NotifyCollectionChangedAction.Reset) { catastrophicDictionaryChangeInfo = ResourcesChangeInfo.CatastrophicDictionaryChangeInfo; } else { if (e.NewItems == null || e.NewItems.Count <= 0) { flag = e.OldItems == null ? false : e.OldItems.Count > 0; } else { flag = true; } System.Diagnostics.Debug.Assert(flag, "The NotifyCollectionChanged event fired when no dictionaries were added or removed"); if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Replace) { resourceDictionaries = new List<ResourceDictionary>(e.OldItems.Count); for (int i = 0; i < e.OldItems.Count; i++) { item = (ResourceDictionary)e.OldItems[i]; resourceDictionaries.Add(item); this.RemoveParentOwners(item); } } if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Replace) { resourceDictionaries1 = new List<ResourceDictionary>(e.NewItems.Count); for (int j = 0; j < e.NewItems.Count; j++) { item = (ResourceDictionary)e.NewItems[j]; resourceDictionaries1.Add(item); if (!this.HasImplicitStyles && item.HasImplicitStyles) { this.HasImplicitStyles = true; } this.PropagateParentOwners(item); } } catastrophicDictionaryChangeInfo = new ResourcesChangeInfo(resourceDictionaries, resourceDictionaries1, false, false, null); } this.NotifyOwners(catastrophicDictionaryChangeInfo); }
private void OnMergedDictionariesChanged(object sender, NotifyCollectionChangedEventArgs e) { List <ResourceDictionary> oldDictionaries = null; List <ResourceDictionary> newDictionaries = null; ResourceDictionary mergedDictionary; ResourcesChangeInfo info; if (e.Action != NotifyCollectionChangedAction.Reset) { Debug.Assert( (e.NewItems != null && e.NewItems.Count > 0) || (e.OldItems != null && e.OldItems.Count > 0), "The NotifyCollectionChanged event fired when no dictionaries were added or removed"); // If one or more resource dictionaries were removed we // need to remove the owners they were given by their // parent ResourceDictionary. if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Replace) { oldDictionaries = new List <ResourceDictionary>(e.OldItems.Count); for (int i = 0; i < e.OldItems.Count; i++) { mergedDictionary = (ResourceDictionary)e.OldItems[i]; oldDictionaries.Add(mergedDictionary); this.RemoveParentOwners(mergedDictionary); } } // If one or more resource dictionaries were added to the merged // dictionaries collection we need to send down the parent // ResourceDictionary's owners. if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Replace) { newDictionaries = new List <ResourceDictionary>(e.NewItems.Count); for (int i = 0; i < e.NewItems.Count; i++) { mergedDictionary = (ResourceDictionary)e.NewItems[i]; newDictionaries.Add(mergedDictionary); // If the merged dictionary HasImplicitStyle mark the outer dictionary the same. if (!this.HasImplicitStyles && mergedDictionary.HasImplicitStyles) { this.HasImplicitStyles = true; } // If the merged dictionary HasImplicitDataTemplates mark the outer dictionary the same. if (!this.HasImplicitDataTemplates && mergedDictionary.HasImplicitDataTemplates) { this.HasImplicitDataTemplates = true; } // If the parent dictionary is a theme dictionary mark the merged dictionary the same. if (this.IsThemeDictionary) { mergedDictionary.IsThemeDictionary = true; } this.PropagateParentOwners(mergedDictionary); } } info = new ResourcesChangeInfo(oldDictionaries, newDictionaries, false, false, null); } else { // Case when MergedDictionary collection is cleared info = ResourcesChangeInfo.CatastrophicDictionaryChangeInfo; } // Notify the owners of the change and fire // invalidation if already initialized this.NotifyOwners(info); }
// Call FrameworkElement.InvalidateTree with the right data private void NotifyOwners(ResourcesChangeInfo info) { bool shouldInvalidate = this.IsInitialized; bool hasImplicitStyles = info.IsResourceAddOperation && this.HasImplicitStyles; //if (shouldInvalidate && InvalidatesImplicitDataTemplateResources) //{ // info.SetIsImplicitDataTemplateChange(); //} if (shouldInvalidate || hasImplicitStyles) { // Invalidate all FE owners if (this._ownerFEs != null) { foreach (FrameworkElement fe in this._ownerFEs) { if (fe != null) { // Set the HasImplicitStyles flag on the owner if (hasImplicitStyles) { fe.ShouldLookupImplicitStyles = true; } // todo: implement this. //// If this dictionary has been initialized fire an invalidation //// to let the tree know of this change. //if (shouldInvalidate) //{ // TreeWalkHelper.InvalidateOnResourcesChange(fe, null, info); //} } } } // Invalidate all App owners if (this._ownerApps != null) { foreach (Application app in this._ownerApps) { if (app != null) { // Set the HasImplicitStyles flag on the owner if (hasImplicitStyles) { app.HasImplicitStylesInResources = true; } // todo: implement this. //// If this dictionary has been initialized fire an invalidation //// to let the tree know of this change. //if (shouldInvalidate) //{ // app.InvalidateResourceReferences(info); //} } } } } }