예제 #1
0
        public static List <IVisio.Shape> ConnectShapes(IVisio.Page page, IList <IVisio.Shape> fromshapes, IList <IVisio.Shape> toshapes, IVisio.Master connector_master, bool force_manual)
        {
            if (connector_master == null && force_manual)
            {
                throw new System.ArgumentException("if the connector object is null then force manual must be false");
            }
            // no_connector + force_manual -> INVALID
            // no_connector + not_force_manual -> AutoConect
            // yes_connector + force_manual -> Manual Connection
            // object false  + not_force_manual-> Autoconnect

            if (fromshapes == null)
            {
                throw new System.ArgumentNullException(nameof(fromshapes));
            }

            if (toshapes == null)
            {
                throw new System.ArgumentNullException(nameof(toshapes));
            }

            if (fromshapes.Count != toshapes.Count)
            {
                throw new System.ArgumentException("must have same number of from and to shapes");
            }

            if (fromshapes.Count == 0)
            {
                return(new List <IVisio.Shape>(0));
            }

            int num_connectors = fromshapes.Count;
            var connectors     = new List <IVisio.Shape>(num_connectors);

            var points = Enumerable.Range(0, num_connectors).Select(i => new Drawing.Point(i * 2.0, -2)).ToList();
            IList <IVisio.Shape> con_shapes = null;

            if (connector_master != null)
            {
                var     masters      = Enumerable.Repeat(connector_master, num_connectors).ToList();
                short[] con_shapeids = page.DropManyU(masters, points);
                con_shapes = VisioAutomation.Shapes.ShapeHelper.GetShapesFromIDs(page.Shapes, con_shapeids);
            }
            else
            {
                short[] con_shapeids = Pages.PageHelper.DropManyAutoConnectors(page, points);
                con_shapes = VisioAutomation.Shapes.ShapeHelper.GetShapesFromIDs(page.Shapes, con_shapeids);
            }

            for (int i = 0; i < num_connectors; i++)
            {
                var from_shape = fromshapes[i];
                var to_shape   = toshapes[i];
                var connector  = con_shapes[i];

                ConnectorHelper.ConnectShapes(from_shape, to_shape, connector, true);

                connectors.Add(connector);
            }

            return(connectors);
        }
예제 #2
0
 public static void ConnectShapes(IVisio.Shape from_shape, IVisio.Shape to_shape, IVisio.Shape connector_shape)
 {
     ConnectorHelper.ConnectShapes(from_shape, to_shape, connector_shape, true);
 }
예제 #3
0
 public static List <IVisio.Shape> ConnectShapes(IVisio.Page page, IList <IVisio.Shape> fromshapes, IList <IVisio.Shape> toshapes,
                                                 IVisio.Master connector_master)
 {
     return(ConnectorHelper.ConnectShapes(page, fromshapes, toshapes, connector_master, true));
 }