Old type connectors and a line can glue only to the connection points.
Soory june I am not clear what do you mean to say "Old type connectors
and a line can glue only to the connection points"
Here when I am using GlueTo (Shape.cell) method then I am getting the
error.means . code is following---
Please see glueConnectionToItems(
drawingPage,newShape, shapeIndexFrom,
shapeIndexTo); method ; I think I need to do some modification in
this method.
private static bool addConnectionsToDrawing(
Visio.Page drawingPage)
{
bool connectionsAdded = false;
try
{
// Use the Connections master.
Visio.Master connectionMaster =
drawingPage.Document.Masters[_VisioConnectionMasterName];
Visio.Master LogicalconnectionMaster =
drawingPage.Document.Masters[_VisioLogicalConnectionMasterName];
Visio.Master CommonconnectionMaster =
drawingPage.Document.Masters[_VisioCommonlinkMasterName];
if (connectionMaster != null ||
LogicalconnectionMaster!=null)
{
// Get the information about the connection data
from the
// linked data recordset.
Visio.DataRecordset connectionsDataRecordset =
drawingPage.Document.DataRecordsets[
_ConnectionsDataRecordsetIndex];
int nameColumnIndex;
int fromColumnIndex;
int toColumnIndex;
Visio.Shape newShape=null;
getConnectionColumnIndicies(connectionsDataRecordset,
out nameColumnIndex, out fromColumnIndex,
out toColumnIndex);
// Loop through each Connection in the Connection
table,
// dropping new shapes in random locations.
Random randomLocation = new Random();
Array rowIDs =
connectionsDataRecordset.GetDataRowIDs(string.Empty);
foreach (int thisRowID in rowIDs)
{
// Populate the shape with information from
the data row.
Array rowData =
connectionsDataRecordset.GetRowData(thisRowID);
if (((string)rowData.GetValue(4))
.Equals("Dynamic"))
{
// Create the DynamicConnectionshape.
newShape =
drawingPage.DropLinked(connectionMaster,
(randomLocation.NextDouble() * 10),
(randomLocation.NextDouble() * 10),
connectionsDataRecordset.ID,
thisRowID,
false);
}
if (((string)rowData.GetValue(4))
.Equals("Logical"))
{
newShape =
drawingPage.DropLinked(CommonconnectionMaster,
(randomLocation.NextDouble() * 10),
(randomLocation.NextDouble() * 10),
connectionsDataRecordset.ID,
thisRowID,
false);
// Visio.Cell shapeCell =
//newShape.get_CellsSRC(
//(short)Visio.VisSectionIndices.visSectionObject,
//2,
//(short)Visio.VisCellIndices.visXFormPinX);
//
shapeCell.set_Result(Visio.VisSectionIndices.visSectionObject, 2);
}
//Visio.Window conwin =
newShape.OpenSheetWindow();
// Set the Name value.
newShape.get_Cells("Prop._VisDM_Name").Formula
=
"\"" +
rowData.GetValue(nameColumnIndex).ToString() + "\"";
newShape.get_Cells("Prop._VisDM_ItemFrom").Formula = "\"" +
rowData.GetValue(fromColumnIndex).ToString() + "\"";
// Glue the connection to the Item shapes.
int shapeIndexFrom =
(int)_ItemShapeIndexMap[
(int)rowData.GetValue(fromColumnIndex)];
int shapeIndexTo =
(int)_ItemShapeIndexMap[
(int)rowData.GetValue(toColumnIndex)];
glueConnectionToItems(
drawingPage,newShape, shapeIndexFrom,
shapeIndexTo);
}
connectionsAdded = true;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return connectionsAdded;
}
//////////////////////////////////////////////glueConnectionToItems
method starts///////////////////////////
private static void glueConnectionToItems(
Visio.Page drawingPage,Visio.Shape
connectionShape,
int fromShapeIndex,
int toShapeIndex)
{
try
{
Visio.Cell shapeCell =
drawingPage.Shapes[fromShapeIndex].get_CellsSRC(
(short)Visio.VisSectionIndices.visSectionObject,
(short)Visio.VisRowIndices.visRowXFormOut,
(short)Visio.VisCellIndices.visXFormPinX);
Visio.Cell connectorCell =
connectionShape.get_CellsSRC(
(short)Visio.VisSectionIndices.visSectionObject,
(short)Visio.VisRowIndices.visRowXForm1D,
(short)Visio.VisCellIndices.vis1DBeginX);
object obj = shapeCell.GetType();
connectorCell.GlueTo(shapeCell);
// Glue the end of the connection to the "To" shape.
shapeCell =
drawingPage.Shapes[toShapeIndex].get_CellsSRC(
(short)Visio.VisSectionIndices.visSectionObject,
(short)Visio.VisRowIndices.visRowXFormOut,
(short)Visio.VisCellIndices.visXFormPinX);
connectorCell =
connectionShape.get_CellsSRC(
(short)Visio.VisSectionIndices.visSectionObject,
(short)Visio.VisRowIndices.visRowXForm1D,
(short)Visio.VisCellIndices.vis1DEndX);
connectorCell.GlueTo(shapeCell);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Shail