aniket096

Mapcontrol not reflected when i split polygon with line?

Discussion created by aniket096 on Feb 17, 2014
I have created a split tool which will create polyline and based this line i want to divide that polygon into two separate polygons.
i have write below code it will create left side and right side geometry very well but that newly created polygon not reflected in mapcontrol.
what i am doing wrong here?
also i attached image of my polygon.
Code:
IMap map1;
IFeature feat;
IFeature outfet;
IFeatureClass outfeturecls;
IFeatureLayer feturelyyr;
IGeometry left;
IGeometry right;
IEnumFeature enumfeture;


screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
  rgbColor.Blue = 255;

ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast
ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new ESRI.ArcGIS.Display.SimpleLineSymbolClass();
simpleLineSymbol.Color = color;
ESRI.ArcGIS.Display.ISymbol symbol = (ESRI.ArcGIS.Display.ISymbol)simpleLineSymbol; // Explicit Cast
ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberLineClass();
IPolyline newPolyline = (IPolyline)rubberBand.TrackNew(screenDisplay, (ESRI.ArcGIS.Display.ISymbol)symbol);
IGeometry polggeomtry=null;
IGeometry polylingeo = null;
map1 = m_hookHelper.FocusMap;
  enumfeture = map1.FeatureSelection as IEnumFeature;

 
feat = enumfeture.Next();
polylingeo = newPolyline as IGeometry;
  while (feat != null)
                {
                    if (feat.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                    {
                      

                        polggeomtry = feat.ShapeCopy as IGeometry;
                                     
                        break;

                    }
                }

  feturelyyr = Program.lyrr as IFeatureLayer;
   outfeturecls = feturelyyr.FeatureClass;
ESRI.ArcGIS.Geometry.ITopologicalOperator4 topologicalOperator = polggeomtry as ESRI.ArcGIS.Geometry.ITopologicalOperator4; // Dynamic Cast
            
                topologicalOperator.Simplify();
        
                topologicalOperator.Cut(polylingeo as IPolyline, out left, out right);

                IGeometryCollection geometryCollection = (IGeometryCollection)new GeometryBag();

            
               geometryCollection.AddGeometry(left, ref before, ref after);
               geometryCollection.AddGeometry(right, ref before, ref after);
               for (int i = 0; i < geometryCollection.GeometryCount;i++)
               {
                   outfet = outfeturecls.CreateFeature();
                   outfet.Shape = geometryCollection.Geometry[i];
                 
                   outfet.Store();
               }
               feat.Delete();

Attachments

Outcomes