Пример #1
0
        public static double GetArea(this IShape shape)
        {
            var visitor = new AreaVisitor();

            shape.Accept(visitor);
            return(visitor.Area);
        }
Пример #2
0
 public IEnumerable <string> ExportShapes(params object[] shapes)
 {
     foreach (object shape in shapes)
     {
         IShape typedShape = (IShape)shape;
         yield return(typedShape.Accept(_exporter));
     }
 }
Пример #3
0
 public void DrawCurrentShape(int x, int y)
 {
     if (_currentShape != null)
     {
         _currentShape.Accept(new CenterShapeOnDrawing(x, y));
         DrawnShapes.Add(_currentShape);
         _g.RefreshView();
         _currentShape = null;
         CreateMemento();
     }
 }
Пример #4
0
 private void ReplaceGroupOnDrawing(IShape shape, int x, int y, int xMin, int xMax, int yMin, int yMax)
 {
     if (shape.GetType() == typeof(GroupShapes))
     {
         var group = (GroupShapes)shape;
         foreach (var child in group.Children)
         {
             ReplaceGroupOnDrawing(child, x, y, xMin, xMax, yMin, yMax);
         }
         group.UpdateBounds();
     }
     else
     {
         var width  = xMax - xMin;
         var height = yMax - yMin;
         shape.Accept(new ReplaceShape(x + shape.X - xMin - width / 2, y + shape.Y - yMin - height / 2));
     }
 }
        private void Build()
        {
            var shapeGeometryVisitor = new BuildShapeGeometryVisitor <T>(this, _hints, _colors);

            _shape.Accept(shapeGeometryVisitor);
        }
 public string GetInfo(IShape shape)
 => ConcatInfoString($"Shape type:{shape.GetType().Name}",
                     $"Square:{shape.Square}",
                     shape.Accept(AdditionalInfoProvider));
Пример #7
0
 public void ShapeEditMenu(IShape shape)
 {
     shape.Accept(new EditMenu(_g));
 }