Ich verwende die AutoConnect-Methode, um Formen programmgesteuert für einen Export von "Aktionen" aus einer Datenbank in meinem Programm zu verbinden. Wenn eine Form sich mit sich selbst verbindet, bombardiert die AutoConnect-Methode. Ich habe mich gefragt, ob jemand Ideen über einen anderen Weg hat, dies zu erreichen.Programmatisches Verbinden einer Form mit sich selbst
private void connectExportedActions(DataTable dt, Page page, Document currentStencil)
{
List<string> Connectors = new List<string>();
Shape parallelShape;
Shape successShape;
Shape unsuccessShape;
Shape timeoutShape;
Master connector;
Shape timeout;
string timeoutDisplay;
foreach (DataRow row in dt.Rows)
{
Shape shape = page.Shapes.get_ItemFromID((int)row["ShapeID"]);
if (row["acdParallelActionDefID"].ToString() != "" && row["acdParallelActionDefID"].ToString() != "NULL")
{
Connectors.Add("Parallel Connector");
}
if (row["acdPositiveActionDefID"].ToString() != "" && row["acdPositiveActionDefID"].ToString() != "NULL")
{
Connectors.Add("Successful Connector");
}
if (row["acdNegativeActionDefID"].ToString() != "" && row["acdNegativeActionDefID"].ToString() != "NULL")
{
Connectors.Add("Unsuccessful Connector");
}
if (row["acdTimeOutActionDefID"].ToString() != "" && row["acdTimeOutActionDefID"].ToString() != "NULL")
{
Connectors.Add("Timeout Connector");
}
foreach (string conn in Connectors)
{
foreach (Master mst in currentStencil.Masters)
{
if (mst.Name == conn)
{
Console.WriteLine(String.Format("Action Name: {0}, ActionDefID: {1}", row["acdName"].ToString(), row["ActionDefID"].ToString()));
switch (conn)
{
case "Parallel Connector":
connector = mst; //page.Drop(mst, 0, 0);
parallelShape = getShape(dt, row, "ActionDefID", "acdParallelActionDefID", page);
**shape.AutoConnect(parallelShape, VisAutoConnectDir.visAutoConnectDirRight, connector);**
break;
case "Successful Connector":
connector = mst; //page.Drop(mst, 0, 0);
successShape = getShape(dt, row, "ActionDefID", "acdPositiveActionDefID", page);
**shape.AutoConnect(successShape, VisAutoConnectDir.visAutoConnectDirDown, connector);**
break;
case "Unsuccessful Connector":
connector = mst; // page.Drop(mst, 0, 0);
unsuccessShape = getShape(dt, row, "ActionDefID", "acdNegativeActionDefID", page);
//Console.WriteLine(String.Format("Action Name: {0}, ActionDefID: {1}", row["acdName"].ToString(), row["ActionDefID"].ToString()));
**shape.AutoConnect(unsuccessShape, VisAutoConnectDir.visAutoConnectDirLeft, connector);**
break;
case "Timeout Connector":
timeout = page.Drop(mst, 0, 0);
timeoutShape = getShape(dt, row, "ActionDefID", "acdTimeOutActionDefID", page);
timeoutDisplay = "T = " + row["acdDeadlinePeriod"].ToString() + " days";
timeout.Cells["Prop.Display"].FormulaU = "\"" + timeoutDisplay + "\"";
**shape.AutoConnect(timeoutShape, VisAutoConnectDir.visAutoConnectDirLeft, timeout);**
timeout.Delete();
break;
}
}
}
}
Connectors.Clear();
}
}
private Shape getShape(DataTable dt, DataRow row, string fieldname, string rowcolumn, Page page)
{
DataRow[] foundRows;
foundRows = dt.Select(fieldname + " = " + row[rowcolumn].ToString());
int ShapeID = (int)foundRows[0]["ShapeID"];
Shape shape = page.Shapes.get_ItemFromID(ShapeID);
return shape;
}
Das ist eine Menge von Text (und zu verstehen) zu lesen ist und eine Menge Code auch (und verstehen) zu lesen. Kannst du das Ganze eingrenzen? –
Grundsätzlich verwende ich die Autoconnect-Methode, um Shapes miteinander zu verbinden. Wenn ich versuche, eine Form mit sich selbst zu verbinden, bombardiert die Autoconnect-Methode. Gibt es eine Möglichkeit, dies programmgesteuert ohne Verwendung der Autoconnect-Methode zu tun? – user2048126