Hello,
I have a very simple program--one shapefile of municipal polygons--which throws an "object reference not set to an instance of an object" when I try to set AllowLineCarriage to true for the TextStyle. If I change to other text columns in the shapefile, the error still occurs, so it doesn't appear to be related to data. If I set AllowLineCarriage to false it doesn't fail, of course. Here's the code:
Here's the MapSuite part of the stack trace:
at ThinkGeo.MapSuite.Core.PositionStyle.GetLabelingCandidateForOnePolygon(PolygonShape polygon, String text, GeoCanvas canvas)
at ThinkGeo.MapSuite.Core.PositionStyle.GetLabelingCandidateForOnePartOfMultipolygon(MultipolygonShape multipolygonShape, String text, GeoCanvas canvas)
at ThinkGeo.MapSuite.Core.PositionStyle.GetLabelingCandidateForMultipolygon(MultipolygonShape multipolygonShape, String text, GeoCanvas canvas)
at ThinkGeo.MapSuite.Core.PositionStyle.GetLabelingCandidateCore(Feature feature, GeoCanvas canvas)
at ThinkGeo.MapSuite.Core.PositionStyle.GetLabelingCandidates(Feature feature, GeoCanvas canvas)
at ThinkGeo.MapSuite.Core.PositionStyle.DrawOneFeature(Feature feature, GeoCanvas canvas, Collection`1 labelsInThisLayer, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.Core.PositionStyle.DrawCore(IEnumerable`1 features, GeoCanvas canvas, Collection`1 labelsInThisLayer, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.Core.Style.Draw(IEnumerable`1 features, GeoCanvas canvas, Collection`1 labelsInThisLayer, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.Core.ZoomLevel.DrawCore(GeoCanvas canvas, IEnumerable`1 features, Collection`1 currentLayerLabels, Collection`1 allLayerLabels)
at ThinkGeo.MapSuite.Core.ZoomLevel.Draw(GeoCanvas canvas, IEnumerable`1 features, Collection`1 currentLayerLabels, Collection`1 allLayerLabels)
at ThinkGeo.MapSuite.Core.FeatureLayer.DrawCore(GeoCanvas canvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.Core.Layer.Draw(GeoCanvas canvas, Collection`1 labelsInAllLayers)
at ThinkGeo.MapSuite.DesktopEdition.LayerOverlay.DrawCore(GeoCanvas canvas)
at ThinkGeo.MapSuite.DesktopEdition.Overlay.MainDraw(GeoCanvas canvas)
at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x03e3d48bcfe7bb6c(IEnumerable`1 xa6f0db4f183189f1)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xff5b27c00f9678c2(RectangleShape x178b193eec228e6e)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.xe3cee4adb9c72451()
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.x9ac8c50f434f4b39(Int32 xb565f4681f05557a)
at ThinkGeo.MapSuite.DesktopEdition.WinformsMap.Refresh()
at AllowLineCarriageError.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\ahuber.ICMC\My Documents\Visual Studio 2008\Projects\AllowLineCarriageError\AllowLineCarriageError\Form1.cs:line 55
Any thoughts? I searched the forums and didn't see too much on this labeling attribute.
Thanks,
Allen Huber
winformsMap1.MapUnit = GeographyUnit.Meter;
GeoPen outlinePen = new GeoPen(GeoColor.FromArgb(0, 250, 245, 230), 4);
GeoSolidBrush solidBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 255, 255, 0));
AreaStyle areaStyle = new AreaStyle(outlinePen, solidBrush);
DrawingFontStyles fontStyles = DrawingFontStyles.Bold | DrawingFontStyles.Italic;
GeoFont font = new GeoFont("Arial",10, fontStyles);
TextStyle textStyle = new TextStyle("ZONE", font, new GeoSolidBrush(GeoColor.FromArgb(255,100,100,100)));
textStyle.AllowLineCarriage = true;
ShapeFileFeatureLayer.BuildIndexFile(Application.StartupPath + @"\zones.shp");
ShapeFileFeatureLayer zones = new ShapeFileFeatureLayer(Application.StartupPath + @"\zones.shp");
zones.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = areaStyle;
zones.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level08;
zones.ZoomLevelSet.ZoomLevel09.DefaultAreaStyle = areaStyle;
zones.ZoomLevelSet.ZoomLevel09.DefaultTextStyle = textStyle;
zones.ZoomLevelSet.ZoomLevel09.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
zones.Open();
RectangleShape extent = zones.GetBoundingBox();
zones.Close();
LayerOverlay overlay = new LayerOverlay();
overlay.Layers.Add(zones);
winformsMap1.Overlays.Add(overlay);
winformsMap1.CurrentExtent = extent;
winformsMap1.Refresh();