使用几何部分
Contents
[
Hide
]
在 ShapeSheet 中编辑连接器几何部分
Microsoft Office Visio 中的任何形状都是由一个或多个“几何图形”组成的。每个几何图形代表形状的不同组成部分。大多数形状只有一种几何形状,但有些形状有两种或更多。 Aspose.Diagram API 允许开发人员以编程方式管理这些几何图形。
编程范例
下面的代码片段管理形状的几何形状。
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); |