コード例 #1
0
 /// <summary>
 /// Stretches all selected shapes to the left edge of reference shape
 /// </summary>
 /// <param name="stretchShapes">The shapes to stretch</param>
 public void StretchLeft(PowerPoint.ShapeRange stretchShapes)
 {
     var appropriateStretch = new GetAppropriateStretchAction((referenceEdge, checkShape) =>
     {
         // Opposite stretch
         if (GetRight(checkShape) < referenceEdge)
         {
             return StretchRightAction;
         }
         return StretchLeftAction;
     });
     var defaultReferenceEdge = new GetDefaultReferenceEdge(referenceShape => referenceShape.VisualLeft);
     Stretch(stretchShapes, appropriateStretch, defaultReferenceEdge, StretchType.Left);
 }
コード例 #2
0
        /// <summary>
        /// Stretches all selected shapes to the right edge of reference shape
        /// </summary>
        /// <param name="stretchShapes">The shapes to stretch</param>
        public void StretchRight(PowerPoint.ShapeRange stretchShapes)
        {
            var appropriateStretch = new GetAppropriateStretchAction((referenceEdge, checkShape) =>
            {
                // Opposite stretch
                if (checkShape.VisualLeft > referenceEdge)
                {
                    return(StretchLeftAction);
                }
                return(StretchRightAction);
            });
            var defaultReferenceEdge = new GetDefaultReferenceEdge(referenceShape => referenceShape.VisualLeft + referenceShape.AbsoluteWidth);

            Stretch(stretchShapes, appropriateStretch, defaultReferenceEdge, StretchType.Right);
        }
コード例 #3
0
        /// <summary>
        /// Stretches all selected shapes to the left edge of reference shape
        /// </summary>
        /// <param name="stretchShapes">The shapes to stretch</param>
        public void StretchBottom(PowerPoint.ShapeRange stretchShapes)
        {
            var appropriateStretch = new GetAppropriateStretchAction((referenceEdge, checkShape) =>
            {
                // Opposite stretch
                if (checkShape.VisualTop > referenceEdge)
                {
                    return(StretchTopAction);
                }
                return(StretchBottomAction);
            });
            var defaultReferenceEdge = new GetDefaultReferenceEdge(referenceShape => referenceShape.VisualTop + referenceShape.AbsoluteHeight);

            Stretch(stretchShapes, appropriateStretch, defaultReferenceEdge, StretchType.Bottom);
        }
コード例 #4
0
        /// <summary>
        /// Stretches all selected shapes to the left edge of reference shape
        /// </summary>
        /// <param name="stretchShapes">The shapes to stretch</param>
        public void StretchLeft(PowerPoint.ShapeRange stretchShapes)
        {
            GetAppropriateStretchAction appropriateStretch = new GetAppropriateStretchAction((referenceEdge, checkShape) =>
            {
                // Opposite stretch
                if (GetRight(checkShape) < referenceEdge)
                {
                    return(StretchRightAction);
                }
                return(StretchLeftAction);
            });
            GetDefaultReferenceEdge defaultReferenceEdge = new GetDefaultReferenceEdge(referenceShape => referenceShape.VisualLeft);

            Stretch(stretchShapes, appropriateStretch, defaultReferenceEdge, StretchType.Left);
        }
コード例 #5
0
        /// <summary>
        /// Stretches all selected shapes to the top edge of reference shape
        /// </summary>
        /// <param name="stretchShapes">The shapes to stretch</param>
        public void StretchTop(PowerPoint.ShapeRange stretchShapes)
        {
            GetAppropriateStretchAction appropriateStretch = new GetAppropriateStretchAction((referenceEdge, checkShape) =>
            {
                // Opposite stretch
                if (GetBottom(checkShape) < referenceEdge)
                {
                    return(StretchBottomAction);
                }
                return(StretchTopAction);
            });
            GetDefaultReferenceEdge defaultReferenceEdge = new GetDefaultReferenceEdge(referenceShape => referenceShape.VisualTop);

            Stretch(stretchShapes, appropriateStretch, defaultReferenceEdge, StretchType.Top);
        }
コード例 #6
0
        /// <summary>
        /// Stretch shapes in the list
        /// </summary>
        /// <param name="stretchShapes">The shapes to stretch</param>
        /// <param name="stretchAction">The function to use to stretch</param>
        /// <param name="defaultReferenceEdge">The function to return the default reference edge</param>
        /// <param name="stretchType">The type of stretch to perform</param>
        private void Stretch(PowerPoint.ShapeRange stretchShapes, GetAppropriateStretchAction stretchAction,
                             GetDefaultReferenceEdge defaultReferenceEdge, StretchType stretchType)
        {
            if (!ValidateSelection(stretchShapes))
            {
                return;
            }

            var referenceShape = GetReferenceShape(stretchShapes, defaultReferenceEdge, stretchType);
            var referenceEdge  = defaultReferenceEdge(new PPShape(referenceShape));

            for (var i = 1; i <= stretchShapes.Count; i++)
            {
                if (referenceShape.Equals(stretchShapes[i]))
                {
                    continue;
                }
                var stretchShape = new PPShape(stretchShapes[i]);
                var sa           = stretchAction(referenceEdge, stretchShape);
                sa(referenceEdge, stretchShape);
            }
        }
コード例 #7
0
        /// <summary>
        /// Stretch shapes in the list
        /// </summary>
        /// <param name="stretchShapes">The shapes to stretch</param>
        /// <param name="stretchAction">The function to use to stretch</param>
        /// <param name="defaultReferenceEdge">The function to return the default reference edge</param>
        /// <param name="stretchType">The type of stretch to perform</param>
        private void Stretch(PowerPoint.ShapeRange stretchShapes, GetAppropriateStretchAction stretchAction, 
            GetDefaultReferenceEdge defaultReferenceEdge, StretchType stretchType)
        {
            if (!ValidateSelection(stretchShapes))
            {
                return;
            }

            var referenceShape = GetReferenceShape(stretchShapes, defaultReferenceEdge, stretchType);
            var referenceEdge = defaultReferenceEdge(new PPShape(referenceShape));

            for (var i = 1; i <= stretchShapes.Count; i++)
            {
                if (referenceShape.Equals(stretchShapes[i]))
                {
                    continue;
                }
                var stretchShape = new PPShape(stretchShapes[i]);
                var sa = stretchAction(referenceEdge, stretchShape);
                sa(referenceEdge, stretchShape);
            }
        }
コード例 #8
0
 /// <summary>
 /// Stretches all selected shapes to the left edge of reference shape
 /// </summary>
 /// <param name="stretchShapes">The shapes to stretch</param>
 public void StretchBottom(PowerPoint.ShapeRange stretchShapes)
 {
     var appropriateStretch = new GetAppropriateStretchAction((referenceEdge, checkShape) =>
     {
         // Opposite stretch
         if (checkShape.VisualTop > referenceEdge)
         {
             return StretchTopAction;
         }
         return StretchBottomAction;
     });
     var defaultReferenceEdge = new GetDefaultReferenceEdge(referenceShape => referenceShape.VisualTop + referenceShape.AbsoluteHeight);
     Stretch(stretchShapes, appropriateStretch, defaultReferenceEdge, StretchType.Bottom);
 }