private void connect(IVisio.Shape a, IVisio.Shape b, bool a_arrow, bool b_arrow)
        {
            var page = a.ContainingPage;
            var connectors_stencil = page.Application.Documents.OpenStencil("connec_u.vss");
            var connectors_masters = connectors_stencil.Masters;

            var dcm = connectors_masters["Dynamic Connector"];

            var drop_point = new VADRAW.Point(-2, -2);
            var c1         = page.Drop(dcm, drop_point);

            ConnectorHelper.ConnectShapes(a, b, c1);

            //a.AutoConnect(b, connect_dir_none, null);

            if (a_arrow || b_arrow)
            {
                var writer = new FormulaWriterSIDSRC();
                if (a_arrow)
                {
                    writer.SetFormula(c1.ID16, VASS.SRCConstants.BeginArrow, "13");
                }
                if (b_arrow)
                {
                    writer.SetFormula(c1.ID16, VASS.SRCConstants.EndArrow, "13");
                }
                writer.Commit(page);
            }
        }
Esempio n. 2
0
        private void _draw_connectors(RenderContext context)
        {
            var connector_nodes = this._shapes.OfType <Connector>().ToList();

            // if no dynamic connectors then do nothing
            if (connector_nodes.Count < 1)
            {
                return;
            }

            // Drop the number of connectors needed somewhere on the page
            var masters = connector_nodes.Select(i => i.Master.VisioMaster).ToArray();
            var origin  = new VisioAutomation.Geometry.Point(-2, -2);
            var points  = Enumerable.Range(0, connector_nodes.Count)
                          .Select(i => origin + new VisioAutomation.Geometry.Point(1.10, 0))
                          .ToList();
            var connector_shapeids = context.VisioPage.DropManyU(masters, points);
            var page_shapes        = context.VisioPage.Shapes;

            // Perform the connection
            for (int i = 0; i < connector_shapeids.Length; i++)
            {
                var connector_shapeid = connector_shapeids[i];
                var vis_connector     = page_shapes.ItemFromID[connector_shapeid];
                var dyncon_shape      = connector_nodes[i];

                var from_shape = context.GetShape(dyncon_shape.From.VisioShapeID);
                var to_shape   = context.GetShape(dyncon_shape.To.VisioShapeID);

                ConnectorHelper.ConnectShapes(from_shape, to_shape, vis_connector);
                dyncon_shape.VisioShape   = vis_connector;
                dyncon_shape.VisioShapeID = connector_shapeids[i];
            }
        }
Esempio n. 3
0
        public static void ConnectorsToBack()
        {
            var doc   = SampleEnvironment.Application.ActiveDocument;
            var pages = doc.Pages;
            var page  = pages.Add();

            // based on this example: http://www.visguy.com/2009/06/17/send-all-connectors-to-back/

            var stencil   = SampleEnvironment.Application.Documents.OpenStencil("basic_u.vss");
            var master    = stencil.Masters["Dynamic Connector"];
            var r0        = page.DrawRectangle(3, 3, 5, 5);
            var r1        = page.DrawRectangle(0, 1, 2, 2);
            var r2        = page.DrawRectangle(7, 7, 8, 8);
            var connector = page.Drop(master, 0, 0);

            ConnectorHelper.ConnectShapes(r1, r2, connector);

            var con_layer = page.Layers["Connector"];

            var sel = page.CreateSelection(
                IVisio.VisSelectionTypes.visSelTypeByLayer,
                IVisio.VisSelectMode.visSelModeSkipSub,
                con_layer);

            sel.SendToBack();
        }
Esempio n. 4
0
        public void Connect1()
        {
            var page1     = this.GetNewPage();
            var s1        = page1.DrawRectangle(1, 1, 2, 2);
            var s2        = page1.DrawRectangle(5, 5, 6, 6);
            var stencil   = page1.Application.Documents.OpenStencil("connec_u.vss");
            var master    = stencil.Masters["Dynamic Connector"];
            var connector = page1.Drop(master, 0, 0);

            ConnectorHelper.ConnectShapes(s1, s2, connector);

            page1.Delete(0);
        }
