本文整理汇总了C#中Dataweb.NShape.Advanced.Template.MapProperties方法的典型用法代码示例。如果您正苦于以下问题:C# Template.MapProperties方法的具体用法?C# Template.MapProperties怎么用?C# Template.MapProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dataweb.NShape.Advanced.Template
的用法示例。
在下文中一共展示了Template.MapProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDiagram
public static void CreateDiagram(Project project, string diagramName, int shapeSize, int shapesPerRow, int shapesPerColumn, bool connectShapes, bool withModels, bool withMappings, bool withLayers)
{
shapeSize = Math.Max(10, shapeSize);
int lineLength = shapeSize / 2;
//
// Create ModelMappings
NumericModelMapping numericModelMapping = null;
FormatModelMapping formatModelMapping = null;
StyleModelMapping styleModelMapping = null;
if (withMappings) {
// Create numeric- and format model mappings
numericModelMapping = new NumericModelMapping(2, 4, NumericModelMapping.MappingType.FloatInteger, 10, 0);
formatModelMapping = new FormatModelMapping(4, 2, FormatModelMapping.MappingType.StringString, "{0}");
// Create style model mapping
float range = (shapesPerRow * shapesPerColumn) / 15f;
styleModelMapping = new StyleModelMapping(1, 4, StyleModelMapping.MappingType.FloatStyle);
for (int i = 0; i < 15; ++i) {
IStyle style = null;
switch (i) {
case 0: style = project.Design.LineStyles.None; break;
case 1: style = project.Design.LineStyles.Dotted; break;
case 2: style = project.Design.LineStyles.Dashed; break;
case 3: style = project.Design.LineStyles.Special1; break;
case 4: style = project.Design.LineStyles.Special2; break;
case 5: style = project.Design.LineStyles.Normal; break;
case 6: style = project.Design.LineStyles.Blue; break;
case 7: style = project.Design.LineStyles.Green; break;
case 8: style = project.Design.LineStyles.Yellow; break;
case 9: style = project.Design.LineStyles.Red; break;
case 10: style = project.Design.LineStyles.HighlightDotted; break;
case 11: style = project.Design.LineStyles.HighlightDashed; break;
case 12: style = project.Design.LineStyles.Highlight; break;
case 13: style = project.Design.LineStyles.HighlightThick; break;
case 14: style = project.Design.LineStyles.Thick; break;
default: style = null; break;
}
if (style != null) styleModelMapping.AddValueRange(i * range, style);
}
}
//
// Create model obejct for the planar shape's template
IModelObject planarModel = null;
if (withModels) planarModel = project.ModelObjectTypes["Core.GenericModelObject"].CreateInstance();
//
// Create a shape for the planar shape's template
Shape planarShape = project.ShapeTypes["RoundedBox"].CreateInstance();
planarShape.Fit(0, 0, shapeSize, shapeSize);
//
// Create a template for the planar shapes
Template planarTemplate = new Template("PlanarShape Template", planarShape);
if (withModels) {
planarTemplate.Shape.ModelObject = planarModel;
if (withMappings) {
foreach (ControlPointId id in planarTemplate.Shape.GetControlPointIds(ControlPointCapabilities.Connect))
planarTemplate.MapTerminal(TerminalId.Generic, id);
planarTemplate.MapProperties(numericModelMapping);
planarTemplate.MapProperties(formatModelMapping);
planarTemplate.MapProperties(styleModelMapping);
}
}
//
// Create a template for the linear shapes
Template linearTemplate = null;
if (connectShapes)
linearTemplate = new Template("LinearShape Template", project.ShapeTypes["Polyline"].CreateInstance());
//
// Insert the created templates into the repository
project.Repository.InsertAll(planarTemplate);
if (connectShapes) project.Repository.InsertAll(linearTemplate);
//
// Prepare the connection points
ControlPointId leftPoint = withModels ? ControlPointId.Reference : 4;
ControlPointId rightPoint = withModels ? ControlPointId.Reference : 5;
ControlPointId topPoint = withModels ? ControlPointId.Reference : 2;
ControlPointId bottomPoint = withModels ? ControlPointId.Reference : 7;
//
// Create the diagram
Diagram diagram = new Diagram(diagramName);
//
// Create and add layers
LayerIds planarLayer = LayerIds.None, linearLayer = LayerIds.None, oddRowLayer = LayerIds.None,
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);
//.........这里部分代码省略.........