public static void ConnectShapes(IVisio.Shape from_shape, IVisio.Shape to_shape, IVisio.Shape connector_shape, bool manual_connection)
        {
            if (from_shape == null)
            {
                throw new System.ArgumentNullException(nameof(from_shape));
            }

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

            if (connector_shape == from_shape)
            {
                throw new System.ArgumentException("connector cannot be the FROM shape");
            }

            if (connector_shape == to_shape)
            {
                throw new System.ArgumentException("connector cannot be the TO shape");
            }

            if (manual_connection)
            {
                // Manuall Set the cells
                if (connector_shape == null)
                {
                    throw new System.ArgumentException("connector cannot be null when specifying manual connection");
                }

                var src_beginx       = ShapeSheet.SRCConstants.BeginX;
                var src_endx         = ShapeSheet.SRCConstants.EndX;
                var connector_beginx = connector_shape.CellsSRC[src_beginx.Section, src_beginx.Row, src_beginx.Cell];
                var connector_endx   = connector_shape.CellsSRC[src_endx.Section, src_endx.Row, src_endx.Cell];
                var from_cell        = from_shape.CellsSRC[1, 1, 0];
                var to_cell          = to_shape.CellsSRC[1, 1, 0];
                connector_beginx.GlueTo(from_cell);
                connector_endx.GlueTo(to_cell);
            }
            else
            {
                // Use the AutoConnect feature
                if (connector_shape == null)
                {
                    from_shape.AutoConnect(to_shape, IVisio.VisAutoConnectDir.visAutoConnectDirNone);
                }
                else
                {
                    from_shape.AutoConnect(to_shape, IVisio.VisAutoConnectDir.visAutoConnectDirNone, connector_shape);
                }
            }
        }
Пример #2
0
        public void ConnectShapes(int upstreamJob, int downstreamJob)
        {
            //Link jobs

            upstreamShape   = this.VisApp.ActivePage.Shapes.get_ItemFromID(upstreamJob);
            downstreamShape = this.VisApp.ActivePage.Shapes.get_ItemFromID(downstreamJob);

            if (upstreamJob != downstreamJob)
            {
                upstreamShape.AutoConnect(downstreamShape, connectParams, connectionMaster);
            }
        }
Пример #3
0
 private void ConnectarDesenhos(IVisio.Shape shapeAtual, IVisio.Shape shapeAnterior)
 {
     shapeAtual.AutoConnect(shapeAnterior, IVisio.VisAutoConnectDir.visAutoConnectDirUp);
 }
Пример #4
0
        public ServerToVisio(DocumentationServer server)
        {
            Visio.Document  doc;
            Visio.Page      adaptPage;
            Visio.Selection select;
            Visio.Shape     group;

            // start Visio
            Visio.Application application = new Visio.Application();
            application.Visible = true;

            // setting up paths
            string templatePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + @"\Benutzerdefinierte Office-Vorlagen\Visio Templates\Adapt.vst";
            string savePath     = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + @"\VS Saves\Adapt.vst";

            // load and set up the ADAPT template (with 2 pages)
            doc         = application.Documents.Add(templatePath);
            doc.Creator = @"gmc²";
            doc.Title   = @"Hier steht dann der Titel";
            doc.SaveAs(savePath);

            //doc.Pages.Add();

            // setting up the pages
            adaptPage      = doc.Pages[1];
            adaptPage.Name = @"ADAPT";
            Visio.Page legende = doc.Pages[2];
            legende.Name = @"Legende";

            // get the necessary shapes...

            //!!! ALT in Dictionary !!!
            Dictionary <string, Visio.Master> masters = new Dictionary <string, Visio.Master>();

            masters.Add(@"Cube", doc.Masters.get_ItemU(@"Cube"));

            Visio.Master visioCubeMaster       = doc.Masters.get_ItemU(@"Cube");
            Visio.Master visioDimensionMaster  = doc.Masters.get_ItemU(@"Dimension");
            Visio.Master visioHierarchytMaster = doc.Masters.get_ItemU(@"Hierarchy");
            Visio.Master visioAttributeMaster  = doc.Masters.get_ItemU(@"Attribute");
            Visio.Master visioUsedByMaster     = doc.Masters.get_ItemU(@"Used By");

            // ...and draw them
            List <Visio.Shape> cubeShapes = new List <Visio.Shape>();

            foreach (DocCube cube in server.cubes)
            {
                cubeShapes.Add(adaptPage.Drop(visioCubeMaster, 6, 5));
            }

            Visio.Shape visioCubeShape1 = adaptPage.Drop(visioCubeMaster, 4.25, 1.5);
            visioCubeShape1.Text = @"My 1st Cube";
            visioCubeShape1.Resize(Visio.VisResizeDirection.visResizeDirN, 2, Visio.VisUnitCodes.visCentimeters);
            visioCubeShape1.Resize(Visio.VisResizeDirection.visResizeDirE, 2, Visio.VisUnitCodes.visCentimeters);

            Visio.Shape visioDimensionShape1 = adaptPage.DropConnected(visioDimensionMaster, visioCubeShape1, Visio.VisAutoConnectDir.visAutoConnectDirNone, visioUsedByMaster);
            visioDimensionShape1.Text = @"My 1st Dimension";

            Visio.Shape visioDimensionShape2 = adaptPage.Drop(visioDimensionMaster, 6.25, 2.5);
            visioDimensionShape2.Text = @"My 2nd Dimension";

            //Visio.Shape visioUsedByShape1 = visioUsedByMaster.Shapes.;

            // Sample code for grouping...
            select = doc.Application.ActiveWindow.Selection;
            select.SelectAll();
            group = select.Group();

            visioDimensionShape2.AutoConnect(visioDimensionShape1, Visio.VisAutoConnectDir.visAutoConnectDirNone);

            //Visio.Connect visioUsedBy1 = adaptPage.Connects(visioUsedByMaster, 6.25, 2.5);
            //visioDimensionShape2.Text = @"My 2nd Dimension";



            //adaptPage.Drop(visioUsedByShape1, 5, 5);
            //Visio.Shape visioCubeShape2 = visioCubeMaster.;
        }