Esempio n. 5
0
        public List <IVisio.Shape> ConnectShapes(IList <IVisio.Shape> fromshapes, IList <IVisio.Shape> toshapes, IVisio.Master master)
        {
            var cmdtarget = this._client.GetCommandTargetPage();

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(ConnectShapes)))
            {
                if (master == null)
                {
                    var connectors = ConnectorHelper.ConnectShapes(cmdtarget.ActivePage, fromshapes, toshapes, null, false);
                    return(connectors);
                }
                else
                {
                    var connectors = ConnectorHelper.ConnectShapes(cmdtarget.ActivePage, fromshapes, toshapes, master);
                    return(connectors);
                }
            }
        }
Esempio n. 6
0
        public List <IVisio.Shape> ConnectShapes(VisioScripting.TargetPage target_page, IList <IVisio.Shape> fromshapes, IList <IVisio.Shape> toshapes, IVisio.Master master)
        {
            target_page = target_page.ResolveToPage(this._client);

            using (var undoscope = this._client.Undo.NewUndoScope(nameof(ConnectShapes)))
            {
                if (master == null)
                {
                    var connectors = ConnectorHelper.ConnectShapes(target_page.Page, fromshapes, toshapes, null, false);
                    return(connectors);
                }
                else
                {
                    var connectors = ConnectorHelper.ConnectShapes(target_page.Page, fromshapes, toshapes, master);
                    return(connectors);
                }
            }
        }
Esempio n. 7
0
        public IList <IVisio.Shape> Connect(IList <IVisio.Shape> fromshapes, IList <IVisio.Shape> toshapes, IVisio.Master master)
        {
            this.AssertApplicationAvailable();
            this.AssertDocumentAvailable();

            var active_page = this.Client.VisioApplication.ActivePage;

            using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication, undoname_connectShapes))
            {
                if (master == null)
                {
                    var connectors = ConnectorHelper.ConnectShapes(active_page, fromshapes, toshapes, null, false);
                    return(connectors);
                }
                else
                {
                    var connectors = ConnectorHelper.ConnectShapes(active_page, fromshapes, toshapes, master);
                    return(connectors);
                }
            }
        }
        public List <IVisio.Shape> Connect(IList <IVisio.Shape> fromshapes, IList <IVisio.Shape> toshapes, IVisio.Master master)
        {
            this._client.Application.AssertApplicationAvailable();
            this._client.Document.AssertDocumentAvailable();

            var application = this._client.Application.Get();
            var active_page = application.ActivePage;

            using (var undoscope = this._client.Application.NewUndoScope("Connect Shapes"))
            {
                if (master == null)
                {
                    var connectors = ConnectorHelper.ConnectShapes(active_page, fromshapes, toshapes, null, false);
                    return(connectors);
                }
                else
                {
                    var connectors = ConnectorHelper.ConnectShapes(active_page, fromshapes, toshapes, master);
                    return(connectors);
                }
            }
        }
        public static void ConnectorsToBack()
        {
            var doc   = SampleEnvironment.Application.ActiveDocument;
            var pages = doc.Pages;
            var page  = pages.Add();

            // get the data and the labels to use
            var data = new double[] { 1, 2, 3, 4, 5, 6 };

            var radius = 3.0;
            var center = new VA.Drawing.Point(4, 4);
            var slices = VA.Models.Charting.PieSlice.GetSlicesFromValues(center, radius, data);

            foreach (var slice in slices)
            {
                slice.Render(page);
            }

            // based on this example: http://www.visguy.com/2009/06/17/send-all-connectors-to-back/

            var stencil   = SampleEnvironment.Application.Documents.OpenStencil("basic_u.vss");
            var master    = stencil.Masters["Dynamic Connector"];
            var connector = page.Drop(master, 0, 0);
            var r1        = page.DrawRectangle(0, 1, 2, 2);
            var r2        = page.DrawRectangle(7, 7, 8, 8);

            ConnectorHelper.ConnectShapes(connector, r1, r2);

            var con_layer = page.Layers["Connector"];

            var sel = page.CreateSelection(
                IVisio.VisSelectionTypes.visSelTypeByLayer,
                IVisio.VisSelectMode.visSelModeSkipSub,
                con_layer);

            sel.SendToBack();
        }