public static double GetArea(this IShape shape) { var visitor = new AreaVisitor(); shape.Accept(visitor); return(visitor.Area); }
public IEnumerable <string> ExportShapes(params object[] shapes) { foreach (object shape in shapes) { IShape typedShape = (IShape)shape; yield return(typedShape.Accept(_exporter)); } }
public void DrawCurrentShape(int x, int y) { if (_currentShape != null) { _currentShape.Accept(new CenterShapeOnDrawing(x, y)); DrawnShapes.Add(_currentShape); _g.RefreshView(); _currentShape = null; CreateMemento(); } }
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));
public void ShapeEditMenu(IShape shape) { shape.Accept(new EditMenu(_g)); }