예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
 //ajouter des propriétés, d'autres visitors...
 //Enrichir l'application
 public void Accept(FigureVisitor figureVisitor)
 {
     figureVisitor.Visit(this);
 }