Exemple #1
0
 private static double GetPositionOnShape(VA.Shapes.XFormCells xform, PositionOnShape pos)
 {
     if (pos == PositionOnShape.PinY)
     {
         return(xform.PinY.Result);
     }
     else if (pos == PositionOnShape.PinX)
     {
         return(xform.PinX.Result);
     }
     else
     {
         var r = GetRectangle(xform);
         if (pos == PositionOnShape.Left)
         {
             return(r.Left);
         }
         else if (pos == PositionOnShape.Right)
         {
             return(r.Right);
         }
         else if (pos == PositionOnShape.Top)
         {
             return(r.Top);
         }
         else if (pos == PositionOnShape.Right)
         {
             return(r.Bottom);
         }
         else
         {
             throw new System.ArgumentOutOfRangeException("pos");
         }
     }
 }
 private static double GetPositionOnShape(VA.Shapes.XFormCells xform, PositionOnShape pos)
 {
     if (pos == PositionOnShape.PinY)
     {
         return xform.PinY.Result;
     }
     else if (pos == PositionOnShape.PinX)
     {
         return xform.PinX.Result;
     }
     else
     {
         var r = GetRectangle(xform);
         if (pos == PositionOnShape.Left)
         {
             return r.Left;
         }
         else if (pos == PositionOnShape.Right)
         {
             return r.Right;
         }
         else if (pos == PositionOnShape.Top)
         {
             return r.Top;
         }
         else if (pos == PositionOnShape.Right)
         {
             return r.Bottom;
         }
         else
         {
             throw new System.ArgumentOutOfRangeException("pos");
         }
     }
 }
        public static IList<int> SortShapesByPosition(IVisio.Page page, IList<int> shapeids, PositionOnShape pos)
        {
            if (page == null)
            {
                throw new System.ArgumentNullException("page");
            }

            if (shapeids == null)
            {
                throw new System.ArgumentNullException("shapeids");
            }

            // First get the transforms of the shapes on the given axis
            var xforms = ArrangeHelper.GetXForm(page, shapeids);

            // Then, sort the shapeids pased on the corresponding value in the results

            var sorted_shape_ids = Enumerable.Range(0, shapeids.Count)
                .Select(i => new {index = i, shapeid = shapeids[i], pos = GetPositionOnShape(xforms[i], pos)})
                .OrderBy(i => i.pos)
                .Select(i=>i.shapeid)
                .ToList();

            return sorted_shape_ids;
        }
Exemple #4
0
        public static IList <int> SortShapesByPosition(IVisio.Page page, IList <int> shapeids, PositionOnShape pos)
        {
            if (page == null)
            {
                throw new System.ArgumentNullException("page");
            }

            if (shapeids == null)
            {
                throw new System.ArgumentNullException("shapeids");
            }

            // First get the transforms of the shapes on the given axis
            var xforms = ArrangeHelper.GetXForm(page, shapeids);

            // Then, sort the shapeids pased on the corresponding value in the results


            var sorted_shape_ids = Enumerable.Range(0, shapeids.Count)
                                   .Select(i => new { index = i, shapeid = shapeids[i], pos = GetPositionOnShape(xforms[i], pos) })
                                   .OrderBy(i => i.pos)
                                   .Select(i => i.shapeid)
                                   .ToList();

            return(sorted_shape_ids);
        }