This project is read-only.

4.7 ocx: shape image problem

Jun 14, 2011 at 2:40 PM
Edited Jun 14, 2011 at 3:24 PM

Hi,

i'm using 4.7 ocx. I use the set_ShapePointImageListID function to set an image for a certain object in the map. It works fine, but if i delete one shape, other object in the map has more than one image...

when i delete a shape, i do this:

//here i delete shape and label

this->platformShpFile->StartEditingShapes(true, nullptr);
this->map->ClearLabels(this->ptf_shapeContainer[i]->layerOwner);
            this->platformShpFile->EditDeleteShape(i);
            this->platformShpFile->StopEditingShapes(true, true, nullptr);

//then i have a structure in which i store some info about object (index of shape, layer owner, ecc)

//i need to clear entry for the related shape deletion and to reorganize the structure to avoid holes in it
            Array::Clear(this->ptf_shapeContainer, i,1);
            //move all platforms in shapeContainer structure to avoid holes
            for(int j = i+1; j <  this->ptf_shapeContainer->Length; j++)
            {
                this->ptf_shapeContainer[j-1] = this->ptf_shapeContainer[j];
                Array::Clear(this->ptf_shapeContainer, j,1);

            }
            //it is needed to update all the shapeIdx of other platforms that follows the deleted (-1)
            for(int k = i; k <  this->ptf_shapeContainer->Length; k++)
            {
                if(this->ptf_shapeContainer[k] != nullptr)
                {                   
                    this->ptf_shapeContainer[k]->shapeIdx = this->ptf_shapeContainer[k]->shapeIdx -1;

                }
            }
//i also have an int that stores the index of the image of the shape, so i use it to refresh the correct image in the shape
            //reassign the correct image for each shape
            for(int k = i; k <  this->ptf_shapeContainer->Length; k++)
            {
                if(this->ptf_shapeContainer[k] != nullptr)
                {                   
                    this->map->set_ShapePointImageListID(this->ptf_shapeContainer[k]->layerOwner,
                            this->ptf_shapeContainer[k]->shapeIdx,
                            this->ptf_shapeContainer[k]->imageIdx);
                    this->map->Redraw();

                }
            }

 

 

everything goes, but i see plus than one image on shapes that remain on the map...the problem does not occur if i delete the last object inserted, so i think that the problem is in the code above (in which i perform the delete of an object on map)

 

anyone can help me for this trouble???

 

thanks all

 

p.s. it is needed to delete also the layer and not only the shape?because, if i print the index of the image before the set_ShapePointImageListID, using get_ShapePointImageListID, i have always -1 for first shape...

 

p.p.s. i think that the problem is that layer number and shape index does not fit after the shape deletion, so how can i know which layer owns a certain shape?

Mar 24, 2012 at 1:25 PM

Hello,seum

     I want to set an image for a certain point shape in the point shapefile use the set_PointShapeType(). And I want to make it work in C#. 

     my code is :

 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    MapWinGIS.Image[] ico = new MapWinGIS.Image[3];
            for (int i = 0; i < 3; i++)
            {
                ico[i] = new MapWinGIS.Image();
            }

            ico[0].Open(@"C:\move.bmp", MapWinGIS.ImageType.USE_FILE_EXTENSION);
            ico[1].Open(@"C:\photo.bmp", MapWinGIS.ImageType.USE_FILE_EXTENSION);
            ico[2].Open(@"C:\Bulbon.bmp", MapWinGIS.ImageType.USE_FILE_EXTENSION);
 
           Shapefile PointShpFile = this.axMap1.get_Shapefile(PointLayer);
            PointShpFile.StartEditingShapes(true);

            MapWinGIS.Shape PointShape = new Shape();
            int[] indextype = new int[3];

            for (int i = 0; i < 3; i++)
            {
                indextype[i]=axMap1.set_UDPointImageListAdd(PointLayer, ico[i]);
            }

            for (int i = 0; i < PointShpFile.NumShapes; i++)
                {       

                        axMap1.ShapeDrawingMethod = tkShapeDrawingMethod.dmStandard;
                        switch (index_show)
                        {
                            case 1:
                                axMap1.set_ShapePointSize(PointLayer, i, 1);
                                axMap1.set_ShapePointType(PointLayer, i, MapWinGIS.tkPointType.ptImageList);
                                axMap1.set_ShapePointImageListID(PointLayer, i, indextype[0]);
                                axMap1.Redraw();                            
                                break;                               
                        }                   
                }
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
But it doesn't work, only drwaing small points with initial type. I want to use the  special picture to indicate the special point. 
Could you  help me ?
Thanks a lot !!