Lavorare con la sezione Geometria
Contents
[
Hide
]
Modifica la sezione della geometria del connettore nello ShapeSheet
Qualsiasi forma in Microsoft Office Visio è composta da una o più “geometrie”. Ogni geometria rappresenta un diverso componente della forma. La maggior parte delle forme ha una sola geometria, ma alcune ne hanno due o più. Le API Aspose.Diagram consentono agli sviluppatori di gestire queste geometrie in modo programmatico.
Esempio di programmazione
I frammenti di codice seguenti gestiscono le geometrie di una forma.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_GeometrySection(); | |
// Load source Visio diagram | |
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx"); | |
// Set connector shape by page name and ID | |
long connectorId = 4; | |
Shape connector = diagram.Pages.GetPage("Page-1").Shapes.GetShape(connectorId); | |
// Get connector geometry at index 0 | |
LineTo defaultLineTo = connector.Geoms[0].CoordinateCol.LineToCol[0]; | |
// Remove connector geometry from index 0 | |
connector.Geoms[0].CoordinateCol.LineToCol[0].Del = BOOL.True; | |
// Initialize LineTo geometry object | |
LineTo lineTo = new LineTo(); | |
// Set X value | |
lineTo.X.Value = 0; | |
// Set Y value | |
lineTo.Y.Value = defaultLineTo.Y.Value / 2; | |
// Add connector geometry | |
connector.Geoms[0].CoordinateCol.Add(lineTo); | |
// Initialize LineTo geometry object | |
lineTo = new LineTo(); | |
// Set Y value | |
lineTo.Y.Value = defaultLineTo.Y.Value / 2; | |
// Set X value | |
lineTo.X.Value = defaultLineTo.X.Value; | |
// Add connector geometry | |
connector.Geoms[0].CoordinateCol.Add(lineTo); | |
// Initialize LineTo geometry object | |
lineTo = new LineTo(); | |
// Set X value | |
lineTo.X.Value = defaultLineTo.X.Value; | |
// Set Y value | |
lineTo.Y.Value = defaultLineTo.Y.Value; | |
// Add connector geometry | |
connector.Geoms[0].CoordinateCol.Add(lineTo); | |
// Save diagram in VDX format | |
diagram.Save(dataDir + "EditConnectorGeometry_out.vsdx", SaveFileFormat.VSDX); |