예제 #1
0
        internal static void AlignTopToBottom(PowerPoint.Selection selection, TopOrLeft topLeft)
        {
            PowerPoint.Shape anchor;
            var list = ToolsCommon.getEdgeShapeAndChildren(selection.ShapeRange, topLeft, out anchor);

            foreach (var s in list)
            {
                if (topLeft == TopOrLeft.Top)
                {
                    s.Top = anchor.Top + anchor.Height;
                }
                else if (topLeft == TopOrLeft.Left)
                {
                    s.Left = anchor.Left + anchor.Width;
                }
            }
        }
예제 #2
0
        public static List <PowerPoint.Shape> getEdgeShapeAndChildren(PowerPoint.ShapeRange shapes, TopOrLeft edge, out PowerPoint.Shape anchor)
        {
            var list = new List <PowerPoint.Shape>();

            // create initial list with all shapes
            foreach (PowerPoint.Shape s in shapes)
            {
                list.Add(s);
            }

            PowerPoint.Shape edgeShape = null;

            // get the edge shape
            switch (edge)
            {
            case TopOrLeft.Left:
                edgeShape = (from s in list
                             orderby s.Left
                             select s).FirstOrDefault();
                break;

            case TopOrLeft.Top:
                edgeShape = (from s in list
                             orderby s.Top
                             select s).FirstOrDefault();
                break;

            default:
                break;
            }

            // remove the edge shape from the list
            list.Remove(edgeShape);

            anchor = edgeShape;
            return(list);
        }