private void OnSketchFinished()
{
ConfigUtil.type = "water";
IFeature pFeat = null;
ISegmentCollection pSegColl = null;
IEnumSegment pESeg = null;
ISegment testSegment = null;
ISegmentCollection segColTest = null;
object Missing = null;
try
{
// Send a shift-tab to hide the construction toolbar
try
{
m_editor.StartOperation();
}
catch
{
m_editor.AbortOperation();
m_editor.StartOperation();
}
bool twoPoint = false;
(ArcMap.Application.Document as IMxDocument).FocusMap.ClearSelection();
List<IFeature> pLstFeat = null;
if (Control.ModifierKeys == Keys.Control)
{
twoPoint = CreateLineWithEndPoints.CreatePoints(ArcMap.Application, ConfigUtil.GetLinePointAtEndsConfig(), m_edSketch.Geometry as IPolyline, (IFeatureLayer)m_editor.CurrentTemplate.Layer, false, out pLstFeat);
}
else
{
twoPoint = CreateLineWithEndPoints.CreatePoints(ArcMap.Application, ConfigUtil.GetLinePointAtEndsConfig(), m_edSketch.Geometry as IPolyline, (IFeatureLayer)m_editor.CurrentTemplate.Layer, true, out pLstFeat);
}
if (twoPoint)
{
pSegColl = (ISegmentCollection)m_edSketch.Geometry;
pESeg = pSegColl.EnumSegments;
pESeg.Reset();
int partIndex = 0;
int segmentIndex = 0;
pESeg.Next(out testSegment, ref partIndex, ref segmentIndex);
while (testSegment != null)
{
segColTest = new PolylineClass();
Missing = Type.Missing;
segColTest.AddSegment(testSegment, ref Missing, ref Missing);
pFeat = Globals.CreateFeature(segColTest as IGeometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true);
pFeat.Store();
pESeg.Next(out testSegment, ref partIndex, ref segmentIndex);
}
}
else
{
pFeat = Globals.CreateFeature(m_edSketch.Geometry, m_editor.CurrentTemplate, m_editor, ArcMap.Application, false, false, true);
pFeat.Store();
}
foreach (IFeature pFt in pLstFeat)
{
pFt.Store();
}
pLstFeat = null;
m_editor.StopOperation(A4LGSharedFunctions.Localizer.GetString("CrtLnWithPts"));
(ArcMap.Application.Document as IMxDocument).ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null);
}
catch { }
finally
{
pFeat = null;
pSegColl = null;
pESeg = null;
testSegment = null;
segColTest = null;
Missing = null;
}
}