/// <override></override> public override IModelMapping Clone() { StyleModelMapping result = new StyleModelMapping(ShapePropertyId, ModelPropertyId, Type, defaultStyle); if (intRanges != null) { foreach (KeyValuePair <int, IStyle> item in intRanges) { result.AddValueRange(item.Key, item.Value); } } else if (floatRanges != null) { foreach (KeyValuePair <float, IStyle> item in floatRanges) { result.AddValueRange(item.Key, item.Value); } } return(result); }
/// <override></override> public override IModelMapping Clone() { StyleModelMapping result = new StyleModelMapping(ShapePropertyId, ModelPropertyId, Type, defaultStyle); if (intRanges != null) { foreach (KeyValuePair<int, IStyle> item in intRanges) result.AddValueRange(item.Key, item.Value); } else if (floatRanges != null) { foreach (KeyValuePair<float, IStyle> item in floatRanges) result.AddValueRange(item.Key, item.Value); } return result; }
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); }
private object[] GetStyleMappingResults(StyleModelMapping mapping, Type propertyType, object[] testData, Project project) { if (mapping == null) throw new ArgumentNullException("maping"); if (testData == null) throw new ArgumentNullException("testData"); // Define mapping int valueCnt = 5; int[] values = new int[valueCnt]; values[0] = int.MinValue; values[1] = -1000; values[2] = 0; values[3] = 1000; values[4] = int.MaxValue; IStyle[] styles = new IStyle[valueCnt]; if (IsOfType(propertyType, typeof(ICapStyle))) { styles[0] = project.Design.CapStyles.Arrow; styles[1] = project.Design.CapStyles.Special1; styles[2] = project.Design.CapStyles.None; styles[3] = project.Design.CapStyles.Special2; styles[4] = project.Design.CapStyles.Arrow; } else if (IsOfType(propertyType, typeof(ICharacterStyle))) { styles[0] = project.Design.CharacterStyles.Caption; styles[1] = project.Design.CharacterStyles.Heading1; styles[2] = project.Design.CharacterStyles.Heading2; styles[3] = project.Design.CharacterStyles.Heading3; styles[4] = project.Design.CharacterStyles.Normal; } else if (IsOfType(propertyType, typeof(IColorStyle))) { styles[0] = project.Design.ColorStyles.Black; styles[1] = project.Design.ColorStyles.Red; styles[2] = project.Design.ColorStyles.Yellow; styles[3] = project.Design.ColorStyles.Green; styles[4] = project.Design.ColorStyles.White; } else if (IsOfType(propertyType, typeof(IFillStyle))) { styles[0] = project.Design.FillStyles.Black; styles[1] = project.Design.FillStyles.Red; styles[2] = project.Design.FillStyles.Yellow; styles[3] = project.Design.FillStyles.Green; styles[4] = project.Design.FillStyles.White; } else if (IsOfType(propertyType, typeof(ILineStyle))) { styles[0] = project.Design.LineStyles.Special1; styles[1] = project.Design.LineStyles.Red; styles[2] = project.Design.LineStyles.Yellow; styles[3] = project.Design.LineStyles.Green; styles[4] = project.Design.LineStyles.Special2; } else if (IsOfType(propertyType, typeof(IParagraphStyle))) { styles[0] = project.Design.ParagraphStyles.Label; styles[1] = project.Design.ParagraphStyles.Text; styles[2] = project.Design.ParagraphStyles.Title; styles[3] = project.Design.ParagraphStyles.Text; styles[4] = project.Design.ParagraphStyles.Label; } // Fill mapping mapping.ClearValueRanges(); for (int i = 0; i < valueCnt; ++i) { if (mapping.CanSetInteger) mapping.AddValueRange(values[i], styles[i]); else if (mapping.CanSetFloat) mapping.AddValueRange((float)values[i], styles[i]); } // Set expected results int cnt = testData.Length; object[] result = new object[cnt]; for (int i = 0; i < cnt; ++i) { double value; if (mapping.CanSetFloat) value = Convert.ToSingle(testData[i]); else value = Convert.ToDouble(testData[i]); if (double.IsNaN(value) || double.IsNegativeInfinity(value)) result[i] = null; else if (value < values[1]) result[i] = styles[0]; else if (value >= values[1] && value < values[2]) result[i] = styles[1]; else if (value >= values[2] && value < values[3]) result[i] = styles[2]; else if (value >= values[3] && value < values[4]) result[i] = styles[3]; else if (value >= values[4]) result[i] = styles[4]; else result[i] = null; } return result; }
// Create a ModelMapping from the given PropertyInfos private IModelMapping CreateModelMapping(PropertyInfo shapePropertyInfo, PropertyInfo modelPropertyInfo) { // Get PropertyId's int? shapePropertyId = GetPropertyId(shapePropertyInfo); int? modelPropertyId = GetPropertyId(modelPropertyInfo); if (!shapePropertyId.HasValue || !modelPropertyId.HasValue) return null; // // Determine property types MappedPropertyType shapePropType; if (IsIntegerType(shapePropertyInfo.PropertyType)) shapePropType = MappedPropertyType.Int; else if (IsFloatType(shapePropertyInfo.PropertyType)) shapePropType = MappedPropertyType.Float; else if (IsStringType(shapePropertyInfo.PropertyType)) shapePropType = MappedPropertyType.String; else if (IsStyleType(shapePropertyInfo.PropertyType)) shapePropType = MappedPropertyType.Style; else return null; // MappedPropertyType modelPropType; if (IsIntegerType(modelPropertyInfo.PropertyType)) modelPropType = MappedPropertyType.Int; else if (IsFloatType(modelPropertyInfo.PropertyType)) modelPropType = MappedPropertyType.Float; else if (IsStringType(modelPropertyInfo.PropertyType)) modelPropType = MappedPropertyType.String; else return null; // // Create a suitable ModelMapping: IModelMapping result = null; switch (modelPropType) { case MappedPropertyType.Float: switch (shapePropType) { case MappedPropertyType.Float: result = new NumericModelMapping(shapePropertyId.Value, modelPropertyId.Value, NumericModelMapping.MappingType.FloatFloat); break; case MappedPropertyType.Int: result = new NumericModelMapping(shapePropertyId.Value, modelPropertyId.Value, NumericModelMapping.MappingType.FloatInteger); break; case MappedPropertyType.String: result = new FormatModelMapping(shapePropertyId.Value, modelPropertyId.Value, FormatModelMapping.MappingType.FloatString); break; case MappedPropertyType.Style: result = new StyleModelMapping(shapePropertyId.Value, modelPropertyId.Value, StyleModelMapping.MappingType.FloatStyle); break; default: break; } break; case MappedPropertyType.Int: switch (shapePropType) { case MappedPropertyType.Float: result = new NumericModelMapping(shapePropertyId.Value, modelPropertyId.Value, NumericModelMapping.MappingType.IntegerFloat); break; case MappedPropertyType.Int: result = new NumericModelMapping(shapePropertyId.Value, modelPropertyId.Value, NumericModelMapping.MappingType.IntegerInteger); break; case MappedPropertyType.String: result = new FormatModelMapping(shapePropertyId.Value, modelPropertyId.Value, FormatModelMapping.MappingType.IntegerString); break; case MappedPropertyType.Style: result = new StyleModelMapping(shapePropertyId.Value, modelPropertyId.Value, StyleModelMapping.MappingType.IntegerStyle); break; default: break; } break; case MappedPropertyType.String: if (shapePropType == MappedPropertyType.String) result = new FormatModelMapping(shapePropertyId.Value, modelPropertyId.Value, FormatModelMapping.MappingType.StringString); break; default: throw new NotSupportedException(); } return result; }
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); 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); }
/// <summary> /// Updates the given ModelMapping with the information from the given row's cells /// </summary> private void UpdateStyleModelMapping(StyleModelMapping styleMapping, int rowIndex) { // First, clear all ranges // ToDo: Optimize this: add new ranges, remove deleted ranges, do not recreate all ranges each time styleMapping.ClearValueRanges(); int rangeColIdx = 0; int styleColIdx = 1; for (int i = 0; i < valueMappingGrid.Rows.Count; ++i) { object rangeValue = valueMappingGrid.Rows[i].Cells[rangeColIdx].Value; object styleName = valueMappingGrid.Rows[i].Cells[styleColIdx].Value; IStyle style = null; // Find style if (valueMappingGrid.Rows[i].Cells[styleColIdx].Value != null) { PropertyInfo shapePropInfo = FindPropertyInfo(shapePropertyInfos, styleMapping.ShapePropertyId); // Get Style value string styleTitle = valueMappingGrid.Rows[i].Cells[styleColIdx].Value.ToString(); foreach (IStyle s in TemplateController.Project.Design.Styles) { Type styleType = s.GetType(); if (!IsOfType(styleType, shapePropInfo.PropertyType)) continue; else if (s.Title.Equals(styleTitle, StringComparison.InvariantCultureIgnoreCase)) { style = s; break; } } } // if all required values were found, create a new mapping range if (rangeValue != null && style != null) { if (styleMapping.Type == StyleModelMapping.MappingType.IntegerStyle) styleMapping.AddValueRange((int)rangeValue, style); else if (styleMapping.Type == StyleModelMapping.MappingType.FloatStyle) styleMapping.AddValueRange((float)rangeValue, style); else throw new NShapeUnsupportedValueException(styleMapping.Type); } } // Set ModelMapping templateController.SetModelMapping(styleMapping); }
private void CreateStyleMappingRows(StyleModelMapping modelMapping) { Debug.Assert(modelMapping != null); valueMappingGrid.Rows.Clear(); valueMappingGrid.AllowUserToAddRows = true; if (modelMapping.Type == StyleModelMapping.MappingType.IntegerStyle) { foreach (object val in modelMapping.ValueRanges) { IStyle style = modelMapping[(int)val]; valueMappingGrid.Rows.Add(new object[] { (int)val, style.Title }); } } else if (modelMapping.Type == StyleModelMapping.MappingType.FloatStyle) { foreach (object val in modelMapping.ValueRanges) { IStyle style = modelMapping[(float)val]; valueMappingGrid.Rows.Add(new object[] { (float)val, style.Title }); } } else throw new NShapeUnsupportedValueException(modelMapping.Type); // Add an empty row for creating new range/style mappings valueMappingGrid.Rows.Add(); }
private void CreateStyleMappingColumns(StyleModelMapping modelMapping) { Debug.Assert(modelMapping != null); valueMappingGrid.Columns.Clear(); // Column for range start value valueMappingGrid.Columns.Add(mappingPropertyNameCol, titleRangeValue); if (modelMapping.Type == StyleModelMapping.MappingType.IntegerStyle) valueMappingGrid.Columns[mappingPropertyNameCol].ValueType = typeof(int); else if (modelMapping.Type == StyleModelMapping.MappingType.FloatStyle) valueMappingGrid.Columns[mappingPropertyNameCol].ValueType = typeof(float); else throw new NShapeUnsupportedValueException(modelMapping.Type); valueMappingGrid.Columns[mappingPropertyNameCol].ReadOnly = false; valueMappingGrid.Columns[mappingPropertyNameCol].Width = valueMappingGrid.Width / 2; // Column for mapped Style PropertyInfo shapePropInfo = FindPropertyInfo(shapePropertyInfos, modelMapping.ShapePropertyId); DataGridViewComboBoxColumn styleValueColumn = new DataGridViewComboBoxColumn(); styleValueColumn.Name = mappingPropertyValueCol; styleValueColumn.HeaderText = titleStyleValue; styleValueColumn.ValueType = typeof(string); styleValueColumn.ReadOnly = false; styleValueColumn.Width = valueMappingGrid.Width / 2; styleValueColumn.MaxDropDownItems = 10; styleValueColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox; styleValueColumn.Items.Clear(); foreach (IStyle style in TemplateController.Project.Design.Styles) { Type styleType = style.GetType(); if (!IsOfType(styleType, shapePropInfo.PropertyType)) continue; else styleValueColumn.Items.Add(style.Title); } valueMappingGrid.Columns.Add(styleValueColumn); }
// Create a ModelMapping from the given PropertyInfos private IModelMapping CreatePropertyMapping(PropertyInfo shapePropertyInfo, PropertyInfo modelPropertyInfo) { int? shapePropertyId = GetPropertyId(shapePropertyInfo); int? modelPropertyId = GetPropertyId(modelPropertyInfo); Debug.Assert(shapePropertyId.HasValue && modelPropertyId.HasValue); MappedPropertyType shapePropType; if (IsIntegerType(shapePropertyInfo.PropertyType)) shapePropType = MappedPropertyType.Int; else if (IsFloatType(shapePropertyInfo.PropertyType)) shapePropType = MappedPropertyType.Float; else if (IsStringType(shapePropertyInfo.PropertyType)) shapePropType = MappedPropertyType.String; else if (IsStyleType(shapePropertyInfo.PropertyType)) shapePropType = MappedPropertyType.Style; else throw new NotSupportedException(); MappedPropertyType modelPropType; if (IsIntegerType(modelPropertyInfo.PropertyType)) modelPropType = MappedPropertyType.Int; else if (IsFloatType(modelPropertyInfo.PropertyType)) modelPropType = MappedPropertyType.Float; else if (IsStringType(modelPropertyInfo.PropertyType)) modelPropType = MappedPropertyType.String; else throw new NotSupportedException(); // Create a suitable ModelMapping: IModelMapping result = null; switch (modelPropType) { case MappedPropertyType.Float: switch (shapePropType) { case MappedPropertyType.Float: result = new NumericModelMapping(shapePropertyId.Value, modelPropertyId.Value, NumericModelMapping.MappingType.FloatFloat); break; case MappedPropertyType.Int: result = new NumericModelMapping(shapePropertyId.Value, modelPropertyId.Value, NumericModelMapping.MappingType.FloatInteger); break; case MappedPropertyType.String: result = new FormatModelMapping(shapePropertyId.Value, modelPropertyId.Value, FormatModelMapping.MappingType.FloatString); break; case MappedPropertyType.Style: result = new StyleModelMapping(shapePropertyId.Value, modelPropertyId.Value, StyleModelMapping.MappingType.FloatStyle); break; default: throw new NotSupportedException(string.Format("Property mappings from '{0}' to '{1}' are not supported.", modelPropType, shapePropType)); } break; case MappedPropertyType.Int: switch (shapePropType) { case MappedPropertyType.Float: result = new NumericModelMapping(shapePropertyId.Value, modelPropertyId.Value, NumericModelMapping.MappingType.IntegerFloat); break; case MappedPropertyType.Int: result = new NumericModelMapping(shapePropertyId.Value, modelPropertyId.Value, NumericModelMapping.MappingType.IntegerInteger); break; case MappedPropertyType.String: result = new FormatModelMapping(shapePropertyId.Value, modelPropertyId.Value, FormatModelMapping.MappingType.IntegerString); break; case MappedPropertyType.Style: result = new StyleModelMapping(shapePropertyId.Value, modelPropertyId.Value, StyleModelMapping.MappingType.IntegerStyle); break; default: throw new NotSupportedException(string.Format("Property mappings from '{0}' to '{1}' are not supported.", modelPropType, shapePropType)); } break; case MappedPropertyType.String: if (shapePropType == MappedPropertyType.String) result = new FormatModelMapping(shapePropertyId.Value, modelPropertyId.Value, FormatModelMapping.MappingType.StringString); else throw new NotSupportedException(string.Format("Property mappings from '{0}' to '{1}' are not supported.", modelPropType, shapePropType)); break; default: throw new NotSupportedException(); } return result; }