toni_mc

StyleGalleryItem Symbol

Discussion created by toni_mc on Aug 24, 2011
Latest reply on Aug 26, 2011 by toni_mc
How can i put(draw) symbol from SymbolControl on map? When selected item symbol from SymbolControl, and then click on map control, selected item from symbol control didnt show.

code:
...
   private IStyleGalleryItem m_StyleGalleryItem;

   private void MainForm_Load(object sender, EventArgs e){

      string sInstall = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path;
      axSymbologyControl1.LoadStyleFile(sInstall + "\\Styles\\ESRI.ServerStyle");
      axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassMarkerSymbol;
   }

   private void axSymbologyControl1_OnItemSelected(object sender, ISymbologyControlEvents_OnItemSelectedEvent e){

     m_StyleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem;

   }

   private void axMapControl1_OnMouseDown(object sender,             IMapControlEvents2_OnMouseDownEvent e){

     IPoint point = new PointClass();
     point.PutCoords(e.x, e.y);
   
     IElement element = (IElement)m_StyleGalleryItem;
     element.Geometry = point;
    
     axMapControl1.ActiveView.GraphicsContainer.AddElement(element, 0);
     axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriGraphics, m_StyleGalleryItem, null);

   }
...

How can i cast m_StyleGalleryItem to IElement?

Any advice! Thanks

Outcomes