本文整理汇总了C#中Diagram.AddShapeToLayers方法的典型用法代码示例。如果您正苦于以下问题:C# Diagram.AddShapeToLayers方法的具体用法?C# Diagram.AddShapeToLayers怎么用?C# Diagram.AddShapeToLayers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Diagram
的用法示例。
在下文中一共展示了Diagram.AddShapeToLayers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDiagram
//.........这里部分代码省略.........
evenRowLayer = LayerIds.None, oddColLayer = LayerIds.None, evenColLayer = LayerIds.None;
if (withLayers) {
const string planarLayerName = "PlanarShapesLayer";
const string linearLayerName = "LinearShapesLayer";
const string oddRowsLayerName = "OddRowsLayer";
const string evenRowsLayerName = "EvenRowsLayer";
const string oddColsLayerName = "OddColsLayer";
const string evenColsLayerName = "EvenColsLayer";
// Create Layers
Layer planarShapesLayer = new Layer(planarLayerName);
planarShapesLayer.Title = "Planar Shapes";
planarShapesLayer.LowerZoomThreshold = 5;
planarShapesLayer.UpperZoomThreshold = 750;
diagram.Layers.Add(planarShapesLayer);
Layer linearShapesLayer = new Layer(linearLayerName);
linearShapesLayer.Title = "Linear Shapes";
linearShapesLayer.LowerZoomThreshold = 10;
linearShapesLayer.UpperZoomThreshold = 500;
diagram.Layers.Add(linearShapesLayer);
Layer oddRowsLayer = new Layer(oddRowsLayerName);
oddRowsLayer.Title = "Odd Rows";
oddRowsLayer.LowerZoomThreshold = 2;
oddRowsLayer.UpperZoomThreshold = 1000;
diagram.Layers.Add(oddRowsLayer);
Layer evenRowsLayer = new Layer(evenRowsLayerName);
evenRowsLayer.Title = "Even Rows";
evenRowsLayer.LowerZoomThreshold = 2;
evenRowsLayer.UpperZoomThreshold = 1000;
diagram.Layers.Add(evenRowsLayer);
Layer oddColsLayer = new Layer(oddColsLayerName);
oddColsLayer.Title = "Odd Columns";
oddColsLayer.LowerZoomThreshold = 2;
oddColsLayer.UpperZoomThreshold = 1000;
diagram.Layers.Add(oddColsLayer);
Layer evenColsLayer = new Layer(evenColsLayerName);
evenColsLayer.Title = "Even Columns";
evenColsLayer.LowerZoomThreshold = 2;
evenColsLayer.UpperZoomThreshold = 1000;
diagram.Layers.Add(evenColsLayer);
// Assign LayerIds
planarLayer = diagram.Layers.FindLayer(planarLayerName).Id;
linearLayer = diagram.Layers.FindLayer(linearLayerName).Id;
oddRowLayer = diagram.Layers.FindLayer(oddRowsLayerName).Id;
evenRowLayer = diagram.Layers.FindLayer(evenRowsLayerName).Id;
oddColLayer = diagram.Layers.FindLayer(oddColsLayerName).Id;
evenColLayer = diagram.Layers.FindLayer(evenColsLayerName).Id;
}
for (int rowIdx = 0; rowIdx < shapesPerColumn; ++rowIdx) {
LayerIds rowLayer = ((rowIdx + 1) % 2 == 0) ? evenRowLayer : oddRowLayer;
for (int colIdx = 0; colIdx < shapesPerRow; ++colIdx) {
LayerIds colLayer = ((colIdx + 1) % 2 == 0) ? evenColLayer : oddColLayer;
int shapePosX = shapeSize + colIdx * (lineLength + shapeSize);
int shapePosY = shapeSize + rowIdx * (lineLength + shapeSize);
planarShape = planarTemplate.CreateShape();
if (planarShape is ICaptionedShape)
((ICaptionedShape)planarShape).SetCaptionText(0, string.Format("{0} / {1}", rowIdx + 1, colIdx + 1));
planarShape.MoveTo(shapePosX, shapePosY);
if (withModels) {
project.Repository.Insert(planarShape.ModelObject);
((GenericModelObject)planarShape.ModelObject).IntegerValue = rowIdx;
}
diagram.Shapes.Add(planarShape, project.Repository.ObtainNewTopZOrder(diagram));
if (withLayers) diagram.AddShapeToLayers(planarShape, planarLayer | rowLayer | colLayer);
if (connectShapes) {
if (rowIdx > 0) {
Shape lineShape = linearTemplate.CreateShape();
lineShape.Connect(ControlPointId.FirstVertex, planarShape, topPoint);
Debug.Assert(ControlPointId.None != lineShape.IsConnected(ControlPointId.FirstVertex, planarShape));
Shape otherShape = diagram.Shapes.FindShape(shapePosX, shapePosY - (shapeSize + lineLength), ControlPointCapabilities.None, 0, null);
Debug.Assert(otherShape != null && otherShape != planarShape);
lineShape.Connect(ControlPointId.LastVertex, otherShape, bottomPoint);
diagram.Shapes.Add(lineShape, project.Repository.ObtainNewBottomZOrder(diagram));
if (withLayers) diagram.AddShapeToLayers(lineShape, linearLayer);
Debug.Assert(ControlPointId.None != lineShape.IsConnected(ControlPointId.LastVertex, otherShape));
}
if (colIdx > 0) {
Shape lineShape = linearTemplate.CreateShape();
lineShape.Connect(1, planarShape, leftPoint);
Debug.Assert(ControlPointId.None != lineShape.IsConnected(ControlPointId.FirstVertex, planarShape));
Shape otherShape = diagram.Shapes.FindShape(shapePosX - (shapeSize + lineLength), shapePosY, ControlPointCapabilities.None, 0, null);
Debug.Assert(otherShape != null && otherShape != planarShape);
lineShape.Connect(2, otherShape, rightPoint);
diagram.Shapes.Add(lineShape, project.Repository.ObtainNewBottomZOrder(diagram));
if (withLayers) diagram.AddShapeToLayers(lineShape, linearLayer);
Debug.Assert(ControlPointId.None != lineShape.IsConnected(ControlPointId.LastVertex, otherShape));
}
}
}
}
diagram.Width = ((shapeSize + lineLength) * shapesPerRow) + lineLength;
diagram.Height = ((shapeSize + lineLength) * shapesPerColumn) + lineLength;
project.Repository.InsertAll(diagram);
}