privatevoid axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvente)
{
IPoint pPoint = newPointClass();
pPoint.PutCoords(e.mapX, e.mapY);
pActiveView=axMapControl1.ActiveView;
if (pFeedBack == null)
{
pFeedBack = newNewBezierCurveFeedbackClass();
pFeedBack.Display = pActiveView.ScreenDisplay;
pFeedBack.Start(pPoint);
}
else
{
pFeedBack.AddPoint(pPoint);
}
}
privatevoid axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvente)
{
if (pFeedBack != null)
{
IPoint pPoint = newPointClass();
pPoint.PutCoords(e.mapX, e.mapY);
pFeedBack.MoveTo(pPoint);
}
}
privatevoid AddBezier(IGeometry pGeometry, IActiveView pActiveView)
{
IElementpElement;
ILineElementpLineElement = newLineElementClass();
ISimpleLineSymbolpSimpleLineSymbol = newSimpleLineSymbolClass();
pElement = pLineElement asIElement;
pElement.Geometry = pGeometry;
pSimpleLineSymbol.Color = GetRGBColor(255, 215,0);
pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
pSimpleLineSymbol.Width = 2;
pLineElement.Symbol = pSimpleLineSymbol;
IGraphicsContainerpGraphicsContainer =axMapControl1.ActiveView asIGraphicsContainer;
pGraphicsContainer.AddElement((IElement)pLineElement, 0);
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
privateIRgbColor GetRGBColor(int red, int green, int blue)
{
IRgbColorrGBColor = newRgbColorClass();
rGBColor.Red= red;
rGBColor.Green = green;
rGBColor.Blue = blue;
return rGBColor;
}
privatevoid axMapControl1_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvente)
{
IGeometrypGeometry;
pGeometry = pFeedBack.Stop();
pActiveView = axMapControl1.ActiveView;
AddBezier(pGeometry, pActiveView);
pFeedBack = null;
}