예제 #1
0
 /// <summary>
 /// Responsible for moving shapes inside frame
 /// </summary>
 /// <param name="shape"></param>
 /// <param name="resizeFactor"></param>
 /// <returns></returns>
 public bool MoveShapesInsideFrame(IShape shape, ResizeFactor resizeFactor)
 {
     if (_frame == null)
     {
         return(false);
     }
     return(_frame.MoveShapeInsideFrame(shape, resizeFactor));
 }
        /// <summary>
        /// Adding Circles inside given frame
        /// </summary>
        /// <param name="frame"></param>
        /// <returns></returns>
        public bool MoveShapeInsideFrame(IShape shape, ResizeFactor resizeFactor)
        {
            if (shape as Circle != null)
            {
                var circle = shape as Circle;

                //Only If same circle is present we can resize
                if (Circles.ContainsValue(circle))
                {
                    var circleTobeMoved = new Circle(resizeFactor.NewValue, circle.Radius);

                    //check new radious fits inside frame then resize
                    if (IsValidPosition(circleTobeMoved))
                    {
                        var newCircle = Circles.FirstOrDefault(x => x.Value == circle).Value;
                        newCircle.MoveShape(resizeFactor.NewValue);
                        return(true);
                    }
                }
            }

            else if (shape as Rectangle != null)
            {
                var rectangle = shape as Rectangle;

                //Only If same circle is present we can resize
                if (Rectangles.ContainsValue(rectangle))
                {
                    var rectangleTobeMoved = new Rectangle(resizeFactor.NewValue, rectangle.Width, rectangle.Height);

                    //check new radious fits inside frame then resize
                    if (IsValidPosition(rectangleTobeMoved))
                    {
                        var newCircle = Rectangles.FirstOrDefault(x => x.Value == rectangle).Value;
                        newCircle.MoveShape(resizeFactor.NewValue);
                        return(true);
                    }
                }
            }

            return(false);
        }