コード例 #1
0
ファイル: Visitor3.cs プロジェクト: Digilad/Patterns
        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));
     }
 }
コード例 #5
0
        private void Build()
        {
            var shapeGeometryVisitor = new BuildShapeGeometryVisitor <T>(this, _hints, _colors);

            _shape.Accept(shapeGeometryVisitor);
        }
コード例 #6
0
 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));
 }