void playingAnimations_CollectionChanged(object sender, TrackingCollectionChangedEventArgs e) { var item = (PlayingAnimation)e.Item; switch (e.Action) { case NotifyCollectionChangedAction.Add: { item.attached = true; break; } case NotifyCollectionChangedAction.Remove: { var evaluator = item.Evaluator; if (evaluator != null) { Blender.ReleaseEvaluator(evaluator); item.Evaluator = null; } item.endedTCS?.TrySetResult(true); item.endedTCS = null; item.attached = false; break; } } }
void playingAnimations_CollectionChanged(object sender, TrackingCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Remove) { var item = (PlayingAnimation)e.Item; var evaluator = item.Evaluator; if (evaluator != null) { Blender.ReleaseEvaluator(evaluator); item.Evaluator = null; } } }
private void DefinitionCollectionChanged(object sender, TrackingCollectionChangedEventArgs trackingCollectionChangedEventArgs) { var modifiedElement = (StripDefinition)trackingCollectionChangedEventArgs.Item; switch (trackingCollectionChangedEventArgs.Action) { case NotifyCollectionChangedAction.Add: modifiedElement.DefinitionChanged += OnStripDefinitionChanged; break; case NotifyCollectionChangedAction.Remove: modifiedElement.DefinitionChanged -= OnStripDefinitionChanged; break; default: throw new NotImplementedException(); } InvalidateMeasure(); }
private void ChildrenCollectionChanged(object sender, TrackingCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: AddItem((TransformComponent)e.Item); break; case NotifyCollectionChangedAction.Remove: RemoveItem((TransformComponent)e.Item); break; default: throw new NotSupportedException(); } }
private void RenderFeatures_CollectionChanged(object sender, TrackingCollectionChangedEventArgs e) { var renderFeature = (SubRenderFeature)e.Item; switch (e.Action) { case System.Collections.Specialized.NotifyCollectionChangedAction.Add: renderFeature.AttachRootRenderFeature(this); renderFeature.Initialize(Context); break; case System.Collections.Specialized.NotifyCollectionChangedAction.Remove: renderFeature.Dispose(); break; } }
private void children_CollectionChanged(object sender, TrackingCollectionChangedEventArgs e) { var child = (Model)e.Item; switch (e.Action) { case NotifyCollectionChangedAction.Add: if (child.parent != null) throw new InvalidOperationException("Model already have a parent."); child.parent = this; break; case NotifyCollectionChangedAction.Remove: if (child.parent != this) throw new InvalidOperationException("Model doesn't have expected parent."); child.parent = null; break; } }
private void UpdatersOnCollectionChanged(object sender, TrackingCollectionChangedEventArgs trackingCollectionChangedEventArgs) { updatersCount = ParticleUtils.CalculateMaximumPowerOf2Count(Updaters.Sum(particleUpdater => particleUpdater.Count)); }
private void VisibilityGroups_CollectionChanged(object sender, TrackingCollectionChangedEventArgs e) { var visibilityGroup = (VisibilityGroup)e.Item; switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (var registeredRenderProcessorType in registeredRenderProcessorTypes) { var processor = CreateRenderProcessor(registeredRenderProcessorType.Value, visibilityGroup); // Assume we are in middle of a compositor draw so we need to run it manually once (Update/Draw already happened) if (currentRenderContext != null) { processor.Update(currentRenderContext.Time); processor.Draw(currentRenderContext); } } break; case NotifyCollectionChangedAction.Remove: foreach (var registeredRenderProcessorType in registeredRenderProcessorTypes) { // Remove matching entries var instances = registeredRenderProcessorType.Value.Instances; for (int i = 0; i < instances.Count; ++i) { var registeredProcessorInstance = instances[i]; if (registeredProcessorInstance.Key == visibilityGroup) { Processors.Remove(registeredProcessorInstance.Value); instances.RemoveAt(i); break; } } } visibilityGroup.Dispose(); break; } }
private void OnSoundsOnCollectionChanged(object sender, TrackingCollectionChangedEventArgs args) { switch (args.Action) { case NotifyCollectionChangedAction.Add: AttachSound((Sound)args.Item); break; case NotifyCollectionChangedAction.Remove: DetachSound((Sound)args.Item); break; } }