本文整理汇总了C#中IDiagramPresenter.IsLayerVisible方法的典型用法代码示例。如果您正苦于以下问题:C# IDiagramPresenter.IsLayerVisible方法的具体用法?C# IDiagramPresenter.IsLayerVisible怎么用?C# IDiagramPresenter.IsLayerVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDiagramPresenter
的用法示例。
在下文中一共展示了IDiagramPresenter.IsLayerVisible方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePreviewShapes
/// <summary>
/// Create Previews of all shapes selected in the CurrentDisplay.
/// These previews are connected to all the shapes the original shapes are connected to.
/// </summary>
private void CreatePreviewShapes(IDiagramPresenter diagramPresenter)
{
if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
if (Previews.Count == 0 && diagramPresenter.SelectedShapes.Count > 0) {
// first, clone all selected shapes...
foreach (Shape shape in diagramPresenter.SelectedShapes) {
if (!diagramPresenter.IsLayerVisible(shape.Layers)) continue;
AddPreview(shape, shape.Type.CreatePreviewInstance(shape), diagramPresenter.DisplayService);
}
// ...then restore connections between previews and connections between previews and non-selected shapes
targetShapeBuffer.Clear();
foreach (Shape selectedShape in diagramPresenter.SelectedShapes.BottomUp) {
if (!diagramPresenter.IsLayerVisible(selectedShape.Layers)) continue;
// AttachGluePointToConnectionPoint the preview shape (and all it's cildren) to all the shapes the original shape was connected to
// Additionally, create previews for all connected shapes and connect these to the appropriate target shapes
ConnectPreviewOfShape(diagramPresenter, selectedShape);
}
targetShapeBuffer.Clear();
}
}
示例2: CreateConnectedTargetPreviewShape
/// <summary>
/// Creates (or finds) a preview of the connection's PassiveShape and connects it to the current preview shape
/// </summary>
private void CreateConnectedTargetPreviewShape(IDiagramPresenter diagramPresenter, Shape previewShape,
ShapeConnectionInfo connectionInfo)
{
// Check if any other selected shape is connected to the same non-selected shape
Shape previewTargetShape;
// If the current passiveShape is already connected to another shape of the current selection,
// connect the current preview to the other preview's passiveShape
if (!targetShapeBuffer.TryGetValue(connectionInfo.OtherShape, out previewTargetShape)) {
// If the current passiveShape is not connected to any other of the selected selectedShapes,
// create a clone of the passiveShape and connect it to the corresponding preview
// If the preview exists, abort connecting (in this case, the shape is a preview of a child shape)
if (previewShapes.ContainsKey(connectionInfo.OtherShape))
return;
else {
previewTargetShape = connectionInfo.OtherShape.Type.CreatePreviewInstance(connectionInfo.OtherShape);
AddPreview(connectionInfo.OtherShape, previewTargetShape, diagramPresenter.DisplayService);
}
// Add passive shape and it's clone to the passive shape dictionary
targetShapeBuffer.Add(connectionInfo.OtherShape, previewTargetShape);
}
// Connect the (new or existing) preview shapes
// Skip connecting if the preview is already connected.
if (previewTargetShape.IsConnected(connectionInfo.OtherPointId, null) == ControlPointId.None) {
previewTargetShape.Connect(connectionInfo.OtherPointId, previewShape, connectionInfo.OwnPointId);
// check, if any shapes are connected to the connector (that is connected to the selected shape)
foreach (ShapeConnectionInfo connectorCI in connectionInfo.OtherShape.GetConnectionInfos(ControlPointId.Any, null)) {
if (!diagramPresenter.IsLayerVisible(connectorCI.OtherShape.Layers)) continue;
// skip if the connector is connected to the shape with more than one glue point
if (connectorCI.OtherShape == FindShapeOfPreview(previewShape)) continue;
if (connectorCI.OwnPointId != connectionInfo.OtherPointId) {
// Check if the shape on the other end is selected.
// If it is, connect to it's preview or skip connecting if the target preview does
// not exist yet (it will be connected when creating the targt's preview)
if (diagramPresenter.SelectedShapes.Contains(connectorCI.OtherShape)) {
if (previewShapes.ContainsKey(connectorCI.OtherShape)) {
Shape s = FindPreviewOfShape(connectorCI.OtherShape);
if (s.IsConnected(connectorCI.OtherPointId, previewTargetShape) == ControlPointId.None)
previewTargetShape.Connect(connectorCI.OwnPointId, s, connectorCI.OtherPointId);
}
else continue;
}
else if (connectorCI.OtherShape.HasControlPointCapability(connectorCI.OtherPointId, ControlPointCapabilities.Glue))
// Connect connectors connected to the previewTargetShape
CreateConnectedTargetPreviewShape(diagramPresenter, previewTargetShape, connectorCI);
else if (connectorCI.OtherPointId == ControlPointId.Reference) {
// Connect the other end of the previewTargetShape if the connection is a Point-To-Shape connection
if (previewTargetShape.IsConnected(connectorCI.OwnPointId, null) == ControlPointId.None)
previewTargetShape.Connect(connectorCI.OwnPointId, connectorCI.OtherShape, connectorCI.OtherPointId);
}
}
}
}
}
示例3: DoFindConnectionTarget
/// <summary>
/// Find the topmost shape that is not selected and has a valid ConnectionPoint (or ReferencePoint)
/// in range of the given point.
/// </summary>
private ShapeAtCursorInfo DoFindConnectionTarget(IDiagramPresenter diagramPresenter, Shape shape, ControlPointId gluePointId, int x, int y, bool onlyUnselected, int range) {
if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
if (range < 0) throw new ArgumentOutOfRangeException("range");
// Find (non-selected shape) its connection point under cursor
ShapeAtCursorInfo result = ShapeAtCursorInfo.Empty;
int resultZOrder = int.MinValue;
if (diagramPresenter.Diagram != null) {
foreach (Shape s in FindVisibleShapes(diagramPresenter, x, y, ControlPointCapabilities.Connect, range)) {
if (s == shape) continue;
if (s.Layers != LayerIds.None && !diagramPresenter.IsLayerVisible(s.Layers)) continue;
// Skip shapes below the last matching shape
if (s.ZOrder < resultZOrder) continue;
// If the shape is already connected to the found shape via point-to-shape connection
if (shape != null) {
if(!CanConnectTo(shape, gluePointId, s)) continue;
if (!CanConnectTo(diagramPresenter, shape,
(gluePointId == ControlPointId.FirstVertex) ? ControlPointId.LastVertex : ControlPointId.FirstVertex,
gluePointId, onlyUnselected)) continue;
}
// Skip selected shapes (if not wanted)
if (onlyUnselected && diagramPresenter.SelectedShapes.Contains(s)) continue;
// Perform a HitTest on the shape
ControlPointId pointId = s.HitTest(x, y, ControlPointCapabilities.Connect, range);
if (pointId != ControlPointId.None) {
if (s.HasControlPointCapability(pointId, ControlPointCapabilities.Glue)) continue;
result.Shape = s;
result.ControlPointId = pointId;
resultZOrder = s.ZOrder;
// If the found connection point is a dedicated connection point, take it. If the found connection point is
// the reference point of a shape, continue searching for a dedicated connection point.
if (result.ControlPointId != ControlPointId.Reference)
break;
}
}
}
return result;
}
示例4: ConnectPreviewOfShape
/// <summary>
/// Create previews of shapes connected to the given shape (and it's children) and connect them to the
/// shape's preview (or the preview of it's child)
/// </summary>
private void ConnectPreviewOfShape(IDiagramPresenter diagramPresenter, Shape shape)
{
// process shape's children
if (shape.Children != null && shape.Children.Count > 0) {
foreach (Shape childShape in shape.Children)
ConnectPreviewOfShape(diagramPresenter, childShape);
}
Shape preview = FindPreviewOfShape(shape);
foreach (ShapeConnectionInfo connectionInfo in shape.GetConnectionInfos(ControlPointId.Any, null)) {
if (!diagramPresenter.IsLayerVisible(connectionInfo.OtherShape.Layers)) continue;
if (diagramPresenter.SelectedShapes.Contains(connectionInfo.OtherShape)) {
// Do not connect previews if BOTH of the connected shapes are part of the selection because
// this would restrict movement of the connector shapes and decreases performance (many
// unnecessary FollowConnectionPointWithGluePoint() calls)
if (shape.HasControlPointCapability(connectionInfo.OwnPointId, ControlPointCapabilities.Glue)) {
if (IsConnectedToNonSelectedShape(diagramPresenter, shape)) {
Shape targetPreview = FindPreviewOfShape(connectionInfo.OtherShape);
preview.Connect(connectionInfo.OwnPointId, targetPreview, connectionInfo.OtherPointId);
}
}
}
else {
// Connect preview of shape to a non-selected shape if it is a single shape
// that has a glue point (e.g. a Label)
if (preview.HasControlPointCapability(connectionInfo.OwnPointId, ControlPointCapabilities.Glue)) {
// Only connect if the control point to be connected is not the control point to be moved
if (shape == selectedShapeAtCursorInfo.Shape &&
connectionInfo.OwnPointId != selectedShapeAtCursorInfo.ControlPointId)
preview.Connect(connectionInfo.OwnPointId, connectionInfo.OtherShape, connectionInfo.OtherPointId);
}
else
// Create a preview of the shape that is connected to the preview (recursive call)
CreateConnectedTargetPreviewShape(diagramPresenter, preview, connectionInfo);
}
}
}
示例5: FindVisibleShapes
/// <summary>
/// Finds all shapes that meet the given requirements and are *not* invisible due to layer restrictions
/// </summary>
protected IEnumerable<Shape> FindVisibleShapes(IDiagramPresenter diagramPresenter, int x, int y, ControlPointCapabilities pointCapabilities, int distance) {
if (diagramPresenter.Diagram == null) yield break;
foreach (Shape s in diagramPresenter.Diagram.Shapes.FindShapes(x, y, pointCapabilities, distance)) {
if (s.Layers == LayerIds.None || diagramPresenter.IsLayerVisible(s.Layers))
yield return s;
}
}