public IEnumerator <IDrawableFigure> GetEnumerator() { var staticFigures = new FixedFigureCollection(); var visitor = new FigureVisitor(); foreach (var staticFigure in staticFigures) { if (staticFigure == null) { continue; } staticFigure.Accept(visitor); yield return(staticFigure); } }
private void Figures_Paint(object sender, PaintEventArgs e) { var figureList = new FigureCollection { new Circle(50, 50, 200, 200), new Ellipse(300, 100, 200, 100), new Square(50, 300, 200, 200), new Rectangle(300, 300, 200, 150), new LineSegment { X1 = 550, Y1 = 50, X2 = 700, Y2 = 200 }, new Rhomb(550, 300, 200, 200) }; var figureDrawer = new FigureVisitor(e); figureDrawer.FiguresVisitor(figureList); }
//ajouter des propriétés, d'autres visitors... //Enrichir l'application public void Accept(FigureVisitor figureVisitor) { figureVisitor.Visit(this); }