ThinkGeo.com    |     Documentation    |     Premium Support

GeoImage as EmbeddedResource

 Hello,


 


Using WPF application,  I want to embedded image from GeoImage() class using an embedded resource ??and I went on to image properties and set image to ( BuildAction -> Action(Embedded Resource).The  goal I  want to achieve is to  read GeoImage() icon path from the Executable file.

 


I tried several different  ways, and I was unsuccessful with below scenarios.


 


  Dictionary<String, GeoImage> _dictImage;


 


Way1:


 _dictImage.Add("PickupIncomplete", new GeoImage("C:\images\PickupIncomplete.png"));


 


Way2:


_dictImage.Add("PickupIncomplete", new GeoImage("pack://application:,,,/testproject;component/\images\PickupIncomplete.png"));


 



  protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)


    {


 



    foreach (Feature feature in features)


        {




 


                if (_dictImage.ContainsKey(srchVal))


                {


        


                    canvas.DrawWorldImageWithoutScaling(_dictImage[srchVal], pointShape.X, pointShape.Y, DrawingLevel.LevelFour, 0, 0, 0);


                }


                else


                {


                    if (_dictImage.ContainsKey(feature.ColumnValues[LayerColNames._FeatureStyle]))


                    {


                        canvas.DrawWorldImageWithoutScaling(_dictImage[feature.ColumnValues[LayerColNames._FeatureStyle]], pointShape.X, pointShape.Y, DrawingLevel.LevelFour, 0, 0, 0);


                    }


               }


}


}



Can you recommend any possible ways


 


 



Hi Srikanth, 
  
 I *THINK* I do the same thing as what you are looking to do.  Marking your image as a Resource and you can create your GeoImage as follows: 
  
 GeoImage gi = new GeoImage(Application.GetResourceStream(new Uri("pack://application:,/TestProject;component/Images/PickupIncomplete.png")).Stream); 
  
  
 I hope this helps, 
 .Ryan.

 


 


Thanks Ryan.This is exactly i was looking for.


 



Hello Ryan, 
  
 Thanks for your help and experience. 
  
 And Srikanth, please feel free to let us know your questions. 
  
 Regards, 
  
 Gary