Пример #5
0
        public void AddShapes()
        {
            Visio.Application visio     = this.Application;
            Visio.Documents   documents = this.Application.Documents;

            Visio.Page     page     = visio.ActivePage;
            Visio.Document document = visio.ActiveDocument;
            if (document == null)
            {
                document = visio.Documents.Add("");
            }

            if (page == null)
            {
                page = document.Pages.Add();
            }

            List <Service> services = null;

            try
            {
                ServicesApi api = new ServicesApi();
                services = api.getServices(true, "");
            }
            catch (ApiException e)
            {
                System.Windows.Forms.MessageBox.Show("Error calling the LeanIX API: " + e.Message);
                return;
            }
            catch (System.Net.WebException)
            {
                System.Windows.Forms.MessageBox.Show("Please check your internet connection");
                return;
            }

            if (services == null || services.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show("No data received from API");
                return;
            }

            Dictionary <String, Visio.Shape> placedShapes = new Dictionary <String, Visio.Shape>();

            //add shapes
            foreach (Service s in services)
            {
                if (s.serviceHasInterfaces == null || s.serviceHasInterfaces.Count == 0)
                {
                    continue;
                }

                Visio.Document stencil = documents.OpenEx("Basic Shapes.vss",
                                                          (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked);
                Visio.Master visioRectMaster = stencil.Masters.get_ItemU(@"Rounded Rectangle");

                Visio.Shape visioRectShape = page.Drop(visioRectMaster, 0, 0);
                visioRectShape.Text = s.name;
                placedShapes.Add(s.ID, visioRectShape);
            }

            //connect shapes
            foreach (Service s in services)
            {
                foreach (ServiceHasInterface si in s.serviceHasInterfaces)
                {
                    Visio.Shape sourceShape = placedShapes[s.ID];
                    Visio.Shape targetShape = placedShapes[si.serviceRefID];
                    if (targetShape != null)
                    {
                        sourceShape.AutoConnect(targetShape, Visio.VisAutoConnectDir.visAutoConnectDirLeft);
                    }
                }
            }

            //set the layout and resize the page
            page.PageSheet.get_CellsSRC(
                (short)Visio.VisSectionIndices.visSectionObject,
                (short)Visio.VisRowIndices.visRowPageLayout,
                (short)Visio.VisCellIndices.visPLOPlaceStyle).ResultIU = 6;

            page.PageSheet.get_CellsSRC(
                (short)Visio.VisSectionIndices.visSectionObject,
                (short)Visio.VisRowIndices.visRowPageLayout,
                (short)Visio.VisCellIndices.visPLORouteStyle).ResultIU = 1;

            page.PageSheet.get_CellsSRC(
                (short)Visio.VisSectionIndices.visSectionObject,
                (short)Visio.VisRowIndices.visRowPageLayout,
                (short)Visio.VisCellIndices.visPLOSplit).ResultIU = 1;

            page.Layout();
            page.ResizeToFitContents();
        }