2012-08-31 3 views
0

Visio에서 프로그래밍 방식으로 UML 다이어그램을 그리는 중입니다. 동적 연결구를 사용하여 셰이프를 연결합니다. 그러나 커넥터가 오히려 모양을 통과하는 상황이 있습니다. (예를 들어, 커넥터는 소스와 대상 사이에있는 다른 모양을 통해 소스 모양에서 대상 모양으로가는 경로를 만듭니다.) 커넥터를 페이지 만 통과시켜야합니다 .Pls가이를 가능하게하는 방법을 제안합니다.UML 다이어그램에서 커넥터 경로를 제어하는 ​​방법

답변

1

당신은 C#을에서 번역해야 할 것이다, 그러나 이것은 내가하고 있어요 방법은 다음과 같습니다

/// <summary>Attaches two Visio shapes to each other with the specified connector object.</summary> 
/// <param name="shape1">Visio shape to connect from.</param> 
/// <param name="shape2">Visio shape to connect to.</param> 
/// <param name="connector">Visio line shape that will connect shape1 to shape2.</param> 
/// <param name="straight">Whether this connector should be a straight line</param> 
[CLSCompliant(false)] 
protected static void ConnectShapes(
    Visio.Shape shape1, 
    Visio.Shape shape2, 
    Visio.Shape connector, 
    bool straight = false) 
    { 
     try 
     { 
      // get the cell from the source side of the connector 
      Visio.Cell beginXCell = connector.CellsSRC[(short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXForm1D, (short)Visio.VisCellIndices.vis1DBeginX]; 

      // glue the source side of the connector to the first shape 
      beginXCell.GlueTo(shape1.CellsSRC[(short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXFormOut, (short)Visio.VisCellIndices.visXFormPinX]); 

      // get the cell from the destination side of the connector 
      Visio.Cell endXCell = connector.CellsSRC[(short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXForm1D, (short)Visio.VisCellIndices.vis1DEndX]; 

      // glue the destination side of the connector to the second shape 
      endXCell.GlueTo(shape2.CellsSRC[(short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXFormOut, (short)Visio.VisCellIndices.visXFormPinX]); 

      if (straight) 
      { 
       connector.CellsU["ConLineRouteExt"].ResultIUForce = (double)Visio.VisCellVals.visLORouteExtStraight; 
       connector.CellsU["ShapeRouteStyle"].ResultIUForce = (double)Visio.VisCellVals.visLORouteCenterToCenter; 
      } 
      else 
      { 
       // THIS IS WHAT YOU ARE LOOKING FOR 
       connector.CellsU["ConLineRouteExt"].ResultIUForce = (double)Visio.VisCellVals.visLORouteExtNURBS; 
       connector.CellsU["ShapeRouteStyle"].ResultIUForce = (double)Visio.VisCellVals.visLORouteRightAngle; 
      } 
     } 
     catch (Exception e) 
     { 
      throw (e); 
     } 
    }