This project is read-only.

Problem using the set_ShapeFillTransparency function

Dec 22, 2011 at 1:49 PM

I'm having problems in use the set_ShapeFillTransparency, I want to set the transparecy of one of the layers that I have on axMap2, but the fuction doesn't seems to work.

 

The piece of code that i set this is:

 

sf = new MapWinGIS.Shapefile();
            sf.CreateNew("", MapWinGIS.ShpfileType.SHP_POLYLINE);
            
            //Create new field
            fld = new MapWinGIS.Field();
            //Set the field properties
            fld.Name = "ID";
            fld.Type = MapWinGIS.FieldType.INTEGER_FIELD;
            fld.Width = 10;
            //Add the filed for the shapefile table
            intFieldIndex = 0;
            sf.EditInsertField(fld, ref intFieldIndex, null);

            if (!sf.EditingShapes)
                sf.StartEditingShapes(true, null);

            shp = new MapWinGIS.Shape();
            shp.Create(MapWinGIS.ShpfileType.SHP_POLYLINE);
            
            nShapes = sf.NumShapes;
            sf.EditInsertShape(shp, ref nShapes);

            hnd = axMap2.AddLayer(sf, true);
            axMap2.set_ShapeFillTransparency(hnd, 0, 0.5f);
            axMap2.set_ShapeLayerFillTransparency(hnd, 0.50f);
            axMap2.Refresh();
            axMap2.set_ShapeLineWidth(hnd, nShapes, 2);
            axMap2.set_ShapeLineStipple(hnd, nShapes, MapWinGIS.tkLineStipple.lsNone);
            uColor = Convert.ToUInt32(ColorTranslator.ToWin32(Color.Blue));
            axMap2.set_ShapeLineColor(hnd, nShapes, uColor);

            sf.StopEditingShapes(true, true, null);
            

Thanks in advance

 

sf = new MapWinGIS.Shapefile();
            sf.CreateNew("", MapWinGIS.ShpfileType.SHP_POLYLINE);
           
            //Create new field
            fld = new MapWinGIS.Field();
            //Set the field properties
            fld.Name = "ID";
            fld.Type = MapWinGIS.FieldType.INTEGER_FIELD;
            fld.Width = 10;
            //Add the filed for the shapefile table
            intFieldIndex = 0;
            sf.EditInsertField(fld, ref intFieldIndex, null);

            if (!sf.EditingShapes)
                sf.StartEditingShapes(true, null);

            shp = new MapWinGIS.Shape();
            shp.Create(MapWinGIS.ShpfileType.SHP_POLYLINE);
           
            nShapes = sf.NumShapes;
            sf.EditInsertShape(shp, ref nShapes);

            hnd = axMap2.AddLayer(sf, true);
            axMap2.set_ShapeFillTransparency(hnd, 0, 0.5f);
            axMap2.set_ShapeLayerFillTransparency(hnd, 0.50f);
            axMap2.Refresh();
            axMap2.set_ShapeLineWidth(hnd, nShapes, 2);
            axMap2.set_ShapeLineStipple(hnd, nShapes, MapWinGIS.tkLineStipple.lsNone);
            uColor = Convert.ToUInt32(ColorTranslator.ToWin32(Color.Blue));
            axMap2.set_ShapeLineColor(hnd, nShapes, uColor);

            sf.StopEditingShapes(true, true, null);
Jan 2, 2012 at 12:49 PM

Anyone had the same problem ?

I found a way to use transparency by applying a texture and then setting the transparency, but I cannot set the transparency to a layer or shapefile.

PS: On the code that I post I'm using a polyline shape, but I saw that transparency only works with polygon shapefile. I tried with all the polygon types, but I still can't make the transparency work.