private void OnColorChanged(AShape shape) { if (shape == null) { throw new ArgumentNullException(nameof(shape)); } ShapeCollection shapeCollection = EnsureEntities(shape.Color); shapeCollection.Add(shape); }
private ShapeCollection EnsureCollection(Color color) { if (shapeCollections.TryGetValue(color, out var shapeCollection)) { return(shapeCollection); } shapeCollection = new ShapeCollection(color, GraphicsDevice, game.GraphicsContext); shapeCollection.ColorChanged += OnColorChanged; shapeCollections[color] = shapeCollection; rootEntity.AddChild(shapeCollection.Entity); return(shapeCollection); }
private void Delete(ShapeCollection shapeCollection) { rootEntity.RemoveChild(shapeCollection.Entity); shapeCollection.ColorChanged -= OnColorChanged; shapeCollections.Remove(shapeCollection.Color); }