本文整理汇总了C#中Template.GetPropertyMappings方法的典型用法代码示例。如果您正苦于以下问题:C# Template.GetPropertyMappings方法的具体用法?C# Template.GetPropertyMappings怎么用?C# Template.GetPropertyMappings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Template
的用法示例。
在下文中一共展示了Template.GetPropertyMappings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitPropertyMappings
private void InitPropertyMappings(Template template, MyBusinessObject modelObj)
{
Debug.Assert(template != null && template.Shape != null && modelObj != null);
// Assign model object to template shape
template.Shape.ModelObject = modelObj;
// Delete and clear all property mappings
// (not really necessary in this case)
project.Repository.Delete(template.GetPropertyMappings());
template.UnmapAllProperties();
// Prepare property mappings (One mapping per property!):
//
// Float to Style
// Change color depending on the integer property
StyleModelMapping lineStyleMapping = new StyleModelMapping(1, MyBusinessObject.FloatPropertyId, StyleModelMapping.MappingType.FloatStyle);
lineStyleMapping.AddValueRange(float.MinValue, project.Design.LineStyles.None);
lineStyleMapping.AddValueRange(16.66f, project.Design.LineStyles.Dotted);
lineStyleMapping.AddValueRange(33.33f, project.Design.LineStyles.Special2);
lineStyleMapping.AddValueRange(50.00f, project.Design.LineStyles.Special1);
lineStyleMapping.AddValueRange(66.66f, project.Design.LineStyles.Dashed);
lineStyleMapping.AddValueRange(83.33f, project.Design.LineStyles.Normal);
template.MapProperties(lineStyleMapping);
//
// Integer to Style
// Change outline thickness depending on the boolean property
StyleModelMapping fillStyleMapping = new StyleModelMapping(3, MyBusinessObject.BooleanPropertyId, StyleModelMapping.MappingType.IntegerStyle);
fillStyleMapping.AddValueRange(0, project.Design.FillStyles.Green);
fillStyleMapping.AddValueRange(1, project.Design.FillStyles.Red);
template.MapProperties(fillStyleMapping);
//
// Integer to Integer
// Change shape's angle depending on the integer property
// Note: Value is modified by a slope factor of 10 because angle is specified in tenths of degrees.
NumericModelMapping angleMapping = new NumericModelMapping(2, MyBusinessObject.IntegerPropertyId, NumericModelMapping.MappingType.IntegerInteger, 0, 10);
template.MapProperties(angleMapping);
// Add model object and update template
project.Repository.Insert(modelObj);
project.Repository.Update(template);
}