Пример #1
2
        public static short[] DropManyU(
            IVisio.Page page,
            IList<IVisio.Master> masters,
            IEnumerable<VA.Drawing.Point> points)
        {
            if (masters == null)
            {
                throw new System.ArgumentNullException("masters");
            }

            if (masters.Count < 1)
            {
                return new short[0];
            }

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

            // NOTE: DropMany will fail if you pass in zero items to drop
            var masters_obj_array = masters.Cast<object>().ToArray();
            var xy_array = VA.Drawing.Point.ToDoubles(points).ToArray();

            System.Array outids_sa;

            page.DropManyU(masters_obj_array, xy_array, out outids_sa);

            short[] outids = (short[])outids_sa;
            return outids;
        }
Пример #2
0
        public static short[] DropManyAutoConnectors(
            IVisio.Page page,
            IEnumerable<VA.Drawing.Point> points)
        {
            if (points == null)
            {
                throw new System.ArgumentNullException("points");
            }

            // NOTE: DropMany will fail if you pass in zero items to drop

            var app = page.Application;
            var thing = app.ConnectorToolDataObject;
            int num_points = points.Count();
            var masters_obj_array = Enumerable.Repeat((object)thing, num_points).ToArray();
            var xy_array = VA.Drawing.Point.ToDoubles(points).ToArray();

            System.Array outids_sa;

            page.DropManyU(masters_obj_array, xy_array, out outids_sa);

            short[] outids = (short[])outids_sa;
            return outids;
        }
        public static IList<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.ArgumentNullException("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 = page.Shapes.GetShapesFromIDs(con_shapeids);
            }
            else
            {
                short[] con_shapeids = Pages.PageHelper.DropManyAutoConnectors(page, points);
                con_shapes = page.Shapes.GetShapesFromIDs(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];

                // Connect from Shape 1 to Shape2
                ConnectorHelper.ConnectShapes(from_shape, to_shape, connector, true);

                connectors.Add(connector);
            }

            return connectors;
        }