I need your help connecting shapes.
I am reading a visio file using aspose, in the first part I have a list with the shapes (Shape, Id) and other list with connectors (shape from, shape to).
The shape to (Id 344) does not exist in my list of shapes.
What can I do?
Attached is the project in visual studio 2015 and the image “ThisIdDoesnotexist.png” with the result.
My code is the following.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;
using Aspose.Diagram;
using System.IO;
namespace ConnShapes
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnRead_Click(object sender, EventArgs e)
{
readfile("CnnShapes.vsd");
}
private void readfile(string fileName)
{
DataTable dt = new DataTable();
dt.Columns.Add(new System.Data.DataColumn("Shape", typeof(string)));
dt.Columns.Add(new System.Data.DataColumn("Shape Id", typeof(string)));
DataTable dt2 = new DataTable();
dt2.Columns.Add(new System.Data.DataColumn("Shape From", typeof(string)));
dt2.Columns.Add(new System.Data.DataColumn("Shape To", typeof(string)));
string licencepath = @"d:\Aspose.Total.lic";
Aspose.Diagram.License diagramLicense = new Aspose.Diagram.License();
diagramLicense.SetLicense(licencepath);
FileStream st = new FileStream(fileName, FileMode.Open);
Diagram vsdDiagram = new Diagram(st);
foreach (Aspose.Diagram.Page page in vsdDiagram.Pages)
{
foreach (Aspose.Diagram.Shape shape in page.Shapes)
{
DataRow r = dt.NewRow();
r["Shape"] = shape.Name + "-" + shape.NameU;
r["Shape Id"] = shape.ID.ToString();
dt.Rows.Add(r);
}
foreach (Aspose.Diagram.Connect connector in page.Connects)
{
DataRow r = dt2.NewRow();
r["Shape From"] = connector.FromSheet.ToString();
r["Shape To"] = connector.ToSheet.ToString();
dt2.Rows.Add(r);
}
}
dataGridView1.DataSource = dt;
dataGridView2.DataSource = dt2;
}
}
}
Thanks for your help.