Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've posted this over on ESRI's ArcGIS Runmtime for WPF forums but I thought I'd repost here to get some more developer exposure. Any input would be greatly appreciated. Original post here: http://forums.arcgis.com/threads/82721-LineSymbol-and-SimpleLineSymbol-not-rendering-without-AcceleratedDisplay

With the AcceleratedDisplay enabled, SimpleLineSymbols and LineSymbols both render correctly. If I turn it off, both fail to render completely. Nothing else has changed such as their geometries or symbologies. Is this a known issue and/or am I doing something wrong? Additionally, SimpleFillSymbols, PictureMarkerSymbols, and TextSymbols seem to work just fine regardless of AcceleratedDisplay settings. That is to say, if I render the symbols as SimpleFillSymbols they will show up (BorderBrush with no FillBrush).

Code Behind:

    private void MakeSimpleSymbol()
{
            //Create a simple line symbol
            SimpleLineSymbol sls = new SimpleLineSymbol();
            sls.Color = new SolidColorBrush(Colors.Blue);
            sls.Style = SimpleLineSymbol.LineStyle.Solid;
            sls.Width = 2;

            //Create a polygon object
            Polygon p = new Polygon();
            p.SpatialReference = new SpatialReference(102100);

            //Populate it with some points
            ESRI.ArcGIS.Client.Geometry.PointCollection pointCollection = new ESRI.ArcGIS.Client.Geometry.PointCollection();
            ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection> rings = new ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection>();
            MapPoint wgsPoint = new MapPoint(0,0);
            MapPoint wgsPoint2 = new MapPoint(50,0);
            MapPoint wgsPoint3 = new MapPoint(0,50);
            pointCollection.Add(wgsPoint);
            pointCollection.Add(wgsPoint2);
            pointCollection.Add(wgsPoint3);
            rings.Add(pointCollection);
            p.Rings = rings;

            //Create a graphic and set its properties
            Graphic graphic = new Graphic();
            graphic.Geometry = p;
            graphic.Symbol = sls;

            //Create a graphics layer and add the graphic to it
            GraphicsLayer gLayer = new GraphicsLayer();
            gLayer.Graphics.Add(graphic);

            //Add the graphics layer to the map
            _map.Layers.Add(gLayer);
}

XAML:

<Window x:Class="ESRIWPFTestApplication.MainWindow"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:esri="http://schemas.esri.com/arcgis/client/2009"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <!-- AcceleratedDisplay is OFF -->
        <esri:Map x:Name="_map" UseAcceleratedDisplay="False">
        </esri:Map>
    </Grid>
</Window>
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I tested your code. Inside of MakeSimpleSymbol method, if you are going to use LineSymbol, then you need to use with Polyline instead of Polygon. But I'm not sure why it correctly work if the UseAcceleratedDisplay is True. Here is code,

private void MakeSimpleSymbol() {
    //Create a simple line symbol
    SimpleLineSymbol sls = new SimpleLineSymbol();
    sls.Color = new SolidColorBrush(Colors.Blue);
    sls.Style = SimpleLineSymbol.LineStyle.Solid;
    sls.Width = 2;

    //Edited: Create a polyline object 
    Polyline p = new Polyline();
    p.SpatialReference = new SpatialReference(102100);

    //Populate it with some points
    ESRI.ArcGIS.Client.Geometry.PointCollection pointCollection = new ESRI.ArcGIS.Client.Geometry.PointCollection();
    ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection> rings = new ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection>();
    MapPoint wgsPoint = new MapPoint(0, 0);
    MapPoint wgsPoint2 = new MapPoint(50, 0);
    MapPoint wgsPoint3 = new MapPoint(0, 50);
    pointCollection.Add(wgsPoint);
    pointCollection.Add(wgsPoint2);
    pointCollection.Add(wgsPoint3);
    //Edited: Close the polyline
    pointCollection.Add(wgsPoint);
    rings.Add(pointCollection);
    //Edited: Set the geometry as a path
    p.Paths = rings;

    //Create a graphic and set its properties
    Graphic graphic = new Graphic();
    graphic.Geometry = p;
    graphic.Symbol = sls;


    //Create a graphics layer and add the graphic to it
    GraphicsLayer gLayer = new GraphicsLayer();
    gLayer.Graphics.Add(graphic);

    //Add the graphics layer to the map
    _map.Layers.Add(gLayer);
}

Hope this helps you.

share|improve this answer
    
This works. I'd prefer to have constructed a "real" polygon, but this will do the job. The difference may be that AcceleratedDisplay uses ESRI's C++ custom rendering engine and with it off it uses the WPF rendering engine. I suppose that means I could probably write a custom renderer for the Polygon object. The end-goal of this was to support dashed/dotted borders. Thanks for the help! –  AHigh Apr 21 '13 at 18:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.