本文整理汇总了C#中IDiagramPresenter.InsertShape方法的典型用法代码示例。如果您正苦于以下问题:C# IDiagramPresenter.InsertShape方法的具体用法?C# IDiagramPresenter.InsertShape怎么用?C# IDiagramPresenter.InsertShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDiagramPresenter
的用法示例。
在下文中一共展示了IDiagramPresenter.InsertShape方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareConnection
private bool PrepareConnection(IDiagramPresenter diagramPresenter, MouseState mouseState,
ShapeAtCursorInfo shapeAtCursorInfo, Action action)
{
// if we're not dealing with filter shapes... well, what the fuck?! get out of here!
FilterSetupShapeBase shape = shapeAtCursorInfo.Shape as FilterSetupShapeBase;
if (shape == null)
throw new Exception("Can't connect a shape that isn't a FilterSetup shape!");
if (shape.OutputCount <= 0)
return false;
// get the starting control point for the line; ie. the first unused output for the shape, or the selected control point (if the mouse is over an output)
ControlPointId connectionPoint = ControlPointId.None;
if (shapeAtCursorInfo.IsCursorAtConnectionPoint &&
shape.GetTypeForControlPoint(shapeAtCursorInfo.ControlPointId) ==
FilterSetupShapeBase.FilterShapeControlPointType.Output) {
connectionPoint = shapeAtCursorInfo.ControlPointId;
}
else {
// try and find the first unconnected output if the mouse isn't over a specific control point
for (int i = 0; i < shape.OutputCount; i++) {
ControlPointId currentPoint = shape.GetControlPointIdForOutput(i);
if (shape.GetConnectionInfos(currentPoint, null).Count() == 0) {
connectionPoint = currentPoint;
break;
}
}
// if we couldn't find an unconnected point, just default to the first
if (connectionPoint == ControlPointId.None) {
connectionPoint = shape.GetControlPointIdForOutput(0);
}
}
DataFlowConnectionLine line =
(DataFlowConnectionLine) diagramPresenter.Project.ShapeTypes["DataFlowConnectionLine"].CreateInstance();
diagramPresenter.InsertShape(line);
diagramPresenter.Diagram.Shapes.SetZOrder(line, 100);
line.SecurityDomainName = ConfigFiltersAndPatching.SECURITY_DOMAIN_MOVABLE_SHAPE_WITH_CONNECTIONS;
line.EndCapStyle = diagramPresenter.Project.Design.CapStyles.ClosedArrow;
line.SourceDataFlowComponentReference = new DataFlowComponentReference(shape.DataFlowComponent,
shape.GetOutputNumberForControlPoint(
connectionPoint));
line.DestinationDataComponent = null;
line.Connect(ControlPointId.FirstVertex, shape, connectionPoint);
line.Disconnect(ControlPointId.LastVertex);
line.MoveControlPointTo(ControlPointId.LastVertex, mouseState.X, mouseState.Y, ResizeModifiers.None);
currentConnectionLine = line;
StartToolAction(diagramPresenter, (int) action, ActionStartMouseState, true);
return true;
}