private static void MarkAllPropertiesDisassociated(ObservableCollectionWorkaround <PropertyEntry> propertyList) { foreach (ModelPropertyEntry property in propertyList) { property.Disassociated = true; } }
private void IncrementallyChangeList <T>(ObservableCollectionWorkaround <T> oldList, IList <T> newList, IComparer <T> comparer) { if (newList.Count == 0) { oldList.Clear(); } else { IList <T> list; if (oldList.Count == 0) { list = newList; } else { HashSet <T> oldItemsSet = new HashSet <T>((IEnumerable <T>)oldList); list = (IList <T>)Enumerable.ToList <T>(Enumerable.Where <T>((IEnumerable <T>)newList, (Func <T, bool>)(item => !oldItemsSet.Contains(item)))); oldItemsSet.ExceptWith((IEnumerable <T>)newList); EnumerableExtensions.ForEach <T>((IEnumerable <T>)oldItemsSet, (Action <T>)(item => ((Collection <T>)oldList).Remove(item))); } foreach (T obj in (IEnumerable <T>)list) { int index = oldList.BinarySearch(obj, comparer); if (index < 0) { index = ~index; } oldList.Insert(index, obj); } } }
public ElementNode(SceneElement element, SelectionContext <ElementNode> selectionContext) { this.element = element; this.selectionContext = selectionContext; this.children = new ObservableCollectionWorkaround <ElementNode>(); this.selectCommand = new DelegateCommand(new DelegateCommand.SimpleEventHandler(this.ElementNode_OnSelected)); this.doubleClickCommand = new DelegateCommand(new DelegateCommand.SimpleEventHandler(this.ElementNode_OnDoubleClick)); this.isSelectable = true; }
protected override bool UpdateAssets() { if (!this.NeedsUpdate) { return(false); } this.NeedsUpdate = false; ObservableCollectionWorkaround <Asset> collectionWorkaround = this.Assets.Clone(); List <Asset> list = new List <Asset>(collectionWorkaround.Count); this.Assets.Clear(); foreach (AssetProvider assetProvider in this.assetProviders) { foreach (Asset asset in (Collection <Asset>)assetProvider.Assets) { list.Add(asset); } } collectionWorkaround.Sort(Asset.DefaultComparer); list.Sort(Asset.DefaultComparer); int index1 = 0; int index2 = 0; while (index1 < collectionWorkaround.Count && index2 < list.Count) { int num = collectionWorkaround[index1].CompareTo(list[index2]); if (num == 0) { this.Assets.Add(list[index2]); ++index1; ++index2; } else if (num < 0) { collectionWorkaround[index1++].IsValid = false; } else { this.Assets.Add(list[index2++]); } } while (index1 < collectionWorkaround.Count) { collectionWorkaround[index1++].IsValid = false; } while (index2 < list.Count) { this.Assets.Add(list[index2++]); } foreach (Asset asset in (Collection <Asset>) this.Assets) { asset.IsValid = true; } this.NotifyAssetsChanged(); return(true); }
public SceneNodeCategory(CategoryLocalizationHelper.CategoryName canonicalName, string localizedName, IMessageLoggingService messageLogger) : base(localizedName) { this.canonicalName = canonicalName; this.messageLogger = messageLogger; this.CategoryEditors.CollectionChanged += new NotifyCollectionChangedEventHandler(this.CategoryEditors_CollectionChanged); this.basicProperties = new ObservableCollectionWorkaround <PropertyEntry>(); this.advancedProperties = new ObservableCollectionWorkaround <PropertyEntry>(); this.order = new SceneNodeCategory.CategoryOrder(this); this.InitializeIcons(); }
protected virtual ObservableCollectionWorkaround <LocalResourceModel> ProvideLocalResources(List <ResourceContainer> activeContainers) { ObservableCollectionWorkaround <LocalResourceModel> collectionWorkaround = new ObservableCollectionWorkaround <LocalResourceModel>(); foreach (DocumentCompositeNode entryNode in this.DesignerContext.ResourceManager.GetResourcesInElementsScope((IList <ResourceContainer>)activeContainers, PlatformTypes.Object, ResourceResolutionFlags.IncludeApplicationResources | ResourceResolutionFlags.UniqueKeysOnly)) { DocumentNode resourceEntryKey = ResourceNodeHelper.GetResourceEntryKey(entryNode); DocumentNode node = entryNode.Properties[DictionaryEntryNode.ValueProperty]; if (resourceEntryKey != null) { DelayedEvaluationLocalResourceModel localResourceModel = new DelayedEvaluationLocalResourceModel(this.DocumentContext, this.DesignerContext, resourceEntryKey, node.TargetType, node); collectionWorkaround.Add((LocalResourceModel)localResourceModel); } } collectionWorkaround.Sort((Comparison <LocalResourceModel>)((left, right) => string.Compare(left.ResourceName, right.ResourceName, StringComparison.CurrentCulture))); return(collectionWorkaround); }
private static bool CullDisassociatedProperties(ObservableCollectionWorkaround <PropertyEntry> propertyList) { bool propertiesCulled = false; for (int i = propertyList.Count - 1; i >= 0; i--) { ModelPropertyEntry property = (ModelPropertyEntry)propertyList[i]; if (property.Disassociated) { property.Disconnect(); propertyList.RemoveAt(i); propertiesCulled = true; } } return(propertiesCulled); }
public override void InvalidateLocalResourcesCache(bool firePropertyChanged) { if (this.localResources == null) { return; } ObservableCollectionWorkaround <LocalResourceModel> collectionWorkaround = this.RecalculateLocalResources(this.localResources); if (collectionWorkaround == this.localResources) { return; } this.localResources = collectionWorkaround; if (!firePropertyChanged) { return; } this.OnPropertyChanged("LocalResources"); }
// // Adds the given property to the specified property bucket (use // ModelCategoryEntry.BasicProperties, ModelCategoryEntry.AdvancedProperties, or // ModelCategoryEntry.GetBucket()) sorted using the specified comparer. // private void Add( PropertyEntry property, ObservableCollection <PropertyEntry> bucket, IComparer <PropertyEntry> comparer, bool fireCollectionChangedEvent) { if (property == null) { throw FxTrace.Exception.ArgumentNull("property"); } if (bucket == null) { throw FxTrace.Exception.ArgumentNull("bucket"); } if (comparer == null) { throw FxTrace.Exception.ArgumentNull("comparer"); } ObservableCollectionWorkaround <PropertyEntry> castBucket = bucket as ObservableCollectionWorkaround <PropertyEntry>; int insertionIndex = 0; if (castBucket == null) { Debug.Fail("Invalid property bucket. The property sort order will be broken."); } else { insertionIndex = castBucket.BinarySearch(property, comparer); if (insertionIndex < 0) { insertionIndex = ~insertionIndex; } } bucket.Insert(insertionIndex, property); if (fireCollectionChangedEvent) { FirePropertiesChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, property)); } }
protected virtual ObservableCollectionWorkaround <LocalResourceModel> RecalculateLocalResources(ObservableCollectionWorkaround <LocalResourceModel> currentResources) { return(currentResources); }
// <summary> // Basic ctor // </summary> // <param name="categoryName">Localized name for this category</param> public ModelCategoryEntry(string categoryName) : base(categoryName) { _basicProperties = new ObservableCollectionWorkaround<PropertyEntry>(); _advancedProperties = new ObservableCollectionWorkaround<PropertyEntry>(); }
private static bool CullDisassociatedProperties(ObservableCollectionWorkaround<PropertyEntry> propertyList) { bool propertiesCulled = false; for (int i = propertyList.Count - 1; i >= 0; i--) { ModelPropertyEntry property = (ModelPropertyEntry)propertyList[i]; if (property.Disassociated) { property.Disconnect(); propertyList.RemoveAt(i); propertiesCulled = true; } } return propertiesCulled; }
private static void MarkAttachedPropertiesDisassociated(ObservableCollectionWorkaround<PropertyEntry> propertyList) { foreach (ModelPropertyEntry property in propertyList) { if (property.IsAttached) { property.Disassociated = true; } } }
protected override ObservableCollectionWorkaround <LocalResourceModel> RecalculateLocalResources(ObservableCollectionWorkaround <LocalResourceModel> currentResources) { List <ResourceContainer> activeContainers = new List <ResourceContainer>(); ResourceContainer container = this.resource.Container; if (container is NodeResourceContainer) { foreach (ResourceContainer resourceContainer in this.designerContext.ResourceManager.ActiveResourceContainers) { if (resourceContainer.DocumentNode.DocumentRoot == container.DocumentNode.DocumentRoot && resourceContainer.DocumentNode.IsAncestorOf(container.DocumentNode)) { activeContainers.Add(resourceContainer); } } } else { activeContainers.Add(container); } return(this.ProvideLocalResources(activeContainers)); }
protected override ObservableCollectionWorkaround <LocalResourceModel> RecalculateLocalResources(ObservableCollectionWorkaround <LocalResourceModel> currentResources) { return((ObservableCollectionWorkaround <LocalResourceModel>) this.baseSet.LocalResources); }
protected void InvalidateTemplateBindableProperties() { this.templateBindableProperties = (ObservableCollectionWorkaround <TemplateBindablePropertyModel>)null; }
protected override ObservableCollectionWorkaround <LocalResourceModel> RecalculateLocalResources(ObservableCollectionWorkaround <LocalResourceModel> currentResources) { this.documentResourcesChangeStamp = this.DesignerContext.ResourceManager.ResourceChangeStamp; if (this.DesignerContext.SelectionManager.SelectedNodes != null && this.DesignerContext.SelectionManager.SelectedNodes.Length != 0) { return(this.ProvideLocalResources(new List <ResourceContainer>(this.DesignerContext.ResourceManager.ActiveResourceContainers))); } if (currentResources == null) { return(new ObservableCollectionWorkaround <LocalResourceModel>()); } currentResources.Clear(); return(currentResources); }
// <summary> // Basic ctor // </summary> // <param name="categoryName">Localized name for this category</param> public ModelCategoryEntry(string categoryName) : base(categoryName) { _basicProperties = new ObservableCollectionWorkaround <PropertyEntry>(); _advancedProperties = new ObservableCollectionWorkaround <PropertyEntry>(); }