How can I use different type of connectors to connect the shapes

S

shailendrasingh823

Hi All,



Currently I can use only one type of connector only (this is Dynamic
connector) to connect my shapes.I want to use another connectors also
like Logical connector,Comm-link like that some more,But when I use
other type of connector shapes couldnot connect & got the error
"Inappropriate Source object for this action" connector has been
dropped on the page but not connect with specific shapes.
If you have any Idea then please let me know.I will be thankful to
you.

Regards
Shelendra Singh
 
S

shailendrasingh823

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top